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
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 |
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 |
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 |
level number 77 is used to define a)group data b)elementary data c)redefine d)none
what is a load module ?
if you give cylinder(1,1)how many cylinders it will be allocate?
Re: 01 NAME1 PIC X(13) VALUE "COBOL PROGRAMMING". 01 NAME2 PIC X(13). now I want to display the value of NAME1 in reverse order i.e value should be displayed as "GNIMMARGORP LOBOC" HOW can I do that ??? please let me know if any one knows it.
can internal sort be applied to sort ksds files?
can I copy book which contain db2 statment in procedure divion?
. How do we cast a variable in COBOL
What is the difference between structured cobol programming and object alternativelyiented cobol?
What are the pertinent COBOL commands?
can you please let me know if there is any walkins for COBOL/PLI/DB2/IMS/JCL in pune other than IBM and ITC infotech
What is length is cobol?
Difference between lrecl, blksize among PS, PDS issues? i.e in jcl at dcb