ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Automatic or selective prompting not allowed

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

  • Automatic or selective prompting not allowed

    PGM

    DCL VAR(&CMD) TYPE(*CHAR) LEN(4024)
    DCL VAR(&CMDLEN) TYPE(*INT) LEN(4) VALUE(1024)
    DCL VAR(&OPTIONS) TYPE(*CHAR) LEN(20)
    DCL VAR(&OPTIONSLEN) TYPE(*INT) LEN(4) VALUE(20)
    DCL VAR(&OPTIONS) TYPE(*CHAR) LEN(20)
    DCL VAR(&NEWCMD) TYPE(*CHAR) LEN(4024)
    DCL VAR(&NEWCMDLENA) TYPE(*INT) LEN(4) VALUE(4024)
    DCL VAR(&NEWCMDLENC) TYPE(*INT) LEN(4) VALUE(4024)

    CHGVAR VAR(%SST(&OPTIONS 1 4)) VALUE(X'00000001')
    CHGVAR VAR(%SST(&OPTIONS 5 1)) VALUE('0')
    CHGVAR VAR(%SST(&OPTIONS 6 1)) VALUE('1')
    CHGVAR VAR(%SST(&OPTIONS 7 1)) VALUE('0')
    CHGVAR VAR(%SST(&OPTIONS 12 4)) VALUE(X'00000000')
    CHGVAR VAR(%SST(&OPTIONS 16 5)) VALUE(X'0000000000')
    CHGVAR VAR(&CMD) VALUE('?CRTLIB ?*LIB(AVK22)')

    CALL PGM(QCAPCMD) PARM(&CMD &CMDLEN &OPTIONS +
    &OPTIONSLEN 'CPOP0100' &NEWCMD +
    &NEWCMDLENA &NEWCMDLENC X'00000000')
    MONMSG MSGID(CPF6801) EXEC(RETURN)
    SBMJOB JOB(TESTJOB) JOBQ(QBATCH) RQSDTA(&NEWCMD)
    ENDPGM


    Trying to submit the command with prompter using API QCAPCMD, however getting error

    CPD0037 Diagnostic

    Message . . . . : -? CRTLIB ?*LIB(AVK22) TEXT(TEST)

    30 11/04/16 20:08:49.848712 QCARULE QSYS 07F0 QCMD
    Message . . . . : Automatic or selective prompting not allowed.
    Cause . . . . . : Automatic and selective prompting are valid in control
    language (CL) programs running interactively. Recovery . . . : Remove
    automatic or selective prompting request from the source, and then try th
    command again.

  • #2
    I looked at the documentation for QCAPCMD to see if there was a combination of options that would return the command string without the prompting characters, and if there is one, I couldn't find it. So the next best thing is to remove the prompting characters yourself. To do that, add the following lines of code between the MONMSG and the SBMJOB:

    Code:
    CHGVAR     VAR(&POS) VALUE(%SCAN('?*' &NEWCMD))
    CHGVAR     VAR(%SST(&NEWCMD &POS 2)) VALUE(' ')
    CHGVAR     VAR(%SST(&NEWCMD 1 1)) VALUE(' ')
    
    Also, add to the declaration section:
    DCL        VAR(&POS) TYPE(*INT)

    Comment


    • #3
      Perhaps not popular, but I suggest using the QCMDCHK API to handle prompting/selective-prompting until it becomes a little familiar. And then learn QCAPCMD later.
      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