ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Receiving parameter, then passing it to the rpg program it calls

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

  • Receiving parameter, then passing it to the rpg program it calls

    Hello everyone, I am working with an application that accesses an RPG program to get information. I have a CL program over it to clear the physical file it writes output in.

    My question is: How would I go about passing a parameter to the cl program and then passing that parameter to the rpg program for it to work with?

  • #2
    Re: Receiving parameter, then passing it to the rpg program it calls

    Originally posted by rsalva0630
    How would I go about passing a parameter to the cl program and then passing that parameter to the rpg program for it to work with?
    Declare the parameter in the PGM command of the CL program. Pass the parameter when you call the RPG program.

    Code:
    PGM  PARM(&SomeParm)
    
    DCL  VAR(&SomeParm) TYPE(??)   LEN(??)
    
    CALL PGM(MyRPGPgm) PARM(&SomeParm)

    Comment


    • #3
      Re: Receiving parameter, then passing it to the rpg program it calls

      Originally posted by TedHolt View Post
      Declare the parameter in the PGM command of the CL program. Pass the parameter when you call the RPG program.

      Code:
      PGM  PARM(&SomeParm)
      
      DCL  VAR(&SomeParm) TYPE(??)   LEN(??)
      
      CALL PGM(MyRPGPgm) PARM(&SomeParm)
      Sorry, one last thing...

      So how would I receive that parameter correctly in an RPG program? I know I would now be in the wrong category at this point, sorry.

      Comment


      • #4
        Re: Receiving parameter, then passing it to the rpg program it calls

        In free-form RPG:
        Code:
               dcl-pi MAIN           extpgm('MyRpgPgm');
                 SomeParm            char(??);
               end-pi;

        Comment


        • #5
          Re: Receiving parameter, then passing it to the rpg program it calls

          Originally posted by rsalva0630
          Hello everyone, I am working with an application that accesses an RPG program to get information.?
          If it's an existing application and RPG program, we can't quite tell you how a parameter value might be received without knowing more. Your OS version will tell us if some code format options are allowed. The RPG version will tell us more -- ILE or OPM? (The age and style of the application can influence what you do.) That is, RPG II, RPG III and RPG IV might all be possible (though RPG II is pretty unlikely.)

          It's also possible that you site has coding standards that might force one variant or another. If we could see some of the existing RPG, it'd be easier to make likely suggestions.

          What you're asking is extremely fundamental info. Are you needing to modify an existing RPG program without knowing RPG? Or is this all new code?
          Tom

          There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

          Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

          Comment


          • #6
            Re: Receiving parameter, then passing it to the rpg program it calls

            I'm writing a program to see where components are used. I'm passing a parameter from Infor XA Powerlink. The cl program gets a parameter from the application and I want to pass that to the RPG code. It is ILE RPG.

            The RPG has this to receive the parameter at this time:
            Dcl-pr CompChk Extpgm('TLCMPNTUSE');
            *N Char(15);
            End-pr;

            Dcl-pi CompChk;
            CINBR Char(15);
            End-pi;



            Sorry I do not know how to use those quote boxes you guys have in yours.

            Comment


            • #7
              Re: Receiving parameter, then passing it to the rpg program it calls

              To call that RPG program, your CL program would look something like this.

              Code:
              PGM  PARM(&CINBR)
              
              DCL  VAR(&CINBR) TYPE(*CHAR) LEN(15)
              
              ... code to clear the file
              
              CALL PGM(TLCMPNTUSE) PARM(&CINBR)
              (To get the code boxes, click the "Go Advanced" button. Then you'll have access to the # button. Select the lines containing the code, then click the button to add the code tags around the code.)

              Comment


              • #8
                Re: Receiving parameter, then passing it to the rpg program it calls

                Declare the field in the *Entry C spec. This is not all free format but gives you a better picture of how it is done. You can put it in free if you want.
                D Field1 S 4
                C *Entry Plist
                C Parm Field1

                Comment


                • #9
                  Re: Receiving parameter, then passing it to the rpg program it calls

                  Originally posted by rsalva0630 View Post
                  Sorry I do not know how to use those quote boxes you guys have in yours.
                  I don't know why it's necessary to Go to the Advanced editor to get the "Code" icon; that's just a quirk of this editor.

                  Sometimes I will paste my code, select it, and then click the "Quote" icon. That wraps the code in 'QUOTE' and '/QUOTE' tags, and it works in the Basic editor. Then I simply change the letters from "QUOTE" to "CODE". Once you see it, you should also be able to see that you can simply type the correct "CODE" tags yourself.
                  Tom

                  There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

                  Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

                  Comment

                  Working...
                  X