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 |
Can somebody tell me that, Is it possible to read all the member of PF without OVRDBF?
How can we make use of SETLL operation in CL?
1) How to retrieve RRN through RPG ? 2) How to pass parameter by value ? 3) How to trap the error through the RPG/400
10 Answers IBM, Tech Mahindra,
How can we receive values from a called procedure in CL?
How to sort an array in descending in RPG
1.Where we declare Variables in RPG/400,RPGIV,RPGILE.? 2.When do we use D-spec and I-spec in real time ?.what is difference between them?
program to find the number of objects used in a given program through a display.
How to get only unique records from a file which contains duplicate data using CPYF command ? Example : FILEA has duplicate records and FILEB is a UNIQUE defined.... and I want to get the data from FILEA to FILEB by eliminating all the duplicate records...
A pgm subroutine calling child subroutine, that child subroutine again calling parent subroutine, u have 1000 lines of code, with out debugging , how can u find that error??? Is there any command to find errors in pgm???
where we give the MSGSFL in rpg400?
What would be the result on writing a data record to a PF file using the "WRITE" opcode after the SETON *ON *INLR statment?
What is the difference between RPG/400 and RPG4