Now, Get RPG Codes in all three formats only on this website on every RPGLE related programming article.

Fixed, /Free and Fully Free RPG


Using EXTFLD to code Externally Described DS in RPG AS400

Using EXTFLD to code Externally Described DS in RPG
Using EXTFLD to code Externally Described DS in RPG AS400, externally described data structure, ds , data structure, create,make,about,what,introduction,as400,EXTNAME
Using EXTFLD to code Externally Described DS in RPG AS400

Example2: Using EXTFLD to code Externally Described DS in RPG

In this example, the Externally described data structure DS1 is defined on a file named RPGLE14PF using the EXTNAME keyword, and individual file fields are renamed using the EXTFLD keyword.

RPG Code in Fixed format for Externally Described Data Structure
                            
     D ds1           E DS                  EXTNAME(RPGLE14PF:RCDFMT14)  
     D a1IDN         E                     EXTFLD(IDN)                  
     D b1Name        E                     EXTFLD(NAME)                 
     D c1Addr1       E                     EXTFLD(ADDR1)                
     D d1Addr2       E                     EXTFLD(ADDR2)                
     C                   EVAL      a1IDN = 2                            
     C                   EVAL      b1Name = 'DUMMY'                      
     C                   EVAL      c1Addr1 = 'Address1'                   
     C                   EVAL      d1Addr2 = 'Address2'                                                            
     C                   SETON                                        LR   
     C                   RETURN                                                                               
RPG Code in /Free format for Externally Described Data Structure
                          
     D ds1           E DS                  EXTNAME(RPGLE14PF:RCDFMT14)  
     D a1IDN         E                     EXTFLD(IDN)                  
     D b1Name        E                     EXTFLD(NAME)                 
     D c1Addr1       E                     EXTFLD(ADDR1)                
     D d1Addr2       E                     EXTFLD(ADDR2)                 
      /Free                                                             
           a1IDN = 2;                                                   
           b1Name = 'DUMMY';                                            
           c1Addr1 = 'Address1';                                        
           d1Addr2 = 'Address2';                                        
           *inlr = *on;                                                 
           return;                                                      
      /End-Free                                                                                                                                                                                                        
RPG Code in fully Free format for Externally Described Data Structure
**FREE                                 
 DCL-DS DS1 EXTNAME('RPGLE14PF') ;  
   a1IDN EXTFLD('IDN');
   b1Name EXTFLD('NAME'); 
   c1Addr1 EXTFLD('ADDR1'); 
   d1Addr2 EXTFLD('ADDR2');   
 END-DS;                                                                                                        
           a1IDN = 2;                                                   
           b1Name = 'DUMMY';                                            
           c1Addr1 = 'Address1';                                        
           d1Addr2 = 'Address2';                                        
           *inlr = *on;                                                 
           return;                                                                                                                                               

Program Output

> EVAL DS1                                                                
  A1IDN OF DS1 = 02.                                                      
  B1NAME OF DS1 = 'DUMMY               '                                  
  C1ADDR1 OF DS1 = 'Address1                                          '   
  D1ADDR2 OF DS1 = 'Address2                                          '   

Related Post

Post a Comment

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