as400 interview questions and answers-Part 22
1. Explain EXFMT opcode in rpgle.
Ans:
EXFMT (Write/Then Read
Format)
·
The EXFMT operation is a combination of a WRITE
operation followed by a READ to the same record format.
Hence, instead of writing the operation code EXFMT we can
also use two operation codes WRITE (format-name) + READ (format-name).
·
This opcode displays whatever we have written to
the workstation fields and waits for the user input to enter anything, once any
input is given then only the processing advances to the next line.
·
EXFMT first of all write the input buffer to the
display device (to the screen field variable) and then reads the fields value
to provide it to the program.
Example
Display file : DSP1
Columns . . . : 1 100 Browse
SEU==>
FMT DP .....AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions++++++++++
*************** Beginning of data *****************************
0001.00 A R DETAIL
0002.00 A FLD1 10A B 3 10
****************** End of data ********************************
RPGLE program
Columns . . . : 6 100 Browse
SEU==>
FMT FX FFilename++IPEASF.....L.....A.Device+.Keywords++++++++++++++++++++++
*************** Beginning of data **********************************
0001.00 FDSP1 CF E WORKSTN
0002.00 C eval fld1='aaaaaaaaaa'
0003.00 C write Detail
0004.00 C read Detail
0005.00 C exfmt detail
0006.00 C seton lr
****************** End of data *************************************
OUTPUT
1st run:
The output will be as below for the first write/read operation:
FIELD-1: aaaaaaaaaa
Now the screen will ask for user input, we simply press ‘ENTER’ key.
We get the same output again as above:
FIELD-1: aaaaaaaaaa
2nd run:
Now we run the program again and this time after the
first write/read operation we input ‘bbbbbbbbb’ in field-1 and press ENTER.
The output will be as below for the first write/read operation:
FIELD-1: aaaaaaaaaa
Now the screen will ask for user input, we input ‘bbbbbbbbbb’ and press ‘ENTER’ key.
We get below output:
FIELD-1: bbbbbbbbbb
2. Explain ITER opcode in rpgle with example.
Ans:
Ü ITER (Iterate)
·
It can be used in DO, DOU, DOUxx, DOW, DOWxx,
and FOR loops to transfer control immediately to a loop's ENDDO or ENDFOR
statement.
·
It causes the next iteration of the loop to be
executed immediately.
·
ITER affects the innermost loop.
Example
C DOW *IN03=*OFF
C 03 LEAVE
C EXSR PROCESS
C IF C_OPT=*ZEROS
C AND *IN66=*OFF
C AND *IN99=*OFF
C AND FLAG='0'
C EXSR DSPLY
C ITER
C ENDIF
C EXSR SHOWSFL
C ENDDO
C SETON LR