I have a sequential file of 100 records. How do I load the
records into a two dimensional array ?
Answer Posted / 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 |
Post New Answer View All Answers
Which division and paragraphs are mandatory for a COBOL program?
how do you reference the rrds file formats from cobol programs
What is the difference between binary search and sequential search?
Which Search verb is equivalent to PERFORM…VARYING?
Difference between array and sub-script ?
How do define dynamic array in cobol.
2 input fles: 2 flat files, with different number of records. both are having unique key for each record and already sorted in ascending order . match these files using unique key and in output only matching key value has to be written. please procide cobol logic
What is the difference between a binary search and a sequential search? What are the pertinent cobol commands?
Differentiate between structured cobol programming and object-oriented cobol programming.
What is the difference between perform … with test after and perform … with test before?
What is the difference between external and global variables in COBOL?
If you are current on the owner of a set, what is the difference between obtain next and obtain first?
What is the difference between Global and External Variables?
How do you differentiate between cobol and cobol-ii?
how do you reference the printer file formats from cobol programs