Q
Manage Learn to apply best practices and optimize your operations.

Read records sequentially from a subfile

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!

More on this topic

The Best Web Links: tips, tutorials and more.

Visit the ITKnowledge Exchange and get answers to your developing questions fast.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

 

This was last published in June 2005

Dig Deeper on Data backup, storage and retrieval on iSeries

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close