I have a sequential file of 100 records. How do I load the
records into a two dimensional array ?

Answers were Sorted based on User's Feedback



I have a sequential file of 100 records. How do I load the records into a two dimensional array ?..

Answer / gopal

01 INPUT-REC.
02 REC-ROWS OCCURS 10 TIMES INDEXED BY I.
03 REC-COLS OCCURS 10 TIMES INDEXED BY J.
04 REC-DATA PIC X(20 ) - assume

PROCEDURE DIVISION.
READ FILE(INPUT) INTO(WORK-REC) - assume length as 100
SET I TO 1. SET J TO 1.
PERFORM 1000-WRITE 10 TIMES
STOP RUN.
1000-SECTION.
MOVE WORK-REC TO REC-DATA(I J).
SET J UP BY 1.
READ FILE(INPUT) INTO(WORK-REC).
This will move the 10 occurences of J that is (I 1) to (I
10)
Then the outer loop should be incremented 10 times that is
I from 1 to 10.

Is This Answer Correct ?    12 Yes 0 No

I have a sequential file of 100 records. How do I load the records into a two dimensional array ?..

Answer / neilsh

It should be
01 xyz
05 pqr occurs 2 times indexed by i
07 abc occurs 50 times indexed by j
09 rec pic x(40).

so it would be like 50 occurance of rec and then 2 occurance
of abc

50 + 50 = two divisions

Is This Answer Correct ?    3 Yes 0 No

I have a sequential file of 100 records. How do I load the records into a two dimensional array ?..

Answer / ameet

The answer for this is as below:

01 INPUT-REC.
02 REC-DETAIL OCCURS 100 TIMES INDEXED BY I.
03 REC-DATA PIC X(10 ) - assume

PROCEDURE DIVISION.
READ FILE(INPUT) INTO(WORK-REC) - assume length as 100
SET I TO 1.
PERFORM 1000-WRITE 100 TIMES
STOP RUN.
1000-SECTION.
MOVE WORK-REC TO REC-DATA(I).
SET I UP BY 1.
READ FILE(INPUT) INTO(WORK-REC).

Is This Answer Correct ?    2 Yes 16 No

Post New Answer

More COBOL Interview Questions

System Testing for Mainframe Developers What is System Testing? integration testing ? what's the procedure ..

0 Answers   Amdocs,


how many bytes does a s9(12)COMP-4 field occupy?? a.2 b.4 c.8 d.1 ans with reason please

2 Answers  


in cobol main pgm is calling sub pgm but sub pgm does not exists , what abend i get if submit the job?

2 Answers   HSBC,


can internal sort be applied to sort ksds files?

1 Answers  


perform I from 0 by 1 until I=5?How maney times it will executes

8 Answers  


how will u pass dadta to cobol+db2 program...?

4 Answers   IBM,


How can you add a particular field/coloumn in copybook?

3 Answers   ADP, DELL, L&T,


WHAT IS SOC3?HOW IT CAN BE RESOLVED?

1 Answers  


How can I tell if a module is being called DYNAMICALLY or STATICALLY?

3 Answers   CTS,


How many sections are there in data division?.

10 Answers   Amdocs, TCS,


How to get the last record in vsam file in cluster? And how can you get the kids file records into your cobol program?

0 Answers  


How to read records which is in sequential file in reverse order ? Exp. 1 2 3 4 5 . i want 5 4 3 2 1?please clear my doubt any one

10 Answers   IBM,


Categories