Problem solve Get help with specific problems with your technologies, process and projects.

How to add confirmation to critic commands

There are a lot of OS/400 commands that make critic tasks. Some of them use confirmation screens when they are invocated from WRK interfaces, ENDJOB is one of them. But when you use ENDSBS or PWRDWNSYS typing them on the command line, they don't ask you for a confirmation! The validation program is an interesting way to "dress" a critic command with a confirmation or validation screen.

The objects *CMD have a powerful attribute: the validation program. You can define it to a command using CHGCMD.

If you want to set a validation program to a command (i.e. for the command ENDSBS), follow these steps:

1. Write and compile this code:

The number of parameters received by this program must be the same that the number of parameters of the command. If this condition is not verified, the command will not be executed.

 /* Program CONTROL in library TEST */

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

               DCL        VAR(&P1) TYPE(*CHAR) LEN(1)
               DCL        VAR(&P2) TYPE(*CHAR) LEN(1)
               DCL        VAR(&P3) TYPE(*CHAR) LEN(1)
               DCL        VAR(&P4) TYPE(*CHAR) LEN(1)

               DCL        VAR(&RESP) TYPE(*CHAR) LEN(2)
               DCL        VAR(&TIPO) TYPE(*CHAR) LEN(1)

               RTVJOBA    TYPE(&TIPO)
               IF         COND(&TIPO = '0') THEN(GOTO CMDLBL(GOODBYE))

               SNDUSRMSG  MSG('Do you wish to execute ENDSBS ?') VALUES(Y 'y' +
                               N 'n') DFT(N) TOMSGQ(*EXT) MSGRPY(&RESP)

               IF         (&RESP = 'n' *OR &RESP = 'N')  +
                          SNDPGMMSG MSGID(CPF0002) MSGF(QSYS/QCPFMSG) +
                                    MSGTYPE(*ESCAPE)

               ELSE       SNDUSRMSG MSG('The command will be executed') +
                                    MSGTYPE(*INFO) TOMSGQ(*EXT)

     GOODBYE:  ENDPGM

2. Change de command:
CHGCMD CMD(ENDSBS) VLDCKR(TEST/CONTROL)

3. Test and enjoy !


Dig Deeper on Performance

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close