rpg400 tutorial
TRANSCRIPT
RPG/400
Report Program Generator is a structural programming language originated in S/36 and
S/38 systems. It was available in two versions, viz., RPG-I and RPG-II. When RPG/400
was introduced in AS/400 it was the third version of the same also known as RPG-III. It
was mainly used for report generation as the name suggests but it has become the first
choice on AS/400 to build application.
It is a fixed format, column based language, i.e, everything in this language is coded
based on the columns in a fixed format of 7 available specifications. That means a
specific intruction has to be typed in specific column only. This column arrangement also
does not remain the same through out the program. The column arrangement is different
declaration or operation.
These are called as HFELICO. It is totally indicator oriented, i.e, extensive use of
indicators is made in this language. The HFELICO stands for the following :
H – Header Specifications used to specify the date format etc. within a given
program. There cannot be more than one H spec. in an RPG program.
F – File Specifications used to declare the files used in an RPG program along
with their attributes.
E – Extension Specifications used to define arrays or tables. A maximum of 256
arrays can be used in one RPG program.
L – Line specifications used to define the no. of lines in a report etc.
I – Input Specifications used to define the working data structures.
C – Calculation specifications used for the main logic control. The arithmetic
calculation and logical data processing is done in this spec.
O – Output specifications used to define the format of the program generated
reports.
The most important thing to be remembered is that the order of these specifications
cannot be altered. They should be present in the same order as they have been mentioned
here above. The following are the pages showing the coding sheets for the respective
specifications.
Another feature of RPG/400 is it has indicator oriented logic. Indicator is a predefined
logical field which can either be OFF or ON. The status is changed system or by
developer. Most of the conditioning in programs is done using these indicators.
There is a set of pre-defined indicators. In case of indicators changed by system the status
of indicator depends on the success or failure of any operation.
For example 75 is one of the general purpose indicator. If it assigned by developer to a
READ operation. It is set off by system when system could read a record. Thus it helps
to decide whether requested record found. It also helps to repeat a loop till the end of file.
Or in following chart we have 1P and OA indicator program can instruct system to print
heading on the top of first every successive page when 1P or OA is ON.
As mentioned earlier, there are many indicators used in this language to control the flow
of the program. They can be categorized and tabulated as follows:
SL.
NO.
INDICATO
R
DESCRIPTION ‘ON’ STATUS USAGE
1. 1P First Page Indicator Only when the
first page of
report is
encountered.
Print the
headings on
the first page.
2. OA – OG,
OV
Overflow Indicators Page-break Print the
headings on
the subsequent
pages.
3. 01 – 99 General Purpose
Indicators
Could be
explicitly
controlled.
Conditional.
4. L1 – L9 Level Break Indicators When a key
value changes
Report sub-
total printing.
5. LR Last Record Indicator When EOF
occurs.
Print report
summary or
terminate the
program.
6. M1 – M9 Match Field Indicator When a match-
field is read.
To assign and
detect and
matching
field.
7. MR Match Record When a match
occurs.
Print data
from multiple
files.
8. U1 – U8 External Indicators When turned
externally.
Conditional
file
processing.
9. KA – KN,
KP – KY
Function Key Indicators When a function
key is pressed.
Function Key
processing.
Note : A thumb rule with these indicators is that whenever a high level indicator is
set on all the lower levels automatically get on. For example, when LR is on all
other indicators (like L1 – L9) are automatically switched on.
There are basically two programming styles with RPG –
1) RPG Logic Cycle
2) User Logic.
RPG logic cycle is best suited for report generation as it is totally controlled by the
system whereas the user logic is best suited for user application because it is at the sole
discretion of the user.
1) RPG Logic Cycle : A logic cycle is a series of steps performed by RPG to process an
individual record. In this style of programming, the system takes entire control of the
files used and the files are opened, read and closed automatically. In this process,
there are two cycles which take place, viz.,
a) One file is designated as Primary file which is processed (READ) by system
implicitly without any READ operation on that file.
b) No loop is used to READ successive records of primary file.
c) The first cycle is the opening where the files are opened, read and records are
processed for the first time.
d) The subsequent cycle where the rest of the records are processed, therefore,
the file opening is not required here.
During the cycle the calculations are done twice:
a) Detail Time : The calculations are performed after the read of every individual
record.
b) Total Time : The calculations are performed for a group of records together.
During the cycle the printing operations are performed 4 times:
a) Heading Time : The headings, titles, etc. are printed during the heading time
for eg. Company Name, Column Headings etc.
b) Detail Time : The printing is done after the processing of every record in the
file.
c) Total Time : The printing is performed for group totals, i.e., whatever
calculations are made for a group of records.
d) Exception time : This is exception for some specific conditions which are
specified in the type column the O specs.
2) User Logic : This style of programming allows the user to specify all the conditions
and the programmer takes the total control of the logic and flow of the program.
As discussed earlier, the user takes the charge of the full programming logic and control.
So, the various arithmetic and logical operations to be performed in the program are
controlled by the so called OPCODEs. These OPCODEs are five letter words, generally
the short forms of the verb describing the action to be performed. For eg.,
ADD – means arithmetic addition
SUB – represents subtraction
MULT – implies multiplication
MVR – implies moving the remainder
IFxx – indicates an IF condition where xx represents any values like
EQ (Equals), NE (Not Equals), GE (Greater than Equal to) etc.
So, let’s discuss some of the OPCODES in detail. These OPCODES are used in the
OPCODE column provided in the C-Specs and perform the operations generally on the
operands that are mentioned in the Factor-1 and Factor-2 columns provided to the left and
right of the OPCODE column in the C-specs respectively. To start with some of the
arithmetic OPCODES:
ADD – Performs an arithmetic addition on the two Operands, and the result can be stored
in the Result field.
Factor-1 Opcode Factor-2 Result-Field
A ADD B C
Means C=A+B
Thus the columns in C-Spec are used for operation.
Factor-1 Opcode Factor-2 Result-Field
ADD B C
Means C=C+B
SUB – Subtracts Factor-2 from Factor-1 and stores the result in the Result field.
DIV – Factor-2 divides Factor-1 and the quotient is stored in the Result field. In case, the
remainder is to be stored the OPCODE to be used is MVR followed by a DIV.
Some more OPCODES,
Z-ADD – It zeroises, i.e., makes the value to zero of the Result field and then writes the
new value (specified in the Factor-2) into it.
Screen related OPCODES,
EXFMT – Executes the screen format specified in Factor-2.
WRITE – Writes the screen format specified in Factor-2.
CLEAR – Clears the record format specified in Factor-2.
READC – Used in subfiles to read the changed records.
File related OPCODES,
CHAIN – Randomly searches for the record specified in Factor-2 based on the field
value specified in Factor-1.
READ – Reads the record specified in the Factor-2.
READP – Reads the record previous to where the record pointer currently is.
REDPE – Reads the prior equal record.
READE – Reads the record for which the Factor-1 field value matches.
WRITE – Writes to a record.
UPDAT – Updates a record.
DELET – Deletes a record.
Structured OPCODES,
IFxx – For the IF conditions where the xx represent values like above under the same
comparision conditions.
DO – Performs a loop as many no. of times as specified in Factor-2.
DOWxx – For the Do While loop where xx could be values like
EQ – for equal
LE – Less than Equal
GE – Greater then Equal
LT – Less Than
GT – Greater than
where the comparision is made between Factor-1 and Factor-2.
DOU – For the Do UNTIL loop where the loop is executed based on the value in Factor-
2.
The major difference between DOU and DOW is that DOU is performed atleast once and
the condition is checked for only after a single execution of the loop whereas the DOW
loop pre-checks the condition and hence will not be executed even once until and unless
the condition is satisfied.
GOTO – Least advised keyword which will take the control of the program to a point
indicated by the TAG OPCODE.
ITER – Iterates a loop, i.e., ignores all the statements below it and goes to the beginning
of the DO loop.
LEAVE – Leaves the loop ignoring all the statements below it and continues execution
after the end of the ENDDO statement.
CASEQ – For the case operation, ended by ENDCS.
General Opcodes,
MOVE – Moves the value specified in Factor-2 into the Result field.
MOVEL – Moves the values specified in Factor-2 into the Result field with a left
alignment.
DSPLY – Displays the value of the variable specified in Factor-1 in the console and not
in userdefined screens.
COMP – Compares the values in Factor-1 and Factor-2.
CAT – It will concatenate the two strings from Factor-1 and Factor-2 and stores in the
Result field.
SST – The substring operation. Extracts from Factor-2 (specified alongwith the start
point) the no. of characters specified in the Factor-1.
SCAN – Searches for the string specified in Factor-1 in the string specified in Factor-2
(alongwith the start point).
KLIST – Specifies the list of Key fields – used for creating composite keys in the
programs.
PLIST – Used to specify the parameter list in a program.
PARM – Used to specify the parameter.
SETON – Sets On the indicator specified in HI, LO or EQ.
SETOF – Sets Off the indicator specified in HI, LO or EQ.
Sub-routine related OPCODES,
EXSR – Executes the subroutine mentioned in the Factor-2.
BEGSR – Indicates the beginning of Subroutine.
ENDSR – Indicates the end of a subroutine.
EXCPT – To process exceptional time output in the Printer Files (O Specs also).
Data Areas
A Data Area is an Object on AS/400 of the type *DTAARA. This stores a single value
of data in a flat format and can be used by one or many programs. However, the data
area can be locked when in use by one program so as to allow synchronized use of the
resource.
There are essentially four types of Dataareas, viz., Local Data Area(*LDA), Program
Initialized Parameter Data Area (*PDA), Group Data Area(*GDA) and the general data
area.
a) The Local Data Area is associated with the current job only (it’s a character data area
of 1024 bytes length).
b) The Program Initialized Parameter Data Area is associated with a pre-start job (max.
length 2000 bytes).
c) The Group Data Area is associated with the group job (character data area with 512
bytes length).
d) General Data Area created by the users (can be of type character, decimal or logical).
Data Structures
It is a storage area with the definition of its sub-fields. Generally, a data structure is
defined in a program but it can also be externally defined or a data area data structure.
In an externally defined data structure, an external file is defined which is used as a data
structure where the fields of the file act as sub-fields of a data structure.
In a data area data structure, a data area is defined and is used as a data structure.
There is also a File Information data structure (INFDS), which gives error/exception
information that may have occurred when processing a file during program execution.
The sub-fields are predefined and they identify the name of the file, record processed,
operation being processed, the status code number and the RPG/400 routine in which the
error occurred.
There is yet another category, viz., Program Status data structure (SDS) which gives the
status of the program and can be used along with the RPG provided *PSSR (Program
Status Sub-Routine) to handle the errors.
Arrays in AS/400
There are basically 3 kinds of arrays in AS/400, viz.,
1) Pre-run Time Array
2) Run Time Array
3) Compile Time Array
Pre-run Time Array : Such an array is populated with data just before the execution of the
program. The data for this array is stored in a table (physical file) and is loaded by the
system itself.
Run Time Array : Such an array gets loaded during the execution of the program. The
data is to be loaded programmatically by the user.
Compile Time Array : Such an array gets populated during the compile time. Values to
this array are defined at the bottom of the source code. When compiled, they become a
permanent part of the program object.
Following is a general example to define an array (Compile time array) :
Prompt type . . . E Sequence number . . . '''''''
From To Table - Entries per --
Length
Filename Filename Name Record Table
of Entry P/B/L/R
ARY 1 3
40
Decimal Sequence Alternate Length
Decimal
Positions (A,D) Name of Entry
P/B/L/R Positions
Sequence Comment
Defining Tables is also possible in RPG/400. The major difference between an Array
and a Table is that an array can be processed by the index and its individual elements can
be accessed using the index, whereas, in case of a table it is not possible the LOKUP
operation has to be performed and the elements can be accessed only sequentially.
Subfiles
Subfiles are an important part of RPG programming. A subfile is a logical group of
records which can be used to view/update data. It is used to handle more than one record
at a time. They are a part of the files created using SDA, i.e., the display file. It
comprises of two record formats, viz., the subfile record format (containing data) and the
subfile control record format (controlling the data).
There are five essential keywords to make a subfile work. They are, viz.,
SFLDSP, SFLDSPCTL, SFLCLR, SFLPAG, SFLSIZ.
SFLDSP – enables the subfile to be displayed.
SFLDSPCTL – enables the display of subfile control format.
SFLCLR – clears the subfile of any records it may previously contain.
SFLPAG – specifies the no. of records a subfile page may contain.
SFLSIZ – specifies the total no. of records contained in a subfile.
There are three types of subfiles, namely, Elastic subfile where SFLPAG<SFLSIZ (also
known as load-all subfile) and Non-elastic subfile where SFLPAG=SFLSIZ (also known
as page equal subfile). In Elastic subfile, the roll-up and the roll-down operations are
automatically taken care of whereas, in case of the non-elastic subfile they have to be
explicitly programmed. The third category is where SFLPAG = SFLSIZ-1, and in this
kind of subfile only the roll-down operation has to be taken care of. However, the non-
elastic subfile also known as Single Page subfile is the most efficient one. An example
has been provide for the same.
Subfiles can also be used for updation and deletion of data from the physical files.
Subroutines
They are integral part of the program objects, which are coded at the end of the program
source. They can be called from anywhere within the program using the EXSR
OPCODE. They increase the readability of the program and make complex programs
appear much simple.
RPG programs also allow call to external programs using the CALL opcode alongwith
which the list of parameters can be specified using the PLIST and individual parameters
mentioned using the PARM OPCODE.
Some examples overleaf would exemplify the OPCODES and their usages.
Given below is an example for RPG Logic Cycle program.
0001.00 FSAMEER3 IP E K DISK
0002.00 FMYREPO O F 80 OA PRINTER
0003.00 IEMPREC 60
0005.00 C ADD BASIC TBAS
92
0006.00 C ADD DA TDA
92
0011.00 OMYREPO H 22 1P
0012.00 O OR OA
0013.00 O 47 'SALARY
REPORT'
0014.00 O H 02 1P
0015.00 O OR OA
0016.00 O 23 '------
-----------------'
0017.00 O 46 '------
-----------------'
0018.00 O 69 '------
-----------------'
0019.00 O H 02 1P
0020.00 O OR OA
0021.00 O 15 'EMP
CODE'
0022.00 O 30 'NAME'
0023.00 O 52 'BASIC'
0024.00 O 66 'DA'
0025.00 O H 01 1P
0026.00 O OR OA
0027.00 O 23 '------
-----------------'
0028.00 O 46 '------
-----------------'
0029.00 O 69 '------
-----------------'
0030.00 O D 11 60
0031.00 O EMPCD 15
0032.00 O EMPNM 45
0033.00 O BASIC J 56
0034.00 O DA J 70
0035.00 O T 20 L1
0036.00 O 70 '------
-----------------'
0037.00 O T 20 L1
0038.00 O 30 'DEPT
TOTAL'
0039.00 O DTBAS JB 56
0040.00 O DTDA JB 70
0041.00 O T 20 L1
0042.00 O 70 '------
-----------------'
0043.00 O T 10 LR
0044.00 O 70
'***********************'
0045.00 O T 20 LR
0046.00 O 30 'GRAND
TOTAL'
0047.00 O TBAS J 56
0048.00 O TDA J 70
****************** End of data
****************************************
Given below is an example illustrating the a screen file used to toggle between the
records of a Physical file. It also illustrates the use of constants as array messages (I
SPECS).
Columns . . . : 1 71 Edit
STDLIB/SAMMAN
SEU==>
RPGDEPT
FMT FX
.....FFilenameIPEAF........L..I........Device+......KExit++
Entry+A....U
*************** Beginning of data
*************************************
0001.00 FDEPART IF E K DISK
A
0002.00 FSCREEN2 CF E WORKSTN
0003.00 I 'ALREADY AT TOP' C
M1
0004.00 I 'ALREADY AT BOTTOM' C
M2
0005.00 I 'RECORD SAVED' C
M3
0006.00 C READ DEPTREC
50
0007.00 C *IN03 DOWEQ*OFF
0008.00 C EXFMTDEPTSCR
0009.00 C MOVE BLANKS MSG
* TO REMOVE THE MESSAGE WHEN NEXT FUNCTION KEY
IS PRESSED .*
0010.00 C *IN04 IFEQ *ON
0011.00 C *LOVAL SETLLDEPTREC
0012.00 C READ DEPTREC
50
0013.00 C ENDIF
0014.00 C *IN05 IFEQ *ON
0015.00 C *HIVAL SETLLDEPTREC
0016.00 C READPDEPTREC
50
0017.00 C ENDIF
0018.00 C *IN06 IFEQ *ON
0019.00 C READ DEPTREC
50
0020.00 C *IN50 IFEQ *ON
0021.00 C MOVELM2 MSG
0022.00 C *HIVAL SETLLDEPTREC
* WHEN POINTER REACHES EOF THEN IT GOES IN THE NO
RECORD AREA HENCE TO GET IT WORKING PROPERLY THE
POINTER HAS TO BE FORCE POSITIONED AT THE EOF
RECORD HENCE THIS . *
0023.00 C ENDIF
0024.00 C ENDIF
0025.00 C *IN07 IFEQ *ON
0026.00 C READPDEPTREC
50
0027.00 C *IN50 IFEQ *ON
0028.00 C MOVELM1 MSG
0029.00 C *LOVAL SETLLDEPTREC
* WHEN POINTER REACHES BOF THEN IT GOES IN THE NO
RECORD AREA HENCE TO GET IT WORKING PROPERLY THE
POINTER HAS TO BE FORCE POSITIONED AT THE BOF
RECORD HENCE THIS . *
0030.00 C ENDIF
0031.00 C ENDIF
0032.00 C *IN08 IFEQ *ON
0033.00 C CLEARDEPTSCR
0034.00 C ENDIF
0035.00 C *IN09 IFEQ *ON
0036.00 C WRITEDEPTREC
0037.00 C MOVELM3 MSG
* TO GET THE MSG ‘ RECORD SAVED ’
0038.00 C ENDIF
0039.00 C ENDDO
0040.00 C SETON
LR
****************** End of data
****************************************
Given below is an example to demonstrate the use of an array:
SEU==>
RPGARY
FMT FX
.....FFilenameIPEAF........L..I........Device+......KExit++
Entry+A....U
*************** Beginning of data
*************************************
0001.00 FDEPART IF E K DISK
A
0002.00 FSCREEN2 CF E WORKSTN
0003.00 E ARY 1 3 40
0007.00 C READ DEPTREC
50
0008.00 C *IN03 DOWEQ*OFF
0009.00 C EXFMTDEPTSCR
0010.00 C MOVE *BLANKS MSG
0011.00 C *IN04 IFEQ *ON
0012.00 C *LOVAL SETLLDEPTREC
0013.00 C READ DEPTREC
50
0014.00 C ENDIF
0015.00 C *IN05 IFEQ *ON
0016.00 C *HIVAL SETLLDEPTREC
0017.00 C READPDEPTREC
50
0018.00 C ENDIF
0019.00 C *IN06 IFEQ *ON
0020.00 C READ DEPTREC
50
0022.00 C 50 MOVELARY,2 MSG
0023.00 C 50 *HIVAL SETLLDEPTREC
0025.00 C ENDIF
0026.00 C *IN07 IFEQ *ON
0027.00 C READPDEPTREC
50
0029.00 C 50 MOVELARY,1 MSG
0030.00 C 50 *LOVAL SETLLDEPTREC
0032.00 C ENDIF
0033.00 C *IN08 IFEQ *ON
0034.00 C CLEARDEPTSCR
0035.00 C ENDIF
0036.00 C *IN09 IFEQ *ON
0037.00 C WRITEDEPTREC
0038.00 C MOVELARY,3 MSG
0039.00 C ENDIF
0040.00 C ENDDO
0041.00 C SETON
LR
0042.00 **
0043.00 'ALREADY AT TOP'
0044.00 'ALREADY AT BOTTOM'
0045.00 'RECORD SAVE'
****************** End of data
****************************************
The following is an example to illustrate the use of subfile:
Columns . . . : 1 71 Edit
STDLIB/SAMMAN
SEU==>
RPGSUB
FMT FX
.....FFilenameIPEAF........L..I........Device+......KExit++
Entry+A....U
*************** Beginning of data
*************************************
0001.00 FSYNTEL1 IF E K DISK
A
0002.00 FSCREEN4 CF E WORKSTN
0003.00 F REC
KSFILE MYSFL
0004.00 C MOVE 0 REC
30
0005.00 C SETON
60
0006.00 C WRITEMYCTL
0007.00 C SETOF
60
0008.00 C *LOVAL SETLLEMPREC
0009.00 C READ EMPREC
55
0010.00 C *IN55 DOWEQ*OFF
0011.00 C ADD 1 REC
0012.00 C WRITEMYSFL
0013.00 C READ EMPREC
55
0014.00 C ENDDO
0015.00 C EXFMTMYCTL
0016.00 C SETON
LR
Given below is an example demonstrating a Data area:
Columns . . . : 1 71 Edit
STDLIB/SAMMAN
SEU==>
DATAPGM
FMT C
.....CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEq
Comments++++
*************** Beginning of data
*************************************
0001.00 C *NAMVAR DEFN DATR00 TEMP
50
0002.00 C *LOCK IN TEMP
0003.00 C ADD 200 TEMP
0004.00 C OUT TEMP
0005.00 C UNLCKTEMP
0006.00 C TEMP DSPLY
0007.00 C SETON
LR
****************** End of data
****************************************
Given below is an example demonstrating a Local Data area:
*************** Beginning of data
*************************************
E COM 1 1 80
ILDADS DS 1024
I 1 50 FLD01
* Calling CL command from RPG
C Z-ADD62 LENGTH 155
C CALL 'QCMDEXC'
C PARM COM,1
C PARM LENGTH
C *NAMVAR DEFN *LDA LDADS
* Using *LDA from RPG
C IN LDADS
C FLD01 DSPLY
C SETON LR
**
CHGDTAARA DTAARA(*LDA (1 50)) VALUE('VENKATRAMAN
AKKINEPALLY')
****************** End of data
****************************************
Given below is an example for single page subfile :
The following is the database file on which the screen is built.
*************** Beginning of data
*************************************
A R PREC
A PCODE 3 0
A PDSC 10
A RATE 3 0
A K PCODE
****************** End of data
****************************************
The following is the example for display file with page equal subfile:
*************** Beginning of data
*************************************
A*%%TS SD 20011022 151748 KIRAN REL-V4R4M0
5769-PW1
A*%%EC
A DSPSIZ(24 80
*DS3)
A R MYSFL SFL
A*%%TS SD 20011022 151748 KIRAN REL-V4R4M0
5769-PW1
A PCODE R O 13
21REFFLD(PREC/PCODE TRNGLIB/PRODPF@)
A PDSC R O 13
34REFFLD(PREC/PDSC TRNGLIB/PRODPF@)
A RATE R O 13
51REFFLD(PREC/RATE TRNGLIB/PRODPF@)
A R MYCTL SFLCTL(MYSFL)
A*%%TS SD 20011022 151748 KIRAN REL-V4R4M0
5769-PW1
A PAGEUP(33)
A PAGEDOWN(34)
A CA03(03)
A N31 SFLDSP
A N31 SFLDSPCTL
A 31 SFLCLR
A 32 SFLEND(*MORE)
A SFLSIZ(0005)
A SFLPAG(0005)
A 6 31'SINGLE PAGE
SUBFILE'
A DSPATR(RI)
A DSPATR(UL)
A 8 15'(Page up or
Page down for other re
A cords, F3 -
EXIT)'
A 11 17'Product Code'
A DSPATR(UL)
A 11 34'Description'
A DSPATR(UL)
A 11 50'Rate'
A DSPATR(UL)
****************** End of data
****************************************
The following is the code for the RPG program using a page equal subfile :
*************** Beginning of data
*************************************
FPRODPF@ IF E K DISK
FSUBSDA@ CF E WORKSTN
F RECNO KSFILE
MYSFL
***********************************************************
******
* 31 - SFLCLR, 32 - SFLEND, 33 - ROLLUP, 34 -
ROLLDOWN, 35 - READ
***********************************************************
******
C *IN03 DOWEQ*OFF
C *IN33 CASEQ*ON PAGEUP
C *IN34 CASEQ*ON PAGEDN
C ENDCS
C EXFMTMYCTL
C ENDDO
C SETON LR
***********************************************************
******
* THIS SUBROUTINE IS CALLED AT THE START-UP
***********************************************************
******
C *INZSR BEGSR
C Z-ADD0 RECNO 30
C EXSR LOAD
C ENDSR
***********************************************************
******
* SUBROUTINE FOR CLEARING THE SUBFILE
***********************************************************
******
C SUBCLR BEGSR
C SETON 31
C WRITEMYCTL
C SETOF 31
C ENDSR
***********************************************************
******
* SUBROUTINE FOR LOADING THE SUBFILE
***********************************************************
******
C LOAD BEGSR
C SETOF 32
C Z-ADD0 RECNO
C DO 5
C READ PREC 35
C N35 ADD 1 RECNO
C *IN35 IFEQ *OFF
C WRITEMYSFL
C ELSE
C SETON 32
C LEAVE
C ENDIF
C ENDDO
C ENDSR
***********************************************************
******
* SUBROUTINE FOR HANDLING PAGE UP
***********************************************************
******
C PAGEUP BEGSR
C SETOF 33
C RECNO IFLT 5
C PCODE SETLLPREC
C ENDIF
C RECNO ADD 5 TEMP 30
C DO TEMP
C READPPREC 66
C ENDDO
C *IN66 IFEQ *ON
C *LOVAL SETLLPREC
C ELSE
C PCODE SETGTPREC
C ENDIF
C EXSR SUBCLR
C EXSR LOAD
C ENDSR
***********************************************************
******
* SUBROUTINE FOR HANDLING PAGE DOWN
***********************************************************
******
C PAGEDN BEGSR
C SETOF 34
C *IN35 DOWEQ*OFF
C EXSR SUBCLR
C EXSR LOAD
C ENDDO
C ENDSR
****************** End of data
****************************************
The following is the code to call an external RPG program using CALL & PLIST:
Columns . . . : 1 71 Edit
TRNGLIB/SUB
SEU==>
RPGMN
FMT C
.....CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEq
Comments++++
*************** Beginning of data
*************************************
0001.00 C PNAME PLIST
0002.00 C PARM A
30
0003.00 C PARM B
30
0004.00 C PARM C
40
0005.00 C Z-ADD10 A
0006.00 C Z-ADD20 B
0007.00 C Z-ADD0 C
0008.00 C CALL 'RPGCL' PNAME
0009.00 C C DSPLY
0010.00 C SETON
LR
0011.00 *CALLING PROGRAM
****************** End of data
****************************************
Columns . . . : 1 71 Edit
TRNGLIB/SUB
SEU==>
RPGCL
FMT C
.....CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEq
Comments++++
*************** Beginning of data
*************************************
0001.00 C *ENTRY PLIST
0002.00 C PARM P1
30
0003.00 C PARM P2
30
0004.00 C PARM P3
40
0005.00 C P1 ADD P2 P3
0006.00 C P3 DSPLY
0007.00 C RETRN
0008.00 *CALLED PROGRAM
****************** End of data
****************************************