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



1.Write code to read the records from a file and load an array of size 99? Make sure that you take..

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

1.Write code to read the records from a file and load an array of size 99? Make sure that you take..

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

Post New Answer

More RPG400 Interview Questions

How to write record if no field or the field are different in physical file in rpgle ?

0 Answers  


1.Are there any errors in the following statement?If so then list them.DTAARA is a data area having a field EMP # and EMPNO is a field in the file EMPPF.Which has one record. READ EMPPF IF %FOUND(EMPPF) IN DTAARA EVAL EMP#=EMPNO OUT DTAARA ENDIF

5 Answers  


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?

2 Answers   HSBC,


Can someone tell me tell me what is meant by message wait...?

1 Answers  


Have a join logical file with more than one members with different record formats. So how can we read the different members from this file and also how we can read the different record format from the join logical?

3 Answers  






what is the necessary command needed before OPNQRYF and why?

5 Answers  


Can somebody tell me that, Is it possible to read all the member of PF without OVRDBF?

6 Answers  


How Chain operation copies the record's data to the input buffer for the program?

0 Answers   IBM,


CAN WE READ RECORDS WITHOUT USING SETLL,READ,CHAIN IN RPG?

6 Answers   Satyam,


How can i check the object existance in RPG program without using QCMDEXC command.

7 Answers   IBM, JDA,


Suppose we have one database file and it is used by 5 programs and in 3 program we have to add some records in datbase file s what is the impact on other program?

0 Answers  


can we perform CHAIN operation on Subfile record format....?

4 Answers  


Categories