The ability to retrieve the CL source from a CL program or CL module can make it easier to diagnose and fix problems in CL code on systems where the original CL source code is not available. To overcome this I code the program name as a field in the file, and I always retrieve the name of the program from within the program itself. In RPG the program name is a subfield in the Program Data Structure so it can be easily retrieved, for an example see the post Externally described Data Structures.
RTVPMTCMD - Retrieve Prompted Command. RTVPMTCMD RETRIEVE PROMPTED COMMAND TAACMFJ The Retrieve Prompted Command command allows an input of a command string (such as just a command name), prompts for the command, and then returns the full command string including keywords without executing the command. Different formats are available such as for a command line or in a CLP source format. RTVPMTCMD is useful to applications that want to allow command input with prompting so the return command string can be run at a later time. The API QCAPCMD is used by the tool.
The following are some typical examples of the use of RTVPMTCMD. Assume you want to allow an input of a command string, prompt for the remainder of the command, and then run the command at a later point in the program. RTVPMTCMD allows you to treat the returned command string as a variable to be executed using QCMDEXC.
Assume the previous example, but now you want to submit the command as a parameter to a batch job. If the only function needed is to submit the prompted command, SBMJOB could be used. If however, you want to wrap the command with your own function, you may want to pass the command as one of several parameters to a batch program.
Assume you want to allow input of a command string, prompt for the command, and store the returned string in a data base file for later execution. Using RTVPMTCMD returns the command string as a variable to allow placing the data in a data base file. Assume you have a program that reads CLP source and then prompts for a command to be returned and placed in the source. RTVPMTCMD provides an option that allows CLP only commands such as RTVJOBA to be used with variable names. RTVPMTCMD escape messages you can monitor for - None.
Escape messages from based on functions will be re-sent. RTVPMTCMD Command parameters.CMD - CMDIN The command or command string to be prompted for.
Up to 2500 bytes may be entered. CMDPRCTYP The command processing type describes what the intent is for use of the returned string. If you are going to use the command with QCMDEXC,. should be used. If you are returning the command for use in a source member, a value other than. should be used and you must describe the type of source that will be used as not all source types are valid. For example, CALLPRC is only valid in a CLLE source type.
![Retrieve Source For Clle Program Retrieve Source For Clle Program](http://www.netterimages.com/images/vpv/000/000/013/13317-0550x0475.jpg)
![Retrieve source for cl program name Retrieve source for cl program name](/uploads/1/2/5/5/125528643/262393945.png)
Note that no formatting of the returned string occurs to fit in the length of the statement for each source record. is the default meaning to return the prompted command as a string intended to be executed using QCMDEXC. The string is validity checked and keywords are inserted. Variables are not allowed. Commands that return variables such as RTVJOBA are not allowed.
If an invalid keyword exists in the input string, the command prompt would occur with a message stating the error in the same manner as if the command had been entered interactively and prompted for with F4.CLP may be specified to return the command for intended use in CL program source. This allows a command such as RTVJOBA to be prompted for. Variables are allowed.CLLE may be specified to return the command for intended use in CLLE program source. Variables are allowed.CLINPSTR may be specified to return the command for an ILE CL source type intended to be executed as as a string.
This prevents the use of commands that return variables such as RTVJOBA. The valid commands must be specified as being allowed in an.IMOD or.BMOD type program.CMDDEF may be specified to return the command for command definition source. The only valid commands that may be entered are CMD, PARM, ELEM, QUAL, DEP, and PMTCTL. CMDOUT The return string with keywords. This is a required return variable that must be declared as.CHAR LEN(5000).
CMDOUTLEN The length of the return string. This is an optional return variable that must be declared as.DEC LEN(5 0).
Restrictions - Because the RTVPMTCMD returns variables, the command may only be used in a CL program. Prerequisites - The following TAA Tools must be on your system: Send escape information Send escape message Implementation - None, the tool is ready to use. Objects used by the tool - Object Type Attribute Src member Src file - - - - - RTVPMTCMD.CMD TAACMFJ QATTCMD TAACMFJC.PGM CLP TAACMFJC QATTCL TAACMFJR.PGM RPGLE TAACMFJR QATTRPG Added to TAA Productivity tools January 15, 2011 © Copyright TAA Tools, Inc.