Using SDA, create the display File.
Type STRSDA.
1 of 10 04/11/20
Type Option 1 – Design Screens
2 of 10 04/11/20
Enter the Source Physical File and Member
Press Enter. A dd the Screen’s Record Format as follows:
3 of 10 04/11/20
Select Record Type
Add special values *date, *time and *user
Add screen literals in single quotes as follows and then, press enter:
4 of 10 04/11/20
Add Input field to collect selected option. See Page 476 in text book.
Ed it the Display Attributes for the Input/Output Option field by placing an ‘*’ in front of the BB and then placing a ‘Y’ beside ‘Display Attributes’.
5 of 10 04/11/20
Place a ‘Y’ in the ‘RI’ (Reverse Image) yes field. Type indicator 99 in one of the Reverse Image indic ators field. This tells the AS/400 that the ‘Enter Selection Field’ will be displayed in Reverse
Image if the indicator 99 is set to ‘1’ or ‘on’.
Place a ‘Y’ in the ‘UL’ (Under Line) yes field to make sure that this field is always underlined.
Place a ‘Y’ in the ‘PC’ (Position Cursor) yes field to make sure that the cursor is always positioned in this field.
6 of 10 04/11/20
Assign a field name to the ‘Enter Selection’ field by placing a ‘?’ in front of the field. This displays the field definition prompt. Name the field.
Press Enter.
Exit and save the screen design.
Press F14 from the Work with Display Records screen to Define F3=Exit.
Enter a ‘Y’ beside Indicator Keywords and press Enter.
Define F3=Exit as follows:
7 of 10 04/11/20
CA03 is the conditioned keyword (or name of indicator 03) that means exit to the AS/400.
Assigning it to 03 tells the AS/400 Display file that F3 is now a valid function key.
We could alternately use the keyword, CF03. CF03 would return the data in the ‘Enter Selection’ field to the program, but if we’re exiting, why would we need it?
Enter the screen design once more and add the message ‘Invalid Entry – Try Again’ to the bottom of the screen. Use the Attribute byte to setup field conditioning based on indicator 99. This will cause the Display File to display the message only when indicator 99 is set to one. Use the
Attribute byte to display the message in red.
8 of 10 04/11/20
Exit and compile the Display File.
CL programs are by default, stored in the members in the Source Physical File, QCLSRC or
QCLPSRC.
The following program will use the above Display File to process commands on the AS/400.
9 of 10 04/11/20
PGM {Field and File Declaration Section}
DCLF FILE(CHAP12) RCDFMT(SCRNR)
{Field initialization section}
CHGVAR VAR(&IN99) VALUE('0')
{Start of iteration (Processing loop)}
READ: SNDRCVF {Program displays the screen and waits here for a response from the keyboard}
{Initialize Error Checking Indicators before validating input}
CHGVAR VAR(&IN99) VALUE('0')
/*********************************************************/
/* CHECK FOR SIGNOFF */ {If screen option is 90, then signoff}
IF COND(&OPTION *EQ '90') THEN(SIGNOFF)
/*********************************************************/
/* CHECK FOR EXIT */ {If F3 pressed, then exit program}
IF COND(&IN03 *EQ '1') THEN(GOTO CMDLBL(END))
/*********************************************************/
/* CHECK FOR INVALID OPTIONS */
IF COND((&OPTION *NE '1') *AND (&OPTION *NE +
'2') *AND (&OPTION *NE ' 1') *AND +
(&OPTION *NE ' 2') *AND (&OPTION *NE +
'01') *AND (&OPTION *NE '02')) THEN(DO)
CHGVAR VAR(&IN99) VALUE('1')
GOTO CMDLBL(READ)
ENDDO
/***************************************************************/
/* OPTION 1 */
IF COND((&OPTION *EQ '1') *OR (&OPTION +
*EQ ' 1') *OR (&OPTION *EQ '01')) THEN(DO)
WRKOBJPDM CMOPS324
ENDDO
/***************************************************************/
/* OPTION 2 */
IF COND((&OPTION *EQ '2') *OR (&OPTION +
*EQ ' 2') *OR (&OPTION *EQ '02')) THEN(DO)
WRKOBJPDM MOOGK
ENDDO
GOTO CMDLBL(READ) /* AFTER EXECUTING OPT 1&2 */
{End of iteration (Processing Loop)}
END: ENDPGM
10 of 10 04/11/20