Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

Arrays

1)COMPILE TIME ARRAY


PRA1/QRPGLESRC
CTA
0001.00
0002.00 Darray1
s
32a dim(4) ctdata
0003.00
0004.00 C array1(1) dsply
0005.00 C array1(2) dsply
0006.00 C array1(3) dsply
0007.00 C array1(4) dsply
0008.00 C
return
0009.00
0010.00 data array2
0011.00
0012.00
0013.00
0014.00
output
DSPLY
DSPLY
DSPLY
DSPLY

100
200
300
400

2) Run Time Array


PRA1/QRPGLESRC
PF1
0001.00
0002.00
R PF1REC
0003.00
ENO
0004.00
ESAL
0005.00
EAGE
0006.00
EADDR
0007.00
K ENO

UNIQUE
4S 0
4S 0
4S 0
20A

output is :ENO ESAL


000001 1 2,000

RTA

EAGE EADDR
23 ashok

0001.00
0002.00 Fpf1
it f 32
disk
0003.00 Darray1
s
32a dim(4) fromfile(pf1)
0004.00 Darray2
s
32a dim(4)
0005.00 Dd
s
4s 0
0006.00 C
movea array1
array2
0007.00 C 1
do
4
d
0008.00 C d
dsply
0009.00 C array1(d) dsply
0010.00 C
enddo
0011.00 C
eval
*inlr=*on
0012.00 C
return

output is:-a
DSPLY 1
DSPLY 000120000023ashok
DSPLY 2
DSPLY
DSPLY 3
DSPLY
DSPLY 4
DSPLY

3) PRE RUNTIME ARRAY


PRA1/QRPGLESRC
PRTA
0001.00
0002.00 Fpf1
it f 17
disk
0003.00 Darray1
s
17a dim(4) fromfile(pf1)
0004.00 Di
s
4s 0
0005.00 Da
s
5s 0
0006.00 C 1
do
4
i
0007.00 C
eval
a=a+100
0008.00 C
move
a
array1(i)
0009.00 C i
dsply
0010.00 C array1(i) dsply
0011.00 C
enddo
0012.00 C
eval
*inlr=*on
0013.00 C
return

output is :DSPLY 1
DSPLY 00012000002300100
DSPLY 2
DSPLY
00200
DSPLY 3
DSPLY
00300
DSPLY 4
DSPLY
00400

summary :1) for compile time array as we give input from program itself we directly declare array
2)for runtime array and prerun time array we have to specify the database file(pf1 here) using fromfile
keyword
3)in preruntime array prog when we give a 5s 0 then it allocates 5 digits but from left or right will be
known by the command used move,movea rightjustified
so see that instead of ASHOK it took 00000 by default first then inserted 00100,00200,...till 00400
4)if we use movel instead of move then the output will be 0010020000023ashok
see prog once again

3.1) PRERUNTIME ARRAY USING MOVEL


PRTA
001.00
002.00 Fpf1
it f 17
disk
003.00 Darray1
s
17a dim(4) fromfile(pf1)
004.00 Di
s
4s 0
005.00 Da
s
5s 0
006.00 C 1
do
4
i
007.00 C
eval
a=a+100
008.00 C
movel a
array1(i)
009.00 C i
dsply
010.00 C array1(i) dsply
011.00 C
enddo
012.00 C
eval
*inlr=*on
013.00 C
return

output is :DSPLY 1
DSPLY 001000000023ashok
DSPLY 2
DSPLY 00200
DSPLY 3
DSPLY 00300
DSPLY 4

You might also like