ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

CPD0031 30 Command WRKMBRPDM not allowed in this setting

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

  • CPD0031 30 Command WRKMBRPDM not allowed in this setting

    Greetings all,

    I've been lurking for a few weeks now, so now it's time to test all of your knowledge with a big challenge (ha).

    I'm a newbie to iSeries, but not I.T. (+20 yrs in mainly p.c. / 'doze admin .. some 'nix).

    I've been puttering around at the free RZKH.DE on the V5R3 system for a few weeks. (Might venture over to timeshare400 in a few weeks for a taste of something more modern).

    I'm trying to create an absurdly simple command (shortcut) for executing "WRKMBRPDM QRPGLESRC". (I'm lazy and that's far too much typing )

    1) I created a EP.CLP file in QCLSRC (not really named "EP.CLP" .. name=EP type=clp) :

    Code:
    PGM
    WRKMBRPDM QRPGLESRC
    This works, but I have to type CALL EP instead of just EP (told you I am lazy !)

    If I just type EP, it says "Command EP in library *LIBL not found". (How do I "path in my library (MSTRAM1) ? )


    2) So I tried to create a "CMD" instead, creating filename= EP type=CMD in QCMDSRC

    Code:
    CMD
    WRKMBRPDM QRPGLESRC
    When I compile that, it says "* CPD0031 30 Command WRKMBRPDM not allowed in this setting. "

    Googling turned up use : DSPCMD WRKMBRPDM and look at the "Where allowed to run" which is :

    *IREXX *IPGM *EXEC *INTERACT

    I guess *IPGM is my compiled CLP, and *INTERACT .. duh .. ok, but what is "*EXEC" ?

    Mike

  • #2
    Re: CPD0031 30 Command WRKMBRPDM not allowed in this setting

    your cl ... only file at this time -- will want to add library later. PROGRAM NAMED: WMPDM
    PHP Code:
    /******************************************************************************/               
    /*                                                                            */               
    /*  A T T E N T I O N :                                                       */               
    /*  -------------------                                                       */               
    /*                                                                            */               
    /*                                                                            */               
    /******************************************************************************/               
                                                                                                   
                 
    PGM        PARM(&INFILE)                                                          
                                                                                                   
                 
    DCL        VAR(&INFILETYPE(*CHARLEN(10)                                       
                                                                                                   
                 IF         
    COND(&INFILE ' 'THEN(CHGVAR VAR(&INFILE) +                         
                              
    VALUE('QRPGLESRC'))                                                  
                                                                                                   
                                                                                                   
                 
    WRKMBRPDM  FILE(&INFILE)                                                          
                                                                                                   
     
    THEEND:     ENDPGM 
    The command
    PHP Code:
    CMD                                                                    
                                                                           
                 PARM       KWD
    (INFILETYPE(*CHARLEN(10) +              
                              
    DFT(QRPGLESRCPROMPT('File Name'

    to compile command
    Code:
    CRTCMD CMD(JAMIELIB/EP) PGM(WMPDM) SRCFILE(JAMIELIB/SOURCE)
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: CPD0031 30 Command WRKMBRPDM not allowed in this setting

      A command (*CMD object) on IBM i is not a program. This is different from Windows or Unix. In Windows or Unix a command and a program are the same thing -- you just type the command name and it runs a program. On IBM i, it's differnet. A program is an executable set of instructions, like it would be on Windows/Unix, but is run with the CALL command.

      A *CMD object is just an interface for running a program. It describes the parameters, the help, etc. In Unix terms, it's like combining the parameter format with the man page and a wizard to help you run it. It's there to make calling a program more user friendly... But does not contain the executable program statements themselves.

      Anyway... for your shortcut command, what you want is something like this:

      Code:
      PGM
          WRKMBRPDM QRPGLESRC
      ENDPGM
      Compile it with:
      Code:
      CRTCLPGM PGM(EP) SRCFILE(QCLSRC)
      Then create the command for it with source like this:
      Code:
      CMD PROMPT('Run WRKMBRPDM on QRPGLESRC')
      Since your program has no parameters, it's that simple... just one line of code. Compile it with:

      Code:
      CRTCMD CMD(EP) SRCFILE(QCMDSRC) PGM(*LIBL/EP) ALLOW(*ALL)
      Now when you type EP, it runs the *CMD object, which in turn runs the CL program.

      As for your question about "what is *EXEC". it means that this is a command that can be run from APIs that execute commands. (Such as QCMDEXC, QCAPCMD, etc). So, *IREXX lets you run it in interactive REXX scripts, *IPGM lets you run it in interactive CL programs, *EXEC lets you run it from APIs, and *INTERACT lets you run it from the command-line interactively. There's also *IMOD which lets you run from interactive ILE modules (modern programs) and there are options for running in batch as well, which you have turned off. I don't really see any harm in allowing all in your case, though...?

      Comment


      • #4
        Re: CPD0031 30 Command WRKMBRPDM not allowed in this setting

        Hi Jamief,

        Thanks !

        I couldn't resist tinkering with your example.

        While your files will handle a parameter (other file), .. and I will probably find it useful, in this case I don't need "EP" to do anything other than access the hard coded filename.

        So I left EP.CLP as is, and in EP.CMD I just have one statement : CMD.

        Then running :
        Code:
        CRTCMD CMD(MSTRAM1/EP) PGM(EP) SRCFILE(MSTRAM1/QCMDSRC))
        did the trick !

        In fact this seems to work as well (apparently the default is QCMDSRC ? )

        Code:
        CRTCMD CMD(MSTRAM1/EP) PGM(EP)
        did the trick !

        ** I've also discovered that '14' (compile) against a CMD file seems to work if the CMD and CLP filenames are the same **

        As an exercise, I'll try modifying the EP.CLP, maybe call it EE.CLP, and instead of accepting an actual file name as a parameter, a "token" like RPG, CLP, which it then "translate" to a WRKMBRPDM FILE(<variable>)

        Mike

        Comment


        • #5
          Re: CPD0031 30 Command WRKMBRPDM not allowed in this setting

          Originally posted by Scott Klement View Post
          A command (*CMD object) on IBM i is not a program. This is different from Windows or Unix. In Windows or Unix a command and a program are the same thing -- you just type the command name and it runs a program. On IBM i, it's differnet. A program is an executable set of instructions, like it would be on Windows/Unix, but is run with the CALL command.

          A *CMD object is just an interface for running a program. It describes the parameters, the help, etc. In Unix terms, it's like combining the parameter format with the man page and a wizard to help you run it. It's there to make calling a program more user friendly... But does not contain the executable program statements themselves.
          Great explanation !

          It should be in the i CL Programming manual !

          Mike

          Comment


          • #6
            Re: CPD0031 30 Command WRKMBRPDM not allowed in this setting

            There's another way to create short-cut commands.
            1. Figure out what library the "real" command is in:
              1. DSPCMD cmdname
              2. If it says it's a proxy command, do DSPCMD proxylib/proxycmd
              3. Repeat until it's not a proxy command
            2. CRTDUPOBJ cmdname OBJTYPE(*CMD) FROMLIB(reallibrary) TOLIB(mylib) NEWOBJ(newname)
            3. If you want to change one of the command defaults in your new version of the command
              1. Prompt (F4) the command and enter the default you want
              2. F14 to get the command string
              3. Copy the parameter and value you're interested in
              4. CHGCMDDFT mylib/newname DFT('PARM(newdft)')


            For example, to make a command WMCLP that will work with CLP members in a file

            Code:
            ==> DSPCMD WRKMBRPDM
            It says "Target Command QPDA/WRKMBRPDM". It's a Proxy!

            Code:
            ==> DSPCMD QPDA/WRKMBRPDM
            The usual info about a command, so ok, it's not a proxy.

            Code:
            ==> CRTDUPOBJ OBJ(WRKMBRPDM) FROMLIB(QPDA) 
                      OBJTYPE(*CMD) TOLIB(QGPL) NEWOBJ(WMCLP)
            Code:
            ==> CHGCMDDFT QGPL/WMCLPDFT('MBRTYPE(CLP)')
            Sometimes writing a completely new command as discussed above is the best way to get your own features. But sometimes it's nice to just make a copy of the real command, especially if it has lots of parameters that would be a pain to duplicate.
            Last edited by Barbara Morris; June 7, 2013, 05:23 PM. Reason: Why does it make the code textboxes so narrow when the text is long, but it makes an nice wide one when the text is short?

            Comment


            • #7
              Re: CPD0031 30 Command WRKMBRPDM not allowed in this setting

              @Barbara: Narrow comment texts happen randomly as ads get inserted on the right-hand side of some comments.

              @The.Thread: I generally think of *CMDs as being 'enhanced program prototypes' for the CL language. Other platforms have very limited things that help understand what *CMDs are good for. OS/2 had desktop objects with somewhat related capabilities that included prompting for parm values. Windows has things like shortcuts that can have properties that specify parm values, which has some relationship to *CMD objects; but I don't know how prompting is possible if it is at all.

              Tom
              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


              • #8
                Re: CPD0031 30 Command WRKMBRPDM not allowed in this setting

                Barbara,

                Thanks for the extra info !

                I tried the dspcmd wrkmbmrpdm command, there is no "Target Command field" (prob because this system is so old 5r3), but there is :
                Program to process command . . . . . . : QUOCPP
                Library . . . . . . . . . . . . . . : QPDA
                State used to call program . . . . . : *SYSTEM
                Source file . . . . . . . . . . . . . : S000000314
                Library . . . . . . . . . . . . . . : QTEMP
                Source file member . . . . . . . . . . : WRKMBRPDM

                I'm not sure if that is a "proxy" command or not.

                I tried running
                Code:
                CRTDUPOBJ OBJ(WRKMBRPDM) FROMLIB(QPDA)   OBJTYPE(*CMD) TOLIB(MSTRAM1) NEWOBJ(WMCLP2)
                but
                I got "Not authorized to object WRKMBRPDM in QPDA type *CMD.", so I tried the CRTDUPOBJ on one of my own cmd files, and
                then the CHGCMDDFT cmd and it worked.

                Except that CHGCMDDFT wanted NEWDFT instead of DFT, and I had to use NEWDFT('QCLSRC') instead to match up with the current parameter spec.

                Always love learning something new !

                Mike

                Comment


                • #9
                  Re: CPD0031 30 Command WRKMBRPDM not allowed in this setting

                  ...there is no "Target Command field" (prob because this system is so old 5r3)...
                  Command proxies were introduced in V5R4, so they're not relevant here. You're right about V5R3.

                  If you run into authority issues, you can only work through the system's security administrator, whoever that is for that system. Until that's handled (and it might never be, depending on your working environment), you can look for alternatives. There is one old method that can work for your very particular need:
                  Code:
                   EP:         CMD        PROMPT('WRKMBRPDM QRPGLESRC')
                  
                               PARM       KWD(CMD) TYPE(*CHAR) LEN(19) +
                                            CONSTANT('WRKMBRPDM QRPGLESRC')
                  
                               PARM       KWD(CMDLEN) TYPE(*DEC) LEN(15 5) CONSTANT(19)
                  That's the source for compiling the *CMD object. The command that compiles the *CMD:
                  Code:
                  CRTCMD CMD( mylib/EP )
                         PGM( QSYS/QCMDEXC )
                         SRCFILE( mylib/QCMDSRC )
                         SRCMBR( EP )
                  Note that no CL program is involved with this method. It's purely a "shortcut".

                  It works for a couple reasons. First, a *CMD PARM() statement can have a CONSTANT() that is up to 32 characters long; yours is only 19 characters. And second, the program that is behind the command (the command-processing program, or CPP) is QCMDEXC in library QSYS, and it's one of the system's APIs that execute commands.

                  The QCMDEXC API takes two parameters, so that's how many are prototyped by the *CMD source.

                  The first parameter for the API is a command string. Yours is short enough to fit into the 32-char limit for PARM constants. The second parameter is a length value defined as a packed-decimal of 15 digits with 5 decimal positions. (It's an odd definition, but you'll run into reasons why at various times in the future.)

                  As long as you can squeeze a valid command string into 32 characters, you can have many of these. Copy the source to a different member, change the constant and length, and compile a new shortcut. Or just keep changing the same source with different constant strings/lengths and give each compiled *CMD a different name.

                  Tom
                  Last edited by tomliotta; June 8, 2013, 01:52 AM. Reason: Add detail.
                  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


                  • #10
                    Re: CPD0031 30 Command WRKMBRPDM not allowed in this setting

                    ** I've also discovered that '14' (compile) against a CMD file seems to work if the CMD and CLP filenames are the same **
                    If you type option '14' and press F4 instead of <Enter>, they don't need to be the same. The compile command will be prompted, and you can make various changes to parameter values.

                    Tom
                    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