ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Define all numeric data structure for call to RPG

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Define all numeric data structure for call to RPG

    I need to call an RPG pgm from a CLLE or CLP, but the RPG pgm has a Numeric data structure (@DT) defined as a parameter.

    Can I define a data structure in the CLLE that will work on the call to the RPG pgm?
    If so, how would it be defined given the below parameter in the RPG pgm:

    Thanks!
    @DT Fiscal dates 6.0 (14 elements)

    E @DT 14 6 0

    IPS@DT DS 84
    I 1 840@DT

    Click image for larger version

Name:	Data Structure RPG.jpg
Views:	202
Size:	50.2 KB
ID:	155746
    Attached Files

  • #2
    It's been 27 years since I've coded in RPG III (RPG/400). However, I'm pretty sure that's an array of zoned decimal fields... There's no such data type as zoned in CL. (*DEC is packed). So you can either change your RPG code to use packed numbers (and hopefully upgrade it to at least 1990's level code if not all the way to modern code) or pass the data as character from CL.

    Comment


    • #3
      What Scott says is spot on (of course). I thought of one other thing that might help. CL doesn't have a syntax for arrays or data structures, but you can use defined variables to do make one variable overlay another, which is similar to a data structure.

      I assume that PS@DT is the parameter to your RPG program.

      Code:
      C                *ENTRY               PLIST
      C                                     PARM                        PS@DT
      You could use code like this in your CL program.

      Code:
      DCL &DATES  *CHAR               LEN(84)
      DCL &DATE01 *CHAR STG(*DEFINED) LEN( 6) DEFVAR(&DATES 1)
      DCL &DATE02 *CHAR STG(*DEFINED) LEN( 6) DEFVAR(&DATES 7)
      /* ... etc. ... */
      DCL &DATE14 *CHAR STG(*DEFINED) LEN( 6) DEFVAR(&DATES 79)
      
      CALL THERPGPGM (&DATES)
      As Scott pointed out, the data is zoned decimal, which means that you have to define it as character in the CL program. You can use CHGVAR to convert it between *CHAR and *DEC data types.

      Comment


      • #4
        Thank you both!

        I'll give it a try

        Comment

        Working...
        X