0% found this document useful (0 votes)
96 views60 pages

RPG Srinivas

1. The document describes various array and data structure concepts in RPG including: normal arrays, compile time arrays, pre-runtime arrays, runtime arrays, and multi-occurrence data structures. It also covers various array operations like XFOOT, LOOKUP, MOVEA, and SORTARRAY. 2. Examples are provided to demonstrate passing array parameters between programs and using data areas to store and retrieve data. 3. Different types of data structures are illustrated including general, multi-occurrence, and those using external files with record formats.

Uploaded by

Saiprasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views60 pages

RPG Srinivas

1. The document describes various array and data structure concepts in RPG including: normal arrays, compile time arrays, pre-runtime arrays, runtime arrays, and multi-occurrence data structures. It also covers various array operations like XFOOT, LOOKUP, MOVEA, and SORTARRAY. 2. Examples are provided to demonstrate passing array parameters between programs and using data areas to store and retrieve data. 3. Different types of data structures are illustrated including general, multi-occurrence, and those using external files with record formats.

Uploaded by

Saiprasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 60

RPG (REPORT PROGRAMMING GENETOR):

ARRAYS:
1. Normal Array:
*************** Beginning of data ********************************
Darry
s
3s 0 dim(5)
Di
s
3s 0 inz(1)
C
doW
I<=5
C
eval
arry(i)=i
C
ARRY(I)
DSPLY
C
eval
i=i+1
C
enddo
C
return
****************** End of data ***********************************
OUTPUT:
DSPLY 1
DSPLY 2
DSPLY 3
DSPLY 4
2. Compile time Array:
*************** Beginning of data *************************************
Darry
s
3a dim(3) ctdata perrcd(2)
Di
s
3s 0 inz(1)
C
dow
i<=3
C
arry(i)
dsply
C
eval
i=i+1
C
enddo
C
return
**ctdata arry
janfeb
mar
****************** End of data ****************************************

OUTPUT
DSPLY jan
DSPLY feb
DSPLY mar
3. Pre Runtime Array:
Pre runtime array using a physical file:
Physical file(pf) :
*************** Beginning of data ******
A
R FORMAT
A
EMPNO
5S 0
A
EMPNAME
5A
A
EMPSAL
5S 0
A
K EMPSAL
****************** End of data *********
OUTPUT:
EMPNO
000001
000002
000003
000004
000005
000006
000007

EMPNAME
24,543 gopi
5,616 rama
1,818 kasuj
603 kasub
202 kasua
203 kasua
203 kasua

Pre Run Time Array program:


*************** Beginning of data *****************************
Fpf
it f 10
disk
Darry
s
10a dim(7) fromfile(pf)
Di
s
5s 0 inz(1)
C
dow
i<=7
C
arry(i)
dsply
C
eval
i=i+1
C
enddo
C
return
2

****************** End of data ********************************

OUTPUT:
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY

24543 gopi
05616 rama
01818 kasuj
00603 kasub
00202 kasua
00203 kasua
00 203 kasua
4. Runtime Array:

*************** Beginning of data *********************


Darry
s
3s 0 dim(5)
Di
s
5s 0 inz(1)
C
dow
i<=5
C
eval
arry(i)=i
C
arry(i)
dsply
C
eval
i=i+1
C
enddo
C
return
****************** End of data ************************
OUTPUT:
DSPLY 1
DSPLY 2
DSPLY 3
DSPLY 4
DSPLY 5
5.Program for XFOOT Op code (compile time) :
*************** Beginning of data *********************************************
0001.00
Darr
s
2s 0 dim(10) ctdata perrcd(10)
0002.00
Dres
s
3s 0 inz(0)
0003.00
Di
s
3s 0 inz(1)
0004.00
C
xfoot
arr
res
0005.00
C
dow
i<=10
0006.00
c
arr(i)
dsply
3

0007.00
C
eval
i=i+1
0008.00
C
enddo
0009.00
C
res
dsply
0010.00
C
return
0011.00 ** ctdata
0012.00 1234567894
****************** End of data ************************************************

OUTPUT:
DSPLY 12
DSPLY 34
DSPLY 56
DSPLY 78
DSPLY 94
DSPLY 0
DSPLY 0
DSPLY 0
DSPLY 0
DSPLY 0
DSPLY 274

6. Program for XFOOT Op code (Runtime time) :


************* Beginning of data *******************************************
Darry
s
3s 0 dim(5)
Darry1
s
3s 0 dim(4)
Di
s
3s 0 inz(1)
Dfld
s
4s 0
C
dow
i<=5
C
eval
arry(i)=i
C
arry(i)
dsply
C
eval
i=i+1
C
enddo
C
eval
fld=%xfoot(arry)
C
fld
dsply
C
EVAL
I=1
C
dow
I<=4
C
EVAL
ARRY1(I)=I
C
ARRY1(I)
DSPLY
4

C
EVAL
I=I+1
C
ENDDO
C
EVAL
FLD=%XFOOT(ARRY1)
C
FLD
DSPLY
C
EVAL
I=1
C
dow
I<=4
C
EVAL
ARRY1(I)=I
C
ARRY1(I)
DSPLY
C
EVAL
I=I+1
C
ENDDO
C
EVAL
FLD=%XFOOT(ARRY1)
C
FLD
DSPLY
C
return
****************** End of data *********************
OUTPUT:
DSPLY 1
DSPLY 2
DSPLY 3
DSPLY 4
DSPLY 5
DSPLY 15
DSPLY 1
DSPLY 2
DSPLY 3
DSPLY 4
DSPLY 10
7. Program for LOOKUP Op code (Compile time) :
*************** Beginning of data
************************************************
0001.00
darr
s
3s 0 dim(10) ctdata perrcd(1)
0001.01
Di
s
3s 0 inz(1)
0005.00
C
dow
i<=10
0006.00
C* arr(i)
dsply
0007.00
C
eval
i=i+1
0009.01
C
enddo
0009.03
C
EVAL
I=1
0009.04
C
IF
I<=10
0009.05
C
200
LOOKUP arr(i)
20
0009.06
C
IF
*IN20=*ON
0009.07
C
'FOUND'
DSPLY
5

0009.08
C
ELSE
0009.09
C
'NOTFOUND' DSPLY
0009.10
C
ENDIF
0009.11
C
ENDIF
0010.00
C
return
0011.00 ** ctdata
0012.00 100
0013.00 200
0014.00 300
0015.00 400
0016.00 500
0017.00 600
0018.00 700
0019.00 800
0020.00 900
0021.00 950
****************** End of data **********************************************
OUTPUT
DSPLY FOUND

8. Program for MOVEA Op code (Compile time):


*************** Beginning of data
*********************************************
0001.00
DARR
S
3S 0 DIM(5) ctdata perrcd(1)
0003.00
DARR1
S
3s 0 DIM(5) ctdata perrcd(1)
0003.01
DI
S
3S 0 INZ(1)
0005.00
C
movea
arr
arr1
0006.00
C
dow
i<=5
0007.00
C
arr(i)
dsply
0008.00
C
arr1(i)
dsply
0009.00
C
eval
i=I+1
0010.00
C
enddo
0011.00
C
return
0012.00 ** ctdata arr
0013.00 101
0014.00 102
0015.00 103
0016.00 104
0017.00 105
0018.00 ** ctdata arr1
6

0019.00 111
0020.00 222
0021.00 333
0022.00 444
0023.00 555
****************** End of data
*********************************************
OUTPUT
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY

101
101
102
102
103
103
104
104
105
105

9. Program for MOVEA Op code (Run Time)


*************** Beginning of data **********************************
Darry1
s
3s 0 dim(5)
Darry2
s
3s 0 dim(5)
Di
s
2s 0 inz(1)
Dj
s
2s 0 inz(1)
C
do
5
C
eval
arry1(i)=i
C
EVAL
I=I+1
C
ENDDO
C
do
3
C
eval
arry2(j)=j
C
eval
j=j+1
C
enddo
C
movea
arry1
arry2
C
FOR
I=1 TO 5 BY 1
C
ARRY2(I)
DSPLY
C
ENDFOR
C
return
C
EVAL
*INLR =*ON
****************** End of data *************************************
7

OUTPUT
OUTPUT:
DSPLY 1
DSPLY 2
DSPLY 3
DSPLY 4
DSPLY 5
10. Program for SORTARRAY Op code :
*************** Beginning of data **********************
Darry1
s
4s 0 dim(6)
Darry2
s
4s 0 dim(5)
Darry3
s
4s 0 dim(4)
Di
s
4s 0 inz(1)
C
dow
i<=6
C
eval
arry1(i)=i
C
arry1(i)
dsply
C
eval
i=i+1
C
enddo
C
sorta
arry2
C
eval
i=1
C
dow
i<=4
C
eval
arry2(i)=i
C
arry2(i)
dsply
C
eval
i=i+1
C
enddo
C
sorta
arry3
C
eval
i=1
C
dow
i<=3
C
eval
arry3(i)=i
C
arry3(i)
dsply
C
eval
i=i+1
C
enddo
C
return
****************** End of data ****************

OUTPUT:
DSPLY

1
8

DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY

2
3
4
5
6
1
2
3
4
1
2
3

11. Pass the Parameters Array to Array


*************** Beginning of data ****************************
DA
S
3S 0
DB
S
3S 0
DC
S
3S 0
C
*ENTRY
PLIST
C
PARM
A
C
PARM
B
C
PARM
C
C
EVAL
C=A+B
C
C
DSPLY
C
RETURN
DA
S
3S 0 INZ(11)
DB
S
3S 0 INZ(10)
DC
S
3S 0
C
CALL
'ARRY16'
C
PARM
A
C
PARM
B
C
PARM
C
C
C
DSPLY
C
RETURN
C
EVAL
*INLR = *ON
C
RETURN
****************** End of data *******************************
OUTPUT:
DSPLY 21
9

DATASTRUCTURES
1. General Data structure:
*************** Beginning of data
*****************************************
0001.00 DSURYA
DS
0002.00 DNAME
25A INZ('PADALASURYANARAYANA')
0003.00 DFNAME
1
6
0004.00 DMNAME
7
12
0005.00 DLNAME
13
21
0006.00 C
NAME
DSPLY
0007.00 C
FNAME
DSPLY
0008.00 C
MNAME
DSPLY
0009.00 C
LNAME
DSPLY
0010.00 C
RETURN
****************** End of data
********************************************
OUTPUT
DSPLY
DSPLY
DSPLY
DSPLY

PADALASURYANARAYANA
PADALA
SURYAN
ARAYANA

2. Multioccurance Data Structure:


*************** Beginning of data **********************************
0001.00 Dmyds
ds
occurs(2)
0002.00 Dempno
3s 0
0003.00 Dempname
10a
0004.00 Dempsal
5s 0
0005.00 C
1
occur
myds
0006.00 C
eval
empno=101
0007.00 c
eval
empname='aa'
0008.00 c
eval
empsal=1000
0009.00 C
2
occur
myds
10

0010.00 C
eval
empno=102
0011.00 c
eval
empname='bb'
0012.00 c
eval
empsal=2000
0013.00 C
1
occur
myds
0014.00 c
empno
dsply
0015.00 c
empname
dsply
0016.00 c
empsal
dsply
0017.00 C
2
occur
myds
0018.00 c
empno
dsply
0019.00 c
empname
dsply
0020.00 c
empsal
dsply
0021.00 c
return
****************** End of data ************************************
OUTPUT
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY

101
aa
1000
102
bb
2000

2(A). Multioccurance Data Structure with file:


Physical file:
*************** Beginning of data **********************************
0001.00
A
R RECFMT1
0002.00
A
STUNUM
3S 0
0003.00
A
STUNAME
5A
0004.00
A
STUBRNCH
5S
0005.00
A
K STUNUM
****************** End of data *************************************
Output:
STUNUM STUNAME STUBRNCH
000001 101 aaa
111
000002 102 bbb
222
000003 103 ccc
333
000004 104 ddd
444
****** ******** End of report ********
11

RPG Program for Multioccurance Data Structure


*************** Beginning of data
********************************************
0001.00 Fexmds1 if e
disk
0002.00 Dds
ds
20 occurs(4)
0003.00 Dstunum
3s 0
0004.00 Dstuname
5a
0005.00 Dstubrnch
5s 0
0006.00 Di
1s 0
0007.00 C
eval
i=1
0008.00 C
i
do
4
0009.00 C
i
occur
ds
20
0010.00 C
read
recfmt1
0011.00 C
stunum
dsply
0012.00 C
stuname
dsply
0013.00 C
stubrnch
dsply
0014.00 C
if
*in20=*on
0015.00 C
'error'
dsply
0016.00 C
endif
0017.00 C
enddo
0018.00 C
eval
*inlr=*on
0019.00 C
return
****************** End of data ********************************
Output
DSPLY 101
DSPLY aaa
DSPLY 111
DSPLY 102
DSPLY bbb
DSPLY 222
DSPLY 103
DSPLY ccc
DSPLY 333
DSPLY 104
DSPLY ddd
DSPLY 444
3. DATA AREA DATA STRUCTURE:
Char Data Area
12

Data area . . . . . . . : GOPI1


Library . . . . . . . :
GOPIBALLA1
Type . . . . . . . . . : *CHAR
Length . . . . . . . . : 9
Text . . . . . . . . . :
'GOPIBAL36'
*************** Beginning of data ***********************
Dgopi
s
9a dtaara(gopi1)
C
*lock
in
gopi
C
gopi
dsply
C
out
gopi
C
return
****************** End of data **************************
OUTPUT:
DSPLY GOPIBAL36
Dec Data Area
Data area . . . . . . . : GOPI2
Library . . . . . . . :
GOPIBALLA1
Type . . . . . . . . . : *DEC
Length . . . . . . . . : 5 0
Text . . . . . . . . . :
Value . . . . . . . . . : 12346

*************** Beginning of data ******************


Dfiled
s
5 0 dtaara(gopi2)
C
*lock
in
filed
C
eval
filed=filed+1
C
filed
dsply
C
out
filed
C
return
****************** End of data *********************
OUTPUT:
DSPLY 12347
4. FILEINFORMATION DATASTRUCTURE:

13

*************** Beginning of data


******************************************
0001.00 Fexmds1 if e
disk infds(myds)
0002.00 Dmyds
ds
0003.00 Dfile
*file
0004.00 Dstatus
*status
0005.00 Droutine
*routine
0006.00 drecord
*record
0007.00 dopcode
*opcode
0008.00 C
file
dsply
0009.00 C
status
dsply
0010.00 C
routine
dsply
0011.00 C
record
dsply
0012.00 C
opcode
dsply
0013.00 C
eval
*inlr=*on
0014.00 c
return
****************** End of data
*********************************************
OUTPUT:
DSPLY PF
DSPLY
0
DSPLY OPEN I
DSPLY *INIT
DSPLY
5. PROGRAM STATUS DS
*************** Beginning of data **********************
Dmypsds
sds
Dproc
*proc
Dstatus
*status
Dparms
*parms
Droutine
*routine
C
proc
dsply
C
status
dsply
C
parms
dsply
C
routine
dsply
C
return
****************** End of data ***********************
OUTPUT:
14

DSPLY DS7
DSPLY
0
DSPLY 0
DSPLY *DETC

6. EXTERNAL DS
First create a pf.
*************** Beginning of data ******************
A
R FORMAT
A
EMPNO
5S 0
A
EMPNAME
5A
A
EMPSAL
5S 0
A
K EMPSAL
****************** End of data *********************

OUTPUT
EMPNO EMPNAME EMPSAL
000001
2 BossB
102
000002
3 naga
103
000003
4 girl
104
000004
5 male
105
000005
6 naga
106
000006
7 moss
107
000007
8 face
108
000008
9 game
109
000009
10 vasu
110
000010
11 samba
111
000011 122 A
112
000012
13 B
113
000013
0
0
000014 101
2
000015
0
0
000016 101
2
000017
0
0
Rpg program for External DS:
*************** Beginning of data ************************************
FPF10
IF E
DISK
DMYDS
E DS
EXTNAME(PF) prefix(empnumber)
15

C
EVAL
EMPNO=101
C
EVAL
EMPNAME='GOPI'
C
EMPNO
DSPLY
C
EMPNAME
DSPLY
C
SETON
LR
C
RETURN
****************** End of data ***************************************
OUTPUT:
DSPLY 101
DSPLY GOPI

FILE OPERATIONS:
Read Operation: Reading data from a PF
PF:
*************** Beginning of data *************
A
R FORMAT
A
EMPNO
5S 0
A
EMPNAME
5A
A
EMPSAL
5S 0
A
K EMPSAL
****************** End of data ****************
OUTPUT:
EMPNO
000001 24,543
000002 5,616
000003 1,818
000004 603
000005 202
000006 203
000007 203

EMPNAME
gopi
rama
kasuj
kasub
kasua
kasua
kasua

Rpg program
*************** Beginning of data ***************************************
Fpf
if e
disk
C
dow
*in03=*off
C
read
format
03
16

C
eval
empno=empno
C
eval
empname=empname
C
empname
dsply
C
empno
dsply
C
enddo
C
seton
lr
C
return
****************** End of data ******************************************
OUTPUT:
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY

gopi
24543
rama
5616
kasuj
1818
kasub
603
kasua
202
kasua
203
kasua
203
KASUA
203

Write Operation: Writing data into a PF


*************** Beginning of data ********************************
Fpf
uf a e
k disk
C
eval
empno=203
C
eval
empname='kasua'
C
empno
dsply
C
empname
dsply
C
write
format
C
return
****************** End of data ***********************************
17

OUTPUT:
DSPLY 203
DSPLY kasua
The above data automatically written into PF.
Delete Operation: Deleting data from a PF
*************** Beginning of data ****************************************
Fpf
uf e
k disk
C
read
format
20
C
DOW
*IN20=*OFF
C
eval
empno=202
C
delete format
C
empno
dsply
C
ENDDO
C
return
****************** End of data *******************************************
OUTPUT:
DSPLY

202

The above data automatically deleted from PF.

Update Operation: Updating data into a PF


*************** Beginning of data ****************************************
Fpf
uf a e
k disk
C
read
format
20
C
eval
empno=208
C
eval
empno=empno + empno * 2
C
update format
C*
read
format
C
empno
dsply
C
seton
lr
C
return
****************** End of data *******************************************
OUTPUT:
DSPLY

624
18

Update Loval Using Setll:


PF:
*************** Beginning of data *************
A
R FORMAT
A
EMPNO
5S 0
A
EMPNAME
5A
A
EMPSAL
5S 0
A
K EMPSAL
****************** End of data ****************
OUTPUT:
EMPNO EMPNAME
000001 24,543 gopi
000002 5,616 rama
000003 1,818 kasuj
000004 603 kasub
000005 202 kasua
000006 203 kasua
000007 203 kasua

Rpg Program:
*************** Beginning of data **************************
Fpf
uf a e
k disk
C
*loval
setll
format
C
read
format
C
eval
empno=empno + empno * 2
C
update format
C
empno
dsply
C
return
****************** End of data *****************************
OUTPUT:
DSPLY 1809
SETGT Opcode:
PF:
*************** Beginning of data *************
A
R FORMAT
19

A
EMPNO
5S 0
A
EMPNAME
5A
A
EMPSAL
5S 0
A
K EMPSAL
****************** End of data ****************
OUTPUT:
EMPNO EMPNAME
000001 24,543 gopi
000002 5,616 rama
000003 1,818 kasuj
000004 603 kasub
000005 202 kasua
000006 203 kasua
000007 203 kasua
Rpg Program:
*************** Beginning of data **************************************
Fpf
uf a e
k disk
C
EVAL
EMPNO=624
C
EMPNO
setgt
format
20
C
read
format
C
EMPNAME
DSPLY
C
return
****************** End of data *****************************************
OUTPUT:
DSPLY KASUJ

CHAIN Opcode:
PF
*************** Beginning of data *********************
A
R FORMAT
A
EMPNO
5S 0
A
EMPNAME
5A
A
EMPSAL
5S 0
A
K EMPNO
20

****************** End of data ************************


OUTPUT:
EMPNO EMPNAME EMPSAL
101 GOPI
1
102 NAGA
2
Rpg Program:
*************** Beginning of data ********************************************
Fpf11
uf a e
k disk
C
eval
empno=101
C
empno
chain
format
20
C
if
*in20=*on
C
'not found' dsply
C
else
C
empname
dsply
C
empno
dsply
C
empsal
dsply
C
endif
C
seton
lr
C
return
****************** End of data ***********************************************
OUTPUT:
DSPLY GOPI
DSPLY 101
DSPLY
1

READP OPcode:
PF:
*************** Beginning of data ************************
A
R FORMAT
A
EMPNO
5S 0
A
EMPNAME
5A
A
EMPSAL
5S 0
A
K EMPNO
****************** End of data ***************************
OUTPUT:
21

EMPNO EMPNAME EMPSAL


000001 101 GOPI
1
000002 102 NAGA
2
Rpg Program:
*************** Beginning of data ***********************************************
FPF11
IF E
K DISK
1
C
EVAL
EMPNO=102
1
C
empno
sETll
FORMAT
40
1
C
IF
*IN40=*On
1
C
READP
FORMAT
1
C
EMPNO
DSPLY
1
C
EMPNAME
DSPLY
1
C
EMPSAL
DSPLY
1
c
else
1
c
'notfound' dsply
1
C
ENDIF
1
C
EVAL
*INLR=*ON
1
****************** End of data **************************************************
OUTPUT:
DSPLY 101
DSPLY GOPI
DSPLY
1
READE Opcode:
PF:
*************** Beginning of data ************************
A
R FORMAT
A
EMPNO
5S 0
A
EMPNAME
5A
A
EMPSAL
5S 0
A
K EMPNO
****************** End of data ***************************
OUTPUT:
EMPNO EMPNAME EMPSAL
000001 101 GOPI
1
000002 102 NAGA
2
22

Rpg Program:
*************** Beginning of data **********************************************
FPF11
IF E
K DISK
C
EVAL
EMPNO=102
C
empno
sETll
FORMAT
40
C
IF
*IN40=*On
C
READE
FORMAT
C
EMPNO
DSPLY
C
EMPNAME
DSPLY
C
EMPSAL
DSPLY
c
else
c
'notfound' dsply
C
ENDIF
C
EVAL
*INLR=*ON
****************** End of data *************************************************
OUTPUT:
DSPLY 102
DSPLY NAGA
DSPLY
2

BUILT IN FUNCTIONS:
1.%ABS
*************** Beginning of data ******************************************
0001.00 *SYNTAX IS %ABS{NUMERIC EXPRESSION}
0002.00 *
0003.00 DPI
C
CONST(3.1432)
0004.00 DRADIOUS
S
7P 2 INZ(-5.2)
0005.00 DAREA
S
7P 2 INZ(0.0)
0006.00 C
EVAL
AREA=PI*%ABS(RADIOUS)**2
0007.00 C
AREA
DSPLY
0008.00 C
SETON
LR
****************** End of data *********************************************
OUTPUT
DSPLY

8499
23

2. %ABS
*************** Beginning of data ***************************************
001.00 *SYNTAX IS %ABS{NUMERIC EXPRESSION}
002.00 *
003.00 Df8
S
8F INZ(-1)
004.00 DI10
S
10I 0 INZ(-123)
005.00 DP7
S
7P 3 INZ(-1234.567)
006.00 C
EVAL
f8=%ABS(f8)
007.00 C
f8
DSPLY
008.00 C
EVAL
I10=%ABS(I10-321)
009.00 C
I10
DSPLY
010.00 C
EVAL
P7=%ABS(P7)
011.00 C
P7
DSPLY
012.00 C
SETON
LR
****************** End of data ******************************************
OUTPUT:
DSPLY +1.000000000000000E+000
DSPLY
444
DSPLY 1234567
3. %CHAR
*************** Beginning of data ****************************************
0001.00 *SYNTAX IS %CHAR{EXPRESSION{:FORMAT}}
0002.00 DNUM1
S
5I 0 INZ(504)
0003.00 DSTR1
C
CONST('PAVAN KALYAN ID: ')
0004.00 DRES
S
20A
0005.00 C
EVAL
RES=STR1+%CHAR(NUM1)
0006.00 C
RES
DSPLY
0007.00 C
SETON
LR
****************** End of data *******************************************
OUTPUT
DSPLY PAVAN KALYAN ID: 50
4. %CHECK
*************** Beginning of data ********************************************
0001.00 * SYNTAX : %CHECK(COMPARATOR:BASE{:START})
0002.00 *
0003.00 DSTR1
C
CONST('PAVAN KALYAN ID: ')
0004.00 DRES
S
3I 0 INZ(0)
0005.00 C
EVAL
RES= %CHECK('I':STR1:9)
24

0006.00 C
RES
DSPLY
0007.00 C
SETON
LR
****************** End of data ***********************************************
OUTPUT
DSPLY

5. %CHECK WITH FOUND


*************** Beginning of data *****************************************
0001.00 *
0002.00 *
0003.00 DDIGITS
C
'0123456789'
0004.00 C
Z-ADD
0
N
10
0005.00 C
MOVE
'$1200'
SALARY
6
0006.00 C
DIGITS
CHECK
SALARY:2
N
0007.00 C
IF
%FOUND
0008.00 C
N
DSPLY
0009.00 C
ENDIF
0010.00 C
SETON
LR
****************** End of data ********************************************
OUTPUT
DSPLY 2
6. %CHECK WITH NOT FOUND
*************** Beginning of data ******************************************
0001.00 DDIGITS
C
'0123456789'
0002.00 C
Z-ADD
0
N
10
0003.00 C
MOVE
'$1200'
SALARY
6
0004.00 C
DIGITS
CHECK
SALARY:3
N
0005.00 C
IF
%FOUND
0006.00 C
N
DSPLY
0007.00 C
ELSE
0008.00 C
'NOT FOUND' DSPLY
0009.00 C
ENDIF
0010.00 C
SETON
LR
****************** End of data *********************************************

OUTPUT
25

DSPLY NOT FOUND


7. %DATE
*************** Beginning of data *************************************
0001.00 *SYNTAX IS %DATE{EXPRESSION{:DATE FORMAT}}
0002.00 *
0003.00 DSTR
C
CONST('062811')
0004.00 DDATE
S
D
0005.00 C
EVAL
DATE=%DATE(STR:*MDY0)
0006.00 C
DATE
DSPLY
0007.00 C
SETON
LR
****************** End of data ****************************************

OUTPUT
DSPLY 2011-06-28
8. %DATE:
*************** Beginning of data **********************************
0001.00 *SYNTAX IS %DATE{EXPRESSION{:DATE FORMAT}}
0002.00 *
0003.00 HDATFMT(*MDY)
0004.00 DSTR
C
CONST('060411')
0005.00 DDATE
S
D
0006.00 C
EVAL
DATE=%DATE(STR:*YMD0)
0007.00 C
DATE
DSPLY
0008.00 C
SETON
LR
****************** End of data *************************************
OUTPUT
DSPLY 04/11/06
9. %DAYS
*************** Beginning of data *****************************************
0001.00 *SYNTAX IS %DAYS(NUMBER)
0002.00 *
0003.00 DSTR
C
CONST('062811')
0004.00 DDATE
S
D
26

0005.00 C
EVAL
DATE=%DATE(STR:*MDY0)
0006.00 C
DATE
DSPLY
0007.00 C
EVAL
DATE=DATE+%DAYS(10)
0008.00 C
DATE
DSPLY
0009.00 C
SETON
LR
****************** End of data ********************************************
OUTPUT
DSPLY 2011-06-28
DSPLY 2011-07-08

10. %DECPOS
*************** Beginning of data **************************************
0001.00 *SYNTAX IS %DEC(NUMERIC EXPRESSION}
0002.00 *
0003.00 DS9
S
9S 5 INZ(23.73442)
0004.00 DP7
S
7P 3 INZ(8236.567)
0005.00 DRES1
S
15P 5
0006.00 DRES2
S
15P 5
0007.00 DRES3
S
15P 5
0008.00 C
EVAL
RES1=%DECPOS(P7)
0009.00 C
RES1
DSPLY
0010.00 C
EVAL
RES2=%DECPOS(S9)
0011.00 C
RES2
DSPLY
0012.00 C
EVAL
RES3=%DECPOS(P7*S9)
0013.00 C
RES3
DSPLY
0014.00 C
SETON
LR
****************** End of data *****************************************
OUTPUT
DSPLY
DSPLY
DSPLY

300000
500000
800000

11. %DECPOS
*************** Beginning of data **************************************
0001.00 *SYNTAX IS %DEC(NUMERIC EXPRESSION{:PRECISION:DECIMAL PLACES})
0002.00 *SYNTAX IS %DECH(NUMERIC EXPRESSION{:PRECISION:DECIMAL
PLACES})
27

0003.00 *
0004.00 DS9
S
9S 5 INZ(73.73442)
0005.00 Df8
S
8f INZ(123.456789)
0006.00 DP7
S
7P 3 INZ(1234.567)
0007.00 DRES1
S
15P 5
0008.00 DRES2
S
15P 5
0009.00 DRES3
S
15P 5
0010.00 C
EVAL
RES1=%DEC(P7)+0.011
0011.00 C
RES1
DSPLY
0012.00 C
EVAL
RES2=%DEC(S9:5:0)
0013.00 C
RES2
DSPLY
0014.00 C
EVAL
RES3=%DECH(f8:5:2)
0015.00 C
RES3
DSPLY
0016.00 C
SETON
LR
****************** End of data *****************************************
OUTPUT
DSPLY
DSPLY
DSPLY

123457800
7300000
12346000

12.%EDITC
*************** Beginning of data ******************************************
0001.00 * %EDITC(NUMERIC:EDITCODE)
0002.00 *
0003.00 DMSG
S
45A
0004.00 DSALARY
S
9P 2 INZ(100)
0005.00 C
EVAL
MSG='L'+%TRIM(%EDITC(SALARY*12:'A':*CURSYM))
0006.00
0007.00 C
MSG
DSPLY
0008.00 C
EVAL
MSG='SL'+%TRIM(%EDITC(SALARY*12:'A'))
0009.00 C
MSG
DSPLY
0010.00 C
EVAL
MSG='$'+%TRIM(%EDITC(SALARY*12:'B':*ASTFILL))
0011.00 C
MSG
DSPLY
0012.00 C
EVAL
MSG='SL'+%TRIM(%EDITC(*DATE:'Y'))
0013.00 C
MSG
DSPLY
0014.00 C
SETON
LR
****************** End of data *********************************************
OUTPUT
DSPLY L$1,200.00
28

DSPLY SL1,200.00
DSPLY $******1,200.00
DSPLY SL9/27/2011
13. %EDITC
*************** Beginning of data ********************************************
0001.00 * SYNTAX %EDITW(NUMERIC:EDITWORD)
0002.00 *
0003.00 DAMOUNT
S
45A
0004.00 DSALARY
S
9P 2 INZ(2451.53)
0005.00 DEDITWD
C
'$ ,
, *DOLLARASAND ANDCENTS'
0006.00 C
EVAL
AMOUNT='L'+%EDITW(SALARY*12:EDITWD)
0007.00 C
AMOUNT
DSPLY
0008.00 C
SETON
LR
****************** End of data ***********************************************

OUTPUT
DSPLY L$*****29,4183DOLLARASAND6ANDCENTS
14. %ELEM
*************** Beginning of data *********************************************
0001.00 *
%ELEM(TABLE_NAME)
0002.00 *
%ELEM(ARRAY_NAME)
0003.00 *
0004.00 DARRLD
S
20 DIM(10)
0005.00 DTABLE
S
20 DIM(20) CTDATA
0006.00 DNUM
S
5P 0
0007.00 DLIKE_ARRAY
S
LIKE(ARRLD)DIM(%ELEM(ARRLD))
0008.00 DARRAY_DIMS
C
CONST(%ELEM(ARRLD))
0009.00 C
EVAL
NUM=%ELEM(ARRLD)
0010.00 C
NUM
DSPLY
0011.00 C
EVAL
NUM=%ELEM(TABLE)
0012.00 C
NUM
DSPLY
0013.00 C
EVAL
*INLR=*ON
****************** End of data ************************************************
OUTPUT
DSPLY
DSPLY

10
20
29

15. %FLOAT
*************** Beginning of data ******************************************
0001.00 * %FLOAT(NUMERIC EXPRESSION)
0002.00 *
0003.00 DP1
S
15P 0 INZ(1)
0004.00 DP2
S
25P13 INZ(3)
0005.00 DRES1
S
15P 5
0006.00 DRES2
S
15P 5
0007.00 DRES3
S
15P 5
0008.00 C
EVAL
RES1=P1/P2
0009.00 C
RES1
DSPLY
0010.00 C
EVAL
RES2=%FLOAT(P1)/P2
0011.00 C
RES2
DSPLY
0012.00 C
EVAL
RES3=%FLOAT(P1/P2)
0013.00 C
RES3
DSPLY
0014.00 C
SETON
LR
****************** End of data *********************************************
OUTPUT
DSPLY
DSPLY
DSPLY

33333
33333
33333

16. %INT
*************** Beginning of data **********************************
0001.00 * %INT(NUMERIC EXPRESSION)
0002.00 * %INTH(NUMERIC EXPRESSION)
0003.00 *
0004.00 DP6
S
5P 0
0005.00 DP7
S
7P 3 INZ(1234.567)
0006.00 DS9
S
9S 5 INZ(73.73442)
0007.00 Df8
S
8F INZ(123.789)
0008.00 DRES1
S
15P 5
0009.00 DRES2
S
15P 5
0010.00 DRES3
S
15P 5
0011.00 Darray
S
1a dim(200)
0012.00 Da
S
1a
0013.00 C
EVAL
p6=%int(p7)
0014.00 C
p6
DSPLY
0015.00 C
EVAL
RES1=%int(p7)+0.011
0016.00 C
RES1
DSPLY
30

0017.00 C
EVAL
RES2=%int(s9)
0018.00 C
RES2
DSPLY
0019.00 C
EVAL
RES3=%int(f8)
0020.00 C
RES3
DSPLY
0021.00 C
EVAL
a=array(%inth(f8))
0022.00 C
a
DSPLY
0023.00 C
SETON
LR
****************** End of data ****************************************
OUTPUT
DSPLY 1234
DSPLY
123401100
DSPLY
7300000
DSPLY
12300000
DSPLY
17. %LEN
*************** Beginning of data ********************************************
0001.00 * %LEN(EXPRESSSION)
0002.00 *
0003.00 DNUM1
S
7P 2
0004.00 DNUM2
S
5S 1
0005.00 DNUM3
S
5I 0 INZ(10)
0006.00 DRES
S
5I 0 INZ(0)
0007.00 C
EVAL
RES=%LEN(NUM1)
0008.00 C
RES
DSPLY
0009.00 C
EVAL
RES=%DECPOS(NUM2)
0010.00 C
RES
DSPLY
0011.00 C
EVAL
RES=%LEN(NUM1*NUM2)
0012.00 C
RES
DSPLY
0013.00 C
SETON
LR
****************** End of data ***********************************************
OUTPUT
DSPLY
DSPLY
DSPLY

7
1
12

18. %LEN
*************** Beginning of data *******************************************
0001.00 * %LEN(EXPRESSSION)
31

0002.00 *
0003.00 DNUM1
S
7P 2
0004.00 DNUM2
S
5S 1
0005.00 DNUM3
S
5I 0 INZ(2)
0006.00 DCHR1
S
10A INZ('TORONTO ')
0007.00 DCHR2
S
10A INZ('MUNICH ')
0008.00 D*TR
S
*
0009.00 C
EVAL
NUM1=%LEN(NUM1)
0010.00 C
NUM1
DSPLY
0011.00 C
EVAL
NUM1=%DECPOS(NUM2)
0012.00 C
NUM1
DSPLY
0013.00 C
EVAL
NUM1=%LEN(NUM1*NUM2)
0014.00 C
NUM1
DSPLY
0015.00 C
EVAL
NUM1=%DECPOS(NUM1*NUM2)
0016.00 C
NUM1
DSPLY
0017.00 C*
0018.00 C*
0019.00 C
EVAL
NUM1=%LEN(CHR1)
0020.00 C
NUM1
DSPLY
0021.00 C
EVAL
NUM1=%LEN(CHR1+CHR2)
0022.00 C
NUM1
DSPLY
0023.00 C
EVAL
NUM1=%LEN(%TRIM(CHR1))
0024.00 C
NUM1
DSPLY
0025.00 C
EVAL
NUM1=%LEN(%SUBST(CHR1:1:NUM3)+''+
%TRIM(CHR2))
0026.00 C
NUM1
DSPLY
0027.00 C
SETON
LR
****************** End of data ************************************************
OUTPUT
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY

700
100
1200
300
1000
2000
700
800

19. %MONTHS
*************** Beginning of data ***************************************
0001.00 *SYNTAX IS %MONTHS(NUMBER)
32

0002.00 *
0003.00 DSTR
C
CONST('062811')
0004.00 DDATE
S
D
0005.00 C
EVAL
DATE=%DATE(STR:*MDY0)
0006.00 C
DATE
DSPLY
0007.00 C
EVAL
DATE=DATE+%MONTHS(04)
0008.00 C
DATE
DSPLY
0009.00 C
SETON
LR
****************** End of data ******************************************

OUTPUT
DSPLY 2011-06-28
DSPLY 2011-10-28

20. %REM
*************** Beginning of data *******************************************
0001.00 *SYNTAX IS %REM(N:M)
0002.00 *
0003.00 DNUM1
S
3I 0 INZ(10)
0004.00 DNUM2
S
3I 0 INZ(20)
0005.00 DRES
S
3I 0 INZ(0)
0006.00 C
EVAL
RES=%DIV(NUM2:NUM1)
0007.00 C
RES
DSPLY
0008.00 C
EVAL
RES=%REM(NUM2:NUM1)
0009.00 C
RES
DSPLY
0010.00 C
SETON
LR
****************** End of data **********************************************

OUTPUT
DSPLY 2
DSPLY 0
21. % REPLACE
*************** Beginning of data *******************************************
0001.00 * %REPLACE(REPLACE STRING: SOURCE STRING{:START POS{:SOURCE
LENTH TO
33

0002.00 *
RREPLACE
0003.00 DSTR1
S
20A INZ('PAVAN KALYAN') VARYING
0004.00 DSTR2
S
20A VARYING
0005.00 DRES
S
5I 0 INZ(0)
0006.00 C
EVAL
STR1=STR1+','+'SSQUARE'
0007.00 C
STR1
DSPLY
0008.00 C
EVAL
STR2=%REPLACE('M.TECHE':STR1:12)
0009.00 C
STR2
DSPLY
0010.00 C
SETON
LR
****************** End of data **********************************************
OUTPUT
DSPLY PAVAN KALYAN,SSQUARE
DSPLY PAVAN KALYAM.TECHERE
22.RESERVED WORDS
*************** Beginning of data ***************************************
0001.00 *RESERVED WORDS
0002.00 *
0003.00 D
SDS
0004.00 DPGNAME
1
10
0005.00 DUNAME
254 263
0006.00 DDATE
270 275
0007.00 DTIME
282 287
0008.00 C
*DATE
DSPLY
0009.00 C
*MONTH
DSPLY
0010.00 C
*YEAR
DSPLY
0011.00 C
*DAY
DSPLY
0012.00 C
TIME
DSPLY
0013.00 C
PGNAME
DSPLY
0014.00 C
UNAME
DSPLY
0015.00 C
DATE
DSPLY
0016.00 C
TIME
DSPLY
0017.00 C
SETON
LR
****************** End of data ******************************************
OUTPUT
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY
DSPLY

9272011
9
2011
27
133802
RWORDS
34

DSPLY SYNI
DSPLY 092711
DSPLY 133802
23. %SCAN
*************** Beginning of data *******************************************
0001.00 * %SUBST(SEARCH ARGUMENT:SORCE STRING{:START})
0002.00 *
0003.00 DNAME
S
15A INZ('PAVAN KALYAN')
0004.00 DPOS
S
5U 0
0005.00 C
EVAL
POS=%SCAN('V':NAME)
0006.00 C
POS
DSPLY
0007.00 C
EVAL
POS=%SCAN('A':NAME)
0008.00 C
POS
DSPLY
0009.00 C
EVAL
POS=%SCAN('N':NAME:7)
0010.00 C
POS
DSPLY
0011.00 C
EVAL
POS=%SCAN('G':NAME)
0012.00 C
POS
DSPLY
0013.00 C
SETON
LR
****************** End of data **********************************************

OUTPUT
DSPLY
DSPLY
DSPLY
DSPLY

3
2
12
0

24. %SQRT
*************** Beginning of data **************************************
0001.00 *SYNTAX IS %SQRT{NUMERIC EXPRESSION}
0002.00 *
0003.00 DNUM1
S
10I 0
0004.00 DNUM2
S
9P 2
0005.00 DNUM3
S
4F
0006.00 C
EVAL
NUM1=%SQRT(239874)
0007.00 C
NUM1
DSPLY
0008.00 C
EVAL
NUM2=%SQRT(239874)
0009.00 C
NUM2
DSPLY
0010.00 C
EVAL
NUM3=%SQRT(239874)
0011.00 C
NUM3
DSPLY
0012.00 C
SETON
LR
35

****************** End of data *****************************************


OUTPUT
DSPLY
489
DSPLY
48976
DSPLY +4.8976935E+02
25.%SUBSTRING
*************** Beginning of data *****************************************
0001.00 * %SUBST(STRING:START{:LENTH})
0002.00 *
0003.00 DSTR1
S
20A INZ('PAVAN KALYAN') VARYING
0004.00 DSTR2
S
20A VARYING
0005.00 DRES
S
5I 0 INZ(0)
0006.00 C
EVAL
STR1=STR1+',' +'SSQUARE'
0007.00 C
STR1
DSPLY
0008.00 C
EVAL
STR2=%SUBST(STR1:1:5)
0009.00 C
STR2
DSPLY
0010.00 C
SETON
LR
****************** End of data ********************************************
OUTPUT
DSPLY PAVAN KALYAN,SSQUARE
DSPLY PAVAN
26. %TIME
*************** Beginning of data *****************************************
0001.00 *SYNTAX IS %TIME{EXPRESSION{:TIME FORMAT}}
0002.00 *
0003.00 DSTR
C
CONST('12:14 PM')
0004.00 DTIME
S
T
0005.00 C
EVAL
TIME=%TIME(STR:*USA)
0006.00 C
TIME
DSPLY
0007.00 C
SETON
LR
****************** End of data ********************************************
OUTPUT
DSPLY 12.14.00
36

27. %TRIM
*************** Beginning of data ******************************************
0001.00 * %TRIM(STRING)
0002.00 *
0003.00 DSTR1
S
20A INZ(' PAVAN ')
0004.00 DSTR2
S
20A INZ(' KALYAN ')
0005.00 DRES
S
5I 0 INZ(0)
0006.00 C
EVAL
STR2=STR1 + '.' + STR2
0007.00 C
STR2
DSPLY
0008.00 C
EVAL
STR2=%TRIM(STR1)+ '.' + %TRIM(STR2)
0009.00 C
STR2
DSPLY
0010.00 C
EVAL
STR2=%TRIML(STR1)
0011.00 C
STR2
DSPLY
0012.00 C
EVAL
STR2=%TRIMR(STR1)
0013.00 C
STR2
DSPLY
0014.00 C
SETON
LR
****************** End of data *********************************************
OUTPUT
DSPLY
DSPLY
DSPLY
DSPLY

PAVAN
PAVAN.PAVAN
PAVAN
PAVAN

28. %XLATE
*************** Beginning of data ******************************************
0001.00 DUC
S
26A INZ('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
0002.00 DLC
S
26A INZ('abcdefghijklmnopqrstuvwxyz')
0003.00 DSTRINP
S
7A INZ('ARJUN')
0004.00 DSTRINP1
S
7A INZ('pavan')
0005.00 DSTROUT
S
7A
0006.00 C
UC:LC
XLATE
STRINP
STROUT
0007.00 C
STRINP
DSPLY
0008.00 C
STROUT
DSPLY
0009.00 C
LC:UC
XLATE
STRINP1
STROUT
0010.00 C
STRINP1
DSPLY
0011.00 C
STROUT
DSPLY
0012.00 C
SETON
LR
****************** End of data *********************************************
OUTPUT
37

DSPLY ARJUN
DSPLY arjun
DSPLY pavan
DSPLY PAVAN
DISPLAY FILES
Simple display file for Arithmetic operations :
*************** Beginning of data
*************************************************
0001.00 A
CF03(03)
0002.00 A
R DSP2FMT
0003.00 A
4 28'ARTHEMATIC OPERTIONS'
0004.00 A
6 20'1. ADDITION'
0005.00 A
8 20'2.SUBSTRACTION'
0006.00 A
10 20'3.MULTIPLICATION'
0007.00 A
12 20'4.DIVISION'
0008.00 A
15 18'ENTER VALUE FOR A:'
0009.00 A
17 18'ENTER VALUE FOR B:'
0010.00 A
19 20'ENTER U R OPTION:'
0011.00 A
21 20'RESULT IS:'
0012.00 A
23 22'F3=EXIT'
0013.00 A
FLD1
4S 0I 15 40
0014.00 A
FLD2
4S 0I 17 40
0015.00 A
OPT
4S 0I 19 40
0016.00 A
RES
9S 0O 21 35
****************** End of data
****************************************************
RPG PROGRAME FOR ABOVE DISPLAY FILE:
*************** Beginning of data *****************************************
0001.00 Fdsp2
cf e
workstn
0002.00 C
dow
*in03=*off
0003.00 C
clear
dsp2fmt
0004.00 C
exfmt
dsp2fmt
0005.00 C
select
0006.00 C
when
opt=1
0007.00 C
eval
res=fld1+fld2
0008.00 C
exfmt
dsp2fmt
0009.00 C
clear
dsp2fmt
0010.00 C
when
opt=2
0011.00 C
eval
res=fld1-fld2
0012.00 C
exfmt
dsp2fmt
0013.00 C
clear
dsp2fmt
0014.00 C
when
opt=3
38

0015.00 C
eval
res=fld1*fld2
0016.00 C
exfmt
dsp2fmt
0017.00 C
clear
dsp2fmt
0018.00 C
when
opt=4
0019.00 C
eval
res=fld1/fld2
0020.00 C
exfmt
dsp2fmt
0021.00 C
clear
dsp2fmt
0022.00 C
other
0023.00 C
'invalid opt' dsply
0024.00 C
exfmt
dsp2fmt
0025.00 C
endsl
0026.00 C
enddo
0027.00 C
return
****************** End of data ***************************************
OUTPUT SCREENS WILL BE AS FOLLOWS:

READ FILES FROM PHYSICAL FILE AND DISPLAY ON SCREEN:


PF USING IN DSPLY FILE
39

*************** Beginning of data *****************


0001.00
A
R RECFMT
0002.00
A
ENO
4S 0
0003.00
A
ENAME
5A
0004.00
A
ESAL
4S 0
0005.00
A
K ENO
****************** End of data ********************
OUTPUT:
ENO ENAME ESAL
000001 102 LUCKY 2,000
000002 103 aaa 3,000
000003 104 ddd
555
000004 105 ggg
142
000005 107 DDD 6,542
000006 1,234 SURI 1,234
****** ******** End of report ********
DISPLAY FILE USING DDS:
Create a display file with name dsp1 in DDS. Following is source..
*************** Beginning of data ************************************
0001.00
A
REF(SURIPAD1/PF1)
0002.00
A
CF03(03)
0021.00
A
R DSPFMT
0022.00
A
4 30'EMPLOYEE DETAILS'
0023.00
A
6 25'EMPLOYEENUMBER:'
0024.00
A
8 25'EMPLOYEENAME:'
0025.00
A
10 25'EMPLOYEESALARY'
0026.00
A
15 25'F3=EXIT'
0027.00
A
ENO
R
B 6 45
0028.00
A
ENAME
R
B 8 40
0029.00
A
ESAL
R
B 10 45
****************** End of data *************************************
RPG PROGRAME FOR DSPLY FILE
*************** Beginning of data
*********************************************
0001.00 Fpf1
if e
disk
0002.00 Fdsp1
cf e
workstn
0003.00 C
read
recfmt
40
0004.00 C
dow
*in40=*off
0005.00 c
exfmt
dspfmt
0006.00 C
read
recfmt
40
0007.00 c
if
*in03=*on
0008.00 C
leave
0009.00 C
endif
0010.00 C
enddo
0011.00 C
eval
*inlr=*on
****************** End of data *************************
OUTPUT SCREENS:
40

Like above screen all the records in pf will be displays in display screens
WRITING FILES INTO PHYSICAL FILE THROUGH DISPLAY SCREEN:
Create a display file with name dsp1 in DDS. Following is source..
*************** Beginning of data ************************************
0001.00
A
REF(SURIPAD1/PF1)
0002.00
A
CF03(03)
0021.00
A
R DSPFMT
0022.00
A
4 30'EMPLOYEE DETAILS'
0023.00
A
6 25'EMPLOYEENUMBER:'
0024.00
A
8 25'EMPLOYEENAME:'
0025.00
A
10 25'EMPLOYEESALARY'
0026.00
A
15 25'F3=EXIT'
0027.00
A
ENO
R
B 6 45
0028.00
A
ENAME
R
B 8 40
0029.00
A
ESAL
R
B 10 45
****************** End of data *************************************
Rpg Program For Writing Files Through Display File
*************** Beginning of data **************************************
41

0001.00 Fpf1
uf a e
disk
0002.00 Fdsp1
cf e
workstn
0003.00 C
exfmt
dspfmt
0004.00 C
dow
*in03=*off
0005.00 C
write
recfmt
0006.00 c
clear
dspfmt
0007.00 c
exfmt
dspfmt
0008.00 C
if
*in03=*on
0009.00 C
leave
0010.00 C
endif
0011.00 C
enddo
0012.00 C
return
****************** End of data *****************************************

OUTPUT SCREEN:

42

By Like above screen all the records are to be written into pf

UPDATING FILES INTO PHYSICAL FILE THROUGH DISPLAY SCREEN


Create a display file with name dsp1 in DDS. Following is source..
*************** Beginning of
0001.00
A
0002.00
A
0004.00
A
R DSPFMT1
0005.00
A
0006.00
A
0007.00
A
0008.00
A
ENO
R
0021.00
A
R DSPFMT
0022.00
A
0023.00
A
0024.00
A
0025.00
A
0026.00
A
0027.00
A
ENO
R
0028.00
A
ENAME
R

data ************************************
REF(SURIPAD1/PF1)
CF03(03)
4 30'EMPLOYEE DETAILS'
6 25'EMPLOYEE NUMBER:'
15 25'F3=EXIT'
B 6 45
4 30'EMPLOYEE DETAILS'
6 25'EMPLOYEENUMBER:'
8 25'EMPLOYEENAME:'
10 25'EMPLOYEESALARY'
15 25'F3=EXIT'
B 6 45
B 8 40
43

0029.00
A
ESAL
R
B 10 45
****************** End of data *************************************
Rpg Program For Updating Files Through Display File
*************** Beginning of data
********************************************
0001.00 fpf1
uf a e
k disk
0002.00 Fdsp1
cf e
workstn
0003.00 C
dow
*in03=*off
0004.00 C
exfmt
dspfmt1
0005.00 c
eno
setll
recfmt
0006.00 c
if
*in30=*on
0007.00 C
read
recfmt
0008.00 c
exfmt
dspfmt
0009.00 c
update recfmt
0010.00 c
clear
dspfmt
0011.00 C
eval
*in30=*off
0012.00 C
endif
0013.00 C
enddo
0014.00 C
eval
*inlr=*on
****************** End of data
***********************************************

30

OUTSCREENS:

44

Enter the employee number, which you want to update the details, after
entering the number the following screen will be displayed, there you can
update what u want..

The shown details can be modifying in the above screen, the modified details
are to be stored in the actual physical file.
DELETING FILES IN PHYSICAL FILE THROUGH DISPLAY SCREEN
Create a display file with name dsp1 in DDS. Following is source.
*************** Beginning of data **********************************
0001.00
A
REF(SURIPAD1/PF1)
0002.00
A
CF03(03)
0004.00
A
R DSPFMT1
0005.00
A
4 30'EMPLOYEE DETAILS'
0006.00
A
6 25'EMPLOYEE NUMBER:'
0007.00
A
15 25'F3=EXIT'
0008.00
A
ENO
R
B 6 45
0009.00
A
R DSPFMT2
0010.00
A
4 30'EMPLOYEE DETAILS'
0011.00
A
6 25'EMPLOYEENUMBER:'
0012.00
A
8 25'EMPLOYEENAME:'
0013.00
A
10 25'EMPLOYEESALARY'
0014.00
A
15 25'DELETE:'
0015.00
A
20 25'F3=EXIT'
0017.00
A
ENO
R
B 6 45
0018.00
A
ENAME
R
B 8 40
0019.00
A
ESAL
R
B 10 45
0020.00
A
DFLD
4A B 15 40
****************** End of data ****************************************
45

Rpg Program For DELETING Files Through Display File


*************** Beginning of data **********************************
0001.00 Fpf1
uf a e
k disk
0002.00 Fdsp1
cf e
workstn
0003.00 C
dow
*in03=*off
0004.00 C
exfmt
dspfmt1
0005.00 C
eno
chain
recfmt
40
0006.00 C
if
*in40=*on
0007.00 C
'recnot found'dsply
0008.00 c
else
0009.00 C
exfmt
dspfmt2
0010.00 C
if
dfld='Y'
0011.00 C
delete recfmt
0012.00 C
clear
dspfmt2
0013.00 C
endif
0014.00 C
endif
0015.00 C
enddo
0016.00 C
eval
*inlr=*on
****************** End of data
**********************************************
OUT PUT SCREENS: Enter the Employee Number which is to delete

46

After giving delete field as Y the record will be deleted.

SUBFILES:
1. LOAD ALL SUBFILE:
STEP 1:
Physical File (Exmds) Which Is Using In Subfile
*************** Beginning of data ********************
001.00
A
R RECFMT
002.00
A
ENO
5S 0
003.00
A
ENAME
20A
004.00
A
EDEPT
15A
005.00
A
K ENO
****************** End of data **********************
Output for above file is:
ENO
000001
000002
000003
000004

ENAME
EDEPT
1 PADALASURYANARAYANA SSQUAREEE
2 SUNILKUMARDANDE
SSQUARE
3 ARJUNYADAVB
SSQUAREE
4 VEERA PRATAP REDDY SSQUARE
47

000005
5 SAI
SSQUARE
000006
6 GOPI
SSQUARE
000007
7 LUCKY
SSQUARE
****** ******** End of report ********
STEP2:
Create a display file for Subfile(sfl):
0003.00
A
DSPSIZ(24 80 *DS3)
0004.00
A
R SFLFMT
SFL
0006.00
A
ENO
R
B 5 7REFFLD(RECFMT/ENO
SURIPAD1/EXMDS)
0007.00
A
ENAME
R
B 5 20REFFLD(RECFMT/ENAME
SURIPAD1/EXMDS)
0008.00
A
EDEPT
R
B 5 46REFFLD(RECFMT/EDEPT
SURIPAD1/EXMDS)
0009.00
A
R CTLFMT
SFLCTL(SFLFMT)
0011.00
A
CF03(03 'exit')
0012.00
A
CF05(05 'refresh')
0013.00
A 20
SFLDSP
0014.00
A 21
SFLDSPCTL
0015.00
A 22
SFLCLR
0016.00
A
SFLSIZ(0050)
0017.00
A
SFLPAG(0010)
0018.00
A
4 8'ENO'
0019.00
A
4 23'ENAME'
0020.00
A
4 51'EDEPT'
****************** End of data
**************************************************
Step 3:
Create RPG program for Load all subfile:
*************** Beginning of data
******************************************
0001.00 FEXMDS
IF E
DISK
0002.00 FSFL
CF e
workstn SFILE(SFLFMT:RRN)
0003.00 DRRN
S
3S 0 INZ(0)
0004.00 C
EXSR
CLRSR
0005.00 C
EXSR
LOADSR
0006.00 C
DOW
*IN03=*OFF
0007.00 C
EXSR
DSPSR
0008.00 C
ENDDO
0009.00 C
EVAL
*INLR=*ON
0010.00 C
CLRSR
BEGSR
0011.00 C
EVAL
*IN22=*ON
0012.00 C
WRITE
CTLFMT
48

0013.00 C
EVAL
*IN22=*OFF
0014.00 C
ENDSR
0015.00 C
LOADSR
BEGSR
0016.00 C
READ
RECFMT
0017.00 C
DOW
*IN40=*OFF
0018.00 C
EVAL
RRN=RRN+1
0019.00 C
WRITE
SFLFMT
0020.00 C
READ
RECFMT
0021.00 C
ENDDO
0022.00 C
ENDSR
0023.00 C
DSPSR
BEGSR
0024.00 C
EVAL
*IN20=*ON
0025.00 C
EVAL
*IN21=*ON
0026.00 C
EXFMT
CTLFMT
0027.00 C
EVAL
*IN20=*OFF
0028.00 C
EVAL
*IN21=*OFF
0029.00 C
ENDSR
****************** End of data
**********************************************

40

40

Output screen for load all subfile:

2. Load Expandable Subfile:


49

STEP 1:
Physical File (Pf1a) Which Is Using In Subfile
*************** Beginning of data **************************************
0001.00
A
R REFMT
0002.00
A
ITMID
5S 0
0003.00
A
ITMTYP
5A
0004.00
A
ITMQNT
5S 0
0005.00
A
K ITMID
****************** End of data *****************************************
Output for above file is:
ITMID ITMTYP ITMQNT
000001 101 aaa
1
000002 102 bbb
2
000003 103 ccc
5
000004 106 ddd
5
000005 105 eee
23
000006 107 fff
107
000007 108 ggg
523
000008 109 hhh
109
000009 110 kkk
110
000010 111 iii
111
****** ******** End of report ********
STEP2:
Create a display file for Subfile(SFL1):
*************** Beginning of data
******************************************
0000.01
A
REF(PF1A/SURIPAD1)
0001.00
A
R SFLFMT
SFL
0002.00
A
ITMID
R
B 6 10
0003.00
A
ITMTYP R
B 6 20
0004.00
A
ITMQNT R
B 6 35
0005.00
A
R CTLFMT
SFLCTL(SFLFMT)
0006.00
A 20
SFLCLR
0007.00
A 21
SFLDSP
0008.00
A 22
SFLDSPCTL
0009.00
A
SFLSIZ(100)
0010.00
A
SFLPAG(5)
0011.00
A
2 15'STOCK DETAILS'
0012.00
A
4 10'ITEM ID'
0013.00
A
4 20'ITEM TYPE'
0014.00
A
4 35'ITEM QUANTITY'
0015.00
A
CF03(03)
0016.00
A
CF05(05)
0016.01
A 23
PAGEUP
50

0016.02
A 24
PAGEDOWN
0016.02
A 24
PAGEDOWN
0017.00
A
OVERLAY
0018.00
A
R FOOTER
0019.00
A
23 15'F3=EXIT'
0020.00
A
23 25'F5=REFRESH'
****************** End of data ************************************
Step 3:
Create RPG program for Load Expandable subfile:
*************** Beginning of data
********************************************
0001.00 FPF1A
IF E
DISK
0002.00 FSFL1sda CF e
workstn SFILE(SFtrec:RRN)
0003.00 DRRN
S
3S 0 INZ(0)
0004.00 C
EXSR
CLRSR
0005.00 C
EXSR
LOADSR
0005.01 C
EXSR
DSPSR
0006.00 C
DOW
*IN03=*OFF
0007.00 C
EXSR
usrSR
0008.00 C
ENDDO
0009.00 C
EVAL
*INLR=*ON
0010.00 C
CLRSR
BEGSR
0011.00 C
EVAL
*IN12=*ON
0012.00 C
WRITE
CTLrec
0013.00 C
EVAL
*IN12=*OFF
0014.00 C
ENDSR
0015.00 C
LOADSR
BEGSR
0016.00 C
READ
REFMT
40
0017.00 C
DOW
*IN40=*OFF
0018.00 C
EVAL
RRN=RRN+1
0019.00 C
WRITE
SFtrec
0020.00 C
READ
REFMT
40
0021.00 C
ENDDO
0022.00 C
ENDSR
0023.00 C
DSPSR
BEGSR
0024.00 C
EVAL
*IN10=*ON
0025.00 C
EVAL
*IN11=*ON
0026.00 C
EXFMT
CTLrec
0027.00 C
EVAL
*IN10=*OFF
0028.00 C
EVAL
*IN11=*OFF
0029.00 C
ENDSR
0030.00 C
USRSR
BEGSR
0031.00 C
DOW
*IN13=*ON
0032.00 C
EVAL
RRN=RRN+1
0033.00 C
EXSR
LOADSR
0034.00 C
EXSR
DSPSR
0035.00 C
EVAL
*IN13=*OFF
0036.00 C
ENDDO
51

0037.00 C
ENDSR
****************** End of data
***********************************************
Output screen for load Expandable subfile:

After above screen press PAGEDOWN following screen will appears:

52

3. Single Page subfile:


STEP1:
Create data Base..
*************** Beginning of data ************************************
0001.00
A
R FORMATE
PFILE(PF112)
0002.00
A
EMPNO
0003.00
A
EMPNAME
0004.00
A
EMPSAL
0005.00
A
K EMPNO
****************** End of data ***************************************
Output:
EMPNO EMPNAME EMPSAL
000001 102 ARJUN
444
000002 135 DSGHJ
222
000003 453 DAGDG
633
000004 245 WQERR
666
000005 5,888 TRUFH
568
000006 56,786 GFTHJ
566
000007 54,546 TDUTF
346
000008 4,578 TEUFU
442
000009 4,832 EYTE
361
000010 54,365 JSYIU
435
000011 47,367 DUTFI
436
000012 796 FDUFH
436
000013 5,578 FDCG
0
000014 46,536 DTFH
246
000015 76,679 RDHGJ
457
000016 367 ETYFI
432
000017 65,178 RTDYG
45
000018 7,556 DFHYK
354
000019 6,468 ETYUH
457
000020 658 YEWUF
896
****** ******** End of report *******
STEP2:
Create a display file for Subfile(SFL1):
*************** Beginning of data
************************************************
0001.00
A*%%TS SD 20110919 081512 LAKUMA
REL-V5R3M0
5722-WDS
0002.00
A*%%EC
0003.00
A
DSPSIZ(24 80 *DS3)
0004.00
A
R SFLREC
SFL
53

0005.00
A*%%TS SD 20110906 135250 LAKUMA
REL-V5R3M0
5722-WDS
0006.00
A
EMPNO
R
B 5 13REFFLD(FORMATE/EMPNO
LAKUMA1/LF)
0007.00
A
EMPNAME R
B 5
29REFFLD(FORMATE/EMPNAME LAKUMA1/LF)
0008.00
A
EMPSAL R
B 5 47REFFLD(FORMATE/EMPSAL
LAKUMA1/LF)
0009.00
A
R CTLREC
SFLCTL(SFLREC)
0010.00
A*%%TS SD 20110919 081512 LAKUMA
REL-V5R3M0
5722-WDS
0011.00
A
TEXT('y')
0012.00
A
CF03(03 'exit')
0013.00
A
PAGEUP(06 'pageup')
0014.00
A
PAGEDOWN(07 'page down')
0015.00
A
OVERLAY
0016.00
A 20
SFLDSP
0017.00
A 21
SFLDSPCTL
0018.00
A 22
SFLCLR
0019.00
A
SFLSIZ(0005)
0020.00
A
SFLPAG(0005)
0021.00
A
4 13'empno'
0022.00
A
4 29'empname'
0023.00
A
4 47'empsal'
****************** End of data ***************************************
Step 3:
Create RPG program for Load Expandable subfile:
*************** Beginning of data
****************************************
0001.00 Flf
if e
k disk
0002.00 Fsubfile3 cf e
workstn sfile(sflrec:rrn)
0003.00 Drrn
s
3s 0 inz(1)
0004.00 DPTR
S
5S 0 INZ(1)
0005.00 C
exsr
clrsr
0006.00 C
exsr
loadsr
0007.00 C
exsr
dspsr
0008.00 C
dow
*in03=*off
0009.00 C
exsr
usrsr
0010.00 C
enddo
0011.00 C
eval
*inlr=*on
0012.00 C
return
0013.00 c**********************************************************
0014.00 C
clrsr
begsr
0015.00 C
eval
*in22=*on
0016.00 C
write
ctlrec
0017.00 C
eval
*in22=*off
0018.00 C
endsr
0019.00 c***********************************************************
54

0020.00 C
loadsr
begsr
0021.00 C
EVAL
rrn=1
0022.00 c
do
5
0023.00 C
read
formate
0024.00 C
if
not %eof(lf)
0025.00 C
write
sflrec
0026.00 C
eval
rrn=rrn+1
0027.00 c
endif
0028.00 c
enddo
0029.00 C
endsr
0030.00 c***********************************************************
0031.00 C
dspsr
begsr
0032.00 C
eval
*in20=*on
0033.00 C
eval
*in21=*on
0034.00 C
exfmt
ctlrec
0035.00 C
eval
*in20=*off
0036.00 C
eval
*in21=*off
0037.00 C
endsr
0038.00 c***********************************************************
0039.00 C
usrsr
begsr
0040.00 * if pressed pageup
0041.00 C
If
*in06=*on
0042.00 c
do
10
0043.00 c
readp
lf
0044.00 c
if
%eof(lf)
0045.00 c
leave
0046.00 c
endif
0047.00 c
enddo
0048.00 c
empno
setll
formate
0049.00 C
exsr
clrsr
0050.00 c
exsr
loadsr
0051.00 c
exsr
dspsr
0052.00 c
endif
0053.00 * if pressed pagedowm
0054.00 C
If
*in07=*on
0055.00 c
empno
setll
formate
0056.00 C
exsr
clrsr
0057.00 c
exsr
loadsr
0058.00 c
exsr
dspsr
0059.00 c
eval
*in07=*off
0060.00 c
endif
0061.00 c
endsr
****************** End of data ***************************
OUTPUT for single page subfile:

55

After the screen appears.. give PAGEDOWN following screen will appears

After the screen appears.. give PAGEUP following screen will appears

56

PRINTER FILES:
Printer file using RLU:
-------------------------------------------------- Start of Page 001 -------------------FLD1
<..........>
RCD001
'EMPDETAILS'
FLD1
<...>
<.....>
<...>
RCD003
STUID
STUNAME
STUNO
FLD1
<..>
<...>
<.>
RCD002
9999
XXXXX
999
00004 S
9999
XXXXX
999
00005 S
9999
XXXXX
999
00006 S
9999
XXXXX
999
00007 S
9999
XXXXX
999
00008 S
9999
XXXXX
999
FLD1
<......>
RCD004
'FOOTER'
---------------------------------------------------- End of Report ---------------------RPG Program for above Printer file:
*************** Beginning of data
********************************************
0001.00 Fpf13
if e
disk
0002.00 Fprint2 o e
printer
0003.00 C
write
RCD001
0004.00 C
write
RCD003
0005.00 C
read
formate

20
57

0006.00 C
dow
*in20=*off
0007.00 c
write
RCD002
0008.00 C
read
formate
0009.00 C* STUID
DSPLY
0010.00 C* STUNAME
DSPLY
0011.00 C* STUNO
DSPLY
0012.00 C
enddo
0013.00 C
write
rcd004
0014.00 C
eval
*inlr=*on
****************** End of data
***********************************************

20

OUTPUT:
For output compile the rpg program with 14 and call it, then check spooled
files, run the spooled file with option 5, then the following screen will
appears

Printer file using DDS:


*************** Beginning of data
*************************************************
0001.00
A
REF(PF12)
0002.00
A
R HEADER
0003.00
A
SPACEA(3)
0004.00
A
30'STUDENT DETAILS'
58

0005.00
A
R SUBHEADER
0006.00
A
SPACEA(2)
0007.00
A
25'STUNO'
0008.00
A
45'STUNAME'
0009.00
A
55'STUM'
0010.00
A
R DATA
0011.00
A
SPACEA(2)
0012.00
A
STUNO
R
25
0013.00
A
STUNAME R
45
0014.00
A
STUM
R
55
0015.00
A
R FOOTER
****************** End of data
****************************************************
RPG Program for above Printer file:
*************** Beginning of data
*******************************************
0001.00 Fpf12
if e
disk
0002.00 Fprint3 o e
printer
0003.00 C
write
HEADER
0004.00 C
write
SUBHEADER
0005.00 C
read
formate
0006.00 C
dow
*in20=*off
0007.00 c
write
DATA
0008.00 C
read
formate
0009.00 C* STUNO
DSPLY
0010.00 C
enddo
0011.00 C
write
FOOTER
0012.00 C
eval
*inlr=*on
0013.00 C
RETURN
****************** End of data
**********************************************

20
20

OUTPUT:
For output compile the rpg program with 14 and call it, then check spooled
files, run the spooled file with option 5, then the following screen will
appears

59

60

You might also like