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
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 |
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 |
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 |
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 |
Answer / ram g
hands off steve!..the answer is absolutely rite...
Is This Answer Correct ? | 3 Yes | 0 No |
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 |
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 |
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 |
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 |
What is the difference between a subscript and an index in a table definition?
01 a pic x(4) value 'abcd' 01 b pic 9(3) can we move from a to b.if possible what would be stored in b.
Syntax for JCLLIB & JOBLIB???
can anybody post me about file-aid and changemen tools pls and give me reference if any mainframe guys are there
What guidelines should be followed to write a structured cobol prgm?
What is the difference between goback, stop run and exit program in cobol?
what is s000 u4087 error? please give the all error codes in cobol,jcl.
What is R-mode and A-mode?
How to find How Many Lines in Sysin DD * Parameter Thru Cobol Coding? If any one knows the Answer Please Reply .....Thanks From Shree
How to print 10 to 1 if the input have only 10 digit number?
what if any ,is the syntex error in the following piece of code 01 B PIC A(7) 02 C PIC 9(4) ........ IF(B NUMERIC) ADD 10 TO C a.the condition in the if statement is wrong b.noting is wrong c.because C is initialised.ADD 10 TO C is wrong d.both B and C shoud have same size.
Give some examples of command terminators?