cleancut-fluent

(Answer) (Category) iSeries / AS400 FAQ : (Category) Programming :
How to create/convert a command object (CMD) from a CL program (CLP)
A simple CMD object, without any of the great bells and whistles capable 
of within a CMD object can be created quite easily from a CL program.  For 
example, take the following:

             PGM        PARM(&WSIDX &JBTYPE)

             DCL        VAR(&WSID)    TYPE(*CHAR) LEN(10)
             DCL        VAR(&WSIDX)   TYPE(*CHAR) LEN(10)
             DCL        VAR(&JOBQ)    TYPE(*CHAR) LEN(10)
             DCL        VAR(&JOBQLBR) TYPE(*CHAR) LEN(10)
             DCL        VAR(&JOBD)    TYPE(*CHAR) LEN(10)
             DCL        VAR(&JBTYPE)  TYPE(*CHAR) LEN(1)
...

Just copy this from QCLSRC to QCMDSRC.
Change the type from CLP to CMD.
Drop all lines except the PGM and any variables that appear on the PGM 
statement.
             PGM        PARM(&WSIDX &JBTYPE)

             DCL        VAR(&WSIDX)   TYPE(*CHAR) LEN(10)
             DCL        VAR(&JBTYPE)  TYPE(*CHAR) LEN(1)

Change the DCL to PARM
             PGM        PARM(&WSIDX &JBTYPE)

             PARM       VAR(&WSIDX)   TYPE(*CHAR) LEN(10)
             PARM       VAR(&JBTYPE)  TYPE(*CHAR) LEN(1)

Drop the VAR from the PARM commands
             PGM        PARM(&WSIDX &JBTYPE)

             PARM       (&WSIDX)   TYPE(*CHAR) LEN(10)
             PARM       (&JBTYPE)  TYPE(*CHAR) LEN(1)

Drop the ampersand, and maybe the parenthesis
             PGM        PARM(&WSIDX &JBTYPE)

             PARM       WSIDX   TYPE(*CHAR) LEN(10)
             PARM       JBTYPE  TYPE(*CHAR) LEN(1)

And, now that you got the variables down, change the PGM to a CMD and drop 
the parameters
             CMD

             PARM       WSIDX   TYPE(*CHAR) LEN(10)
             PARM       JBTYPE  TYPE(*CHAR) LEN(1)

This will compile successfully and work just fine.  This is a quick and 
dirty way to convert a SBMJOB CMD(CALL ...  that's getting you into all 
sorts of trouble because of parameters lengths to a nice SBMJOB 
CMD(MYCMD...   that won't have that trouble.

Now, there's a lot more potential there.  Like keyword prompting, default 
values, multiple list items, indents like library/object and so on.  But 
this will do that fast conversion.
ans-ins-part
Append to This Answer
rob
Previous: (Answer) PRTF with position value more than 255
Next: (Answer) Options to get data from Excel into, or out of, iSeries
This document is: http://faq.midrange.com/index.pl?file=576
[Search] [Appearance]
This is a Faq-O-Matic 2.721.