29
Fri, Nov
0 New Articles

Creating OS/400-Style Rolling Menus

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

Now you can build menus just like the AS/400's own rolling menus.

by Art Tostaine, Jr.

Programmers migrating from the System/36 to the AS/400 are pleased to see the OS/400 "Rolling Menus" that are used almost everywhere you look. The beauty of these menus is that you can store a great number of options on each menu in an uncluttered, neatly organized manner. I decided that in order to make my applications have that truly native look, I would have to change my System/36-style menu design to this new appearance. Hence, I designed a set of programs that would allow me to quickly set up menus with up to ten pages of menu options. Once these programs are in your system, you only need to add, change, or delete records from a menu option database file in order to set up or modify a rolling menu!

When I first decided to use the rolling menu, I quickly went to SDA and took option #1 (Design Menus) to design my first one. Surprisingly, or maybe not surprisingly, IBM decided not to provide a tool for creating rolling menus such as theirs. I thought that maybe I was missing something, so I called the Midrange Computing BBS and asked everyone, "How do I get AS/400 Rolling Menus?". The answer I received was, "Write a program." So I did.

The system I call MENUS is the result. It consists of the six objects, physical file MENUSPF (1), display file MENUSDF (2), RPG/400 program MENUSR1 (3), CL programs MENUCL and MENUECL (4 and 5), and the command MENU (6).

The system I call MENUS is the result. It consists of the six objects, physical file MENUSPF (Figure 1), display file MENUSDF (Figure 2), RPG/400 program MENUSR1 (Figure 3), CL programs MENUCL and MENUECL (Figures 4 and 5), and the command MENU (Figure 6).

Setting Up the Programs

The first thing you'll need to do is create the physical file MENUSPF. Use option 14 of PDM, or the CRTPF command to create the file after you've keyed in the DDS member. This is the file that will contain the menu information such as title, option numbers, option descriptions, and commands.

Second, key and compile the display file MENUSDF. It consists of a subfile (SCN01B), SFL control record (SCN01A), and command entry line (SCN01C). This screen is formatted in such a way that it will be difficult for the user to distinguish between this menu and an OS/400 menu.

