You are on page 1of 32

RPG IV

Interractive Applications - Chapter 8

Objectives
Define display files Develop interactive applications

Display Files
Coded on DDS Specification Sheets (A) Enter using SEU and compile File, Record, and Field level entries Each record format defines what is written to or read from the workstation in a single I/O operation On an output operation, the record may fill an entire screen with prompts and/or values

Display Files cont.


On an input operation, the record may read in several values keyed in from the workstation Unless you make special provisions, only one screen displays at a time When a different record format is written, the first screen is erased prior to the display of the second

DDS Coding
Record format begins with an R in position 17, followed by the name of the format Location of each literal and field on the screen is specified by using the screen line (39-41) and starting column (42-44) Code literals in position 45-80 and enclose them in apostrophes

DDS Coding cont.


Field names are entered left-adjusted in positions 19-28. Each field name is assigned a usage, coded in position 38 Usage codes include I for input, O for output and B for both input and output Each field must have a length (30-34), data type (35) and decimal positions (36-37) if numeric

Data Type/Keyboard Shift


Column 35 is also keyboard-shift to limit what characters the user can enter A (Alphanumeric shift): used for character fields; puts keyboard in lower shift, allows any character to be entered X (Alphabetic only): used for character fields; allows only A-Z, commas, periods, dashes, and spaces to be entered; lowercase letters sent as uppercase

Data Type/Keyboard Shift cont.


S (Signed numeric): used for numeric fields; allows digits 0-9; no signs; use Field-Exit key to enter a negative value Y (Numeric only): can enter digits 09, plus or minus signs, periods, commas, and spaces Y allows the used of edit codes and edit words to be associated with the field, while S does not

CA
CA (Command Attention) returns control to the program without the input data values that the user has just entered CA03(03 F3=EXIT) CA03 establishes F3 as a value command key The 03 within the parentheses associates indicator 03 with F3,when F3 is pressed, indicator 03 comes on F3=EXIT serves only as documentation

CF
CF (Command Function) returns control to the program with the input values that the user has just entered

Using an Indicator Data Structure


INDARA keyword instructs the system to organize all display files indicators into a 99-byte data area Include the INDDS keyword in the F Spec for the display file Code a data structure in the D Spec with a field name of Exit for the *IN03 indicator and Cancel for *IN12 indicator

File-Level Keywords
MSGLOC (Message Location) specifies the position of the message line for error and other messages PRINT enables the PRINT key allowing the user to print the current screen VLDCMDKEY is a file-level or recordlevel keyword used to turn on an indicator when the user presses any valid (enabled) command key

Record-Level Keywords
Keywords CAnn, CFnn, PRINT, and VLDCMDKEY, can be used as recordlevel keywords BLINK causes the cursor to blink during the display of the record format with which it is associated OVERLAY specifies that the record format be displayed without clearing the previous display

Field-Level Keywords
EDTCDE (Edit Code) and EDTWRD (Edit Word) control the format of numeric output fields ERRMSG (Error Message): a message will display on the message line and the field appears on the screen in reverse image DSPATR (Display Attributes) determines the appearance of fields on the screen

DSPATR
The following attributes can be assigned to all types of fields
BL Blinking Field CS Column Separator HI High Intensity ND Nondisplay PC Position Cursor PR Protect RI Reverse Image UL Underline

Data Validation
VALUES keyword allows you to specify the exact valid values allowed for this field RANGE keyword allows you to specify a range within which the users entry must fall to be considered valid COMP allows you to specify a relational comparison to be made with the users entered value to determine validity

Data Validation cont.


CHECK keyword is used for validity checking
ME (Mandatory Entry) MF (Mandatory Fill) AB (Allows blanks) LC (Lowercase)

Conditioning Indicators
Three indicators can be included on one line, these indicators are in an AND relationship If you want an event to occur if one of several indicators is on (an OR relationship), code one indicator per line with an O in position 7

What is File Maintenance?


Adding records to a file Changing the values of fields on a record(except the key) Deleting records from a file

