TechTalk: Self-submitting CL Programs

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

Q.I am designing a Cost Accounting application for the furniture manufacturing firm where I work. The Finance staff wants me to design many different reports, and each report should be available by taking an option from a menu. My problem is that I end up writing two CL programs: one to prompt for the report options and the other to actually generate the report. The first CL program runs the Submit Job (SBMJOB) command to place the second program in a job queue. I remember doing this hundreds of times on the S/36 with the // IF JOBQ statement. Is there a simple way to do the same on the AS/400?

A.Yes, there's a way. Your CL program needs a 1-byte character variable and the Retrieve Job Attributes (RTVJOBA) command, which can determine if the program is running interactively or in batch. Let's create a self-submitting CL program named PGM1; refer to 5 on page 67.

A.Yes, there's a way. Your CL program needs a 1-byte character variable and the Retrieve Job Attributes (RTVJOBA) command, which can determine if the program is running interactively or in batch. Let's create a self-submitting CL program named PGM1; refer to Figure 5 on page 67.

When this program is called by taking an option from a menu, it runs interactively. The RTVJOBA command assigns &JOBTYPE a value of 1, which makes the IF command fail, so the program displays the options panel with the SNDRCVF command. When the user presses Enter, the CL program runs SBMJOB to submit itself to the job queue.

When the program begins running from the job queue, the RTVJOBA command assigns '0' to variable &JOBTYPE; the IF command then transfers control to tag EXEC, bypassing the SNDRCVF and SBMJOB commands and going directly to the portion that generates the report.


TechTalk: Self-submitting CL Programs

Figure 5 Sample self-submitting CL program

 Figure 5: Sample Self-submitting CL Program PGM1: PGM PARM(&PARM1 &PARM2 &PARM3) DCL VAR(&JOBTYPE) TYPE(*CHAR) LEN(1) DCLF FILE(OPTIONS) RTVJOBA TYPE(&JOBTYPE) IF COND(&JOBTYPE *EQ '0') THEN(GOTO CMDLBL(EXEC)) /* Present options display */ SNDRCVF SBMJOB CMD(CALL PGM(PGM1) PARM(&PARM1 &PARM2 &PARM3)) + JOB(REPORT) JOBQ(QBATCH) RETURN /* Generate report */ EXEC: (etc.) ENDPGM 
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: