TechTalk: Not Quite an S/36E MONMSG

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

The S/36E on the AS/400 provides a terrific way to "dabble" in native CL commands while staying within the comfortable confines of S/36E OCL. It allows you to use most native CL commands from within your OCL procedures.

The problem is that if a native command fails, the system takes the default response to the OS/400 error message and returns control to the procedure as if nothing happened! Your OCL then goes merrily on its way thinking that the native command ran successfully when in actual fact it did not. When you try to use the MONMSG command to check for error conditions you find that this is one of those CL commands that doesn t work in OCL.

There is a solution, albeit not very well-documented. The S/36E provides a new system variable ?MSGID?. This is similar to a return code (?CD?) and can be used to check for error conditions in lieu of MONMSG.

To take advantage of the ?MSGID? substitution parameter, you must code it following the CL command you think may cause an error. If no error message is issued, ?MSGID? will be blank; if OS/400 issues an error message, ?MSGID? will have the seven-character message ID of the escape message, such as CPF1234.

For example, 2 shows an OCL procedure in the S/36E containing the RGZPFM native command, which may result in an error if the file is not found.

For example, Figure 2 shows an OCL procedure in the S/36E containing the RGZPFM native command, which may result in an error if the file is not found.

As we can see, the procedure will take care of the problem should the file not be found. Although this particular case could have been handled by the // IF DATAF1 procedure control expression, the example clearly demonstrates the ?MSGID? technique.

- Rich Loeber


TechTalk: Not Quite an S/36E MONMSG

Figure 2 S/36E error trapping

 Figure 2: S/36E Error Trapping // RGZPFM FILE(?1?) MBR(*FIRST) // IF ?MSGID?= GOTO OK // ** Procedure aborted - File ?1? not found // CANCEL // TAG OK // LOAD PGM1 // FILE NAME-?1?,DISP-OLD // RUN 
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: