Data Area Data Structure in RPG AS400 |
What is Data Area Data Structure
When andy data structure subfields are based upon the Data area then it's a Data area Data Structure.
In position 23 in D specs, specify U for defining a data area data structure.
Prompt type . . . D Sequence number . . . 0002.00 Declaration To / Name E S/U Type From Length ds1 U DS Internal Decimal Data Type Positions Keywords DTAARA('DATAAREA1') Comment
Declaring Data area Data Structure in RPGLE Fixed format
* ds subfields are based upon data area D ds1 UDS DTAARA('DATAAREA1') D sbfld1 10 D sbfld2 10
Declaring Data area Data Structure in RPGLE Fully Free format
Use the DTAARA keyword in fully free RPG with the data structure to make it data area data structure.
dcl-ds ds1 dtaara('*LIBL/DATAAREA1') ; sbfld1 char(10); sbfld2 char(10); end-ds;
Create a 20 Character Data area to be used in Data Structure
CRTDTAARA DTAARA(DATAAREA1) TYPE(*CHAR) LEN(20)
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 DATAAREA1 *DTAARA EASYCLASS1
dspdtaara DATAAREA1
Display Data Area Data area . . . . . . . : DATAAREA1 Library . . . . . . . : EASYCLASS1 Type . . . . . . . . . : *CHAR Length . . . . . . . . : 20 Text . . . . . . . . . : Value Offset *...+....1....+....2....+....3....+....4....+... 0 ' '
Coding Data Area Data Structure in RPGLE Fixed, /Free and Fully Free format
In this example, we first declare a data area data structure in RPG program and the read that using IN opcode and update the data area using OUT opcode.
RPG Code in Fixed format for Data Area data structure in RPGLE AS400
* ds subfields are based upon data area D ds1 UDS DTAARA('DATAAREA1') D sbfld1 10 D sbfld2 10 C IN DS1 C EVAL sbfld1 = 'changed1' C EVAL sbfld2 = 'changed2' C OUT DS1 C SETON LR C RETURN
RPG Code in /Free format for Data Area data structure in RPGLE AS400
* ds subfields are based upon data area D ds1 UDS DTAARA('DATAAREA1') D sbfld1 10 D sbfld2 10 /Free IN ds1; sbfld1 = 'changed1'; sbfld2 = 'changed2'; OUT ds1; *inlr = *on; return; /End-Free
RPG Code in Fully Free format for Data Area data structure in RPGLE AS400
**FREE dcl-ds ds1 DTAARA('DATAAREA1'); sbfld1 char(10); sbfld2 char(10); end-ds; IN *lock ds1; sbfld1 = 'changed1'; sbfld2 = 'changed2'; OUT ds1; *inlr = *on; return;
Run Time Error (RNQ0412)!
Data area *LIBL/DATAAREA1 is not allocated for output (C G D F).
program Output
Data area value will get updated.To see the changed data area value again run DSPDTAARA DATAAREA1 command on command line.
Display Data Area System: PUB400 Data area . . . . . . . : DATAAREA1 Library . . . . . . . : EASYCLASS1 Type . . . . . . . . . : *CHAR Length . . . . . . . . : 20 Text . . . . . . . . . : Value Offset *...+....1....+....2....+....3....+....4....+....5 0 'changed1 changed2 '
Related Post
Read also :
- Data Structure and Types of DS in RPG AS400
- Using a Data Structure to subdivide the field in RPG AS400
- Using a Data Structure to group fields in RPG AS400
- Externally Described Data Structure in RPG AS400
- Using EXTFLD to code Externally Described DS in RPG AS400
- Using PREFIX to rename all fields in an external data structure in RPG AS400
- Define an externally-described data structure using the LIKEREC keyword in RPG AS400
- Difference between LIKEREC and EXTNAME keyword in RPG AS400
- Multiple Occurrence Data Structure in RPG AS400
- *LDA Local data area data structure in RPG AS400
- File information data structures (INFDS) in RPG AS400
- Indicator data structure in RPG AS400
- Program Status Data Structure in RPG AS400
- Using keywords QUALIFIED, LIKEDS, and DIM with data structures
- Array Data Structures in RPG AS400
- Defining Data Structure Parameters in a Prototype or Procedure Interface