07
Tue, May
2 New Articles

Instant Menus!

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

Menus are important. Imagine, for a minute, what the AS/400 would be like if, after signing on, you got nothing but a blank screen or a C:> prompt. Sure, once you get the hang of it and learn what commands are available, you can get around without menus. But the overwhelming majority of AS/400 users don’t have enough room left in their skulls to memorize the dozens upon dozens of commands they would need to use every day.

But IBM is not the only one that can create menus. You can design and create them, too, and you have a choice of several ways to go about it:

• Create a display file and a program to drive it. These menus have the advantage of letting you have absolute control over design, although that may lead to lack of standardization.

• Create a menu through SDA. SDA-created menus are limited to a single screen, but at least, the design of the menu panel is of an enforced standard.

• Create a menu using UIM (User Interface Manager). UIM menus are, by far, the most versatile and function-rich. You can define what each function key does and automatically provide for F4=Prompt and F9=Retrieve (without going into their sordid details). UIM menus can also roll. In fact, UIM menus can have up to 999 options. The downside of these menus is UIM’s incredibly cumbersome syntax.

Introducing CRTUIMMNU

As I implied above, UIM menus are the way to create AS/400 menus. Unfortunately, you have to write a couple dozen lines of cryptic UIM code before you even get to describe the first menu option, and describing each option is complicated enough.

In this article, I present the Create UIM Menu (CRTUIMMNU) command, which, as its name implies, creates a menu from a much simplified version of the source code using a syntax that even a chimpanzee can understand. For instance, suppose you want to create a menu named PROGRAMMER and you want it to have the following options:
• Display Messages (DSPMSG)
• Work with Submitted Jobs (WRKSBMJOB)
• Work with Spooled Files (WRKSPLF)

UIM requires dozens of lines of incredible gibberish to build the menu. CRTUIMMNU builds the same menu from the source member in Figure 1. Just run the following command:

CRTUIMMNU MENU(QGPL/PROGRAMMER) +

SRCFILE(library/file)

That’s it! CRTUIMMNU creates menu PROGRAMMER in library QGPL, picking up the source code from the file of your choice. It assumes that the source member name will be the same as the menu name unless you override it.

Analyzing the Source

Take a moment to learn the simple syntax that I’ve invented. First, you do not have to write any preamble; CRTUIMMNU takes the menu title, its top instruction line (“Select one of the following”), and the copyright text from the command itself. You can’t see any of it in the example, because there are default values for all those options. You need only write the specs for each menu option.

Each menu option requires three lines. The first line, prefixed with a pound symbol (#), provides the option number to be assigned. You can assign option numbers or have CRTUIMMNU assign them for you. The second line starts with a greater-than symbol (>), indicating which command is to be executed when the user selects the option. You can specify up to 60 characters in this command string. The third and last line, prefixed with an asterisk (*), provides the description of the option as it should appear on the menu panel. My choice of #, >, and * has a mnemonic justification. After all, # means “number.” The > symbol is part of DOS’s C:> prompt and also the rightmost character of the “arrow” that appears to the left of the command line on OS/400 menus, so > suggests “command.” And * is the symbol that RPG uses for comments, so it’s used here to “comment” (describe) each menu option.

Note that the last option has a question mark (?) before the command name. The question mark is the standard means by which OS/400 invokes the command prompter. If the user selects option 3, the Work with Spooled Files (WRKSPLF) command won’t be executed but will be prompted just as if the user had typed WRKSPLF at the command line and pressed F4.

You don’t have to provide option numbers. CRTUIMMNU assigns those automatically, beginning with 1 and continues to increment by 1 for each additional option. Also, if you leave source lines that are almost empty (they contain only the > and * prefixes), there will be a gap in the menu and the option numbers will skip the number that would have been assigned.

If you want to assign option numbers, type a three-digit number (from 001 to 999) immediately after the # on the first of each three-line group. (Make sure you type all three digits!) If the option that follows has no number assigned, CRTUIMMNU continues automatically incrementing 1.

You can also group menu options. For example, the first two options of a menu may perform related tasks. In that case, the menu would look better if it had some kind of subtitle before those two options and the options were separated from the options that follow. To group options, write an additional line before the group and another line after the group. The line before the group must begin with a B (begin group) and contain additional text immediately after that (which is then used as the subtitle for the group). The line after the group must begin with an E and contain nothing else.

Consider the example in Figure 2, which produces a menu containing the following segment:

Message Management

41. Display messages

42. Send a message

If you wish to display another menu when the user selects an option (this process is called “chaining menus”), code the GO command. For example, if you want to add an option to display the AS/400 main menu, you can add the following three lines to the source member:

>GO MAIN *NO
*AS/400 main menu

The *NO that follows the menu name means that the menu being created should not be considered a return point. Consequently, if the user presses F3 from the MAIN menu, OS/400 goes all the way back to the point before the menu appeared. Similarly, you can execute programs from within menus by coding the CALL command.

A Brief Description of CRTUIMMNU

Take a look at CRTUIMMNU’s parameters in full detail:

• MENU (Name of menu). Enter the name of the menu you want to create, qualified with a library name. This parameter is required.

• SRCFILE (Name of source file). Enter the name of the source file containing the member in which you’ve written the source code. You can qualify the name with a library. If you don’t, the library name defaults to *MENULIB, which means that the source file is assumed to be in the same library indicated in the MENU parameter.

• SRCMBR (Source member). Enter the name of the source member containing the source code. If you don’t, it defaults to *MENU, which means that the source member is expected to have the same name as the menu being created.

• TEXT (Text description). Enter up to 50 characters to describe the menu. This description is stored in the menu object itself, as are text descriptions of any other object types. If not given, it defaults to the text description of the source member (*SRCMBRTXT).

• TITLE (Menu title). Enter up to 50 characters that should appear as the title of the menu (centered on line 1, in high intensity). If not given, it defaults to the text description of the source member.

• TOPINST (Top instructions). Type up to 50 characters of instructions to appear in blue on line 3 of the menu. The default value, *STD, will display “Select one of the following:” on that line.

• CMDLINE (Command line). Select *LONG, *SHORT, or *NONE. *LONG is the default and includes a command line that extends two physical screen lines. *SHORT is just one line long. *NONE shows the menu without a command line, giving you a four- position input field for an option number.

• COPYRIGHT (Copyright notice). Type up to 50 characters to appear on line 24 of the menu the first time the menu is invoked. If you prefer not to have any copyright notice, the default is *NONE.

• PRDLIB (Product library). Type the name of a library that will automatically be placed in the library list as the product library when the user invokes the menu. When the user leaves the menu, OS/400 automatically restores the product library to what it was before the menu appeared. By default (*NOCHG), there will be no change in the product library.

• CURLIB (Current library). This is the same as for the PRDLIB parameter but applies to the current library instead of the product library.

CRTUIMMNU takes the source code you have written and writes the real UIM source in a temporary source file created in QTEMP. Then, it runs the standard Create Menu (CRTMNU) command using that source in QTEMP. Figure 3 contains simplified

menu source code containing the features I’ve described. Figure 4 shows the UIM source code generated in the temporary file.

CRTUIMMNU, therefore, is a preprocessor for menu source code. It doesn’t have much intelligence, but it gets the job done. If you fail to write the source code as indicated above, CRTUIMMNU will tell you on which line it found the error but won’t tell you what it is. For instance, if you write an > line but follow it with another > line (instead of the correct * line), CRTUIMMNU triggers a terse *ESCAPE message that identifies, by sequence number, the source line in which it discovered the error.

Bonus: CRTOBJMNU

If you think CRTUIMMNU is “kewl,” Create Objects Menu (CRTOBJMNU) takes CRTUIMMNU’s automation one step beyond. CRTOBJMNU creates a single menu for a group of (or all) commands or programs in a library. For example, suppose you have a utilities library named UTILITY and you want to create a menu of all commands that begin with the letters PRT. You don’t need to write a single line of source code. Just run the following command:

CRTOBJMNU OBJ(UTILITY/PRT*) +

OBJTYPE(*CMD) +

MENU(UTILITY/PRINT)

That command creates a menu in which there’s one option per command, found in UTILITY, that begins with the letters PRT. The menu it creates is named PRINT and is placed in UTILITY. When you subsequently enter the menu (GO PRINT), you’ll see that, automatically, all PRT* commands are there listed in alphabetic sequence, in a neat listing showing option numbers, the command name, and the command text description (taken from the *CMD object itself).

No More Drudgery

You can download the source code from Midrange Computing’s Web site at www.midrangecomputing.com/mc/99/08. To install the two utilities presented in this article, you must first install the Forward Program Messages (FWDPGMMSG) utility command if necessary. (See “How to Forward Messages in CL,” MC, January 1998). Then, use the code in Figure 5 to create the objects.

CRTUIMMNU and CRTOBJMNU remove the drudgery of maintaining menus. I think you’ll like these menu utilities. I’ve been using them myself for a few months and would not consider going back to the old ways.

Reference

“How to Forward Messages in CL,” Ernie Malaga, MC, January 1999

#

>DSPMSG
*Display Messages (DSPMSG)
#

>WRKSBMJOB
*Work with Submitted Jobs (WRKSBMJOB)
#

>?WRKSPLF
*Work with Spooled Files (WRKSPLF)

Figure 1: CRTUIMMNU generates a UIM menu from this simple source code.

BMessage Management
#041

>DSPMSG
*Display messages
#

>?SNDMSG
*Send a message
E

Figure 2: Menu options may be organized into groups.

BPrograms
#

>CALL CASH430CL
*Enter cash receipts
#

>CALL BILL202CL
*Enter miscellaneous charges
#

>CALL ARINQ33CL
*Accounts receivable inquiry
E
BMessage commands
#011

>DSPMSG
*Display your messages
#

>?SNDMSG
*Send a message
E
BReports
#051

>WRKSPLF
*Work with your spool files
#

>WRKOUTQ PRT01
*Work with outq PRT01
E
BMiscellaneous
#090

>SIGNOFF
*Signoff
E

Figure 3: This simplified source code generates a complex UIM menu complete with groups of options.

:PNLGRP.
:VAR NAME=ZMENU.
:KEYL NAME=MENUKEYS HELP=X.
:KEYI KEY=F1 HELP=X ACTION=HELP.
:KEYI KEY=F3 HELP=X ACTION='EXIT SET' VARUPD=NO.
F3=Exit
:KEYI KEY=F4 HELP=X ACTION=PROMPT.

F4=Prompt
:KEYI KEY=F9 HELP=X ACTION=RETRIEVE.
F9=Retrieve
:KEYI KEY=F12 HELP=X ACTION='CANCEL SET' VARUPD=NO.
F12=Cancel
:KEYI KEY=ENTER HELP=X ACTION=ENTER.
:KEYI KEY=HELP HELP=X ACTION=HELP.
:KEYI KEY=PAGEDOWN HELP=X ACTION=PAGEDOWN.
:KEYI KEY=PAGEUP HELP=X ACTION=PAGEUP.
:KEYI KEY=PRINT HELP=X ACTION=PRINT.
:EKEYL.
:PANEL NAME=MYMENU
HELP=X KEYL=MENUKEYS
ENTER='MSG CPD9817 QCPFMSG'
PANELID=ZMENU TOPSEP=SYSNAM.
Test CRTUIMMNU Command
:MENU DEPTH='*' SCROLL=YES BOTSEP=SPACE.
:TOPINST.Select one of the following:

:MENUGRP.
Programs
:MENUI OPTION=001
ACTION='CMD CALL CASH430CL'
HELP=X.
Enter cash receipts
:MENUI OPTION=002
ACTION='CMD CALL BILL202CL'

HELP=X.
Enter miscellaneous charges
:MENUI OPTION=003
ACTION='CMD CALL ARINQ33CL'
HELP=X.
Accounts receivable inquiry
:EMENUGRP.
:MENUGRP.
Message commands
:MENUI OPTION=011
ACTION='CMD DSPMSG'
HELP=X.
Display your messages
:MENUI OPTION=012
ACTION='CMD ?SNDMSG'
HELP=X.

Send a message
:EMENUGRP.
:MENUGRP.
Reports
:MENUI OPTION=051
ACTION='CMD WRKSPLF'
HELP=X.
Work with your spool files
:MENUI OPTION=052
ACTION='CMD WRKOUTQ PRT01'
HELP=X.
Work with outq PRT01
:EMENUGRP.
:MENUGRP.

Miscellaneous
:MENUI OPTION=090
ACTION='CMD SIGNOFF'
HELP=X.

Signoff
:EMENUGRP.
:EMENU.
:CMDLINE SIZE=LONG.
Selection or command
:EPANEL.
:HELP NAME=X.
No help available.
:EHELP.
:EPNLGRP.

Figure 4: The simplified code in Figure 3 generates this UIM source.

CRTCMD CMD(xxx/CRTUIMMNU) PGM(xxx/CRTUIMMNUC) SRCFILE(xxx/QCMDSRC)
CRTCMD CMD(xxx/CRTOBJMNU) PGM(xxx/CRTOBJMNUC) SRCFILE(xxx/QCMDSRC)
CRTCLPGM PGM(xxx/CRTUIMMNUC) SRCFILE(xxx/QCLSRC)
CRTCLPGM PGM(xxx/CRTOBJMNUC) SRCFILE(xxx/QCLSRC)
CRTBNDRPG PGM(xxx/CRTUIMMNUR) SRCFILE(xxx/QRPGLESRC) +

DFTACTGRP(*NO) ACTGRP(*CALLER)
CRTBNDRPG PGM(xxx/CRTOBJMNUR) SRCFILE(xxx/QRPGLESRC) +

DFTACTGRP(*NO) ACTGRP(*CALLER)

Figure 5: These commands create objects for the CRTUIMMNU and CRTOBJMNU utilities.

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: