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

Why there is invention of RPG if we can do insert update delete in CL through SQL.Why the rise of RPG?

1 Answers   Infogain,


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.

4 Answers   HCL,


what is the difference between SETON RT & RETURN?

5 Answers  


How to handle duplicate error handling in RPG?

0 Answers  


how do u find whether a record is locked or not??/

5 Answers   CTS,






Why we need to give File and To file Names While we are using OVRDBF. What is your understanding related to this?

2 Answers   Cap Gemini,


ESCAPE message sent by child program can be handled by parent program using which keyword?

2 Answers  


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.

2 Answers   iGate,


what is data area and how it is used in rpg program ?

0 Answers   IBM,


Anyone help me for the below question:- If problem/error occur in *PSSR subroutine,how should I handel it in RPG program.

1 Answers  


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

0 Answers   IBM,


In how many ways a session/device error occurs,,, and what is the remedy for it?

3 Answers  


Categories