RPG ILE Specifications Explantion
RPG ILE Specifications Explantion
RPG ILE Specifications Explantion
RPG IV source is coded on a variety of specifications. Each specification has a specific set of
functions.
There are three groups of source records that may be coded in an RPG IV program:
The main source section consists of the first set of H, F, D, I, C, and O specifications in a module.
If the keyword NOMAIN is not specified, it corresponds to a standalone program or a main
procedure. If NOMAIN is specified, it does not contain a main procedure, and so it does not
contain any executable calculations. Every module requires a main source section
independently of whether subprocedures are coded.
Main Source Section Specifications
(H)
Control (Header) specifications provide information about program generation and
running of the compiled program.
(F)
File description specifications define all files in the program..
(D)
Definition specifications define items used in your program. Arrays, tables, data
structures, subfields, constants, standalone fields, prototypes and their parameters, and
procedure interfaces and their parameters are defined on this specification.
(I)
Input specifications describe records and fields in the input files and indicate how the
records and fields are used by the program.
(C)
Calculation specifications describe calculations to be done by the program and indicate
the order in which they are done. Calculation specifications can control certain input
and output operations.
(O)
Output specifications describe the records and fields and indicate when they are to be
written by the program.
Subprocedure Specifications
(P)
Procedure specifications describe the procedure-interface definition of a prototyped
program or procedure
(D)
Definition specifications define items used in the prototyped procedure. Procedure-
interface definitions, entry parameters, and other local items are defined on this
specification.
(C)
Calculation specifications perform the logic of the prototyped procedure.
Program Data
Source records with program data follow all source specifications. The first line of the data
section must start with **.
If desired, you can indicate the type of program data that follows the **, by specifying this
keyword required: CTDATA, By associating the program data with the appropriate keyword, you
can place the groups of program data in any order after the source records.
The first entry for each input record must begin in position 1. The entire record need not be
filled with entries. Array elements associated with unused entries will be initialized with the
default value.
Control (Header) specifications
H SPEC
H is the alphabetic code used for Control Specification. It is used to define the
controlling entity of the program e.g. date/ time format, default program name,
program as PEP, to define the decimal precision etc.
It is also used to define the compiler options to be used while we are compiling the
program.
e.g. default activation group, authority, compiler source generation options etc.
Keywords
Comment
___________________
H SPEC Keywords
o DEBUG (*Yes)
Use this keyword to indicate whether or not to perform DUMP operations in your RPG
program. The default is *NO, which means DUMP operations will not be performed. If you
have an error handler that uses the DUMP op-code, you should specify DEBUG (*YES) in
your H-spec.
o DATEDIT (*DMY)
The two most useable options however are still probably *{NO}SRCSTMT and
*{NO}DEBUGIO.
*{NO}DEBUGIO: If you use the interactive source debugger to step through a program,
you'll notice that the debugger will break many times on every I/O
statement. This is because a separate breakpoint is inserted for every
field returned from the I/O buffer. This is not a major problem, and very
inconvenient. Coding *NODEBUGIO will break only once for each I/O
statement.
o DATFMT (FMT)
Specify this keyword to define the default format for date fields within the program.
*MDY (mm/dd/yy)
*DMY (dd/mm/yy)
*YMD (yy/mm/dd)
*ISO (yyyy-mm-dd)
*USA (mm/dd/yyyy)
*EUR (dd.mm.yyyy)
e.g. H datfmt(*MDY)
*HMS (hh:mm:ss)
*ISO (hh.mm.ss)
*EUR (hh.mm.ss)
If ACTGRP (*NEW) is specified, then the program is activated into a new activation group. If
ACTGRP(*CALLER) is specified, then the program is activated into the caller's activation group. If an
activation-group-name is specified, then that name is used when this program is called.
o NOMAIN
Specify this keyword to indicate that this module does not contain a main (program-entry) procedure.
The AUT keyword specifies the authority given to users who do not have specific authority to the
object.
o BNDDIR ('library-name/binding-directory-name')
We can mention the bind directory name here that is to be used at the time of compilation.
________ _ _ _ _ _
_ ____ _ ____ _
File
_ ______ __________________________
Comment
_______________
1. File name: Mention here name of the file that you are going to use in your program.
2. File Type: Mention the file type as I, O, U, C where I= INPUT, O=OUTPUT, U=UPDATE, C=COMBINED.
These are the modes in which we are going to use the file. C is used for display file.
3. File Designation: Mention the File Designation as P, S, F where P=PRIMARY,S=SECONDARY,F=FULL
PROCEDURAL.
Primary File = Record will be processed in the order; from start to end by rpg program cycle i.e.
OPEN, READ, PROCESS, CLOSE. User can't change this order. There can be only one primary file in
the program.
Secondary Files = Secondary files apply to programs that do multifile processing. All of the files
involved in multifile processing, except the primary file, are secondary files.
Full Procedural file = User can control any order by rpg program opcode. User can change any order
by rpg opcode. With full procedural files the programmer determines which record or a block of
records to be read by way of the value of the key field used.
4. File Addition: Mention ‘A’ if you want to add record to the DISK FILE. In update mode of file, use ‘A’
file designation.
5. File Format: Mention if the file is program described or externally described.
6. Record Address Type: Mention this field entry as ‘K’ if the file is a keyed file, blank if the file is a
sequential access file or based on RRN.
7. Device: Mention the device as DISK, PRINTER or WORKSTN.
F PREFIX(D20:3)
o In order to refer the named record format as a subfile record format in the program.
F SPEC Keywords
o COMMIT{(rpg_name)}
The COMMIT keyword allows the processing files under commitment control. By specifying
the optional parameter, you can control at run time whether to enable commitment control. If
the parameter contains a '1', the file will be opened with the COMMIT indication on, otherwise
the file will be opened without COMMIT.
o IGNORE(recformat{:recformat...})
The IGNORE keyword allows a record format from an externally described file to be ignored.
The external name of the record format to be ignored is specified as the parameter recformat.
One or more record formats can be specified, separated by colons (:).
Example:
Now if we need only Rec_format_1 in our program, then we can IGNORE rest of the two
record formats Rec_format_2 and Rec_format_3.
o INCLUDE(recformat{:recformat...})
The INCLUDE keyword specifies those record format names that are to be included; all other
record formats contained in the file will be ignored.
Example:
Now if we need only Rec_format_1 in our program, then we can INCLUDE this record format
and rest of the record formats will be ignored.
o PREFIX(prefix{:nbr_of_char_replaced})
The PREFIX keyword is used to partially rename the fields in an externally described file.
PREFIX(YE:3) would change the field name 'YTDTOTAL' to 'YETOTAL'.
Example:
FACCLG01 UF A E K Disk
F Prefix(A01:3)
FACCLG02 UF A E K Disk
F Prefix(A02:3)
Here above logical files ACCLOG1 and ACCLOG2 both are based on same physical file and
only difference is their key fields. But they do have same field names. If we are using both file
at the same time, we cannot distinguish the field name of the two. Hence, to overcome this
problem we use PREFIX that partially renames the fields of the file.
Here ACCLG01 file will have its field’s first 3 character replaced with A01 and ACCLG02 file
will have its field’s first 3 character replaced with A02.
o RENAME(Ext_format:Int_format)
The RENAME keyword allows you to rename record formats in an externally described file.
Example:
FACCLG01 UF A E K Disk
F Rename(format1:format_xxx)
FACCLG02 UF A E K Disk
F Rename(format1:format_yyy)
Suppose we are using two files ACCLG01 and ACCLG02 both having the same record format
name format1, In such a case to distinguish the two files on the basis of their record format
name, we can use the RENAME keyword to rename the record format of one file to make it
different than the other one.
Here the new record format name for the two file will be format_xxx and format_yyy.
o SFILE(recformat:rrnfield)
Type the name of the record format and the field to contain the relative record number for the
entry field to be processed as a subfile. This keyword is valid only for externally described
files.
If we compile the program, we can see in the compiler report that all the formats related to the
subfile will get included in the program by using subfile.
Compiler report
*---------------------------------------------------------------------
* ACCCTL ACCCTL
* MSGSFL MSGSFL
* MSGCTL MSGCTL
*---------------------------------------------------------------------
o USROPN
Specify this keyword to indicate that the file must be explicitly opened with the OPEN operation and
should be
/FREE
open FILE1;
endif;
/END-FREE
A file information data structure (INFDS) can be defined for each file to make file
exception/error and file feedback information available to the program.
Example: Using INFDS & EXTMBR
SEU==> MBR_READ
FMT FX .....FFilename++IPEASF.....L.....A.Device+.Keywords++++++++++++++++++++
0001.01 F INFDS(FILEDS)
0001.02 *
0001.03 DFILEDS DS
0001.07 *
0001.08 *
0001.09 DDATA1 DS
0001.10 DFLD1 10
0001.12 DFLD2 10
0001.14 DFLD3 4 0
0001.16 *
0001.17 *
0001.18 DDATA2 DS
0001.19 DFLD4 6
0001.21 DFLD5 10
0001.25 DFLD7 10 0
0001.26 *
0001.27 *
0001.28 *
0004.00 C ENDDO
0005.00 C SETON LR
File . . . . . . CUST
CUST 07/27/12
MBR2 07/23/12
MBR3 07/23/12
Bottom
Parameters or command
===>
CUST data
MBR2 data
MBR3 data
Output
000001--AMI --00000--0000000000
000002--upi --00000--0000000000
000003--KUM --00000--0000000000
000004--RAHIN --12256--0000454654
100002--upi --00000--0000000000
100003--KUM --00000--0000000000
100003--KUM --00000--0000000000
Example 2: INFDS using 369 position of display file to handle PAGEUP, PAGEDOWN, ENTER KEY…
d ScnDS ds
d EnterKey c const(x'F1')
d RollUp c const(x'F5')
d RollDown c const(x'F4')
select;
Endsl;
Seton lr;
o INFSR(subroutine_name)
Type the name of the subroutine that will get control when an exception/error condition occurs.
The file error subroutine can only be coded in the main source section. You cannot code an
INFSR for a file that is used in subprocedure.
Specifying INFSR (*PSSR) means that you want the "standard" *PSSR subroutine to
handle the file exception which it would do by default - that's the reason why *PSSR is
handling the exceptions for your files.
If you only want exceptions handled for the specific file then give the subroutine a name
other than *PSSR, for example "FileErrSr" and assign that with INFSR(FileErrSr).
o OFLIND(indicator)
Indicator value from *INOA to *INOG or *INOV, is used to specify the overflow condition
for the program described printer files.
Indicator value from *IN01 to *IN99 is used to specify the overflow condition for the
externally described printer files.
Example:
Columns . . . : 1 80 Browse
AMIT/QRPGLESRC
SEU==>
PRINT4
0000.01
A*%%***********************************************************************
0000.03 A*%%FI+10660100000000000000000000000000000000000000000000000000
0000.05
A*%%***********************************************************************
0000.06 A R RCD001
0000.07
A*%%***********************************************************************
0000.09
A*%%***********************************************************************
0000.10 A 80 2
0000.13 A FLD001 2S 0O +2
0000.14 A EDTCDE(L)
0000.15 A UNDERLINE
0000.16
A*%%***********************************************************************
0000.17 A*%%SS
0000.18
A*%%***********************************************************************
0000.19 A R HEADER
0000.20
A*%%***********************************************************************
0000.23
A*%%***********************************************************************
0000.24 A SPACEB(002)
0000.25 A 9
0000.26 A 'ORG'
0000.27 A HIGHLIGHT
0000.28 A +9
0000.30 A +9
0000.31 A 'CCY'
0000.32 A +9
0000.34
A*%%***********************************************************************
0000.35 A*%%SS
0000.36
A*%%***********************************************************************
0000.37 A R DETAIL
0000.38
A*%%***********************************************************************
0000.40
A*%%***********************************************************************
0000.41 A SPACEB(001)
0000.42 A ORG R O 9
0000.44 A ACC R O +8
0000.46 A CCY R O +8
0000.48 A PARTY R O +8
0000.50
A*%%***********************************************************************
0000.51 A*%%SS
0000.52 A*%%SS
0000.53 A*%%SS
0000.54 A*%%SS
0000.55 A*%%SS
0000.56 A*%%SS
0000.57
A*%%***********************************************************************
0000.58 A R FOOTER
0000.59
A*%%***********************************************************************
0000.62
A*%%***********************************************************************
0000.63 A SPACEB(002)
0000.64 A 13
0000.65 A 'TOTAL CUSTOMER FOUND = '
0000.66 A TOTAL 2S 0O +0
0000.67
A*%%***********************************************************************
0000.68 A*%%SS
0000.69 A*%%CP+999CRTPRTF
0000.73 A*%%CS+999CRTPRTF
0000.77
A*%%***********************************************************************
Columns . . . : 6 80 Browse
AMIT/QRPGLESRC
SEU==>
PRINT4PGMC
0001.00
are printed.
0013.00 C SETON 99
0014.00 C ELSE
0015.00 C SETOFF 99
0016.00 C ENDIF
0017.00 C ENDDO
0020.00 C SETON LR
Output
A. If you want to do this inside of the RPG then have at least V5R1, you can use EXTFILE and
EXTMBR.
Or,
o For accounting purpose each month data can be stored as 12 different members so that we
can easily access one month data or 12 months together. Easy to maintain 12 members in
one PF file instead of 12 PF Files. Hence, in such a case the members will be JANUARY,
FEBRUARY, MARCH and so on.
Columns . . . : 6 76 Browse
AMIT/QRPGLESRC
SEU==>
MBR_READ
FMT FX
FFilename++IPEASF.....L.....A.Device+.Keywords+++++++++++++++++++++++++
0001.01 F INFDS(FILEDS)
0001.02 *
0001.03 DFILEDS DS
0001.07 *
0001.08 *
0001.09 DDATA1 DS
0001.10 DFLD1 10
0001.12 DFLD2 10
0001.14 DFLD3 4 0
0001.16 *
0001.17 *
0001.18 DDATA2 DS
0001.19 DFLD4 6
0001.21 DFLD5 10
0001.23 DFLD6 5 0
0001.25 DFLD7 10 0
0001.26 *
0001.27 *
0001.28 *
0004.00 C ENDDO
0005.00 C SETON LR
Declaration To /
Internal Decimal
_ __ _____________________________
Comment
________________
D SPEC Keywords
o VARYING
Here, the maximum length of the variable varstr will be 50, but the actual length can vary as
per the value assigned to this variable. Here the current size of variable will be the size of
string “Amit Jaiswal”.
o *VARSIZE
*VARSIZE has nothing to do with the data type of the variable. All it does is disable the
compiler's validity checking of the length.
Export indicates that the variable has been defined (stored) in this module and will be used by some
other module which is importing this variable using Import keyword.
Import indicates that the variable has been defined (stored) in some other module and will be used
here.
Example:
SEU==> MODULE1
FMT H HKeywords++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
0001.00 HOPTION(*NODEBUGIO)
SEU==> MODULE2
FMT D DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++
0005.00 C RETURN
SEU==> MODULE3
FMT D DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++
0004.01 C RETURN
****************** End of data ****************************************
o EXTPGM
This keyword is used in case of prototyping. So first of all we will go through the concept of prototyping.
Prototyping
A prototype tells the compiler how the parameters of a called program or procedure are
defined.
Prototyping makes the compiler to verify that whatever parameters that will be passed to a
called program or procedure appropriately defined.
Prototyping benefit us by showing the error at compile time rather than at run time.
Columns . . . : 1 71 Browse
AMIT/QRPGLESRC
SEU==>
SENDPGM
C EXSR SEND
C SEND BEGSR
C CALL 'MSGSFLCL'
C PARM MSGID 7
C PARM MSGF 10
C PARM MSGOPT 1
C ENDSR
Message ID . . . . . . . . . : MSG0001
Library . . . . . . . . . : AMIT
Message text . . . . . . . . : THE ACCOUNT NUMBER CAN NOT BE BLANK
Columns . . . : 1 71 Browse
AMIT/QRPGLESRC
SEU==>
MSGSFLCL
0006.00
0007.00
0010.00
0013.00 ENDPGM
When we run the program SENDPGM then at runtime it checks if the parameters are appropriately
passed or not. If we change PARM “MSGID” to some other data type or change its length, we will get
the error but not at compile time. We will get the error at run time and our program cannot continue
further.
To make sure that the program doesn’t crash at run time, we detect the error at compile time itself by
using prototyping. This is depicted in Case2 below.
SEU==> SENDPGM
DMSGF S 10
DMSGOPT S 1
DMSGSFLCL PR EXTPGM('MSGSFLCL')
DMSGID 7
DMSGF 10
DMSGOPT 1
C EXSR SEND
C SEND BEGSR
C CALLP MSGSFLCL(MSGID:MSGF:MSGOPT)
C ENDSR
Now when we compile the program, we get the below error at compile time.
**Error: The type and attributes of the parameter do not match those of the prototype.
But the error that we have got here is at compile time that is what we wanted.
o EXTPROC
If you've built modules with commands like CRTRPGMOD, CRTCLMOD, CRTCBLMOD, and CRTCMOD,
you're accustomed to calling them with the CALLB op code. Just as you can with CALL, you can replace
CALLB with CALLP.
Columns . . . : 1 71 Browse
AMIT/QRPGLESRC
SEU==>
SENDPGM
C SEND BEGSR
C CALLB 'MSGSFLCL'
C PARM MSGID 7
C PARM MSGF 10
C PARM MSGOPT 1
C ENDSR
Columns . . . : 1 71 Browse
AMIT/QRPGLESRC
SEU==>
MSGSFLCL
0006.00
0007.00
0010.00
0013.00 ENDPGM
****************** End of data ****************************************
Now when we run the program we get the same run time error. To avoid this we will go for prototyping.
SEU==>
SENDPGM
DMSGF S 10
DMSGOPT S 1
DMSGSFLCL PR EXTPROC('MSGSFLCL')
DMSGID 7
DMSGF 10
DMSGOPT 1
C EXSR SEND
C SEND BEGSR
C CALLP MSGSFLCL(MSGID:MSGF:MSGOPT)
C ENDSR
Using this we get the error at compile that we can correct and can easily avoid the situation of any run
time error due to parameters wrong definition.
o EXTNAME(file-name{:format-name}{:*ALL| *INPUT|*OUTPUT|*KEY})
The EXTNAME keyword is used to specify the name of the file which contains the field descriptions used
as the subfield description for the data structure being defined.
The file-name parameter is required. Optionally a format name may be specified to direct the compiler
to a specific format within a file.
The last parameter specifies which fields in the external record to extract:
D Fileds1 E DS Export
D EXTNAME(file1)
Subfield name : Same as the external file’s fields name, unless it id renamed by
keyword EXTFLD
or the PREFIX keyword on a definition specification is used to apply a
prefix).
Subfield length
Subfield internal data type
All data structure keywords except LIKEDS and LIKEREC are allowed with the EXTNAME keyword.
D D0220NEW E DS PREFIX(D21:3)
D EXTNAME(CZGD02H0:CZTD02H2)
D D0220OLD E DS PREFIX(D@@:3)
D EXTNAME(CZGD02H0:CZTD02H2)
o CONST(value)
* Constant variables
D INTRO C CONST('Introduction')
o LIKE(RPG_name)
The LIKE keyword allows us to define a data element of same data type and length as another field. This
keyword may be used in place of the *LIKE DEFINE op-code.
* Variables
o OVERLAY(name{:pos | *NEXT})
The OVERLAY keyword allows us to define a field name on the basis of overlaying a data structure or a
data structure subfield.
D DataStruct DS
D MainField 10
D Field1 5 overlay(MainField)
D Field2 5 overlay(MainField:*next)
o OCCURS
Columns . . . : 6 80 Browse
AMITCC/QRPGLESRC
SEU==>
MULTDS
FMT D DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++
0002.00 D FLDA 1 5
0003.00 D FLDB 6 10
0004.00 DX S 2 0 INZ(1)
0005.00
0006.00 C X DO 10
0013.00 C SETON LR
OUTPUT
DSPLY 1 1
DSPLY 2 2
DSPLY 3 3
DSPLY 4 4
DSPLY 5 5
DSPLY 6 6
DSPLY 7 7
DSPLY 8 8
DSPLY 9 9
DSPLY 10 10
o DTAARA{(data_area_name)}
Specifies the name of the external data that is associated with a field, data structure, data structure
subfield or data area data structure.
Dtime_is S z
Dtime_isO S 20
DACCCONVF S 1 INZ('N')
DLdadateY 1 4 0
DLdadateM 5 6 0
DLdadateD 7 8 0
DCURTIMDAT DS
DCURTIMDATE 1 16S 0
DCURRYEAR 1 4S 0
DCURRMONTH 5 6S 0
DCURRDAY 7 8S 0
DCURRHRS 9 10S 0
DCURRMINS 11 12S 0
DCURRSECS 13 16S 0
C TIMECAL BEGSR
C EVAL TIME_IS=%TIMESTAMP()
C EVAL TIME_ISO=%char(TIME_IS:*iso0)
C EVAL CURRYEAR=%dec(%SUBST(TIMe_ISo:1:4):4:0)
C EVAL CURRMONTH=%dec(%SUBST(TIMe_ISo:5:2):2:0)
C EVAL CURRDAY=%dec(%SUBST(TIMe_ISo:7:2):2:0)
C EVAL CURRHRS=%dec(%SUBST(TIMe_ISo:9:2):2:0)
C EVAL CURRMINS=%dec(%SUBST(TIMe_ISo:11:2):2:0)
C EVAL CURRSECS=%dec(%SUBST(TIMe_ISo:13:4):4:0)
C ENDSR
OUTPUT
TIME_IS = '2012-05-18-07.11.00.926000'
TIME_ISO = '20120518071100926000'
o CTDATA
o DIM(numeric_constant)
o PERRCD(numeric_constant)
Specifies the number of elements per record for a compile-time or a prerun-time array or table.
Example
Columns . . . : 1 100 Browse
SEU==>
FMT D .....DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++
0003.00 dS s 3p 0 inz(0)
0004.00 dn s 2p 0 inz(1)
0005.00 c n do 5
0007.00 c s dsply
0008.00 c add 1 n
0009.00 c enddo
0010.00 c seton lr
0012.00 101
0013.00 102
0014.00 103
0015.00 104
0016.00 105
0018.00 201
0019.00 202
0020.00 203
0021.00 204
0022.00 205
O/P
DSPLY 100
DSPLY 100
DSPLY 100
DSPLY 100
DSPLY 100
o STATIC
Type this keyword in the D specifications of sub-procedures to indicate that a standalone field or data
structure is stored in static storage.
Automatic Storage
By default, whatever stand-alone fields, data structures, arrays, etc. fields are defined inside a
sub-procedure use automatic storage.
The scope of these sub-procedure’s fields will be till the sub-procedure runs. After that it will be
reset to default value(0 or blank).
It has no effect of SETON LR. It really doesn’t matter if LR is SETON or SETOFF, its value will be
reinitialized each time the procedure is called.
Static Storage
Static storage has its life cycle from the time the program is called until the activation group
where it is running ends, or until the job or group job ends.
Static fields defined inside P specs has no effect of SETON LR, its values remain the same
between multiple calls to the program.
Global variable is the one that is defined outside P-spec. Its values remain the same between
multiple calls to the program. But it is affected by SETON LR i.e. SETON LR resets the global
variable.
Columns . . . : 1 80 Browse
AMITCC/QRPGLESRC
SEU==>
STATICPGM
FMT D
.....DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++
0001.00 D Checkcount PR
0002.00 D n S 2 0 inz(1)
0003.00
0004.00 DDS1 DS
0006.00 DAuto 1 0
0008.00 DStatic 1 0
0011.00 C n DO 3
0013.00 C ENDDO
0015.00 C SETON LR
0016.00
0017.00 P Checkcount B
0018.00 D PI
0019.00
0020.00 D AutoCount S 3 0
0021.00 D StaticCount S 3 0 STATIC
0025.00
0028.00
0030.00
0031.00 P Checkcount E
0032.00
Case5: 3RD CALL with RETURN op-code after RCLRSC or SIGNOFF or RCLACTGRP (if used in
the program)
o INZ
Columns . . . : 6 100 Browse
SEU==>
FMT D
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++
0003.00 Dc S 10 0 inz(*zeros)
0005.00 De S 10 0 inz
0006.00 C a DSPLY
0007.00 C b DSPLY
0008.00 C c DSPLY
0009.00 C d DSPLY
0010.00 C e DSPLY
0011.00 C SETON
LR
O/P
DSPLY ZZZZZZZZZZ
DSPLY
DSPLY 0
DSPLY
DSPLY 0
C Specification
C is the alphabetic code used for Calculation specifications.
Decimal
____ __ __ __ __ _________________
Position: 09
If we put N at position 9 then it means that the operation will be done only if the indicator at
position 10 is off.
Position: 10-11
Blank
The position can be left blank if we don’t want to put any condition for the calculation
operation.
01-99
Type a value from 01 to 99 to represent a general indicator.
KA-KN or KP-KY
Type a value from KA to KN or KP to KY to represent a function key indicator.
OA-OG or OV
Type a value from OA to OG or OV to represent an overflow indicator.
o Factor 1
Factor1 represents the name or literal on which the actual operation is to be performed.
For each operation there are certain op-codes defined that we can write in this section.
*** All the listed op-codes are explained in the next chapter.
Operator Extender:
Operation extender is used along with the op-codes to customize the op-code e.g. to half adjust the
decimal value, to read file without lock, to make the value padded with blank etc.
Possible values:
Blank
It can be left blank if we don’t want any kind of extender with the op-code.
(E)
Type (E) for error handling to occur. An error indicator is not allowed if the E extender is
specified.
(H)
Type (H) if half adjust is to be performed.
(N)
Type (N) if to read a file without lock.
(P)
Type (P) if the result field is to be padded with blanks.
o Factor 2
Factor1 represents the name or literal on which the actual operation is to be performed.
o Result
Result field is used to hold the result of the calculation operation in a name or literal.
o Field Length
Possible values:
Blank
Leave the field blank if the result field is already defined.
1-30
Type a value from 1 to 30 to specify the length for a numeric field.
1-32767
Type a value from 1 to 32767 to specify the length for a character field.
o Decimal Positions
Blank
Leave the field blank if the result field is already defined or if it is not decimal.
0-30
Type a value from 0 to 30 to indicate the number of decimal positions of the result field.
o HI
This resulting indicator representing a condition found for greater than, high or no record found
condition.
Possible values:
Blank
Leave the field blank if no indicator is to be set on.
01-99
Type any two-digit number to indicate general indicators.
KA-KN or KP-KY
Type a value from KA to KN or from KP to KY to indicate a function key indicator.
LR
Type LR to indicate a last record indicator.
OA-OG or OV
Type a value from OA to OG or OV to indicate any overflow indicator.
o LO
This resulting indicator representing a condition found for less than or an error condition
Possible values:
Blank
Leave the field blank if no indicator is to be set on.
01-99
Type any two-digit number.
KA-KN or KP-KY
Type a value from KA to KN or from KP to KY to indicate a function key indicator.
OA-OG or OV
Type a value from OA to OG or OV to indicate an overflow indicator.
o EQ
This resulting indicator representing a condition found for equal, beginning-of-file, an end-of-file, or a
search string-found condition.
Possible values:
Blank
Leave the field blank if no indicator is to be set on.
01-99
Type any two-digit number.
KA-KN or KP-KY
Type a value from KA to KN or from KP to KY to indicate a function key indicator.
OA-OG or OV
Type a value from OA to OG or OV to indicate an overflow indicator.
o Comment
Extended
Factor 2 Comment
_______________________________________________ ________________
O Specs:
Output Specification describe the record and the format of fields, in a program described file
and when the record is to be written
ä Column 7-14
ä Same file name that appears in the F-Spec for the output file
ä Column 15-16
ä H , D - Detail record
ä T - Total Record
ä E - Exception record
ä Used to indicate whether fields within the record are printed/ written to
file
Procedure Specifications
Procedure specifications are used to define prototyped procedures that are specified after the main
source section, otherwise known as subprocedures.
Entry
Explanation
Name
The name of the subprocedure to be defined.
Use positions 7-21 to specify the name of the subprocedure being defined. If the name is longer
than 15 characters, a name is specified in positions 7 - 80 of the continued name lines. The
normal rules for RPG IV symbolic names apply;
Position 24 (Begin/End Procedure)
Entry
Explanation
B
The specification marks the beginning of the subprocedure being defined.
E
The specification marks the end of the subprocedure being defined.
Procedure-Specification Keywords
EXPORT
The specification of the EXPORT keyword allows the procedure to be called by another module
in the program. The name in positions 7-21 is exported in uppercase form.