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

what is redefines? where it can be effectively use for the purpose of memory utilization? give an example?

4 Answers   IBM,


Are you comfortable in cobol or jcl?

0 Answers  


what is the difference between external and global variables?

1 Answers  


I had 100 records and i want to execute last three records by using cobol programming?what will be coding?

4 Answers   IBM,


if a file has 1000 recods how copy the records from 1 to 100 records using sort

4 Answers   IBM,






what is MSGLEVEL?

1 Answers   IBM,


how can u redefine picx(10) with pic 9(6).

3 Answers   TCS,


I have a sequential file. How do I access a record in this sequential file randomly in my program ?

8 Answers   CGI, Xansa,


Consider the following code: 77 A PIC 99V99 VALUE 55.35 77 B PIC 99V999 VALUE 32.754 ADD B TO A ON SIZE ERROR DISPLAY "ERROR!!!" What will be the result ? (a) A=88.10, B=32.754 (b) A=87.00 B=32.754 (c) A=87.10 B=32.754 (d) ERROR!!! will be DISPLAYed on the screen.

3 Answers   TCS,


What is COMP-1? COMP-2?

4 Answers   CitiGroup,


I have put two write operations in a single para for two different conditions.Will that lead to an abend or run successfully and write two records?

1 Answers   CTS,


What is the difference between structured cobol programming and object alternativelyiented cobol?

0 Answers  


Categories