Week 3LectureNotes
Week 3LectureNotes
Computing
Week 3: RPGLE Programming with
Display files
1
Agenda
► DisplayFiles with DDS code
► Using RDi tool – Screen Designer
► RPGLE Programming
free Format syntax
using Display File
► QuickCheck (Questions)
2
Lesson Objectives
Upon completion of this lecture and lab 2 you'll be
able to:
► Create a display file using Screen Designer with
DDS code
► Code an interactive RPGLE program that uses the
display file
3
DDS Concepts
► Data Description Specifications (DDS) – a
traditional mean to describe data attributes
(such as the names and lengths of records and
fields) on the IBM® i operating system.
► The file types that use DDS describe:
Physical and logical files (database tables or views)
Display files
Printer files
…
Display Files
► Display (or WORKSTN) files are
objects of type *FILE with attribute of DSPF on the IBM i.
► e.g. INCOMETDSP.*file.dspf
used to communicate interactively with users at display terminals.
► In a record of display file, DDS describes:
named fields (as variables in RPG program)
constants (text, date, time, user)
► DDS is also used to specify:
positions (of fields), display attributes (e.g. highlight, reverse
image), data validation, screen control (e.g. overlay),
indicators (01~99), edit code (EDTCDE), edit word
(EDTWRD) and subfiles.
3 types of fields: input, output, and both (input/output)
Control screen record
► Example DDS code:
"000024 A R YOURTAX CF03(03 'EXIT')"
"000025 A OVERLAY "
INCOMETDSP INCTAXRPG
*file.dspf *pgm.rpgle
Create an RPGLE Program that uses the display file
11
Indicators
► 'Boolean' variables – predefined
*IN00 - *IN24 are usually used to map 24
function keys in display file.
*INLR – Last Record Indicator
►How we end RPG programs
► Have the values:
‘0’ or *OFF
‘1’ or *ON
RPG Syntax
► Each program statement ends with a “;” – semicolon.
► Comment
e.g. // This is a comment
► IF Statements
OPERATOR: =, <, <=, <>, NOT, AND, OR
e.g.
IF Test1 < Test2;
Minimum = Test1;
ENDIF;
e.g.
IF Test1 < Test2;
Minimum = Test1;
ELSE;
Minimum = Test2;
ENDIF; 13
RPG Syntax
► Loops – DO While
e.g.
DOW (a <= 5) AND (b + c = 0);
EXSR nextRecord;
ENDDO;
► Loops – DO UNTIL
e.g.
DOU X > 10;
Total = Total + Array(x);
X = X + 1;
ENDDO;
14
RPG Syntax - Subroutines
► Blocksof logic
► Execute a subroutine
e.g. EXSR GETGRADE
► Define a subroutine
e.g.
BEGSR GETGRADE;
TOTALMARK = 90;
LETGRADE = ‘A+’;
ENDSR;
RPG Syntax
► At the end of program
*INLR = *ON;
RETURN;
► *INLR = *ON;
The standard way of ending an RPG program.
► RETURN;
To return control to the operation system.
16
Lab 3 Demo
17
Homework?
► Review lecture notes.
► Complete Lab 3
► Lab 2 due
The End
19