TechTalk: Submitting Programs From Within RPG

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

From: Toby Miller To: All

I have a question for all of you RPG programmers out there:

Our software calls a CL program to submit a report (written in RPG) to batch. Is there anyway to have the RPG program to submit itself without having to call the CL program? Any help is appreciated.

From: Ernie Malaga To: Toby Miller

Yes, there's a way. You can call QCMDEXC from the RPG program. QCMDEXC requires two parameters:

* A character string containing the command to be executed. * A decimal value (15 digits, 5 decimals -- this is a must!) describing the length of the character string.

Therefore, all you need to do is execute the following in your RPG program:

 CALL 'QCMDEXC' PARM CMD PARM CMDLEN 155 

Variable CMD should have the following:

 'SBMJOB CMD(CALL PGM(YOURLIB/RPGPGM) + PARM(...)) JOB(...) JOBQ(...)' 

CMDLEN can have a number greater than the actual length of the string. For example, if CMD is a 64-character alpha variable, CMDLEN can contain the number 64 or any number greater than 64.

Care must be taken so that the RPG program doesn't go into an infinite loop submitting itself, however. That is, the RPG program must know when it's being run interactively and when it's already running in batch, so that when it submits itself, the submitted copy doesn't submit yet another. You can do this with a parameter; perhaps there's a better way. For example:

 *ENTRY PLIST PARM ALWSBM 1 ALWSBM IFEQ 'Y' CALL 'QCMDEXC' PARM CMD PARM CMDLEN 155 MOVE '1' *INLR ELSE (etc) 
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: