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 |
what is redefines? where it can be effectively use for the purpose of memory utilization? give an example?
Are you comfortable in cobol or jcl?
what is the difference between external and global variables?
I had 100 records and i want to execute last three records by using cobol programming?what will be coding?
if a file has 1000 recods how copy the records from 1 to 100 records using sort
what is MSGLEVEL?
how can u redefine picx(10) with pic 9(6).
I have a sequential file. How do I access a record in this sequential file randomly in my program ?
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.
What is COMP-1? COMP-2?
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?
What is the difference between structured cobol programming and object alternativelyiented cobol?