How to read from a subfile and copy the data into a PF

I have a subfile which is load-all.I have a function key (eg: F6).On pressing F6,i want data from subfile to be written into a PF.How to do this in RPGLE.Please give me a pseudocode if possible or steps.

Software/Hardware used:

Answer Wiki

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

If *in06 = *on (I like to link my F keys to indicators in DDS – else you can If KF)
*loval setll subfilename
DoW not%eof(Subfilename)
Read Subfilename
If not%eof(Subfilename)
<load fields>
Write PFFormatname

Discuss This Question: 5  Replies

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.
  • philpl1jb
    Not sure about that technique Not sure about read from a subfile Not sure about %EOF with the subfile name I would usually create a for loop, for x = ...but that requires that you know the number of records in the subile Chain into the subfile on the value of x move the fields to the physical file files write the physical file Phil
    54,090 pointsBadges:
    Phil, READC would work if the subfile was filled with SFLNXtCHG *on Otherwise Define the INFDS file information data structure. Part of the information for dispay file is the number of records in the subfile DO RECIN# KEY# KEY# CHAIN SFL 55 (EOF) IF *IN55 LEAVE ENDIF WRITE Physical_File ENDDO Good Luck
    1,235 pointsBadges:
  • TomLiotta
    READC will work if the MDT was set on, which it probably should have been the records are going to be read in to the program. CHAIN by subfile RRN works well in a FOR-loop; the program often knows how many records have been written because the program often does the writing. If the subfile is a set of records that will all be entered by the user, CHAIN by RRN could still be used -- ignore any rows that don't exist, i.e., empty rows that the user didn't type in to. And READC should also work, since you'll usually only be interested in stuff that was typed. The program will have created an empty subfile and it should know how big it was. I haven't seen a usage where a user can add rows without the program being informed. If the display file is shared and passed to a different program, the INFDS is definitely useful. Tom
    125,585 pointsBadges:
  • philpl1jb
    Thanks That's how I remember it. READC or CHAIN no READ. EOF() function but no file or record name. I would have style issues witj PGMBOB code but it'll work. Phil.
    54,090 pointsBadges:
  • NickHutcheson1
    Funny this question popped up when I am in the midst of my current project. I have an old manufacturing package and in the Bill of Lading Post process, I am to check the lines in the subfile for back ordered quantities and write just those lines to another file for other reporting purposes. SFLNXTCHG (MDT) is not specified in the DDS. That would be my only reason for changing the DDS (which if it ain't broke, don't fix it). And of course the INFDS is not specified. So I am doing as said, which is the easiest to do and look at later. Notice: I am using the subfile counter specified on the Sfile keyword in the F spec for the display file - srecno. This has the number of records written to the subfile. c z-add 1 chkbolrrn 4 0 c DOU chkbolrrn > srecno c chkbolrrn Chain MAINSFL 69 process some stuff C add 1 chkbolrrn c EndDO I just wonder why this has never been changed so you can process a subfile like a physical file. i.e. c *start Setll mainsfl c dou %eof(mainsfl) c read mainsfl This may be another reason so many of us 20 year guys are loosing hair and turning grey; having to remember little quirks like this. Or we send it to compile and then slap our heads when we get messages. Just my two cents....
    1,485 pointsBadges:

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.

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


Share this item with your network: