Sei sulla pagina 1di 13

RPG Notes

RPG -400 (Report program Generator)


RPG/400 OR RPG-3NEXT LEVEL RPGILE/RPG-4---NEXT LEVEL RPG FREE FORMAT
DB2/400 ---PF,LF,DISPLAY FILE
RPG has specifications level or specks (it is at root level)
These specifications are row oriented.
Type-RPG400/RPGILE/FREE FORMAT)
There are seven specifications in RPG400 and seven specification or level in RPG

HFELICO

These specifications are defined at position 6th.


RPGLE format is HFDICO

H specification
Also known as control specification
This is not a mandatory specification.
Program has only one H specification level.
If in a library there are 10 to 15 prog and we want the common H spec for all them then we
need to defined a common DATA AREA RPG H spec this will be in the common lib list where
all the program are executed.
The length of data area is 80 char and is position specific.
Comments are given either before position 6th or after position 80 and incase * is given at
position 7th then it is a comments.
EX 1------------------6-----------15---------------80
H
1
(This sets that debug & dump option is set to yes.)
H spec is also used for DATE format
Ex 1------------6-----------------19-------H
blank (the date format used is MMDDYY
If M is specified used as MMDDYY
If D specify DDMMYY
If Y specified YYMMDD
At 20th position---if its blank then it check for position 21
At position 21st position if any character is given it takes it as a separator.
If I is given at the position then it takes a period (.) as a separator.
Currency and decimal are also given at 21st position.
Position 75--------80 if we specify something at this position (ABCDE) then it overwrites the
program name given at CRTPGM.
And in case its blank the same name of the program given at CRTPGM is taken as it is.

Steria Limited / 2 May 2013

Page 1 of 13 / Version 1.0

F Specification (file description specification)


Define files in the program that includes PF, LF (disk file), DSPF (work station file), and printer
files.
Up to 50 files can be defined (RPG/400)
1-------------6-------------F
Position 7 to 14file name
Position 15--------input output update and combined (I, O, U, C)
C is for mainly display file.
Position 16 (P, S, R, T, F)
The most relavent is F
p- Primary
S-secondary
r-record set
t-table
F-fully procedural
P,s,r,t used in cycle programming
DSPF is also called display file.
F is used for LF,PF,DSPF, printer file
At position 17 blank
At position 18A/D (ascending/descending order)
At position 19 F/E
F---programmed described
Eexternally described mostly E is used as files are externally used.
At position 2427 here we specified record length
We dont need this for externally described file. it is blank
In program described file, we need to specified the record length.
At position 28 blank for externally described file but for programmed described file random and
sequential.
At position 2930 blank for E described file./if key used.
At position 31record address type (keyed or sequential)
K/S (blank for sequential)
At position 32blank
At position 3334 overflow indicator is used. (this is used only in case of printer file)
Ex If indicator no. is specified as 56, we check *int 56 = *on then it is overflow and print status at next
page.
At position 3538 blank for e described file and program described key field starting position.
At position 39blank.
At position 4046specified file type,the options are Printer, Disk, Workstn(Dspf) special.
Special, sequential is for program described file.
At position 53 given K this is for continuation in case we are specifying the information of the
same file on the nest line.
At the position 66A(addition)
This specified that we need to add the records in the file.
If the file specified already as o then this is not required. this is mainly used for U update
At position 7172 UC user control (blank)

Steria Limited / 2 May 2013

Page 2 of 13 / Version 1.0

If in a program pgm1 a file pf1 is available as soon as we use the pgm leave the option blank at
position 71-72.
EXPLICITY OPENthis statement needs to be written in the program. Similarly CLOSE
In case close is not specified then when the program ends the file is also closed.
Ex filePF1
Call CL OVRDBF PF1 PF2
READ PF1
DATA PF1
This is in case of blank as the ovrdbf is executed & then the data of PF2 is available.
FSPEC (keywords)
At position 53 if K is given for execution added line.
Then we can add some keywords
COMMIT position 5459 COMIT
ROLLBACK position 54-59 ROLBK
2.IGNORE position 5459 this is when it is a multi format file (i.e LF ,R1,R2,R3))
1------19----28-----53-----------54----59---------rec1
K
IGNORE
REC1 RECORD FORMAT NAME
3.INFDS(exception/error) info
Position 53K position 6067 DS name
02/06/09
4. INFSR: error subroutine
ex subr1,subr2,subr3 using all off them instead of that we can create subroutine then call this subr at
different steps.
Control file exceptional error
1-----------53------------54-59---------------60-67------K
INFSR
name of subroutine
5. RECNO: Record number
53--------54-59----60-67
K
RECNO field name
Used for all operationread, write, update, cursor set.
This is used only when the position 31st is blank i.e there is no key.
6. RENAME used position 5459
here we can rename record format
At position 1928 old position and 60-67 new format
The old record format is not used.
If 2 different files has same record format name then we need to change one of them else we will get
error while compiling.
7. SFILE used for sub file type of display file
1---------------5459-----53--------60-67--------------- 47------52
SFILE K
subfile rec format
name of field (RRN) of the sub file

Steria Limited / 2 May 2013

Page 3 of 13 / Version 1.0

8. SLN start line number used for display file


1----------------53------------54---59--------60-------65
K
SLN
name of field
If row is required dynamically printing
In display file given at record format level
R
RCD1
SCNO(*VAR)
2.4 text
EXFMT(no7) poison start from 7th
IN EXFMT if we have given 7th position that means the record format is now starting at row 7 so the
text at 2nd position will print at 9th row.

E-specification (Extension specification)


IT is used to explain some extra attributes of file and also used to defined array tables and record
address file.
Arrays: used as same length same type and same decimal position.
Types of array:
Compile time array: defined at the time of compilation
Pre run time array: data file load array it means data loaded from file
Run time array
In compile array defined data in array written with in program only.
Pre run time array The data file can be loaded into array, so that we dont have to compile the program
again & again before perform input, output, calculation operation.
Run time array open in (c,o)
Input and output
Values are loaded at the run time in the array.
Whenever we use tables, we can always use array but vice-verse is not possible.
Data access is sequential in table but randomly access data in array due to by index.
A full array can be used with its name (AR!) but with tables it only uses the last element whereas
array name access all the 10 elements.

Types of tables:Compile time


Run time
Position
Position 15 comments
,,
6 E
position 710 blank
position 11---18 blank for array (compile and run time) and table (compile)
And file name in both (pre run time)

Steria Limited / 2 May 2013

Page 4 of 13 / Version 1.0

Position 1926 blank and file name (this file is one which contain all data of the array/table but in this
case this file should be defined in F specification this file should be output file/combined.
The file name mentioned in position 1118 and 19---26 can be same but the file type should bu
combined i.e display file.
Position 2732 array/table name
Position 3335 blank (run time array) and compile or pre rum time we have entries per element value
in position 3335 can be form 1999
If we have taken 10 element array and given element size 3 for each then 3 element comes in each
row.
R1 3 elements
R2 3 elements
R3 3 elements
If we have given 4 element then it will not taken and show some error.
Position 3639 maximum no. of elements i.e 1-999
Position 40-42 length of element
Position 43 data type (P, B,blank for character)
Position 44 for decimal position (in case of packed decimal)
45blank for no sequence A for ascending and D for descending.
L Specification (Line level specification)

Only used for program described file.


Used only for two cases : Length of the form & no. of lines to be printed on a page.
For this in F specification we will give L at position 39.
At position 6 L (for l specification)
At position 714 file name as given F specification)
15----17 lines per page (2112 no. of lines specified for the page)
1819 FL (form length)
2022 overflow line number (this can be <= form length)
2324 given as OL only if we have given overflow line number.

I specification (input specification)


Program described file (mandatory)
If you are using externally described file (optional)
Data structure
Named constant
Externally described file have two type of entries
1. record identification (714 & 1920)
2. field description (2130 & 5362 & 6570)
3.
1. Record Identification :At position 6 I
At position 714 name of record format
At position 1920 record identifying indicators

Steria Limited / 2 May 2013

Page 5 of 13 / Version 1.0

Indicators:0199---general indicator
l1l9 or LRcontrol level indicator
H1H9 halt indicator
U1U8-External indicator
RT-return indicator
At position 21 blank
2. Field Description Entry:
At position 6 I
7---20 blank
2130 old name
3152 blank
5358 new name
6162 M1 M9 matching field indicator
6570 halt, general, external, return indicators
5960 indicator

Data structure
1.
2.
3.
4.

Normal Data structure program and external


Data Area Data structure
Program status data structure (PSDS)
INFDS (file information data structure

IN the program described normal ds all the information about the ds is stored within
the program.
External desc ds all the information present in some file.

Data Area Data structure


We make data area DS on the given data area.
Data area--------after read this its locked
---- write back to data area
EXIT
In RPG other option is IN OUT
Program Status data structure
Exception or error handling
We find some values related to a program (we will have these values at run time)
Program status
Program name
Subroutine or routine
Operation code
If we want the data area while job is running we use LDA and it is to be specified in I specification.

Steria Limited / 2 May 2013

Page 6 of 13 / Version 1.0

Difference between Array and data structure


Array can have multiple values where as DS have single value.
Array has the field of same length but in DS it can be different.
Data structure specification:At position 6 I
712 data structure name (optional) (in case of LDA)
2130 blank /external dec Data area name of file (6 characters)
13---16 blank
17 blank (it means the data structure is internally defined)
or E (means based on externally file)
At position 18 blank (either internally desc/ externally desc)
I mean to initialize all its subfields
S mean it is PSDS (will be only one for PSDS)
U Data area data structure i.e. it depends on some data area.
If U is given it checks position 712 for the name of the data area on which it is based data area &
data structure is same.
If U is given & at position 712 blank it is used LDA.
1920 DS
2130 filename (in case there is file record format select first one by default and blank the desc is in
program.
At position 31---43 blank
44---47 blank at position 48---51 blank (19999)
52---74 blank
4447value is specified in case of multi occurrences data structure else it is blank
4851 value specified is the length of data structure and if it is blank it will take the length of the fields
itself.

AMANLIB/AMANSRC
TRYARR

Steria Limited / 2 May 2013

Page 7 of 13 / Version 1.0

Data structure subfields


Program described data structure
At position 6 I
7 blank
8 blank (no subfield initialized)
internally 2142 position value with which it needs to be initialized
920 blank
2130
externally field name rename in externally described file
21---42 value for initialization
blank, zero values depending on the field is char or numeric.
At position 31---42 blank (in case of externally desc file)
43 ppacked B--Binary
blank for char type
44---51 field location begin 4447 end 4851lenght will be calculated itself.
At position 44---51 keywords in case of PSDS/INFDS
PSDS (*STATUS, ROUTINE, PARMS, PROGRAM)
INFDS (*FILE, RECORD, OPCODE, STATUS, ROUTINE)
At position 52 decimal
5358 name of the field
5874 blank
74 onwards comments

I Specification
Named constants are the values that have same value through out the program.
At position 6 I
720 blank
21---42 value (constant)
43 cconstant, Bincase the value is moving on towards line as the space is not enough on the
given line
5358 name of constant
Ex 6
21----------42 43 53----58
I
ABCDE C FLD1
Q create an initial data structure & dont specify its name and see the result.
F1 123456
F1 1,2,3,4,5,6 then we can take a data structure of F2
F1=1, F2=, ,F3=2, F4=, ,

Steria Limited / 2 May 2013

Page 8 of 13 / Version 1.0

C Specification
All data operation are performed at this level.
It is divided into three parts:
Position 7-17conditioning indicators
Position 18-53what kind of calculation need to be done on the given data.
5459resulting indicators.
At position 6 C
78 control level (AN & OR this is for indicators that we will defined)
917 general indicators (0199)
123
18-27 factor1 (this could be field, actual data & keyword)
2832 opcode
3342 factor2
4348 result field
4951 length of the result field (numeric 130 and char 1256)
blank it means result field is already defined in the program.
52decimal position of result field min 0 or max-9
53 operational extender
H-half adjust only for numeric
N-record locking
P-padding right side
Ex- H 1.234 used as +5 or -5
It leaves the last position on the right 1.28
N when the opcode is working then the record gets locked. But if not use N does not allow record
locked.
54---59
5455 HI high
5657 low
5859 equal
6074 blank
7580 comments

Steria Limited / 2 May 2013

Page 9 of 13 / Version 1.0

Introduction
Business overview
System walkthrough
Major functionality
Transaction
Charge backs
Letter generation
Interfaces
Interfaces job
Connect direct log
Major file
System access
Library structure
Archive job
XHIMANSHU/RPGPRAC
FRPG1
FQSYSPRT O F

132

OF

PRINTER to print report file on printer.

EXFMT TO DISPLAY
To work in synon check two library Y1SY and Y2SY should be listed in lib list.
To create travel services order manually
YSTRY2 *S to start synon modal

DSPFD-- file level information---file type attributes member type attributes file, File is currently
journaled access path, (keyed or arable) record format attributes
DSPFFD -- field level information in the file
DSPDBR--to find out logical file on perticuler ph file
WRKOBJthat is used to show or check object authority and the command worked in back ground is
DSPOBJAUT. Or display object discretion
DSPMSG QSYSOPR used to check operator queue
DSPPGMREF
DSPUSRPRF
DSPUSRPRF USRPRF(*ALL) TYPE(*BASIC) OUTPUT(*OUTFILE) OUTFILE(XDILIPTS/...

Steria Limited / 2 May 2013

Page 10 of 13 / Version 1.0

Following commands are used for CL.


CLRLIB

Clear library

CPYFRMIMPF

Copy file form ifs to PF file (CSV or DBF to PF file)

CPYTOIMPF

Copy PF file to ifs (PF file to CSV or DBF)

CRYTOSTMF

Copies file, member or save file to an object on the IFS

CRTDIR

Create Directory on IFS

CRTJRN

Create journal

CRTLIB

Create library

CRTPAGSEG

Create page segment for printer file's overlay

CRTOVL

Create overlay for printer file's overlay

CRTSRCPF

Create source physical file

CVTPCDPAGS

Convert PC document to page segment

CVTOVLPFM

Convert Overlay to Physical File Member

CVTPAGSPFM

Convert Page Segment to Physical File Member

CVTPFMPAGS

Convert Physical File Member to Page Segment

DBU Qualified Name

Runs DBU without the STRDBU command.

DLCOBJ

De-allocate object

DLTJRN

Delete journal

DLTLIB

Delete library

DLTLICPGM

Delete license program

DSPDBF

Displays contents of database file. (must add TAATOOL to libra

DSPDBR LIB/FILE

Shows logicals related to a physical file

DSPFD

Displays file description for specified file

DSPFFD

Displays file field descriptions

DSPJRN

Display journal

DSPLIB

Displays contents of specified library

DSPLIBD

Display library description

DSPLICKEY

Display license key info

DSPMSG

Displays messages in queue

DSPMSGD

Displays description of messages, i.e. CPF messages

DSPPFM

Displays member of a physical file before

DSPPGMREF

Display the files used in a pgm and which libraries


the pgm was compiled over

DSPRCDLCK

Display record locks

DSPUSRPRF

Display user profile

Steria Limited / 2 May 2013

Page 11 of 13 / Version 1.0

ENDDBG

End Debug

ENDJRN

End journal

EDTLIBL

Allows addition and deletion of libraries to and from list

OUTQ

Must add PRTRNG to library list before using this


command

OUTQ(PRINTER)

Mark object in spool file with 2 for change.

PRTRNG

Print a range of pages from a member in the specified

PRTPFDDTA

Print PFD Data

RMVDIR

Remove directory on IFS

RMVBKP

Remove a break point in debug

RMVLICKEY

Remove license key information

RMVLNK

Delete object from IFS

RMVJRNCHG

Remove journaled changes

RSTLICPGM

Restore licensed program

RTVJOBA

Retrieve job attributes

RUNQRY
QRYFILE(LIB/FILE)

Run query on a file with no parameters

SAVLIB

Save library

SAVLICPGM

Save licensed program

SAVRSTLIB

Save restore library

SNDMSG

Send message to a message queue

SNDPGMMSG

Send message to program's message queue

STRAFPU

Start AFP Utilities for iSeries

STRDBG

Start Debug

STRDBMON

Start Database Monitor - display access path

STRDBU

Start DBU (Database Utility) Look at and make changes


to the database

STRDFU

Start DFU (Data File Utility) Many of the same


functions of DBU

STRJRN

Start journal

STROVLU

Start Overlay Utility

STRPDM

Start PDM

STRPFU

Start Print Format Utility

STRSQL

Start SQL interactive

WRKACTJOB

Displays all active jobs (Select order by column


(job, user, %CPU)

WRKJOBSCDE

Look at scheduled jobs

Steria Limited / 2 May 2013

Page 12 of 13 / Version 1.0

WRKLICINF

Work with license information

WRKOBJ

Work with an object. Use *ALLUSR in qualified name to skip Q l

WRKOUTQ

Displays members in specified OUTQ

WRKMSGF QCPFMSG

Displays contents of MONMSG file

WRKNETF

Work with users network files

WRKOBJLCK

Work with Object Locks

WRKSBMJOB *JOB

Displays my jobs for the current session

WRKSPLF

Displays spool files

WRKSYSACT

Display System Activity - Client activity

WRKSYSSTS

Display System Status

WRKUSRJOB

Displays list of my jobs to work with

WRKUSRPRF

Can work with specified user's profile

Steria Limited / 2 May 2013

(in all output queues)

Page 13 of 13 / Version 1.0

Potrebbero piacerti anche