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 |
A LESS 1200 IF B GREATER 25 MOVE 47 TOC ELSE MOVE 57 TO C IF A GREATER 249 MOVE 67 TO C ELSE NEXT SENTENCE ELSE IF B LESS 67 MOVE 27 TO C What will be the value of C, when A is 137 and b is 25
how do u indetify files succesfully executed or not ?
what are the control characters used in reports
what is s000 u4087 error? please give the all error codes in cobol,jcl.
What are the pertinent COBOL commands?
In COBOL "BEFORE" advancing is there or not ?
can anybody post me about file-aid and changemen tools pls and give me reference if any mainframe guys are there
I have a file it contain 10 records.i got abend at 8th record because of soc7.how do you know that perticular record got abend?
How you can delete a record from a ps file in cobol?
Whtz the specialty of 77 level number ?
How to find out the closest prime number of an input number? I believe it has something to do with SEARCH and COBOL Linear Array.
I hv ten records in ps file and i hv say some 15 records in vsam file .i hv empno and age in ps file n empno,empname,dept n desig in vsam file. i hv 2 read the ps file n check wid matching empno in vsam file and then insert all fields from ps and vsam into db2 table....plz help in writin the procedure division