TechTalk: Execute multiple commands from an SDA menu without writing a CL program.

CL
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

I like building AS/400 menus with SDA. I can create or change a menu quickly and easily and move on to other things. One thing I dislike about SDA menus is that I can put only one command behind an option. I often have to write a CL program just to run two CL commands behind a menu option, and I dislike cluttering up my libraries with tiny CL programs that are used on only one menu.

The Execute Command (XC) command (shown in Figures 1 and 2) provides a way to execute more than one command when choosing a menu option. The first parameter is a series of CL commands separated by some delimiter. The system executes each command in order. All commands in the command string must be executable by the QCMDEXC program. To check whether QCMDEXC will execute a command, use the Display Command (DSPCMD) command. If the "Where allowed to run" parameter includes *EXEC, you can use the command within an XC command string.

The second parameter is the delimiter. It defaults to a backslash (), but any character that isn't used in the commands in the command string will do.

The third parameter tells the job what to do if a command terminates abnormally. You can ignore the error and continue with the next command or cancel processing the command string.

3 illustrates how I might issue an override, call two programs, and delete the override from one menu option. Because I wanted to be able to enter a long command string, I kept the name of the command and all parameters as short as I could. I also provided defaults for parameters D and F so they would not have to be coded.

Figure 3 illustrates how I might issue an override, call two programs, and delete the override from one menu option. Because I wanted to be able to enter a long command string, I kept the name of the command and all parameters as short as I could. I also provided defaults for parameters D and F so they would not have to be coded.

- Ted Holt


TechTalk: Execute multiple commands from an SDA menu without writing a CL program.

Figure 1: The XC Command Definition

 /*==================================================================*/ /* To compile: */ /* */ /* CRTCLPGM PGM(XXX/XC) SRCFILE(XXX/QCLSRC) */ /* */ /*==================================================================*/ CMD PROMPT('Execute commands') PARM KWD(C) TYPE(*CHAR) LEN(110) MIN(1) + PROMPT('Commands') PARM KWD(D) TYPE(*CHAR) LEN(1) DFT('') + PROMPT('Command delimiter') PARM KWD(F) TYPE(*CHAR) LEN(1) RSTD(*YES) DFT(C) + VALUES(C I) CHOICE('C=cancel, I=ignore') + PROMPT('Command failure option') 
TechTalk: Execute multiple commands from an SDA menu without writing a CL program.

Figure 2: CL Program XCL

 /*==================================================================*/ /* To compile: */ /* */ /* CRTCLPGM PGM(XXX/XCL) SRCFILE(XXX/QCLSRC) */ /* */ /*==================================================================*/ PGM PARM(&CMDSTRING &DELIMITER &FAILOPTION) DCL VAR(&CMDSTRING) TYPE(*CHAR) LEN(110) DCL VAR(&DELIMITER) TYPE(*CHAR) LEN(1) DCL VAR(&FAILOPTION) TYPE(*CHAR) LEN(1) DCL VAR(&CMDS) TYPE(*CHAR) LEN(111) DCL VAR(&COMMAND) TYPE(*CHAR) LEN(110) DCL VAR(&FX) TYPE(*DEC) LEN(3) DCL VAR(&TX) TYPE(*DEC) LEN(3) DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(132) DCL VAR(&MSGF) TYPE(*CHAR) LEN(10) DCL VAR(&MSGFLIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) CHGVAR VAR(&CMDS) VALUE(&CMDSTRING *CAT &DELIMITER) /* Begin extraction of next command in series */ NEXTCMD: CHGVAR VAR(&COMMAND) VALUE(' ') CHGVAR VAR(&TX) VALUE(0) /* Build a command 1 character at a time */ BLDCMD: CHGVAR VAR(&FX) VALUE(&FX + 1) IF COND(%SST(&CMDS &FX 1) *EQ &DELIMITER) + THEN(GOTO CMDLBL(RUNCMD)) CHGVAR VAR(&TX) VALUE(&TX + 1) CHGVAR VAR(%SST(&COMMAND &TX 1)) VALUE(%SST(&CMDS + &FX 1)) GOTO CMDLBL(BLDCMD) /* Command has been extracted -- execute it */ RUNCMD: IF COND(&COMMAND *NE ' ') THEN(DO) CALL PGM(QCMDEXC) PARM(&COMMAND 110) MONMSG MSGID(CPF0000) EXEC(DO) FWDMSG: RCVMSG MSGDTA(&MSGDTA) MSGID(&MSGID) MSGF(&MSGF) + SNDMSGFLIB(&MSGFLIB) IF COND(&MSGID *NE ' ') THEN(DO) SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) + MSGDTA(&MSGDTA) GOTO CMDLBL(FWDMSG) ENDDO IF COND(&FAILOPTION *EQ C) THEN(GOTO + CMDLBL(ENDPGM)) ENDDO ENDDO IF COND(&FX *LT 110) THEN(GOTO CMDLBL(NEXTCMD)) ENDPGM: ENDPGM 
TechTalk: Execute multiple commands from an SDA menu without writing a CL program.

Figure 3: Example Use of XC

 XC ('ovrprtf arrpt hold(*yes)call pgmacall pgmbdltovr arrpt') 
TED HOLT

Ted Holt is IT manager of Manufacturing Systems Development for Day-Brite Capri Omega, a manufacturer of lighting fixtures in Tupelo, Mississippi. He has worked in the information processing industry since 1981 and is the author or co-author of seven books. 


MC Press books written by Ted Holt available now on the MC Press Bookstore.

Complete CL: Fifth Edition Complete CL: Fifth Edition
Become a CL guru and fully leverage the abilities of your system.
List Price $79.95

Now On Sale

Complete CL: Sixth Edition Complete CL: Sixth Edition
Now fully updated! Get the master guide to Control Language programming.
List Price $79.95

Now On Sale

IBM i5/iSeries Primer IBM i5/iSeries Primer
Check out the ultimate resource and “must-have” guide for every professional working with the i5/iSeries.
List Price $99.95

Now On Sale

Qshell for iSeries Qshell for iSeries
Check out this Unix-style shell and utilities command interface for OS/400.
List Price $79.95

Now On Sale

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: