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 |
HOW TO DELETE THE RECORD FROM MASTER FILE WHICH IS LINK BY ANOTHER TRASATION FILE WITH REFERTIAL INTYGRITY?
Anyone help me for the below question:- If problem/error occur in *PSSR subroutine,how should I handel it in RPG program.
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 ?
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...?
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.
parameters cannot be passed in which one???
How can we change element of compile time array?Can we do so
how can you display specific subfile page on the screen in unequal subfile?
What is the purpose of FRCDTA keyword?
Errors in Sql query will be in which state?
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.