1.Write code to read the records from a file and load an
array of size 99? Make sure that you take care of all the
error conditions?
Answers were Sorted based on User's Feedback
Answer / rosh
Fpf1 if e k disk
D Max s 2p 0 inz(99)
d Lowrec s 2p 0 inz
Read(e) PF1
Dow not %EOF(PF1)
IF Lowrec <= Max
Move record to array(Lowrec)
eval Lowrec = Lowrec + 1
else
Leave
Endif
Read(e) Pf1
ENDDO
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / sachin
IDENTIFICATION DIVISION.
PROGRAM-ID.PGM1.
ENVIRONMENT DEVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT FILE1 ASSIGN TO DD1
FILE STATUS IS FS1.
DATA DIVISION.
FILE-SECTION.
FD FILE1.
RECORDING MODE IS FB.
LABLES ARE STANDARD.
01 WS-INPUT PIC X(80).
WORKING-STORAGE SECTION.
01 WS-ARRAY.
02 WS-NAME OCCURS 99 TIMES.
01 SWITCHES.
02 WS-EOF-SWITCH PIC X(1)
88 WS-EOF VALUE 'Y'
88 WS-NOT-EOF VALUE 'N'
PROCEDURE DIVISION.
MAIN-PARA.
PERFORM 1000-INITIALIZATION THRU 1000-EXIT.
PERFORM 2000-READ-FILE1 THRU 2000-EXIT
UNTIL WS-EOF.
PERFORM 3000-MAIN-PROCESS THRU 3000-EXIT
STOP RUN.
1000-INITIALIZATION.
INITIALIZE VARIABLES.
OPEN INPUT FILE1.
1000-EXIT
EXIT.
2000-READ-FILE.
READ FILE AT END MOVE 'Y' TO WS-EOF-SWITCH
NOT AT END
CONTINUE
END-READ.
2000-EXIT.
EXIT.
3000-MAIN-PROCESS.
PERFORM VARYING I FROM 1 BY UNTIL WS-EOF
MOVE INPUT-REC TO WS-ARRAY(I)
PERFORM 2000-FILE-READ THRU 2000-EXIT
END-READ.
3000-EXIT.
EXIT.
4000-CLOSE-PARA.
CLOSE FILE1.
Is This Answer Correct ? | 2 Yes | 4 No |
Why there is invention of RPG if we can do insert update delete in CL through SQL.Why the rise of RPG?
what is meant by record lock.how records are locked.what is the purpose of record lock.if records are locked what happens.how to find out which record is locked.
what is the difference between SETON RT & RETURN?
How to handle duplicate error handling in RPG?
how do u find whether a record is locked or not??/
Why we need to give File and To file Names While we are using OVRDBF. What is your understanding related to this?
ESCAPE message sent by child program can be handled by parent program using which keyword?
how to find whether a date format is valid or not in RPG400 not in RPGILE.Can you please write the coding for this sir,i'm new to AS400.Please help.
what is data area and how it is used in rpg program ?
Anyone help me for the below question:- If problem/error occur in *PSSR subroutine,how should I handel it in RPG program.
How Chain operation copies the record's data to the input buffer for the program?
In how many ways a session/device error occurs,,, and what is the remedy for it?