Q
Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

Read records on a subfile

One user writes, "How can I read all records on a subfile? Using READC opcode, one can read only the changed records. I have been working with the SFLNXTCHG keyword but without success. A simple example illustrating the subfile DDS, as well as the DDS of the relevant RPG 400/RPG-ILE program, would be very helpful." Application development expert John Blenkinsop responds.

How can I read all records on a subfile? Using READC opcode, one can read only the changed records. I have been working with the SFLNXTCHG keyword but without success. A simple example illustrating the subfile DDS, as well as the DDS of the relevant RPG 400/RPG-ILE program, would be very helpful.
A subfile is a 'direct' file, and can be accessed by relative record number. The field you specified in your DDS as SFLRCDNBR and in your RPG F-spec in the SFILE keyword holds the RRN of the record currently available in your program.

So, set that field or one defined like it in a loop, incrementing the field and using it in factor 1 of a chain to the subfile record format. On error or end of file you leave the loop. You will read all the records in the subfile.

I have given links to useful material on subfiles in other replies in Ask The Experts, so please look at other subfile questions to see them.

==================================
MORE INFORMATION 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 September 2005

Dig Deeper on iSeries application development tools

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.

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

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close