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

Wat is the difference between NEXT and CONTINUE statement in cobol,can any one explain with example.

11 Answers   Deloitte,


i have a sequencial file contains multiple records, i want to extract one row which contains various fields like order number,date,warehouse,.ect.. in to the another file by accepting the order number from jcl. how can i do it. pls help me..

4 Answers   CGI,


How do you code cobol to access a parameter that has been defined in jcl? And do you code the parm parameter on the exec line in jcl?

0 Answers  


What is level 66 used for ?

3 Answers   TCS,


wht is packed decimal in cobol

2 Answers  






what is call by value and call by reference ?

3 Answers   Infosys, ITC Indian Tobacco Company,


In which area will you utilize 88 level items in cobol?

0 Answers  


I have a cobol program with a sub program. How ca i find that it is a dynamic call? or static call..?

3 Answers   HCL, IBM,


Why occurs can not be used in 01 level ?

2 Answers   TCS,


What are the differences bitween cobol and cobol-2?

1 Answers   Wipro,


can anybody post me about file-aid and changemen tools pls and give me reference if any mainframe guys are there

0 Answers  


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

3 Answers  


Categories