*LDA Local data area data structure in RPG AS400

*LDA Local data area data structure in RPG AS400
*LDA Local data area data structure in RPG AS400, *LDA, local data area, local data area data structure, data area, ds, data structure, Define *LDA data area data structure, create, make, about, introduction
*LDA Local data area data structure in RPG AS400

What is *LDA Local Data Area for IBM i

  • A local data area is created for each Job in the IBM i system which is initially blank with a length of 1024 and type *CHAR.
  • We can refer to the Job's local data area by specifying *LDA for the DTAARA keyword on DSPDTAARA, CHGDTAARA, and RTVDTAARA command.
  • The local data area is unique and specific to the job. Therefore we cannot refer one job *LDA from other jobs.
  • No library is associated with the *LDA local data area.
  • We cannot Create, Delete or Allocate an *LDA local data area.
  • We can use the *LDA local data area to pass information to a procedure or program without using the parameters.
  • We can use *LDA local data area to store information without the need to create or delete the data area by ourselves.
  • Submit Job (SBMJOB) command allows us to pass the data of the submitting job's local data area to the new job.
  • Run the below command to see the *LDA of your job.

    dspdtaara *LDA
                                   Display Data Area                      
                                                                 System:  
     Data area . . . . . . . :   *LDA                                     
     Type  . . . . . . . . . :   *CHAR                                    
     Length  . . . . . . . . :   1024                                     
     Text  . . . . . . . . . :   *LDA for Job 003990/EASYCLASS/QPAD191838 
                                                                          
                                                                          
                Value                                                     
     Offset      *...+....1....+....2....+....3....+....4....+....5       
         0      '                                                  '      
        50      '                                                  '      
       100      '                                                  '      
       150      '                                                  '      
       200      '                                                  '      
       250      '                                                  '      
       300      '                                                  '      
       350      '                                                  '      
       400      '                                                  '      
    

    What is *LDA Local data area data structure?

  • When we do not specify the name of the data structure and use UDS and do not specify the DTAARA keyword then it's a data area data structure.
  • Specify DTAARA(*LDA) then it's a data area data structure.
  • Use *N (No name) and DTAARA(*AUTO) to refer to *LDA local data area data structure.
  • No need to perform read (IN) and write (OUT) to *LDA local data area data structure. At program initialization, *LDA contents are being read, and at program termination, the local data area contents get updated.
  • Declaring *LDA local data area data structure in Fixed format RPG

         D                UDS                          
         D subfld1                       10a                      
    

    Or

         D ldaDS          UDS                  DTAARA(*LDA)  
         D subfld1                       10a                           
    

    Declaring *LDA local data area data structure in Fully Free-format RPG

    dcl-ds *n dtaara(*auto) ;
      subfld1 char(10);
    end-ds;
    

    Or

    dcl-ds ldaDS dtaara(*LDA) ;
      subfld1 char(10);
    end-ds;                     
    

    Coding *LDA local data area data structure in RPGLE Fixed, /Free and Fully Free format.

    In this example, we write data to *LDA local data area data structure.

    RPG Code in Fixed format for *LDA Local Data Area data structure in RPGLE AS400
          * unnanmed data area ds                                                             
          * don't require IN/OUT for *lda ds (INIT --> IN and TERM --> OUT)                  
          * created for each job. (1024 char (blank))                                        
          * dspdtaara *lda (cannot create, delete,allocate, no library associated with this)                                
         D                UDS                                         
         D subfld1                       10a         
          * You can define *LDA as below too. Currently below definition commented.                 
         D*ldaDS          UDS                  DTAARA(*LDA)           
         D*subfld1                       10a                                                                                     
         C                   EVAL      sbfld1 = 'hello lda'                                            
         C                   SETON                                            LR 
         C                   RETURN                                                                                     
    
    RPG Code in /Free format for *LDA Local Data Area data structure in RPGLE AS400
         D                UDS                                                               
         D subfld1                       10a   
          * You can define *LDA as below too. Currently below definition commented.                                                    
         D*ldaDS          UDS                  DTAARA(*LDA)                                 
         D*subfld1                       10a                                                
          /Free                                                                                                                                            
              subfld1 = 'hello lda';                                                        
              *inlr = *on;                                                                  
              return;                                                                       
          /End-Free                                                                                                                                                                                                                                                
    
    RPG Code in Fully Free format for *LDA Local Data Area data structure in RPGLE AS400
    **FREE                            
    dcl-ds *N DTAARA(*AUTO);          
     subfld1 char(10);                
    end-ds;                           
              subfld1 = 'hello lda';  
              *inlr = *on;            
              return;                                                               
    
    RPG Code in Fully Free format for *LDA Local Data Area data structure in RPGLE AS400
    **FREE                            
    dcl-ds ldaDS DTAARA(*LDA);        
     subfld1 char(10);                
    end-ds;                           
       IN ldaDS;                      
              subfld1 = 'hello lda';  
       OUT ldaDS;                     
              *inlr = *on;            
              return;                                                                              
    

    Output

                                   Display Data Area                      
                                                                 System:  
     Data area . . . . . . . :   *LDA                                     
     Type  . . . . . . . . . :   *CHAR                                    
     Length  . . . . . . . . :   1024                                     
     Text  . . . . . . . . . :   *LDA for Job 003990/EASYCLASS/QPAD191838 
                                                                          
                                                                          
                Value                                                     
     Offset      *...+....1....+....2....+....3....+....4....+....5       
         0      'hello lda                                         '      
        50      '                                                  '      
       100      '                                                  '      
       150      '                                                  '      
       200      '                                                  '      
       250      '                                                  '      
       300      '                                                  '      
       350      '                                                  '      
       400      '                                                  '      
                                                                          
     Press Enter to continue.                                             
    

    Related Post

    Post a Comment

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