Data Structure and Types of DS in RPG AS400

Data Structure and Types of DS in RPG AS400
Data Structure and Types of DS in RPG AS400,data structure,data structure use,use of data structure,Using a data structure to break fields,Using a data structure to group fields,Types of data structures,PROGRAM DESCRIBED DATA STRUCTURE,EXTERNALLY DESCRIBED DATASTRUCTURE,MULTIPLE OCCURENCE DATASTRUCTURE,INDICATOR DATA STRUCTURE,DATA AREA DATA STRUCTURE,PROGRAMME STATUS DATASTRUCTURE,PROGRAMME STATUS DATASTRUCTURE,FILE INFORMATION DATASTRUCTURE,LIKEDS keyword,likerec,PSDS,INFDS,*LDA,PREFIX, DIM, Array Data structure, DS with PR PI,introduction,about,what is,what,create,make
Data Structure and Types of DS in RPG AS400

Introduction to Data Structure

The data structure allows users to define an area in the storage and the fields of the data structure are called Subfields in that storage area. So basically, In simple terms, the data structure is comprised of different data types.

Declare Data Structure in Fixed Format RPG

You can declare the data structure in Fixed format RPG by specifying DS in position 24 through 25 in D specs (Definition Specifications).

 DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++Comments++++++++++++ 
 *************** Beginning of data **************************************************************
 D DS1             DS                                                                            

When you press F4 by placing the cursor on this line. You will see below i.e. DS is specified in Declaration Type.

 Prompt type . . .    D      Sequence number . . .  0001.00                  
                                                                             
                             Declaration                      To /           
 Name              E   S/U      Type              From       Length          
  DS1                            DS                                          
 Internal               Decimal                                              
 Data Type             Positions      Keywords                               
                                                                             
 Comment                                                                     

Declare Data Structure in Fully Free RPG

You can declare the data structure in a fully free RPG by specifying the DCL-DS followed by the data structure name and keywords.

DCL-DS DS1;
  SUBFIELD1 CHAR(1);
END-DS;

Use of Data Structure

  1. Using a data structure to subdivide the field.
  2. Using a data structure to group fields.

Types of Data Structure in RPG AS400

A Data Structure can be either program described or an externally described DS. Ap program described data structure does not use keyword EXT or EXTNAME in fully free definition or a BLANK in position 22 for the fixed-format definition.

  1. Externally Described Data Structure
  2. Multiple Occurrence Data Structure
  3. Data Area Data Structure
  4. Qualified Data Structure
  5. File Information Data Structure
  6. Indicator Data Structure
  7. Program Status Data Structure

LIKEDS Keyword

  • We can define a data structure like another using LIKEDS keyword.
  • Data Structure Examples

  • Using keywords QUALIFIED, LIKEDS, and DIM with data structures.
  • Using PREFIX to rename all fields in an external data structure.
  • Defining an *LDA data area data structure.
  • Array Data Structures.
  • Defining Data Structure Parameters in a Prototype or Procedure Interface.
  • Define an externally-described data structure using the LIKEREC keyword.
  • LIKEREC vs EXTNAME.
  • Post a Comment

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