Using PERRCD keyword in compile Time Array in RPG AS400

Using PERRCD keyword in compile Time Array in RPG
Using PERRCD keyword in compile Time Array in RPG AS400, Array, types of array, compile time array, perrcd, ctdata,dim
Using PERRCD keyword in compile Time Array in RPG AS400

PERRCD keyword

PERRCD keywords define the number of entries in one array record.

if PERRCD(3) is defined with compile-time CTDATA array then there would be three entries in each compile-time array record element.

Code Example for using PERRCD keyword in Compile-Time Array

RPG Code in Fixed format for Compile Time Array in AS400
      *Header Specification                                                 
     HDebug(*Yes)                                                           
     HOption(*NoDebugio)                                                    
      * program variables                                                   
     D CompileTimeArray...                                                 
     D                 S             10A   DIM(10) CTDATA PERRCD(2)                                       
      *                                                                     
     D Index           S             10i 0                                  
     D AddArrayData    S             30A                                    
      *                                                                     
     C                   EVAL      Index = 1                                
     C                   DOW       Index <=10                                
     C                   EVAL      AddArrayData =                           
     C                             %Trim(CompileTimeArray(Index))  
     C     AddArrayData  DSPLY                                              
     C                   EVAL      Index = Index + 1                        
     C                   ENDDO                        
     C                   EVAL      *INLR = *ON        
** CTDATA CompileTimeArray
AMIT      SINGH           
ABHAY     KAPOOR          
AJAY      VERMA           
AMAR      LAL             
ANUJ      SINGHANIA                                                   
RPG Code in /Free format for Compile Time Array in AS400
      *Header Specification                                            
     HDebug(*Yes)                                                      
     HOption(*NoDebugio)                                               
      * program variables                                              
     D CompileTimeArray...                                            
     D                 S             10A   DIM(10) CTDATA PERRCD(2)                            
      *                                                                
     D Index           S             10i 0                             
     D AddArrayData    S             30A                               
      *                                                                
      /Free                                                            
       // Begin program                                                
       Index =  1;                                                     
       Dow (Index <=10);                                                
         AddArrayData = %Trim(CompileTimeArray(Index));            
         DSPLY AddArrayData;                                           
         Index = Index + 1;                      
       EndDo;                                    
                                                 
       //Set Last Record Indicator ON            
       *Inlr = *ON;                              
                                                 
      /End-Free                                  
** CTDATA CompileTimeArray
AMIT      SINGH           
ABHAY     KAPOOR          
AJAY      VERMA           
AMAR      LAL             
ANUJ      SINGHANIA                                                                                             
RPG Code in fully Free format for Compile Time Array in AS400
**FREE                                                     
                                                           
ctl-opt debug(*yes);                                       
ctl-opt Option(*NoDebugio);                                
                                                           
dcl-s CompileTimeArray char(10) DIM(10) CTDATA PERRCD(2);                       
                                                           
dcl-s Index int(10);                                       
dcl-s AddArrayData char(30);                               
                                                           
// Begin program                                           
Index =  1;                                                
Dow (Index <=10);                                           
  AddArrayData = %Trim(CompileTimeArray1(Index)) ;          
  DSPLY AddArrayData;                                      
  Index = Index + 1;                                       
EndDo;        
                                             
//Set Last Record Indicator ON   
*Inlr = *ON;                     
                                 
** CTDATA CompileTimeArray
AMIT      SINGH           
ABHAY     KAPOOR          
AJAY      VERMA           
AMAR      LAL             
ANUJ      SINGHANIA                       

Program Output

DSPLY  AMIT     
DSPLY  SINGH    
DSPLY  ABHAY    
DSPLY  KAPOOR   
DSPLY  AJAY     
DSPLY  VERMA    
DSPLY  AMAR     
DSPLY  LAL      
DSPLY  ANUJ     
DSPLY  SINGHANIA

Post a Comment

© AS400 and SQL Tricks. All rights reserved. Developed by Jago Desain