how to read records from Externally Described file into data structure
0 pts.
0
Q:
how to read records from Externally Described file into data structure
FAAAL21 UF A E K DISK
F RENAME(REC:arec)

D jkdata E DS extname(aaal21)

c read arec jkdata

after compiling, the error message is :
RNF7701 20 The data structure is not allowed for the operation

according to the book <ILE RPG Reference?SC09-2508-4?>, the above operation should be allowed. I want to know WHY. Thank you very much! :)
ASKED: Aug 1 2005  11:49 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
7785 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
In the ILE RPG reference manual the follwoing is listed:

If file name refers to an externally-described file or a record format from an externally described file, the data structure must be a data structure defined with EXTNAME(...:*INPUT) or LIKEREC(...:*INPUT).

You don't show these keywords on your DS definition.

========================================================

There is no need for any additional keywords; the additional keywords are all optional. Nor does it matter if the file reference is for input, output or update -- the file format is the same regardless of I/O operation and the DS is based on format, not operation.

The default is *INPUT which means that only fields defined as input-capable will be declared in your DS. Note that you would probably be better off specifying *ALL explicitly since you're working with an 'U'pdate file.

The problem appears to be due to this from the RPG Reference:

  • The first parameter for keyword LIKEREC is a record name in the program. If the record name has been renamed, it is the internal name for the record.


You say both RENAME(REC:arec) and extname(aaal21). Try coding extname(arec). If you're going to rename a record format in your program, then you need to use the name that you assigned.

Tom
Last Answered: Oct 31 2009  7:57 AM GMT by TomLiotta   7785 pts.
Latest Contributors: WaltZ400   535 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

jaicee   0 pts.  |   Aug 3 2005  6:12PM GMT

Without knowing what you’re trying to do, there’s a few things you have to look at. First off, the book says (for READ):

“If the data-structure operand is specified, the record is read directly into the data structure. … If name refers to an externally-described file or a record format from an externally described file, the data structure must be a data structure defined with EXTNAME(…:*INPUT) or LIKEREC(…:*INPUT)”.

Your file is defined as update/add so you could read, write or update a record. You may need more than one data-structure. The following would work…

D jkDataIn ds likerec(arec: *input) //for reads
D jkDataOut ds likerec(arec: *output) //for writes and updates

However the error you got says: “Recovery: For an input operation, define the data structure using keyword LIKEREC, with the record name as the first parameter and *INPUT as the second parameter. For output operations, code *OUTPUT as the second parameter of LIKEREC. Compile again”.

So again, you may want to read up on the other opcodes, likerec() and extname().

Hope that helps!

 
0