How do I insert some CL commands inside a CL program dynamically.
How do I insert some CL commands inside a CL program dynamically.
Prem, There are a few ways. The most common is to call qcmdexc passing the commands and their associated length. Another API, qcapcmd can also be used. This api has several advantages over qcmdexc that make it better for interactive prompting, but in your case it may be overkill. Another technique is to add the commands to a source file and submit them as a database reader job using SBMDBJOB. I would recommend one of the previosly mentioned methods. David Morris
Do you want to "insert" or "append"? To insert, use QCMDEXC or QCAPCMD API. To append, send the commands like this:SNDPGMMSG MSG(' first command string ') TOPGMQ(*EXT) MSGTYPE(*RQS) SNDPGMMSG MSG(' next command, etc. ') TOPGMQ(*EXT) MSGTYPE(*RQS) Then call a request processing program, like QCMD.