Third, key and compile the RPG/400 program, MENUSR1, and the two CL programs, MENUCL and MENUECL. The RPG/400 program provides for menu to menu chaining (using (F12=Previous), retrieval of previous commands entered (F9=Retrieve), and the Refresh option (F5). The program also allows F4=Prompt by forcing a '?' to the left of the command entered. The MENUCL CL program works with the MENU command to call our system. The MENUECL CL program is called by MENUSR1 to run any command typed in on the command line. The main reason behind not using QCMDEXEC instead was to provide for some error control over what the user enters. More sophisticated error control could be implemented by using QCMDCHK first to verify the command.

Fourth, key and compile the command MENU using MENUCL as the "Program to process command." This is the command which prompts for the name of the first menu to display.

Setting Up the Menu Option File

You will set up your menu names, option numbers, command to be run, and other associated fields in the physical file MENUSPF. You can write an update program to update this file or just use the UPDDTA command. Each record is associated with the option number of a particular menu.

The two key fields of the file are MNNAME (menu name) and MNOPT# (option number). These fields identify what option number of what menu the record represents.

The MNTITL (menu title) field is a 32 character heading for the menu, which displays on screen line one. When keying the title you should center it within the field. You only need to complete this field for the first menu option record of each menu.

MNDESC (option description) is a fifty character field that contains the description of the menu option that the user will see.

MNPGM (program name) is the name of the program to call when the record's menu option is selected. If empty, the program assumes that you want it to run the command in the next field, MNCMD. This system does not provide for the passing of parameters to programs, but you could easily modify it to do so.

MNCMD (command name) is the name of the command to call when the record's menu option is selected. If empty, the program assumes that you want it to run the program in MNPGM. Here you can type the entire command and any parameters, such as WRKSPLF SELECT(*ALL). Any rules that apply to the command also apply to placing the command in the menu system. You can force a command to be prompted when the user selects the option by placing a question mark before the command name.

Use MNNEW (new menu name) to provide menu chaining. Any menu name in this field must be a valid menu name found in this file. When a user selects the option for this record, the system displays the menu indicated in this field. The previous menu name is saved so that the F12=Previous key will return to the previous menu. The program allows you to chain through 99 menus.

A Sample Menu

7 shows a sample PMENUS file. It contains records for the menus MAIN and APMENU. You can use UPDDTA MENUSPF to create the file. Run the sample by entering MENU MAIN. The MAIN menu will be displayed with it's seven options. If MAIN had more than 11 options, a plus sign would display on the bottom right corner to indicate more options. The roll keys will page through up to 99 selections.

Figure 7 shows a sample PMENUS file. It contains records for the menus MAIN and APMENU. You can use UPDDTA MENUSPF to create the file. Run the sample by entering MENU MAIN. The MAIN menu will be displayed with it's seven options. If MAIN had more than 11 options, a plus sign would display on the bottom right corner to indicate more options. The roll keys will page through up to 99 selections.

Option 7 chains you to the menu, APMENU. From there, F12 will return you to MAIN. Play around with this sample and you'll find that it functions just like IBM's menus.


Creating OS/400-Style Rolling Menus

Figure 1 Physical file MENUSPF

 A R MENUS TEXT('Menu Source') A MNNAME 10 COLHDG('Menu' 'Name') A MNOPT# 2S 0 COLHDG('Option#') A MNTITL 32 COLHDG('Menu' 'Title') A MNDESC 50 COLHDG('Description') A MNPGM 10 COLHDG('Program' 'Name') A MNCMD 154 COLHDG('Command' 'Name') A MNNEW 10 COLHDG('New' 'Menu') A K MNNAME A K MNOPT# 
Creating OS/400-Style Rolling Menus

Figure 2 Display file MENUSDF

 A REF(MENUSPF) A PRINT A R SCN01B SFL A MNOPT# R O 5 6EDTWRD(' 0.') A MNDESC R O 5 10 A MNPGM R H A R SCN01A SFLCTL(SCN01B) A CF03(03 'EXIT') A CF04(04 'PROMPT') A CF05(05 'REFRESH') A CF09(09 'RETRIEVE') A CF12(12 'PREVIOUS') A OVERLAY A 21 SFLDSP A 21 SFLDSPCTL A N21 SFLCLR A N29 SFLEND A SFLSIZ(0099) A SFLPAG(0011) A DSPREC 4S 0H SFLRCDNBR A MNNAME R O 1 2 A MNTITL R O 1 24DSPATR(RI) A 3 2'Select one of the following:' A 1 64'Date:' A 1 70DATE EDTCDE(Y) A 2 64'Time:' A 2 70TIME A R SCN01C A 16 6'90. Sign off' A 19 2'Selection or command' A 20 2'===>' A CMD 154A B 20 7DSPATR(HI UL) A 22 2'F3=Exit F4=Prompt F9=Retreive- A F12=Previous' A 23 2'F5=Refresh' A R FMSGSFL SFL A SFLMSGRCD(24) A MSGKEY SFLMSGKEY A PGMQ SFLPGMQ A R FMSGCTL SFLCTL(FMSGSFL) A BLINK OVERLAY A 21 SFLDSP SFLDSPCTL SFLINZ SFLEND A SFLSIZ(0002) SFLPAG(0001) A PGMQ SFLPGMQ 
Creating OS/400-Style Rolling Menus

Figure 3 RPG program MENUSR1

 FMENUSDF CF E WORKSTN F RRN KSFILE SCN01B F KINFDS DFINF FMENUSPF IF E K DISK E CM 100100 PREVIOUS CMD'S E CW 100 1 WORK ARRAY E MEN 100 10 PREVIOUS MENUS IDFINF DS I B 378 3790FROP# IDATA01 DS I 1 2 OPT I 1 1 OPT1 I 2 2 OPT2 C Z-ADD1 X 20 RETRIEVE IDX C Z-ADD1 X1 20 RETRIEVE IDX C Z-ADD1 Y 20 MENU INDEX C MOVEL'*' PGMQ PGM QUEUE C *ENTRY PLIST C PARM MNNAME 10 FIRST MENU C MENU KLIST C KFLD MNNAME C KFLD MNOPT# C EXSR FILSBF SETUPSUBFIL C SETON 21 DSPCTL C WRITESCN01C FUNCT KEYS C EXFMTSCN01A SHOWSCREEN * C *IN03 DOWEQ'0' C READ SCN01C 99READ COMMAND C Z-ADDFROP# DSPRSV 40 C *INKI IFEQ '1' C X1 IFGT 1 NOT 1ST REC C SUB 1 X1 C END C MOVELCM,X1 CMD C ELSE C *INKE IFEQ '1' F5=REFRESH C EXSR FILSBF C ELSE C *INKL IFEQ '1' F12=PREVIOUS C Y IFGT 1 NOT 1ST MENU C SUB 1 Y C MOVELMEN,Y MNNAME C EXSR FILSBF C END C ELSE C MOVELCMD WRK5 5 C MOVELCMD OPT C OPT1 IFGT '0' C OPT2 ANDEQ' ' C MOVELOPT1 OPT2 RIGHT ADJUST C MOVEL'0' OPT1 C END C TESTN OPT 50 C *IN50 IFEQ '1' NUMERIC=Y C WRK5 OREQ 'MENU ' C WRK5 IFEQ 'MENU ' C MOVEACMD CW C MOVE *BLANKS CMD C MOVEACW,6 MNNAME C MOVE '01' OPT C END C EXSR MENU# GET OPT# REC C MOVEL*BLANKS CMD COMMAND LN C ELSE C CMD IFGT *BLANKS C MOVELCMD CM,X C ADD 1 X C Z-ADDX X1 20 C END C Z-ADD154 LENGTH 155 LEN COMMAND C *INKD IFEQ '1' PROMPT C MOVE CMD CMD1 155 LEN=155 C MOVEL'?' CMD1 C MOVEL*BLANKS CMD C MOVELCMD1 CMD C END C CALL 'MENUECL' EXECUTE C PARM CMD C PARM LENGTH C MOVEL*BLANKS CMD COMMAND LN C END C END C END C END C *IN03 IFEQ '0' C SETON 21 SFLDSPCTL C Z-ADDDSPRSV DSPREC C WRITESCN01C C EXFMTSCN01A C MOVE *BLANKS CMD C MOVEL'RMVMSG' CMD C CALL 'MENUECL' C PARM CMD C PARM LENGTH C END C END * C SETON LR C****************************************************** C MENU# BEGSR * C****************************************************** C Z-ADD1 DSPREC C MOVELOPT MNOPT# C MNOPT# IFEQ 90 SIGNOFF CMD C SETON 03 C Z-ADD7 LENGTH C MOVEL*BLANKS CMD C MOVEL'SIGNOFF' CMD C CALL 'MENUECL' EXECUTE C PARM CMD C PARM LENGTH C ELSE C MENU CHAINMENUS 99 C WRK5 IFEQ 'MENU ' C MOVELMNNAME MNNEW C END C MNNEW IFNE *BLANKS C MOVELMNNAME MEN,Y C ADD 1 Y C MOVELMNNEW MNNAME C Z-ADD1 DSPRSV C EXSR FILSBF C ELSE C MNCMD IFNE *BLANKS COMMAND C Z-ADD80 LENGTH 155 C CALL 'MENUECL' C PARM MNCMD C PARM LENGTH C ELSE C MNPGM IFNE *BLANKS C CALL MNPGM C END C END C END C END C MOVELSVTITL MNTITL C MOVELSVNAME MNNAME C ENDSR C****************************************************** C FILSBF BEGSR * C****************************************************** C Z-ADD0 RRN 30 C Z-ADD1 DSPREC C SETOF 21 SFLCLR C WRITESCN01A C *LIKE DEFN MNTITL SVTITL SAVETITLE C *LIKE DEFN MNNAME SVNAME SAVENAME C MNNAME SETLLMENUS C Z-ADD0 RRN C RRN DOWLT100 C *IN99 ANDEQ'0' C ADD 1 RRN C MNNAME READEMENUS 99 C *IN99 IFEQ '1' C RRN ANDEQ1 C MOVE '1' *IN03 ENDPROGRAM C ELSE C RRN IFEQ 1 C MOVELMNTITL SVTITL C MOVELMNNAME SVNAME C END C END C *IN99 IFEQ '0' C WRITESCN01B WRITE SUBFL C END C END C MOVELSVTITL MNTITL RESTORETITL C MOVELSVNAME MNNAME RESTORENAME C ENDSR 
Creating OS/400-Style Rolling Menus

Figure 4 CL program MENUCL

 MENUCL: + PGM PARM(&MENUNM) DCL VAR(&MENUNM) TYPE(*CHAR) LEN(10) CALL PGM(MENUSR1) PARM(&MENUNM) ENDPGM 
Creating OS/400-Style Rolling Menus

Figure 5 CL program MENUECL

 MENUECL: + PGM PARM(&CMD &LEN) DCL VAR(&CMD) TYPE(*CHAR) LEN(154) DCL VAR(&LEN) TYPE(*DEC) LEN(15 5) DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(100) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR)) IF COND(&CMD *EQ 'RMVMSG') THEN(DO) RMVMSG PGMQ(*PRV) CLEAR(*ALL) GOTO CMDLBL(ENDPGM) ENDDO CALL PGM(QCMDEXC) PARM(&CMD &LEN) GOTO CMDLBL(ENDPGM) ERROR: + RCVMSG MSGDTA(&MSGDTA) MSGID(&MSGID) SNDPGMMSG MSGID(&MSGID) MSGF(QCPFMSG) MSGDTA(&MSGDTA) ENDPGM: + ENDPGM 
Creating OS/400-Style Rolling Menus

Figure 6 Command MENU

 CMD PROMPT('Display User-Menus') PARM KWD(MENUNM) TYPE(*CHAR) LEN(10) RSTD(*NO) + MIN(1) PROMPT('Menu Name') 
Creating OS/400-Style Rolling Menus

Figure 7 A sample menu file

 Figure 7: A Sample Menu File Menu Name Option# Menu Title Description Program Command Name MAIN 01 SAMPLE Print A/R Report AR100 MAIN 02 StartDaily Save SAVECL MAIN 03 Print A/R-Select ?AR100CL MAIN 04 Work Spool File WRKSPF MAIN 05 Work Spool-Select ?WRKSPLF MAIN 06 Go to A/P Menu APMAIN 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

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: