25
Thu, Apr
0 New Articles

Programmer's Toolbox

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

Status messages are the messages that wink and blink at users during certain system functions like Copy File (CPYF) or Open Query File (OPNQRYF). They are helpful when a long-running function is occurring and you want to tell the user that something good is happening or you want to show progress as you perform different logical steps. With some simple coding, you can make your program a lot more informative to the end user.

Status messages are sent to the external message queue (*EXT). Every job has an external message queue that the system creates automatically. Fully understanding the external message queue is not easy, but, fortunately, you only have to name it to use it. You don't have to worry about whether your program is running interactively or in batch. If you send a status message in a batch job, it is just ignored.

There is room for only one status message at a time on a display. To clear off a status message, you must do one of the following:

o Use one of the commands that sends a status message.

o Send another status message.

o Send a blank message. The system provides CPI9801 for this purpose. It is a totally blank message with no message data that is actually sent to the display.

o Return to a command entry display, which automatically clears the status line. Note that if a CL program returns to another program (not a command entry display), the message is not cleared when the CL program ends.

When you send a status message, users cannot put the cursor on the message and request help as they can with many system messages. Consequently, there is no way for users to determine which message ID is being used when they see a status message. Furthermore, when you send CPI9801, no one can tell that you just sent blanks to the display.

To send a status message, the message must exist in a message file. You can add a specific message description for each status message. I prefer to use CPF9898, which is a blank message provided by the system, and control the text of the message by using the MSGDTA parameter.

Assume you want to use Display Object Description (DSPOBJD) in a CL program to create an outfile. This operation takes some time, so you want to send a status message to inform the user of what is happening. The code you would need is shown in 1. You either remember the details of the two commands or look up a sample each time you want to send a status message.

Assume you want to use Display Object Description (DSPOBJD) in a CL program to create an outfile. This operation takes some time, so you want to send a status message to inform the user of what is happening. The code you would need is shown in Figure 1. You either remember the details of the two commands or look up a sample each time you want to send a status message.

A much simpler command, Send Status Message (SNDSTSMSG), is in both QUSRTOOL and the TAAProductivity Tools. (For more information, see the "Obtaining and Installing the SNDSTSMSG Command" sidebar.) If you can remember the command name, you just key in the code shown in 2. The special value *REMOVE sends the CPI9801 message to blank out the status line. The SNDSTSMSG tool uses CPF9898, which automatically places a period at the end of the message.

A much simpler command, Send Status Message (SNDSTSMSG), is in both QUSRTOOL and the TAAProductivity Tools. (For more information, see the "Obtaining and Installing the SNDSTSMSG Command" sidebar.) If you can remember the command name, you just key in the code shown in Figure 2. The special value *REMOVE sends the CPI9801 message to blank out the status line. The SNDSTSMSG tool uses CPF9898, which automatically places a period at the end of the message.

You cannot use the Send Program Message (SNDPGMMSG) command from a high-level language (HLL) program by using QCMDEXC because SNDPGMMSG is restricted to a CL program. You can, however, use the QMHSNDPM API or call a CL program and use SNDPGMMSG. Once again, QUSRTOOL makes it easier. You can call the command processing program (CPP) of SNDSTSMSG directly using code, as shown in 3, then do your long-running function.

You cannot use the Send Program Message (SNDPGMMSG) command from a high-level language (HLL) program by using QCMDEXC because SNDPGMMSG is restricted to a CL program. You can, however, use the QMHSNDPM API or call a CL program and use SNDPGMMSG. Once again, QUSRTOOL makes it easier. You can call the command processing program (CPP) of SNDSTSMSG directly using code, as shown in Figure 3, then do your long-running function.

If you happen to be using a command (such as CPYF or OPNQRYF) that sends a status message, the end user may be confused by messages blinking on and off the screen. You can prevent status messages from being displayed using the technique shown in 4.

If you happen to be using a command (such as CPYF or OPNQRYF) that sends a status message, the end user may be confused by messages blinking on and off the screen. You can prevent status messages from being displayed using the technique shown in Figure 4.

The bad thing about this type of coding is that, if your program terminates abnormally, the second Change Job (CHGJOB) command may never get executed. The result is that the user's job is set for STSMSG(*NONE). In another article, I'll talk about how to recover automatically.

Jim Sloan is president of Jim Sloan, Inc., a consulting company. Now a retired IBMer, Sloan was a software planner on the S/38 when it began as a piece of paper. He also worked on the planning and early releases of the AS/400. In addition, Jim wrote the TAA tools that exist in QUSRTOOL and is now the owner of the TAA Productivity Tools product. He has been a speaker at COMMON for many years.


Programmer's Toolbox

Obtaining and Installing the SNDSTSMSG Command

The SNDSTSMSG command can be found in the TAA Tools in the QUSRTOOL library, which is shipped with every AS/400 through V3R1M0. The TAATools of QUSRTOOL will no longer be shipped with V3R6.

The QUSRTOOL library must be unpackaged and each tool within the library must be created. If you haven't unpackaged the QUSRTOOL library, see source member AAAMAP in source file QATTINFO, library QUSRTOOL for instructions. If you haven't created all the tools or at least the SNDSTSMSG command, see source member CRTTAATOOL in source file QATTINFO, library QUSRTOOL for instructions.

The SNDSTSMSG command can also be found in TAA Productivity Tools, a licensed product from Jim Sloan, Inc. TAA Productivity Tools ships with both source and object code already created. There's no need to create the tools as with the QUSRTOOL library (the SNDSTSMSG command will already exist in library TAATOOL).

For more information about TAA Productivity Tools, contact

Jim Sloan, Inc.

c/o Barsa Consulting Group, Inc.

914-939-6100


Programmer's Toolbox

Figure 1: Sending a Status Message with SNDPGMMSG

 SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('DSPOBJD + outfile being created')
 TOPGMQ(*EXT)+ MSGTYPE(*STATUS) DSPOBJD OBJ(lib/object) OBJTYPE(object-type)
 + OUTPUT(*OUTFILE)OUTFILE(QTEMP/DSPOBJDP) SNDPGMMSG MSGID(CPI9801) 
MSGF(QCPFMSG) TOPGMQ(*EXT) + MSGTYPE(*STATUS) 
Programmer's Toolbox

Figure 2: Sending a Status Message with SNDSTSMSG

 SNDSTSMSG MSG('DSPOBJD outfile being created') DSPOBJD OBJ(XXX/YYYY) 
OBJTYPE(*ALL) OUTPUT(*OUTFILE)
+ OUTFILE(QTEMP/DSPOBJDP) SNDSTSMSG MSG(*REMOVE) 
Programmer's Toolbox

Figure 3: Sending a Status Message from Within an RPG Program

 I 'Please wait' C MSG * * Send status message... C MOVELMSG STSMSG
 80 C CALL 'SNDSTS' C PARM STSMSG *
 * Do some long running function here ... * * * Remove status message... 
C MOVEL'*REMOVE 'STSMSG P C CALL 'SNDSTS' C PARM STSMSG 
Programmer's Toolbox

Figure 4: Preventing Status Messages from Displaying

 DCL VAR(&STSMSG) TYPE(*CHAR) LEN(7) /* Retrieve current value */
 RTVJOBA STSMSG(&STSMSG) / * Turn off status messages */ 
CHGJOB STSMSG(*NONE) /* Run a command which causes a status message */
CPYF FROMFILE(FILE_A) TOFILE(FILE_B) + MBROPT(*REPLACE) 
/* Put back previous value */ CHGJOB STSMSG(&STSMSG)
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$0.00 Raised:
$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • 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.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • 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

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • 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: