You are on page 1of 24

Advanced RPG

Chapter 8 Interactive Applicatons

Interactive Applications
Batch Processing: Program is run without human intervention or control. Interactive Processing: User driven
Display files are needed for interaction.

Screen Design Aid (SDA): Graphical utility that will generate DDS source code.

Screen Design Aid


You can have multiple record formats per DDS member.

Screen Design Aid


Section Inquiry Type value, then Enter. Section number . . ____________

F3=Exit

Screen Design Aid


Section Information Section number . . . . . 12435 Course . . . . . . . . . BIS350 Instructor . . . . . . . . Johnson Room . . . . . . . . . . 1120 Meets on days . . . . . . MWF Starting Time . . . . . . . 10:30 Enrollment . . . . . . . . 36

Press Enter to Continue F3=Exit F12=Cancel

Screen Design Aid


AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions+++++++++++++++++ ********** Beginning of data ************************************ A REF(SECTIONS) A INDARA A R SECT1 A CA03(03 'F3=EXIT') A 1 28'SECTION INQUIRY' A 3 2'TYPE VALUE, THEN ENTER.' A 5 5'SECTION NUMBER . .' A SECTION 5A I 5 24 A 23 2'F3=EXIT'

Screen Design Aid


AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions++++++++++++++++++ A R SECT2 A CA03(03 'F3=EXIT') A CA03(12 'F12=CANCEL') A 1 10'SECTION INFORMATION' A 3 2'SECTION NUMBER . . .' A SECTNO R O 3 29 A 3 2'COURSE . . . . . . .' A COURSE R O 4 29 A 5 2'INSTR . . . . . . .' A INSTR R O 5 29 A 6 2'ROOM . . . . . . .' A ROOM R O 6 29 A 7 2'MEETS ON DAYS . . .' A DAYS R O 7 29 A 8 2'STARTING TIME . . .' A BEGTIME R O 8 29 A 9 2'ENROLLMENT . . . . . A ENROLL R O 9 29 A 21 2'PRESS ENTER TO CONTINUE' A 23 2'F3=EXIT' A 23 11'F12=CANCEL'

Screen Design Aid


CA03(03 F3=EXIT)
CA: Command Attention, enables the function key of F3. Returns control to RPG program without passing user input values. When F3 is pressed by the user, indicator 03 is turned on. F3=EXIT: Programmer comment.

Screen Design Aid


CF03(03 F3=EXIT)
CF: Command Function Functions the same as CA03 except that the values the user has inputted are passed back to the RPG program.

CA12(12 F12=Cancel)
Generally used to move the user back a screen.

Screen Design Aid


Display files are defined in File Specs just like any other file.
Full Procedural Externally defined Key is not relevant (position 34 blank) type (position 17) is C for combined file, supports both input and output but as independent operations. Optional keyword INDDS: Stores indicators passed to and from display file in data structure named Fkeys.

Screen Design Aid


Interactive programs are prone to spaghetti code.
flow of control is not straight forward User can press F3 to Exit or F12 to Cancel
Causes programmer to back up, repeat or exit early.

Screen Design Aid


WHILE user wants to continue (no Exit) Display first screen

Obtain users response to the screen


IF user wants to continue (no exit) Random read section file to get section information IF record found Display second screen Obtain users response ENDIF

ENDIF
ENDWHILE

Screen Design Aid


WHILE user wants to continue (no Exit) (*IN03 = *OFF) Display first screen (EXFMT Sect1) Obtain users response to the screen IF user wants to continue (no exit) (IF *IN03 = *OFF) Random read section file to get section information (Section CHAIN Sections)

IF record found (IF %FOUND(Sections)

Display second screen (EXFMT Sect2)


Obtain users response ENDIF ENDIF ENDWHILE

Screen Design Aid


Allowable functions for I/O
WRITE: Displays a screen and returns control to program without waiting for user input. READ: Sends control to currently displayed screen waits for end of user input (usually triggered by Enter key) EXFMT: Combines WRITE/READ, first writes a record to the screen and then waits for user input to the screen, when signaled it returns control to RPG program. USED MOST OFTEN!

Screen Design Aid


RPG IV gets away from referencing indicators
Must specify INDDS keyword in F Spec. Indicator Data Structure in DDS (INDARA) Define data structure in D Spec to contain indicators.
Only have to define the ones you are using.
D FKeys D D Exit Cancel DS 3 12 99 3N 12N

Screen Design Aid


CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++ C DOW NOT Exit C EXFMT Sect1 C IF NOT Exit C Section CHAIN Sections C IF %FOUND(Sections) C EXFMT Sect2 C ENDIF C ENDIF C ENDDO C C EVAL RETURN *INLR = *ON

DDS Keywords
File Level:
Must be on first line of DDS, before Record Format REF: reference another file for specifications INDARA: organize indicators into 99-byte data structure MSGLOC: specifies message line for error messages (default is last line, 24)

File or Record Level:


CA or CF: coded at file level they will apply to all record formats within the file PRINT: enables Print Key for user screen printing. VLDCMDKEY: turns on indicator when users presses any valid command key

DDS Keywords
Record Level:
Appear on line record is named or lines immediately following, prior to field names. BLINK: causes cursor to blink OVERLAY: Display record without clearing previous record display.

DDS Keywords
Field Level:
Apply only to specific field it is associated. EDTCDE, EDTWRD: format numeric output DSPATR: Display Attribute, determines appearance. (BL blinking field, UL underline)
DSPATR(BL UL)

DDS Keywords
Field Level: Data Validation
VALUES: Specify exact values allowed.
VALUES(value1 value2 . . .)

RANGE: Specify range of values allowed.


RANGE(low-value high-value)

COMP: Relational comparison with inputted value (EQ,NE,GT,NG,LT,NL,GE,LE):


COMP(GT 100)

CHECK: Validity checking (ME, MF, AB)


CHECK(Validity code)

ERRMSG: TIME and DATE

DDS Keywords
Conditioning Indicators:
Field Keyword will only apply if conditioning indicator is turned on by the RPG program.

AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions++++++++++++++++++ ********** Beginning of data ************************************* A REF(SECTIONS) A PRINT A INDARA A R SECT1 A BLINK A CA03(03 'F3=EXIT') A 1 28'SECTION INQUIRY' A 3 2'TYPE VALUE, THEN ENTER.' A 5 5'SECTION NUMBER . .' A SECTION 5A I 5 24 A DSPATR(UL) A DSPATR(HI) A ERRMSG('SECTION NOT FOUND 90) A 23 2'F3=EXIT' A A R SECT2 A CA03(03 'F3=EXIT') A CA03(12 'F12=CANCEL') A 1 10'SECTION INFORMATION' A 3 2'SECTION NUMBER . . .' A SECTNO R O 3 29 A 3 2'COURSE . . . . . . .' A COURSE R O 4 29 A 5 2'INSTR . . . . . . .' A INSTR R O 5 29 A 6 2'ROOM . . . . . . .' A ROOM R O 6 29EDTCDE(Z) A 7 2'MEETS ON DAYS . . .' A DAYS R O 7 29 A 8 2'STARTING TIME . . .' A BEGTIME R O 8 29EDTWRD(' 0: ') A 9 2'ENROLLMENT . . . . .' A ENROLL R O 9 29EDTCDE(3) A 21 2'PRESS ENTER TO CONTINUE' A 23 2'F3=EXIT'

Revised RPG code


DFKeys D Exit D Cancel D SectNotFnd C C C C C C C C C C DS

3 12 90
DOW EXFMT IF CHAIN EVAL IF EXFMT ENDIF ENDIF ENDDO

3N 12N 90N
NOT Exit Sect1 NOT Exit Sections SectNotFnd = NOT %FOUND(Sections) %FOUND(Sections) Sect2

Section

Interactive File Maintenance


Adding, changing or deleting records instantly.
Must verify data validity Three methods of safeguarding
Validation Keywords in PF description Validation Keywords in Display file description Validating values in program

You might also like