Data area in AS400

Data area in AS400
Data area in AS400, Data area,Types of data area,User defined data area,System defined data area,User defined data area example,System defined data area example,Program initialization parameter data area,PIP data area,Local data area,LDA,CRTDTAARA,RTVDTAARA,CHGDTAARA,DSPDTAARA,DSPDTAARA,DLTDTAARA,Group data area,GDA,as400,ILE RPG, rpg,rpgle,,command,CL command,control language,cl programming,CL,programs,use
Data area in AS400

Data Area

Data Area is an object which is used to hold data for access by any job running on the AS400 system. You can store a limited size of data in the data area.

We can journal data areas which allow us to recover data area objects to their consistent state if any issue occurs.

Use of Data Area

  1. To provide storage to pass information within a job.
  2. To provide a field that is frequently changed such as any next number whether its order number or check number or user number etc.
  3. To provide a constant field to be used by several jobs such as library name or any flag etc.
  4. To provide limited access to a large process. A data area can be locked by a single user, therefore, preventing others from processing at the same time.

Create Data Area

Use command CRTDTAARA to create a data area other than a local or a group data area. You create a separate object in a library and you can initialize it to a default value.

                         Create Data Area (CRTDTAARA)                         
                                                                              
Type choices, press Enter.                                                    
                                                                              
Data area  . . . . . . . . . . . > DTARA1        Name                         
  Library  . . . . . . . . . . . >   EASYCLASS1  Name, *CURLIB                
Type . . . . . . . . . . . . . . > *CHAR         *DEC, *CHAR, *LGL, *DDM      
Length:                                                                       
  Length . . . . . . . . . . . . > 2000          1-2000                       
  Decimal positions  . . . . . .                 0-9                          
Initial value  . . . . . . . . . > TEST                                       
Text 'description' . . . . . . . > 'Test Data Area'                           
                                                                              
                                                                              
                           Additional Parameters                              
                                                                              
Authority  . . . . . . . . . . .   *LIBCRTAUT    Name, *LIBCRTAUT, *CHANGE... 

The data area is created successfully.

Data area DTARA1 created in library EASYCLASS1. 

WRKOBJ EASYCLASS1/DTARA1

                              Work with Objects                              
                                                                             
Type options, press Enter.                                                   
  2=Edit authority        3=Copy   4=Delete   5=Display authority   7=Rename 
  8=Display description   13=Change description                              
                                                                             
