Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Using CRTPGM in a CL with Parms?

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

  • Using CRTPGM in a CL with Parms?

    Hi all. Could someone take a look at the following example and let me know if their is an easy way around my problem? The following piece of code takes an incoming parm which is an RPG program name. It then goes to a database and retrieves all of the associated modules need to use the CRTPGM correctly. At least, that was the idea.

    First some sample Code:

    PGM PARM(&EPARM)
    DCL VAR(&EPARM) TYPE(*CHAR) LEN(200)
    DCL VAR(&PGMNAM) TYPE(*CHAR) LEN(10)
    DCL VAR(&MODLST) TYPE(*CHAR) LEN(180)

    /************************************************** */
    /* Take the incoming program name and pass it to the RPG program */
    /* to extract the associated module names from my database */
    /************************************************** */

    CALL PGM(UT204) PARM(&EPARM)

    CHGVAR VAR(&PGMNAM) VALUE(%SST(&EPARM 1 10))
    CHGVAR VAR(&MODLST) VALUE(%SST(&EPARM 11 180))

    CRTPGM PGM(MWLIB/&PGMNAM) MODULE(&MODLST)

    There is more to this code, but in a nutshell it is NOT happy with &MODLST. &Modlist contains the following:

    'SC114 MWLIB/SC114 MWLIB/pu911 MWLIB/pu919 MWLIB/pu921'

    When I looked into it further, I got the impression that the command would prefer something in this format:
    CRTPGM PGM(MWLIB/&PGMNAM) MODULE(&LIB/&MODA &LIB/&MODB &LIB/&MODC &LIB/&MODD )

    This creates a problem as I really don't want to have to hardcode in unique CRTPGM commands depending on the number of modules being passed in.


    I hope this makes sense. If any of you have a method / workaround, I would really appreciate it.

    A final note, yes I am completely aware of modifying the H specs in all my RPG code to handle using PDM's option #14 to do all of this work for me.

    Thanks in advance for any help you can provide.

    Coldplay

  • #2
    The problem is that you are putting a list of parameters into a single parm.

    You need to build the command in a parameter and then call qcmdexc.

    Something like this:

    dcl &qcmd *char 1024
    dcl &qcmdl *dec (15 5) 1024

    chgvar &cmd ('CRTPGM PGM(MWLIB/' *tcat &PGMNAM *tcat ') MODULE(' *tcat &MODLST *tcat ')')

    call qcmdexc (&cqcmd &qcmdl)


    -dan

    Comment

    Working...
    X