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 DELETE THE RECORD FROM MASTER FILE WHICH IS LINK BY ANOTHER TRASATION FILE WITH REFERTIAL INTYGRITY?

1 Answers   TCS,


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

1 Answers  


HI,1: What is the function of 'SETON LR' AND '*INLR=*ON ? 2:Can we used "seton lr" OR "*INLR = *ON" in between the program code ? 3:if yes then according to there function the code which is written acter seton lr/ *inlr should not be execute . Can any one tell me why those code get executed ?

2 Answers  


How do you find out whether a record is present in the physical file without reading the file? for Example Employee No: 100 in an Employee master.How do we find out whther 100 is present in Employee master without reading the file?

11 Answers   Bank Of America, CSC, IBM,


One of the job in subsystem is in Running status,expected time to complete this job is 2 minutes. But from last 5 -10 minutes this job is still in running status....What are the possible reasons...and What are the actions i need to perform to check this...?

4 Answers  


i 'm new to as/400.in an interview i was asked this question.give a practical example for passing information or data through local data area. I know only that data area is an object used to store tiny bits of data or it can store one value at a time and it is used to store frequently changing values or datas.thats all i know about data area can any one tell me how local data area and user defined data area are used to pass data between jobs with a example or coding.thanks in advance.

2 Answers   CTS,


parameters cannot be passed in which one???

4 Answers   CTS,


How can we change element of compile time array?Can we do so

1 Answers   TCS,


how can you display specific subfile page on the screen in unequal subfile?

0 Answers   IBM,


What is the purpose of FRCDTA keyword?

3 Answers   IBM,


Errors in Sql query will be in which state?

1 Answers  


Mr.Sidc sirfor my question{how to convert date format from one format to another i think in CL/400 its CVTDAT,Please tell in RPG/400 sir not in RPGILE} you have answered using MOVE opcode,can you illustrate me with a small example sir very kind of you.

1 Answers   CTS, IBM, iGate,


Categories