IBMi (AS400) fans only - RPG Free. Minimalist program with a single video format

 



#IBMiSample


Remember that you need my CLANA00F file to compile the following program. So, f
irst of all look at this post and compile and populate these files to use this example.




A01ARPCL.CLP

             PGM                                                
             DCL        VAR(&PPCCL0) TYPE(*DEC)   LEN(7 0)      
             DCL        VAR(&PPEXIT) TYPE(*CHAR)  LEN(1)        
             DCL        VAR(&OUTPU1) TYPE(*CHAR)  LEN(1)        
             DCL        VAR(&OUTPU7) TYPE(*CHAR)  LEN(7)        
             DCL        VAR(&OUTPU8) TYPE(*CHAR)  LEN(8)        
             CALL       PGM(A01ARP) PARM(&PPEXIT &PPCCL0)       
             CHGVAR     VAR(&OUTPU1) VALUE(&PPEXIT)             
             CHGVAR     VAR(&OUTPU7) VALUE(&PPCCL0)             
             CHGVAR     VAR(&OUTPU8) VALUE(&OUTPU1 *CAT &OUTPU7)
             SNDPGMMSG  MSG(&OUTPU8)                            
             ENDPGM                                             



A01ARPV.DSPF

     A                                      DSPSIZ(*DS3)                   
     A                                      REF(*LIBL/CLANA00F)     
     A                                      CHGINPDFT(UL CS)        
     A                                      PRINT                    
     A                                      CF03(03)               
     A                                      CF05(05)                
     A                                      CF06(06)                
     A*******************************************************
     A*  F01                                                         
     A*******************************************************
     A          R F01                                                    
     A                                      OVERLAY                   
   
     A                                  1 31'PARAMETERS REQUEST'     
   
     A                                      DSPATR(HI)               
     
      *                                                               
   
     A                                  2 10'CUSTOMER CODE:'         
   
     A            PPCCL0    R        B   + 1REFFLD(CLCCL0)           
   
     A  61                                  DSPATR(RI PC)             
     
      *                                                               
   
     A            F1ERR1        78A  O 22  2COLOR(RED)       

     A            F1ERR2        78A  O 23  2COLOR(RED)       
      *******************************************************
      *  P00                                                 
      *******************************************************
     A          R P00                                        
     A                                 24  3'F3=EXIT'        
     A  60                                +3'F6=GO'          


A01ARP.RPGLE




      **free
      *********************************************************
      *  Parameter request. One format only                   *
      *********************************************************
       ctl-opt DFTACTGRP(*NO);
      *
       dcl-f A01ARPV workstn;//indds(Dspf);
      *
       dcl-s chkAllRight char(2);
      *
       dcl-pi A01ARP ;
         PPEXIT char(1);
         PPCCL0 packed(7:0);
       end-pi ;
      *
       // *****************************************************
       // PGM start
       // *****************************************************
       PPEXIT = 'N';
       dow (1 = 1) ;

         write p00;
         exfmt f01;

         if (*in03);
           PPEXIT = 'Y';
           leave;
         endif;

         if (*in05 = *off and *in03 = *off and *in06=*off);
         *in60 = *off;
         *in61 = *off;
         F1ERR1 = *blanks;
         F1ERR2 = *blanks;
         chkAllRight='NO';

           dow (chkAllRight<>'SI');

             // cliente
             if (PPCCL0 = 0);
               F1ERR1 = 'Errore Cliente';
               *in61 = *on;
               leave;
             endif;

             chkAllRight='SI';
             *in60=*on;

           enddo;

         endif;

         // se F6 e tutto va bene...
         if (chkAllRight='SI' and
             *in06=*on        and
             *in61=*off
             );
           leave;
         endif;

       enddo;

       *inlr = *on;




Now execute:

CALL A01ARPCL


Fill the CUSTOMER CODE with a value and type ENTER...


Type F6=EXIT or F6=GO...




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



I appreciate all the comments made on this blog.

Comments

  1. I don’t really like it when I see code with “Dow (1=1)”. Make the code have a real meaning. Like “Dow P1Exit <> ‘1’”

    ReplyDelete
    Replies
    1. I don't like leave in Loop.
      I don't like association between CFxx and general indicators. Better using *ink_ (dow 1=1 become dow not *inkc).
      With flat screen, not need a plus format for bottom.

      Delete
    2. Thank you for your continued input; your insights are incredibly valuable. I appreciate your specific suggestions regarding leaving loops, the use of *ink_ for indicators, and the elimination of the plus format for the bottom with flat screens. Your guidance will certainly help enhance the program.

      I'm grateful for your help in making the code more efficient and readable.

      As soon as I can, I'll make the adjustments to the code.

      Delete
  2. Thank you for sharing your thoughts, and I genuinely appreciate your feedback. It's always valuable to receive input from peers like you. I'll take your advice to heart and strive to make the code more meaningful in the future. If you or any of my LinkedIn friends have additional suggestions, please don't hesitate to share them. Constructive feedback helps us all grow and improve. Thanks again!

    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!