👇 Search Here Everything & Get Smart Results instantly

OS/400 CL Programming : Using the QCMDEXC Program

OS/400 CL Programming 



QCMDEXC in AS400 • AS400 qcmdexc QCMDEXC • OS/400 CL Programming : Using the QCMDEXC Program


Using the QCMDEXC Program

QCMDEXC is an IBM-supplied program that runs a single command. It is used to run a command from within a high-level language (HLL) program or from within a CL procedure or program where it is not known at compile time what command is to be run or what parameters are to be used. The QCMDEXC program is called from within your HLL or CL procedure or program and the command it runs is passed to it as a parameter on the CALL command.

         CL or HLL program                      QCMDEXC
/---------------------------\ /------------------\
| . | | |
| . | /--� | PGM(PARM1 PARM2) |
| . | | | . |
| CALL QCMDEXC(PARM1 PARM2) |----/ | . |
| . | | . |
| . | �-------| RETURN |
| . | | |
\---------------------------/ \------------------/
After the command runs, control returns to your HLL or CL procedure or program.
The command is run as if it were not in a program. Therefore, variables cannot be used on the command; values cannot be returned by the command to CL variables; and commands that can only be used in CL procedures or programs cannot be run by the QCMDEXC program. The format of the call to the QCMDEXC program is the following:


CALL PGM(QCMDEXC) PARM(command command-length)
The command you wish to run is entered as a character string on the first parameter. If the command contains blanks, it must be enclosed in apostrophes. The maximum length of the character string is 6000 characters ; delimiters (the apostrophes enclosing the string) are never counted as part of the string. The length specified as the second value on the PARM parameter is the length of the character string passed as the command. Length must be a packed decimal value of length 15 with 5 decimal positions .
Thus, if you wish to replace a library list, the call to the QCMDEXC program would look like this:


CALL PGM(QCMDEXC) PARM('CHGLIBL LIBL(QGPL NEWLIB QTEMP)' 31)
This statement could be coded into the HLL or CL program, and when the program runs, the library list would be replaced. Used this way, however, the QCMDEXC program does not provide run-time flexibility. That is accomplished by substituting variables for the constants in the parameter list, and specifying the values for the variables in the call to the HLL or CL program.
For instance:

CALL PGM(PGMA) PARM('CHGLIBL...' 3000)
|
|
| /-----------------------------------------\
\---�| PGM PARM(&STRING &LENGTH) /* PGMA */ |
| DCL &STRING *CHAR LEN(3000) |
| DCL &LENGTH *DEC LEN(15 5) |
| . |
| . | /----� QCMDEXC
| . | | /-------------\
| CALL PGM(QCMDEXC) PARM(&STRING &LENGTH)-+--/ | . |
| . �-------------------------------------+---\ | . |
| . | | | . |
| . | | | CHGLIBL... |
| END | | | . |
\-----------------------------------------/ | | . |
\-+-. |
\-------------/
The command length, which is passed to the QCMDEXC program on the second parameter, is the maximum length of the command string being passed. If the command string is passed as a quoted string, the command length is exactly the length of the quoted string. If the command string is passed in a variable, the command length is the length of the CL variable. It is not necessary to reduce the command length to the actual length of the command string in the variable, although it is permissible to do so.
The same command could be run using the following CALL command from the CL procedure or program because numeric literals are passed as packed decimal values of length 15 with 5 decimal positions:

CALL QCMDEXC (&STRING 3000)
Not all commands can be run using the QCMDEXC program. The command passed on a call to the QCMDEXC program must be valid within the current environment (interactive or batch) in which the call is being made. The command cannot be one of the following:
o       An input stream control command (BCHJOB, ENDBCHJOB, and DATA)
o       A command that can be used only in a CL program


To find the environment in which the command can be run, look at the syntax diagram for the command. The small box in the upper right corner of the diagram indicates the environment in which the command can be run. For example, JOB: I indicates that the command can be run interactively; JOB: B indicates that the command can be run in a batch job; Exec indicates that the command can be run with QCMDEXC.
You can precede the CL command with a question mark (?) to request prompting, or use selective prompting, when you call QCMDEXC in an interactive job.
If an error is detected while a command is being processed through the QCMDEXC program, an escape message is sent. You can monitor for this escape message in your CL procedure or program using the Monitor Message (MONMSG) command.

If a syntax error is detected, message CPF0006 is sent. If an error is detected during the processing of a command, any escape message sent by the command is returned by the QCMDEXC program. You monitor for messages from commands run through the QCMDEXC program in the same way you monitor for messages from commands contained in CL procedures and programs. 

Jobklix provides you recruitment notifications only you should refer official website of related department. Subscribe Free!!  for upcoming exams, job notifications, study material, latest walk-ins, latest job fairs and more...

 


0 comments:

Post a Comment

 
Top