What is Data Validation?


Safeguarding against invalid data entering the file Validation keywords within the physical file Validation keywords and data definitions within the display file Validating fields values within the program

File Maintenance Program


Accept users update request - add, change or delete Using the input key value, check for the existence of the record If found then the user can change or delete If not found then the user can add Validate entered data Update the file

Pseudocode for File Maintenance Program


Main
DO WHILE F3 is off Turn F12 off Initialize key field EXFMT Menu Screen SELECT When F3 = on Leave When F12 = on Iter When Action Code = A EXSR Add Subroutine When Action Code = C EXSR Change Subroutine When Action Code = D EXSR Delete Subroutine END SELECT END DO Turn Last Record on RETURN

Pseudocode for File Maintenance Program cont.


Add Subroutine
CHAIN key field to physical file with indicator in HI position IF Chain indicator off (record found in physical file, cannot add) Turn on invalid add indicator (to display error message) ELSE EXSR Initialization Subroutine EXFMT Add Screen Turn on invalid record indicator (set entire record to invalid right away) DO WHILE Invalid record indicator is on AND F3 is off AND F12 is off EXSR Validation Subroutine IF Invalid record indicator is on EXFMT Add Screen ELSE WRITE record END IF END DO END IF

Pseudocode for File Maintenance Program cont.


Validation Subroutine Turn off invalid record indicator IF name = blanks Turn on name field error message indicator Turn on invalid record indicator ELSE Turn off name field error message indicator END IF IF state = blanks Turn on state field error message indicator Turn on invalid record indicator ELSE Turn off state field error message indicator Chain state field to physical file with chain indicator in HI position IF chain indicator is on (state not found) Turn on state not found error message indicator Turn on invalid record indicator ELSE Turn off state not found error message indicator END IF END IF IF zip = zeros Turn on zip code field error message indicator Turn on invalid record indicator ELSE Turn off zip code field error message indicator END IF

Pseudocode for File Maintenance Program cont.


Change Subroutine
Chain key field to physical file with indicator in HI position IF chain indicator is on (record not found in physical file, cannot change) Turn on invalid change indicator (to display error message) ELSE EXFMT Change Screen Turn entire invalid record indicator on DOW entire invalid record indicator is on AND F3 is off AND F12 is off EXSR Validation Subroutine IF entire invalid record indicator is on EXFMT Change Screen ELSE UPDATE record END IF END DO END IF

Pseudocode for File Maintenance Program cont.


Delete Subroutine
Chain key field to physical file with indicator in HI position IF chain indicator is on (record not found in physical file, cannot delete) Turn on invalid add indicator (to display error message) ELSE EXFMT Delete Screen IF F3 is off AND F12 is off DELETE record END IF END IF

Screen Design and CUA


CUA - Common User Access Screen design standards Four panel types - Menu, List, Entry and Information

Screen Example
Panel ID Panel Title Optional Information Area (on menu, list, or info) And/or controlling fields for list panel Instruction Area (on menu, list, or entry) Panel Body Area Menu choices on Menu Panel List area on List Panel Entry Prompts on Entry Panel Information prompts on Information Panel

Points to Remember
Each record format of a display file defines a screen The format may include literals to display and fields for output, input, or both Each data item is positioned on the screen based on a line and column DDS entry for each

Points to Remember cont


DDS relies on keywords to achieve specific desired effects Some keywords are associated with the entire file, others with a specific record format, and others yet with specific fields Keywords enable function keys, determine the appearance and format of displayed items, control what the user can enter as input values, and associate error messages with fields

Points to Remember cont.


Most keywords, as well as fields and literals, can be conditioned by indicators If the indicator is on at display time, the keyword is in effect (or the field or literal displays); if the indicator is off, the effect or data item the indicator is associated with is suppressed The indicators are turned on within a program to control screen display

Points to Remember cont.


On the display side, valid command keys can be associated with indicators to convey information back to the program The important concept to remember for file maintenance is GIGO

You might also like