ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

cl program

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

  • cl program

    Hi,

    How can we write a generic command to pass parameters from one CL program to another RPG program?

    It should accept program name and variables as parameters.



    Thanks...

  • #2
    That's what the CALL command does. I saw your other question and haven't figured out how to respond to it. Maybe you can tell us more about your problem in the other thread.

    Comment


    • #3
      let's leave those errors for that thread so that we don't get confused, I know that it is CL command but if we need to write a generic program which will simply take program names and parameters to be passed then how can we write a generic program for that?

      I mean if we want to make a command which accepts these parameters like program name from which parameters to be passed and program to which they need to be passed and these many parameters whatever we give the names in a generic way then how can we create that command ,is there anyway to achieve this?



      Thanks much....

      Comment


      • #4
        Are you saying that your two threads are two different problems? I got the impression they were related. My mistake.

        I don't understand this question. Given two programs -- A and B -- you want a generic command that runs A, receives data from A, and then passes that data to B?

        Comment


        • #5
          Yes, these are two different problems.

          Yes, I want a generic command that runs A, receives data from A, and then passes that data to B?"

          How to achieve this ?


          Thanks much....

          Comment


          • #6
            Is your command intended to work with a specific set of programs? Or should it work with any program?

            I don't think it's possible to write a command that will call any program and then pass the resulting parameters to any other program.

            But if you know in advance what programs would be involved, then I think you would need to write code to pass the correct parameters to each candidate program A, and then how to transform those parameters to be passed to each candidate program B.

            That would be very complex. Very very very complex.

            What problem is your approach intended to solve? Perhaps there is another approach to solving that problem.

            Comment


            • #7
              I wanted to make it generic o be used frequently whenever i need to pass parameters from program A to B then through some command like utility I should be able to do this How can we achieve this ? I mean how can we write code for this probable command which we would like to build for this purpose?


              Thanks much...

              Comment


              • #8
                I'm really curious.

                First question. What would this command look like? Let' say I want to call program A, then pass the data from A into program B. Would it be something like this?

                Code:
                DOIT FROMPGM(A) TOPGM(B)
                Second question is the one Barbara asked. What problem is your approach intended to solve?

                Comment


                • #9
                  First question:- Yes, I want to pass parameters from program A to B.

                  Second Question:- I am not at all sure what approach should i take to resolve this or How can I code a generic command which would resolve this purpose ?




                  Thanks much...

                  Comment


                  • #10
                    I think we're going in circles, so let's take a different approach.

                    (1) There is no way to create a CL command like what you are describing. It's impossible.

                    (2) I have been programming S/38, AS/400, and successors since 1988. That's 33 years and 4 months, and I have never needed such a command. Why do you think you need one?

                    We're not going to be able to help you if you keep telling us you need to write a command, but won't tell us what problem you're trying to solve.

                    Comment


                    • #11
                      the command is simply required to make day to day task easier a kind of automation approach or modernization approach so that each time we may not have to search which are the parameter names for a particular program which need to be passed to another program . system should automatically be able to understand once we enter the program name then with thse use of some kind of automatically it should be able to generate the list of parameters to be passed or kind of popup should appear in front of screen like a command which should give us liberty which paramters do you want to pass to the called program.

                      Hope this helps..


                      Thanks much...

                      Comment


                      • #12
                        I don't think it is possible to write such a utility to be generic. And I think it would be extremely difficult to write such a utility even if you know all the candidate programs.

                        Here are some of the problems I see:
                        1. How to find out what parameters each program needs. If the program was compiled with PGMINFO(*PCML *MODULE) you could call the QBNRPII API to retrieve the PCML, and find out the definition of the parameters. But you would not know the meaning of the parameters.
                        2. How to prompt the user to get the parameter values for calling program A. You need to tell the user what the parameters mean so they know what values to specify. Creating a *CMD object for each program A would help, where you would prompt the user for the input parameters, and make the output parameters capable of having a variable. It would be difficult to support parameters that were both input and output.
                        3. How to transform the parameters returned from program A to the values required for program B. If you know all the candidate programs A and B in advance, you might need to write code for every possible combination of program A and B. If you don't know the candidate programs A and B in advance, I cannot imagine how you could write generic code to transform the parameters from program A to the parameters for program B.
                        4. It doesn't seem very user friendly. I think programmers would rather just code the required calls.

                        Comment


                        • #13
                          The requirements are a little unclear to me. If you want to run a variable program and pass parms to other programs here's an idea, maybe you can build upon it.

                          Code:
                          Member Type
                          PGMA   REXX
                          PGMB   CLP
                          PGMC   CLP
                          PGMD   CLP
                          
                          
                          PGMA:
                          
                          PARSE ARG ARG1
                          VAR1 = CALL ARG1 '&PARM'
                          ADDRESS COMMAND VAR1
                          Say PARM
                          
                          
                          PGMB:
                          
                          PGM PARM(&PARMB)
                          DCL &PARMB *CHAR LEN(10)
                          CHGVAR &PARMB VALUE('FROM PGM B')
                          ENDPGM
                          
                          
                          PGMC:
                          
                          PGM PARM(&PARMC)
                          DCL &PARMC *CHAR LEN(10)
                          CHGVAR &PARMC VALUE('FROM PGM C')
                          ENDPGM
                          
                          
                          PGMD:
                          
                          PGM PARM(&PARMD)
                          DCL &PARMB *CHAR LEN(10)
                          DCL &PARMC *CHAR LEN(10)
                          DCL &PARMD *CHAR LEN(21)
                          CALL PGMB PARM(&PARMB)
                          CALL PGMC PARM(&PARMC)
                          CHGVAR &PARMD VALUE(&PARMB *BCAT &PARMC)
                          ENDPGM
                          Compile CL pgms B C and D

                          Then:

                          STRREXPRC SRCMBR(PGMA) SRCFILE(LIB/SRCF) PARM(PGMB)
                          STRREXPRC SRCMBR(PGMA) SRCFILE(LIB/SRCF) PARM(PGMC)
                          STRREXPRC SRCMBR(PGMA) SRCFILE(LIB/SRCF) PARM(PGMD)

                          Rexx is calling a cl program passed as a parm on the command line and the cl programs are passing parms between themselves.

                          Comment


                          • #14
                            I'm confused too.
                            If you want PGMA to call PGMB via CL program PGMC with 4 parameters you can do it like this:

                            PGM PARM(&PGM &P1 &P2 &P3 &P4)
                            DCL &PGM *CHAR 10
                            DCL &P1 *CHAR 1
                            DCL &P2 *CHAR 1
                            DCL &P3 *CHAR 1
                            DCL &P4 *CHAR 1

                            CALL PGM(&PGM) PARM(&P1 &P2 &P3 &P4)

                            ENDPGM


                            The length if &P1 ... &P4 doesn't matter because it is only the adresses that is passed.
                            So it is enough to declare them as one byte.
                            Of course you must declare the program name to be 10 characters long.

                            Comment


                            • #15
                              I mean it should be generic like system should automatically be able to intelligent enough to recognize by just entering program names in which mutually parameters need to be passed by just entering the program names. The moment we enter program names on prompt then it should automatically decide whether entered program name is CL or RPGLE and based on this automatic decision then it should have capability to pass required parameters between these called and calling programs.

                              when below is advised:-



                              PGMA: PARSE ARG ARG1 VAR1 = CALL ARG1 '&PARM' ADDRESS COMMAND VAR1 Say PARM


                              then how can we parse ARG here and what does this REXX type program mean?



                              Thanks much...



                              Comment

                              Working...
                              X