Load All Subfile in Full Free Format RPGLE
Earlier in my post I shared a simple Load All Subfile in RPGLE. Click Here for this post and for more details on Subfile.In this post, we will use the same Example using Full Free Format RPGLE.
Refer this link for the Sample Physical file and Display File used in this Article.
Below is the Sample RPGLE code for Load All Subfile.
**Free
// Define Physical File
Dcl-F TESTFILE ;
// Define Subfile
Dcl-F TESTSUBFIL WORKSTN SFILE(SFDTAR:SFRRN) ;
// Define Required Variables
// Main Process
ExSr Sub_Init ;
ExSr Sub_Main ;
ExSr Sub_Exit ;
// Sub_Init - First time initialization routine
BegSr Sub_Init ;
SFPGMNAM = 'TESTLODALL'
// Clear Subfile
*In25 = *Off ;
*In26 = *Off ;
*In28 = *On ;
Write SFCTLR ;
*In28 = *Off ;
*In25 = *On ;
*In26 = *On ;
EndSr ;
// Sub_Main - Main Processing Routine
BegSr Sub_Main ;
ExSr Sub_Load ;
Dow *In03 = *Off ;
// If You Need Cursor to be Pointed on Specific Record,
// You can move corresponding RRN to CSRRR field. In this
// example I am placing Cursor on 3rd Page.
CSRRRN = 17 ;
If SFRRN = 0 ;
*In25 = *Off ;
EndIf ;
Write SFFTRR ;
Exfmt SFCTLR ;
EndDo ;
EndSr ;
// Sub_Load - Load Subfile
BegSr Sub_Load ;
SFRRN = 0 ;
CSRRRN = 1 ;
Read TESTFILE ;
Dow Not %Eof(TESTFILE) And SFRRN < 9999 ;
SFRRN = SFRRN + 1 ;
SFTSFLD1 = TSFLD1 ;
SFTSFLD2 = TSFLD2 ;
SFTSFLD3 = TSFLD3 ;
SFTSFLD4 = TSFLD4 ;
Write SFDTAR ;
Read TESTFILE ;
EndDo ;
*In40 = *On ;
EndSr ;
// Sub_Exit - Finalization Routine
BegSr Sub_Exit ;
*InLr = *On ;
EndSr ;
Hi PR, your code is showing last page of the subfile. How i can display first page of subfile.
ReplyDeleteHi Sandeep, Yes it does point to the last page as we are setting the CSRRRN to 17. See the below code and change CSRRRN to 1 to point to the first record.
Delete// If You Need Cursor to be Pointed on Specific Record,
// You can move corresponding RRN to CSRRR field. In this
// example I am placing Cursor on 3rd Page.
CSRRRN = 17 ;
Hi Can you please help for selection option
ReplyDeletesuppose if i select any record by select option 1 it will go to next screen
can you please help me
Hi Durga,
DeleteYou could take a look at the below post (example for expandable sub file) which also has a piece of sample code for options processing as well. In brief you would be reading subfile record format using READC which would fetch the changed record, you would then need to check for the option and do the required operation.
https://www.codewithpr.com/2020/08/expandable-subfile-example-program.html
Please see if this is of any help, If not, you could consider sharing more specific details on what you are looking at, so that I would be able to advise you. You could either reply to this comment or reach out using the contact form.
Thanks.
Hi Pradeep
ReplyDeleteIam doing load all subfile in that iam having selection option
when selection I on one particular record it will go to the next screen
that logic i want
Hi Durga,
DeleteI understand, logic for processing the option selection should be similar to the example link I have shared in the previous comment. I'm pasting the subroutine for your quick reference.
// ------------------------------------------------------------------------
// Process Subfile Options
// ------------------------------------------------------------------------
BegSr SrProcessOptions ;
ReadC PPSFL01 ;
Dow Not %Eof(TESTSUBFIL) ;
If SOpt = '1' ;
EXFMT ;
EndIf ;
ReadC PPSFL01 ;
EndDo ;
EndSr;
This is a sample, you can try something similar, You can also try using SrValidateOptions which is intended for validating options before processing.
Let me know if it doesn't help you.
Thanks.