Question & Answer
Question
How to Add a Menu Option to IBM i TYPE(*DSPF) Menus?
This document explains the step-by-step process to add a new option to an existing IBM i menu that uses TYPE(*DSPF) with a display file and message file.
This example references IBM i 7.6 Documentation - Running from a Menu-Driven Application
Outline of the steps:
To update a menu created using Screen Design Aid (SDA), follow these steps:
- Edit the Display File: Add the necessary lines in DDS for the new option number and description.
- Recompile the Display File.
- Add a new message to the menu file for the menu option.
- Recreate the Menu object.
Test the Menu: Use GO LIB/MENU to test the updated menu.
Answer
## Prerequisites
Before adding a menu option, you need:
1. **Display file** - The DDS source that defines the menu screen layout
2. **Message file** - Contains the commands that execute for each option
3. **Program** - The program that will be called by the new option
---
## The 5-Step Process
---
### Step 1: Edit the Display File Source
Add two lines to the DDS source for the new option:
- One line for the option number
- One line for the option description
**Important:**
- Keep within 80 columns
- Maintain alignment with existing options
- Ensure INDARA keyword is present at the file level
**Example - Adding Option 4 to the DDS:**
A DSPSIZ(24 80 *DS3 27 132 *DS4)
A INDARA
A R MENUNAME
A 1 34'MY MENU TITLE'
A 5 7'1.'
A 5 11'First option description'
A 7 7'2.'
A 7 11'Second option description'
A 9 7'3.'
A 9 11'Third option description'
A 11 7'4.' ← NEW LINE
A 11 11'Fourth option description' ← NEW LINE
A 23 2'Type choice, press Enter.'
A OPT 1A B 23 27---
### Step 2: Recompile the Display File
CRTDSPF FILE(MYLIB/MENUNAME) SRCFILE(MYLIB/QDDSSRC) SRCMBR(MENUNAME)**What this does:** Rebuilds the display file object with the new option visible on screen.
---
### Step 3: Add Message Description
Add a message to the message file that defines what command executes when the option is selected.
ADDMSGD MSGID(USR0004) MSGF(MYLIB/MENUNAME) MSG('CALL PGM(MYLIB/NEWPGM)') SEV(0)
**Message ID Pattern:**
- Option 1 = USR0001
- Option 2 = USR0002
- Option 3 = USR0003
- Option 4 = USR0004
- etc.
**What this does:** Links the menu option number to the command that will execute.
---
### Step 4: Recreate the Menu
Delete and recreate the menu object to pick up all changes.
DLTMNU MENU(MYLIB/MENUNAME)
CRTMNU MENU(MYLIB/MENUNAME)
TYPE(*DSPF)
DSPF(MYLIB/MENUNAME)
MSGF(MYLIB/MENUNAME)
TEXT('Menu description')**What this does:** Rebuilds the menu object to recognize the new display file and message.
---
### Step 5: Test the Menu:
GO MYLIB/MENUNAME
**Verify:**
1. New option appears on the menu screen
2. Selecting the option executes the correct program
3. No error messages appear
Was this topic helpful?
Document Information
Modified date:
20 March 2026
UID
ibm17267003