Can we use READ opcode to read records from a subfile record format(Data part)?
Yes, you can read records sequentially from a subfile, but you would do it using the CHAIN operation because a subfile is a 'direct' file. That means that a subfile is accessed using its relative record numbers.
So to read the subfile, use the subfile record number field you defined on the F-spec for the display file in a DO or FOR loop, starting at value 1 and ending at the last record number in the subfile -- you should know that value through having loaded the subfile in the first place.
You code would look like this :
C For ##SFR3 = 1 to LastRec C ##SFR3 Chain (E) #SFL3 : : : C Update #SFL3 C EndFor Between the Chain and the Update you can do what you like!
Dig Deeper on Data backup, storage and retrieval on iSeries
Related Q&A from John Blenkinsop
When an error occurs on an IBM command, the diagnostic messages are sent first, then an escape message, which you can monitor. On AS/400 you see the ... Continue Reading
Learn how to 'append data to the file' with the FTP DIR command, and eliminate the hassle of having to end the FTP session and restart to view ... Continue Reading
RPGIV will 'think of' incoming integer fields as binary, and then will redefine them in the program structures as PACKED. So, when you chain a record... Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.