Ü   Data area  

ü  A data area is an object used to store the shared data of different jobs running on the system.

ü  It is permanent storage.

ü  A data area is useful in a case we want a place to store small information of data that can be shared by different jobs running on the system or in other words we want the updated data to be available for all jobs irrespective of all the updating done in the data of data area by any job.

ü  Hence we can say its an storage to pass information within job.

ü  Another feature of data area is that it can be locked by a single user, thus preventing other users from processing the data in it at the same time. Once the processing is done it can be unlocked also.

ü  Main uses of dataarea can be:

o   To store basic job information that is needed to run a group of jobs

o   Use in auto-generation of numbers e.g. next account no. generation, next invoice no. generation, next order no. generation etc.

 

Ü   Types of data area

1)    User defined data area

2)    System defined data area

a.   Local data area

b.   Group data area

c.   Program initialization parameter (PIP) data area

 

I.     User defined data area

To create user defined data area command is : CRTDTAARA

 

e.g.

 

CRTDTAARA DTAARA(IROBO1/DA) 
          TYPE(*CHAR) LEN(12) 
          VALUE('100000000001')  
          TEXT('IROBO DATA AREA')

 


                              Create Data Area (CRTDTAARA)             
                                                                   
 Type choices, press Enter.                                        
                                                                   
 Data area  . . . . . . . . . . . DTAARA       > DA                
   Library  . . . . . . . . . . .              >   IROBO1          
 Type . . . . . . . . . . . . . . TYPE         > *CHAR   >>>> *CHAR/*INT/*LGL/*DDM          
 Length:                          LEN                              
   Length . . . . . . . . . . . .                12                
   Decimal positions  . . . . . .                                  
 Initial value  . . . . . . . . . VALUE          ‘100000000001’      
                                                                    
 Text 'description' . . . . . . . TEXT           IROBO DATA AREA   
                                                                   
                                                                   
                            Additional Parameters                  
                                                                   
 Authority  . . . . . . . . . . . AUT            *LIBCRTAUT        

 

To check the value in the data area:

DSPDTAARA DTAARA(IROBO1/DA)

 


                               Display Data Area                          
                                                             System:   PUB1
 Data area . . . . . . . :   DA                                           
   Library . . . . . . . :     IROBO1                                     
 Type  . . . . . . . . . :   *CHAR                                        
 Length  . . . . . . . . :   12                                           
 Text  . . . . . . . . . :   IROBO DATA AREA                               
                                                                          
            Value                                                         
 Offset      *...+....1....+....2....+....3....+....4....+....5           
     0      '100000000001'     
                 

  


Program using user defined data area DA for AUTOGENERATION of Next Number

 


Columns . . . :    6  76            Edit                           AMINEM/PRJ1
SEU==>                                                                  GENACC
FMT C  CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
*************** Beginning of data *************************************
0004.00 C     *DTAARA       DEFINE                  DA               12
0005.00 C     *ENTRY        PLIST
0006.00 C                   PARM                    A1               12
0007.00 C     *LOCK         IN        DA              >>>>Lock and Read the data area DA
0008.00 C                   MOVEL     DA            C                12
0009.00 C                   MOVEL     *ZEROS        I                12 0
0010.00 C                   EVAL      I=%INT(C)
0011.00 C                   ADD       1             I
0012.00 C                   EVAL      C=%CHAR(I)
0013.00 C                   MOVEL     C             DA
0015.00 C                   MOVEL     C             A1
0016.00 C                   OUT       DA                >>>>>>> Write/Update the data area
0017.00 C                   UNLOCK    DA                >>>>>>> Unlock the data area
0019.00 C                   SETON                                        LR
0020.00 C                   return

****************** End of data ****************************************

 

Output:

Then each time GETACC is called, the generated no. will be 100000000002, 100000000003, 100000000004…….

 

 

II.            System defined data area

¤ Local data area (LDA)

ü  A local data area is created for each job in the system automatically.

ü  When you submit a job using SBMJOB command, the value of the submitting job’s local data area is copied into the submitted job’s local data area.

ü  The system create a local data area, which is initially filled with blanks, with a length of 1024 and type *CHAR.

ü  Steps accessing data area in CL:

o  The first create a general data area use the command (CRTDTAARA)

o  To retrieve values from data area use (RTVDTAARA)

o  To change this value, use (CHGDTAARA)

o  To display the current value, use (DSPDTAARA)

o  To delete a data area use (DLTDTAARA)

e.g.


0045.00      DCL VAR(&PRCDATY) TYPE(*CHAR) LEN(4)
0046.00      DCL VAR(&PRCDATM) TYPE(*CHAR) LEN(2)
0047.00      DCL VAR(&PRCDATD) TYPE(*CHAR) LEN(2)
0048.00      DCL VAR(&SYSID) TYPE(*CHAR) LEN(10)
0050.00      DCL VAR(&MSG) TYPE(*CHAR) LEN(80)
0051.00      MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(E0))
0052.00      RTVDTAARA DTAARA(*LDA (1 4)) RTNVAR(&PRCDATY)
0053.00      RTVDTAARA DTAARA(*LDA (5 2)) RTNVAR(&PRCDATM)
0054.00      RTVDTAARA DTAARA(*LDA (7 2)) RTNVAR(&PRCDATD)
0055.00      RTVDTAARA DTAARA(*LDA (161 10)) RTNVAR(&SYSID)
0056.00      CHGDTAARA DTAARA(*LDA (13  15)) VALUE(123)

       

 

An rpgle program using *Lda to get the Local data area information


189  * Storage fields for Local Data Area.                                 *
190 DLda             UDs                  DTAARA(*Lda)
191 DLdadateY                 1      4  0
192 DLdadateM                 5      6  0
193 DLdadateD                 7      8  0
194 DLcycur                  36     38
195 DXrateQto               405    405
 
745  **********************************************************************
746  * INZSR        : Subroutine for Initialization the Rerieval of the
747  *              : Local Data Area Information.
748  **********************************************************************
749 C     *INZSR        BEGSR
750  * Get the Local data area values for the LDA date,Local currency and  *
751  * Exchange Notation.                                                  *
752 C                   IN (E)    *DTAARA
753  *
754 C                   IF        NOT %Error
755 C                   Eval      #LdaYear  = LdadateY
756 C                   Eval      #LdaMonth = LdadateM
757 C                   Eval      #LdaDay   = LdadateD
758 C                   Eval      #LcyCur   = Lcycur
759 C                   Eval      #XrtQto   = XrateQto
760 C                   EndIF
761  *
762 C     @INZSR        ENDSR

 

 

¤ Group data area (GDA)

ü  The system creates a group data area when an interactive job becomes a group job.

ü  Only one group data area can exist for a group.

ü  The group data area is deleted when the last job in the group is ended, or when the job is no longer part of the group job.

ü  A group data area, which is initially filled with blanks, has a length of 512 and type *CHAR.

 

 
CHGDTAARA DTAARA (*GDA) VALUE (‘THIS IS GDA’)
RTVDTAARA DTAARA (*GDA) RTNVAR (&GRPVAR)

 

 

 

¤ Program initialization parameter (PIP) data area

ü  A PIP data area is created for each pre-started job when the job is started.

ü  The PIP can only be referred to by the special value name *PDA.

ü  The size of the PDA is 2000 bytes but the number of parameter contained in it is not restricted.

 




 

 







User Comments:



Copyright © www.go4as400.com, 2013-2023. Copyright notice   Terms of services   Privacy policy