Defining Data Structure Parameters in a Prototype or Procedure Interface |
In the ILE procedure prototype (PR) and procedure interface (PI), we can define different types of parameters to the procedures such as CHAR, INTEGER, etc. But, How do we pass the data structure as the parameter to the PR and PI of the ILE procedure? So, In this blog, we will talk about the same.
For Example
Let's define a Qualified data structure named DS1 having two subfields of type char and packed.
Define a data structure in RPG Fixed Format
D DS1 DS QUALIFIED D subfield1 10a D subfield2 5p 0
Define a data structure in RPG Fully Free Format
**Free dcl-ds DS1 Qualified; subfield1 char(10); subfield2 packed(5:0); end-ds;
Define a procedure prototype (PR) in RPG Fixed Format
D DSparmDemo PR D Inds1 LIKEDS(DS1)
Define a procedure prototype (PR) in RPG Fully Free Format
**Free dcl-pr DSparmDemo; Inds1 likeds(DS1); end-pr;
Define a procedure Interface (PI) within Procedure Begin and End in RPG Fixed Format
P DSparmDemo B D DSparmDemo PI D Inds1 LIKEDS(DS1) C IF DS1.subfield1 = 'TEST' C DS1 DSPLY C ENDIF C IF DS1.subfield2 > 0 C DS1 DSPLY C ENDIF C SETON LR P DSparmDemo E
Define a procedure Interface (PI) within Procedure Begin and End in RPG /Free Format
P DSparmDemo B D DSparmDemo PI D Inds1 LIKEDS(DS1) /Free if DS1.subfield1 = 'TEST'; DSPLY DS1; endif; if DS1.subfield2 > 0; DSPLY DS1; endif; *INLR = *ON; /End-Free P DSparmDemo E
Define a procedure Interface (PI) within Procedure Begin and End in RPG Fully Free Format
**Free dcl-proc DSparmDemo; dcl-pi *N; inds1 likeds(DS1); end-pi DSparmDemo; if DS1.subfield1 = 'TEST'; DSPLY DS1; endif; if DS1.subfield2 > 0; DSPLY DS1; endif; *INLR = *ON; end-proc;
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
- Data Area 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