Can we dynamically increase the size of occurs clause? i.e
In case I an not sure of the size of array and want to
increase the size at run time.If yes , how?



Can we dynamically increase the size of occurs clause? i.e In case I an not sure of the size of ar..

Answer / lu

yes, ...you declare an array like this:
77 ws-counter pic 9(04) value zeroes.
01 ws-array.
07 ws-field pic x (01) ouccurs 1 to 1000
depending on ws-counter.

Procedure Division.
Perform Read-file until ws-end-of-file = 'y'.
Read-file.
Read file at end
move 'y' to ws-end-of-file.
if ws-end-of-file not = 'y'
add 1 to ws-counter
move aa of file to ws-field (ws-counter).

the maximun is 1000 occurrences and minimun is 1...

Is This Answer Correct ?    14 Yes 0 No

Post New Answer

More COBOL Interview Questions

How do you define a variable of COMP-1? COMP-2?

3 Answers  


How do you get the data to code the BMS macro?

0 Answers   IBM,


How can we pass data from cobol to JCl?

7 Answers   ADP, Amdocs, IBM,


Can we change the password using ALTER? anyone tried and changed?

0 Answers   IBM,


I have one column say 'X' defined as VARCHAR Can anyone tell me What are the different ways to update this column thru COBOL-DB2 program?

5 Answers  






if we display var1 then what will b displayed in below condition. 77 var1 pic s9(2) value -10. 77 var1 pic s9(2) value -11. " " " -12. " " " -13. -14 ... ... -19.

2 Answers   IBM, Steria,


Will the variable POS in the following code have a value of 2 or not? 01 POS PIC S9(4) COMP VALUE 2. 01 FIRST-NAME PIC X(10) VALUE 'ABC'. 01 LAST-NAME PIC X(10) VALUE 'XYZ'. 01 NAME PIC X(20) VALUE SPACES. STRING FIRST-NAME DELIMITED BY SPACES ' ' DELIMITED BY SIZE LAST-NAME DELIMITED BY SPACES INTO NAME WITH POINTER POS

2 Answers  


What is an index for tables?

2 Answers  


i have a variable block which is used in my cobol program as input file having records of 4080 after compilation while runing the program im getiing file attribut mismatch and it is saying tht the record length of the file is 4084 can any one knw the answer how to reslove it ?

2 Answers  


I encountered an error when I move spaces to a numeric field?What should I do to move spaces on that field?help please.

9 Answers  


The disposition parameter in the jcl is share ( DISP+SHR ) and the program opens file in extend mode what will happen?

6 Answers   Cognizant,


how many bytes does s9(7)COMP-3 field occupies?

6 Answers   ADP,


Categories