Answer Posted / nagaraj
You can initialize an array in several ways based on the
values in the array.
If you know the values in the array already, then you can
do it through REDEFINE clause. I will give an example here.
05 MONTHS-VAL PIC X(36)
VALUE 'JanFebMarAprMayJunJulAugSepOctNovDec'.
05 MONTHS REDEFINE MONTHS-VAL PIC X(3)OCCURS 12 TIMES.
If you want to initialize at run time based on the user
input, then you can pass the values via ACCEPT statement
(online) /SYSIN DD statement (batch) and initialize the
COBOL array.
If you want to initialize with default values then you can
do it using INITIALIZE verb but be careful doing so.
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is a scope terminator give example?
how do you reference the variable unblock file formats from cobol programs
How do define dynamic array in cobol.
What is the difference between next sentence and continue in cobol programing language?
)If there are 10 steps in GDG, if I want to refer the step2 after step5 . what should I do?
Can we change the password using ALTER? anyone tried and changed?
how do you reference the variable block file formats from cobol programs
What kind of error is trapped by on size error option?
What is the difference between PIC 9.99 and PIC9v99?
What is the difference between PIC 9.99 and 9v99 in COBOL?
What is the difference between Global and External Variables?
Why occurs cannot be used in 01 level in COBOL?
what is amode(24), amode(31), rmode(24) and rmode(any)?
How to know whether the module is dynamical or statistical?
i want a program using by if, evaluate , string, unstring, perform, occurs?