Updating a file on the basis of rrn

45 pts.
Tags:
RPGLE
Hi All, The question is: Can we update a non keyed file on the basis of RRN retreived by the INFDS. FABC UF E DISK INFDS(DS1) D DS1 DS D RRNF 397 400I 0 If yes than how. If no than why. Thanks in advance

Answer Wiki

Thanks. We'll let you know when a new response is added.

This is all from the ILE RPG programmers redbook – there is more on the topic in the redbook. You can find at www.redbooks.ibm.com and search away.

FX …..FFilename++IPEASF…..L…..A.Device+.Keywords++++++++++++++++++++
0011.02 Ffilename IF E Disk RECNO(RRNF)

C RRNF Chain Filename
C If %Found
C Put your logic
C Endif

Relative-Record-Number Processing
Random input or update processing by relative record number applies to full procedural files only. The desired record is accessed by the CHAIN operation code. Relative record numbers identify the positions of the records relative to the
beginning of the file. For example, the relative record numbers of the first, fifth,
and seventh records are 1, 5, and 7, respectively.
For an externally described file, input or update processing by relative record
number is determined by a blank in position 34 of the file description
specifications and the use of the CHAIN operation code. Output processing by
relative record number is determined by a blank in position 34 and the use of the
RECNO keyword on the file description specification line for the file.
Use the RECNO keyword on a file description specifications to specify a numeric
field that contains the relative record number that specifies where a new record is
to be added to this file. The RECNO field must be defined as numeric with zero
decimal positions. The field length must be large enough to contain the largest
record number for the file. A RECNO field must be specified if new records are to
be placed in the file by using output specifications or a WRITE operation.
When you update or add a record to a file by relative record number, the record
must already have a place in the member. For an update, that place must be a
valid existing record; for a new record, that place must be a deleted record.
You can use the CL command INZPFM to initialize records for use by relative
record number. The current relative record number is placed in the RECNO field
for all retrieval operations or operations that reposition the file (for example,
SETLL, CHAIN, READ).

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

The above seems a little complex to me. The answer is very simple.

If you put a “K ” in front of “DISK” in the “F” specs, you are saying you will use a key.
Leave that column blank and you are saying you will process by relative record number.

(IIRC that column is “Access Method”)

Everything else remains the same.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following