Rename a field in CL Program - iSeries(AS400)

You need to use the Open ID when declaring the file in DCLF

Sample Order Header File

File . . :  OHEAD      Record format . : OHEADR     Record length . . :     63
Library . : DAS        File type . . . : PF         Number of fields . :     8
Text . . :  Order Header                                                      
                                                                              
Field      Type      Size    Key    Text                                      
X1DEL      Char       1             Status                                    
X1CMP      Zoned      3,0     1     Company No.                               
X1ORD      Zoned      9,0     2     Order Number                              
X1TYPE     Char       1             Transaction Type                          
X1ORDT     Zoned      8,0           Order Date                                
X1CUST     Char      10             Customer Number                           
X1PO       Char      20             PO Number                                 
X1OTOT     Zoned     11,2           Order Total  

Sample CL Program

PGM                                           
DCLF       FILE(OHEAD) OPNID(RENAME)          
RCVF       OPNID(RENAME)                      
SNDPGMMSG  MSG(&RENAME_X1CUST) TOPGMQ(*EXT)   
ENDPGM  

Look at the spool file for the compiled CL program

100-              PGM                                                                 
200-              DCLF       FILE(OHEAD) OPNID(RENAME)                                
     QUALIFIED FILE NAME - DAS/OHEAD                                                  
        RECORD FORMAT NAME - OHEADR                                                   
          CL VARIABLE               TYPE     LENGTH     PRECISION     TEXT            
           &RENAME_X1DEL            *CHAR       1                     Status          
           &RENAME_X1CMP            *DEC        3           0         Company No.     
           &RENAME_X1ORD            *DEC        9           0         Order Number    
           &RENAME_X1TYPE           *CHAR       1                     Transaction Type
           &RENAME_X1ORDT           *DEC        8           0         Order Date      
           &RENAME_X1CUST           *CHAR      10                     Customer Number 
           &RENAME_X1PO             *CHAR      20                     PO Number       
           &RENAME_X1OTOT           *DEC       11           2         Order Total     
300-              RCVF       OPNID(RENAME)                                            
400-              SNDPGMMSG  MSG(&RENAME_X1CUST) TOPGMQ(*EXT)                         
500-              ENDPGM     

No comments:

Post a Comment

NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.