TechTalk: SBMJOB Command Successful

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

I was working on a batch process that is initiated by a single command from any command line for one of our clients and wanted to devise some method of reporting back to the user that the request had been submitted for processing. The best way to accomplish this was to send the user a message from the command screen much like one receives when a program is submitted to batch for compilation.

After some research I discovered that the message I needed is CPC1221 in message file QCPFMSG. Using this information, I added the following section to the program that submits the job to batch:

 DCL VAR(&MSGDTA) + TYPE(*CHAR) + LEN(46) SBMJOB CMD(...) JOB(...) RCVMSG MSGDTA(&MSGDTA) SNDPGMMSG MSGID(CPC1221) + MSGF(QCPFMSG) + MSGDTA(&MSGDTA) + TOPGMQ(*PRV) + MSGTYPE(*INFO) 

The pertinent operations above are the DCL, RCVMSG, and SNDPGMMSG commands.

The declaration of correct length and type for the &MSGDTA variable was ascertained by performing the DSPMSGD command for CPC1221 in QCPFMSG and then taking option 2 to display field data. This option shows all of the variables used in a message and their respective data type, length, decimal positions, varying length and dump status as applicable.

The command RCVMSG acts much like the MONMSG command (although it does not substitute) in that you can place the command immediately after an operation to capture any message generated. In this case, I wanted to capture the job submission message so I placed the command right after the SBMJOB command. There are several items of information available through the RCVMSG command; however, in this case all I wanted to capture was the variable message data.

Once I had captured the message data from the submit, it was turned around and sent to the requesting user through the SNDPGMMSG command. Using this command you can format messages either free-form or use messages already defined in message files like QCPFMSG as I did in this case.

When you use a predefined message, there can be variable data which needs to be passed. In this case, the &MSGDTA held the five variables job number, User ID, job name, job queue, and job queue library. By placing this variable in the MSGDTA parameter of the SNDPGMMSG, the appropriate information is sent. An additional key point here is the designation of TOPGMQ. By using the *PRV designation for this parameter, the message is sent to the calling program in the invocation stack, in this case, the program, menu or other object on which the command was entered. Finally, it is important to note the use of the *INFO value for the MSGTYPE parameter. This designates the message as informational only and thus requires no user action.

Jim Johnson Murfreesboro, Tennessee

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: