ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

RETURN Variable from RPG to CL ?

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

  • RETURN Variable from RPG to CL ?

    I have a simple RPG IV program, keeping count of bad records found. At the end, I want to return that COUNT # to the calling CL program

    Code:
    C            ADD          1          COUNT       5 0
    …..
    …..
    CLR           RETURN          COUNT
    Gives me an error. IBM Document says to put the variable in Factor 2.

    "...An operand must not be specified for a procedure that does not return a value. "


    EDIT....Nevermind……….I realize I can just use *ENTRY PLIST in the RPG and it will return to the CL
    Last edited by MFisher; July 7, 2020, 07:42 AM.

  • #2
    You can only return values via the RETURN op-code from procedures - not from programs. Programs can only handle parameters.

    Perhaps a bigger question though is why you are writing a new program in fixed format RPG? A format that was deprecated some 19 years ago!

    Comment


    • #3
      I haven't done much RPG in the last 20 years, and my current place has lots of legacy code that mainly just gets minor changes.

      I needed a quick 20 line program, so copied some lines from an existing program and modified it.

      If a major new program is needed, there's often an existing program that can be cloned, then changed a bit for the new requirements.
      I did recently write a new 6000 line RPG program, but I did it all in embedded SQL, except for SETON LR at the end.

      Otherwise, I am working in SQL, some reporting, SAP BODS tool....
      Last edited by MFisher; July 7, 2020, 09:02 AM.

      Comment


      • JonBoy
        JonBoy commented
        Editing a comment
        6,000 lines - <shudder>
    Working...
    X