IBMi (AS400) fans only - Fully free RPG: minimalist SUBFILE example


Subfile




#IBMiSample 

First of all look at this post and compile and populate these files to use this example.

Then copy e compile the following sources.


SFLMINV.DSPF

      * SFLCTL | SFLPAGE - SFLSIZE - SFLDSP - SFLDSPCTL - SFLEND - SFLCLR
      *        |      10       100       50          50       50      N50
      *        |                                                         
      * SFL01  | RRN 4S 0                                                
      * CLEAR  | SFLCLR=ON & write SFLCTL & RRN = 0                      
      * LOAD   | increase RRN & write sfl01                            
      * DISPLAY| exfmt SFLCTL record format                              
      *                                                                     
     A                                      REF(*LIBL/CLANA00F)          
     A          R SFL01                     SFL                          
     A            SFLRRN         5S 0H                                   
     A            CLANN0    R        O  5  2                             
     A            CLNOM0    R        O   + 1                             
     A          R SFLCTL                    SFLCTL(SFL01)              
     A                                      SFLSIZ(0100)                 
     A                                      SFLPAG(0010)                 
     A                                      OVERLAY                      
     A  50                                  SFLDSP                        
     A  50                                  SFLDSPCTL                    
     A  50                                  SFLEND(*MORE)                      
     A N50                                  SFLCLR                       
     A                                  1  3'Minimal Subfile RPGLE Sample'

SFLMIN.RPGLE
      **FREE
      // minimalist SUBFILE sample fully free RPG
      // Compile with:
      // CRTBNDRPG PGM(mylib/SFLMIN) SRCFILE(mylib/QRPGLESRC)
     
       ctl-opt DFTACTGRP(*NO);
 
       dcl-f CLANA01L keyed usage (*input); // Customer File
       dcl-f SFLMINV workstn sfile(SFL01:rrn); // Displayfile
 
       dcl-s rrn like(sflrrn);
 
       // *********************************************************************
       // PGM start
       // *********************************************************************
 
       ClearSr();
       LoadSr();
       exfmt SFLCTL;
 
       *inlr = *on;
       return;
       // *********************************************************************
       // Clear Subfile procedure...
       // *********************************************************************
       dcl-proc ClearSr;
 
         *in50 = *off;
         write SFLCTL;
         *in50 = *on;
         rrn = 0;
 
       end-proc;
 
       // *********************************************************************
       // Load  Subfile procedure...
       // *********************************************************************
       dcl-proc LoadSr;
 
         Setll (*loval) CLana01L;
         Read CLana;
         Dow not %eof(CLana01L);
           rrn += 1;
           write SFL01;
           Read CLana;
         Enddo;
 
       end-proc;








Another version with DSPSIZ, INDARA, CAnn

SFLMINV.DSPF

      * SFLCTL | SFLPAGE - SFLSIZE - SFLDSP - SFLDSPCTL - SFLEND - SFLCLR
      *        |      10       100       50          50       50      N50
      *        |                                                         
      * SFL01  | RRN 4S 0                                                
      * CLEAR  | SFLCLR=ON & write SFLCTL & RRN = 0                      
      * LOAD   | increase RRN & write sfl01                            
      * DISPLAY| exfmt SFLCTL record format                              
      *                                                                     
     A                                      DSPSIZ(27 132 *DS4)
     A                                      INDARA
     A                                      CA03(03 'F3=EXIT')
     A                                      CHGINPDFT(CS UL HI)   
     A                                      REF(*LIBL/CLANA00F)          

     A          R SFL01                     SFL                          
     A            SFLRRN         5S 0H                                   
     A            CLANN0    R        O  5  2                             
     A            CLNOM0    R        O   + 1                             
     A          R SFLCTL                    SFLCTL(SFL01)              
     A                                      SFLSIZ(0100)                 
     A                                      SFLPAG(0010)                 
     A                                      OVERLAY                      
     A  50                                  SFLDSP                        
     A  50                                  SFLDSPCTL                    
     A  50                                  SFLEND(*MORE)                      
     A N50                                  SFLCLR                       
     A                                  1  3'Minimal Subfile RPGLE Sample'
     A          R BOTTOM                                         
     A                                 24  3'F3=Exit'  COLOR(BLU)






SFLMIN.RPGLE
      **FREE
      // minimalist SUBFILE sample fully free RPG
      // Compile with:
      // CRTBNDRPG PGM(mylib/SFLMIN) SRCFILE(mylib/QRPGLESRC)
     
       ctl-opt DFTACTGRP(*NO);
 
       dcl-f CLANA01L keyed usage (*input); // Customer File
       dcl-f SFLMINV workstn indds(Dspf) sfile(SFL01:rrn); // Displayfile
 
       dcl-s rrn like(sflrrn);

       dcl-ds Dspf qualified ;                 
         Exit            ind pos(03) inz(*off);
         SflClr          ind pos(50) inz(*off);
       end-ds ;

 
       // *********************************************************************
       // PGM start
       // *********************************************************************
 
       ClearSr();
       LoadSr();
       exfmt SFLCTL;
 
       *inlr = *on;
       return;
       // *********************************************************************
       // Clear Subfile procedure...
       // *********************************************************************
       dcl-proc ClearSr;
 
         Dspf.SflClr = *off;
         write SFLCTL;
         Dspf.SflClr = *on;
         rrn = 0;
 
       end-proc;
 
       // *********************************************************************
       // Load  Subfile procedure...
       // *********************************************************************
       dcl-proc LoadSr;
 
         Setll (*loval) CLana01L;
         Read CLana;
         Dow not %eof(CLana01L);
           rrn += 1;
           write SFL01;
           Read CLana;
         Enddo;
 
       end-proc;

 

Don't forget to set the screen to 132 columns!



I appreciate all the comments made on this blog.

Comments

  1. I try on my AS400, usualy a use a PDM for Freerpg program and VCode for java ord python, but i try it,
    it work very well

    ReplyDelete
  2. Nice example, i like the use of only one indicator for all subfile keywords. I Always wonder why IBM has not developed a Better way to handle subfiles

    ReplyDelete

Post a Comment

Popular posts from this blog

IBMi (AS400) fans only ‘ Memories (IBM Coding Forms)

IBMi (AS400) fans only ' SQLCODE values: Dear readers, unleash your suggestions!

Efficient WRKSPLF with WSF: How to Search string into spooled files, Sort, and Generate PDFs on IBMi