what is the difference between occurs and occurs depending
on? i dont think so there is the difference in
storage..then why we should use occurs depending on?

Answers were Sorted based on User's Feedback



what is the difference between occurs and occurs depending on? i dont think so there is the differ..

Answer / steve dipaula

Okay folks, I know it has been a while since this was posted
but here is the answer. (1) The memory allocation is the
same whether or not the depending on clause is used period!
(2) The reason for making it a variable length table is for
sorting purposes. More specifically Binary Searches! For a
large table it will have to split the halves more time that
if you have a smaller table. So when loading the table you
keep count of the number of entries at the end of that
process you can set the depending on variable to that value.
Then when the search is executed it will see the table size
as the exact amount of entries, not the full number of
allocated slots.

Example:

Table is defined to have 100 occurrences. And you load 35
items in the table. If you do a search-all (binary search)
it may have to be tested 7 time before finding the item you
are looking for.

Same scenario 100 occurrences, 35 items loaded. But the
depending on variable is set to 35. It might only have to
search 6 times. I know the difference is negligible but in
a much larger case the difference would be quite significant.

Is This Answer Correct ?    19 Yes 1 No

what is the difference between occurs and occurs depending on? i dont think so there is the differ..

Answer / venkat

when we define cobol table with OCCURS, it is of fixed
storage and length. The program execution will take the
total storage irrespective of utiliztaion. Where as table
degined with OCCURS DEPENDING ON provides flexibility to
the developers to choose length of table dynamically.
Length of below table is based on WS-OBJ value.

WS-SUB OCCURS 1 TO 5 TIMES DEPENDING ON WS-OBJ PIC X(2).

For example if you want to stoge employee detail in an
cobol table and you are not aware of number of employees at
the time of table declaration, you can use variable length
cobol table. During program execution based on number of
employees you can set the length of table

Is This Answer Correct ?    14 Yes 5 No

what is the difference between occurs and occurs depending on? i dont think so there is the differ..

Answer / thilak

yes as for as storage is considered, there is no difference.
Occurs & occurs depending on allocates the maximum memory
specified in the "integer TIMES" CLAUSE.

But there are options of allocating memory dynamically at
the cost of runtime overhead.

for more
http://coding.derkeiler.com/Archive/Cobol/comp.lang.cobol/20
05-05/msg00396.html

Is This Answer Correct ?    4 Yes 0 No

what is the difference between occurs and occurs depending on? i dont think so there is the differ..

Answer / anna.

For hard-coded table we define cobol table with OCCURS,
becouse it is fixed numbers of occurances.

For input-loaded table (varb/l) with OCCURS DEPENDING ON
counter.Loading with perform vayring.
In this case we have exac numbers of entry and table can
easily access.

Is This Answer Correct ?    4 Yes 0 No

what is the difference between occurs and occurs depending on? i dont think so there is the differ..

Answer / ram g

hands off steve!..the answer is absolutely rite...

Is This Answer Correct ?    3 Yes 0 No

what is the difference between occurs and occurs depending on? i dont think so there is the differ..

Answer / ram g

no i cant agree with ur ans..
for eg: ws-var occurs 1 to 5 times depending on ws-cnt
it means that u can store max of 5 entries..
if i wanna store 50 entries instead of 5 at run time...what
could be the code change u can do on this?
ur ans indirectly saying that occurs depending on is
dynamic array isn't ? never is the my ans...
if u hv any idea please explain with simple eg

Is This Answer Correct ?    3 Yes 1 No

what is the difference between occurs and occurs depending on? i dont think so there is the differ..

Answer / sivakumar sekharannair

As ram said the number of occurances stored can be only 5
in either case. it cannot exceed more than that. what i
feel is when the first occurs clause is used regardless of
the number of occurances are loaded in the table the memory
allocation would be 5 bytes but if occurs 1 to 5 times
depending on ws-var, memory allocation will be made based
on the number of occurances loaded.

Is This Answer Correct ?    4 Yes 3 No

what is the difference between occurs and occurs depending on? i dont think so there is the differ..

Answer / piyush mani

hi all...
if ssrange is not spacified in compiler option then the storage will change as per the user dynamically....


giv ur feedback...

Is This Answer Correct ?    0 Yes 0 No

what is the difference between occurs and occurs depending on? i dont think so there is the differ..

Answer / tripti

IF AN INTERNAL TABLE OCCURS 100 TIMES.

I USE OCCURS DEPENDING ON <NUMBER OF RECS IN INPUT FILE>
CLAUSE WHILE DECLARING THE TABLE

MY INPUT FILE HAS 125 ITEMS.

CAN I ACCESS 125TH ITEM IN THE FILE USING THE INTERNAL
TABLE?

MY ANSWER ID YES. IN DEPENDING ON <XX> CLAUSE XX OVERWRITES
THE OCCURS CLAUSE

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More COBOL Interview Questions

can we use variable picture clause as xx.99 in cobol.

3 Answers  


What is the difference between performing a SECTION and a PARAGRAPH?

5 Answers   Accenture, Patni,


how to transfer the file from pc to mainframe??

2 Answers  


select TURE Statement(s) aboUt eject statemenet in cobol? a)The eject statememnt must be the only statement on the line b.It causes the program to edit abnormally c. eject statement can be written in either area A or area B d. specifies that the next source statement is to be printed at Top of the next page e.The EJECTstatement has no effect on the compilation of the source program itself

2 Answers  


What is the Importance of GLOBAL clause According to new standards of COBOL?

2 Answers   Infosys,






How many bytes will be allocated for the following record description entries? 01 REC-A. 05 A PIC S9(4). 05 B PIC XXXBXXX. 05 C PIC ____9.99. 05 D PIC S9(5) COMP-3. 05 E PIC 9(3) COMP.

16 Answers   IBM, TCS,


why do u need inspect verb?

3 Answers   Patni,


file status 00 is checked after opening the file or reading the file

4 Answers   John Deere,


In INITIALIZE what is Repalcing Word will do

1 Answers   CTS,


what is internal sort and external sort ? which is preferable ?

2 Answers   TCS,


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?

2 Answers   IBM,


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

0 Answers  


Categories