How do u initialize an array?

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


Please Help Members By Posting Answers For Below Questions

Which mode is used to operate the sequential file?

928


What is Pic 9v99 Indicates in COBOL?

934


What is amode(24)?

884


What is the difference between a binary search and a sequential search what are the pertinent cobol?

928


Why is it necessary that file needs to be opened in I-O mode for REWRITE?

987


here is my requirement A1 is alphanumeric with value 'A1B2C3D4' as defined below 05 A1 PIC X(8) VALUE IS 'A1B2C3D4' but i need to have A2,A3 as ABCD & 1234 repectively...... A2 = ABCD A3 = 1234 Can you please explain me what are the different ways to do it?

7298


How can i load all the data from a file to Table (array) in cobol.How i manage the occurs clause with out reading the file.Any options avilable ? Please can any one help me it is urgent?

2343


how do you reference the fixed unblock file formats from cobol programs

924


Define cobol?

1073


Write the code to count the sum of n natural numbers.

928


What are the different open modes available in cobol?

939


What are all the divisions of a COBOL program?

894


how do you reference the variable unblock file formats from cobol programs

1006


what is search and searchall?what is the diffrence between them?give an best example?

6181


How to traceback if I am getting SOC7 or SOC4 abend? List down the steps

5084