Pages

Friday, May 1, 2020

Load All Subfile - Full Free Format RPG

Load All Subfile in Full Free Format RPGLE:

Earlier in my Article I wrote a Simple Load All Subfile in RPGLE. Click Here for this Article and for more details on Subfile.

In this Article, 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 ; 

2 comments:

  1. Hi PR, your code is showing last page of the subfile. How i can display first page of subfile.

    ReplyDelete
    Replies
    1. Hi 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.

      // 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 ;

      Delete

Numeric data types in Python

Numeric Data types There are three different data types to store numeric data.  int float complex int (integer) Data type 'int' is u...