Opt  Object      Type      Library     Attribute   Text                      
     DTARA1      *DTAARA   EASYCLASS1              Test Data Area            
  • The data area can be of Type character(*CHAR), decimal(*DEC), Logical(*LGL), and remote data area(*DDM).
  • The Default Length for the Decimal data area is (15,5) and the maximum length for the decimal data area is (24,9).
  • The Default Length for the character data area is 32 and the maximum length for the character data area is 2000.
  • The Default and maximum Length for the Logical data area are 1.
  • A logical data area contains the value of '0' or '1', where '0' means off, false, or no and '1' means on, true, or yes.
  • When you create the data area you can specify the initial value. If you do not specify the default values would be 0 for decimal, blanks for the character, '0' for logical data area.
  • Retrieve Data Area value in CL program

    Use command RTVDTAARA to retrieve data area value in CL program variable.

  • Retrieve all the data from the data area.
  •                          Retrieve Data Area (RTVDTAARA)                 
                                                                            
     Type choices, press Enter.                                             
                                                                            
     Label  . . . . . . . . . . . . .                                       
     Data area specification:         DTAARA                                
       Data area  . . . . . . . . . .              > DTARA1                 
         Library  . . . . . . . . . .              >   EASYCLASS1           
       Substring specifications:                                            
       Substring starting position  .              > *ALL                   
       Substring length . . . . . . .                                       
     CL variable for returned value   RTNVAR       > &VALUE                 
     Comment  . . . . . . . . . . . .                                       
    
  • Retrieve substring of data from the data area.
  •                         Retrieve Data Area (RTVDTAARA)               
                                                                         
    Type choices, press Enter.                                           
                                                                         
    Label  . . . . . . . . . . . . .                                     
    Data area specification:         DTAARA                              
      Data area  . . . . . . . . . .              > DTARA1               
        Library  . . . . . . . . . .              >   EASYCLASS1         
      Substring specifications:                                          
      Substring starting position  .              > 5                    
      Substring length . . . . . . .                5                    
    CL variable for returned value   RTNVAR       > &VALUE               
    Comment  . . . . . . . . . . . .                                     
    

    Change Data area

    Use command CHGDTAARA to change the contents of the data area.

  • Change All the content of the data area
  •                          Change Data Area (CHGDTAARA)                   
                                                                            
    Type choices, press Enter.                                              
                                                                            
    Data area specification:         DTAARA                                 
      Data area  . . . . . . . . . .              > DTARA1                  
        Library  . . . . . . . . . .              >   EASYCLASS1            
      Substring specifications:                                             
      Substring starting position  .                *ALL                    
      Substring length . . . . . . .                                        
    New value  . . . . . . . . . . . VALUE        > 'HELLO'                 
    
  • Change substring content of the data area
  •                          Change Data Area (CHGDTAARA)                    
                                                                             
    Type choices, press Enter.                                               
                                                                             
    Data area specification:         DTAARA                                  
      Data area  . . . . . . . . . .              > DTARA1                   
        Library  . . . . . . . . . .              >   EASYCLASS1             
      Substring specifications:                                              
      Substring starting position  .              > 2                        
      Substring length . . . . . . .              > 4                        
    New value  . . . . . . . . . . . VALUE        > 'CHG1'                   
                                                                             
    

    Display Data area

    Use command DSPDTAARA to display the current value of the data area.

                             Display Data Area (DSPDTAARA)      
                                                                
    Type choices, press Enter.                                  
                                                                
    Data area  . . . . . . . . . . . DTAARA       > DTARA1      
      Library  . . . . . . . . . . .              >   EASYCLASS1
    Output . . . . . . . . . . . . . OUTPUT         *           
    Output format  . . . . . . . . . OUTFMT         *CHAR       
                                                                
                               Additional Parameters            
                                                                
    System . . . . . . . . . . . . . SYSTEM         *LCL        
    

    Press ENTER to display the content of the data area after entering the above DSPDTAARA command.

                                   Display Data Area                  
                                                                 System
     Data area . . . . . . . :   DTARA1                               
       Library . . . . . . . :     EASYCLASS1                         
     Type  . . . . . . . . . :   *CHAR                                
     Length  . . . . . . . . :   2000                                 
     Text  . . . . . . . . . :   Test Data Area                       
                                                                      
                Value                                                 
     Offset      *...+....1....+....2....+....3....+....4....+....5   
         0      'TEST                                              '  
        50      '                                                  '  
       100      '                                                  '  
       150      '                                                  '  
       200      '                                                  '  
       250      '                                                  '  
       300      '                                                  '  
       350      '                                                  '  
       400      '                                                  '  
                                                                      
     Press Enter to continue.                                         
     

    Delete Data area

    Use command DLTDTAARA to delete the data area object.

                             Delete Data Area (DLTDTAARA)        
                                                                 
    Type choices, press Enter.                                   
                                                                 
    Data area  . . . . . . . . . . . DTAARA       > DTARA1       
      Library  . . . . . . . . . . .              >   EASYCLASS1 
    

    Data area object deleted successfully.

     Selection or command                             
     ===>                                             
                                                      
     F3=Exit   F4=Prompt   F9=Retrieve   F12=Cancel   
     F23=Set initial menu                             
     Object DTARA1 in EASYCLASS1 type *DTAARA deleted.
    

    Data Area Locking and Allocation

  • CHGDTAARA command uses a *SHRUPD (Shared for Update) lock on the data area during command processing.
  • RTVDTAARA and DSPDTAARA command uses an *SHRRD (Shared for Reading) lock on the data area during command processing.
  • If you want to perform more than one operation on the data area, you can use Allocate Object (ALCOBJ) command to prevent others from accessing the data area until your operations are completed. For example, reading a value from a data area and increment it by some value at the same time.
  • Remote Data Area

    Read about Remote Data Area from the following article

    Remote Data Area in AS400

    Local Data Area

    Read about Local Data Area from the following article

    Local Data Area in AS400

    Group Data Area

    Read about group Data Area from the following article

    Group Data Area in AS400

    Program Initialization Parameter Data Area

    Read about Program Initialization Parameter Data Area from the following article

    Program Initialization Parameter Data Area in AS400

    Post a Comment

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