You can use the QCAPCMD as400 API to:
Check the syntax of a command string prior to running it
Prompt the command and receive the changed command string
Run a command from an HLL
An advantage of using QCAPCMD over QCMDEXC is the exception handling. An exception that occurs when using QCAPCMD command is trapped and notified via the QUSEC structure. The error is not passed up the call stack so can be handled gracefully in programs.
ILE RPG Example of QCAPCMD API
RPGLE:
fnewfile if e k disk usropn dcommand s 40 inz(' ') dcmdlng s 10i 0 inz(40) docb ds d type 10i 0 inz(0) d DBCSdh 1 inz('0') d prompt 1 inz('0') d cmdsyntax 1 inz('0') d msgrtvkey 4 inz(x'00000000') d reserve1 9 inz(x'000000000000000000') docblength 10i 0 inz(x'00000014') docbfmt 8 inz('CPOP0100') dchgcmd 1 inz(' ') dlngchgcmd 10i 0 inz(0) dlngchgrtn 10i 0 inz(0) d/COPY QSYSINC/QRPGleSRC,QUSEC d qused01 17 116 c eval command = 'OVRDBF NEWFILE SHARE(*YES)' c Z-ADD 116 QUSBprv c call 'QCAPCMD' c parm command c parm cmdlng c parm ocb c parm ocblength c parm ocbfmt c parm chgcmd c parm lngchgcmd c parm lngchgrtn c parm QUSEC c QUSBavl ifgt 0 c 'Error on API'DSPLY c qusei dsply c end c open newfile c *loval setll fmt1 c read fmt1 30 c *in30 ifeq '0' c fld1 dsply c else c 'No Records' dsply c end c close newfile c eval *INLR = '1' DDS for newfile: R FMT1 FLD1 10 FLD2 10 K FLD1
More as400 Command API examples to follow
No comments:
Post a Comment