urgent - dynamic array.

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
User avatar
arrbee
Active Member
Posts: 144
Joined: Fri Feb 24, 2006 11:33 am

urgent - dynamic array.

Post by arrbee » Wed Mar 05, 2008 7:44 pm

Hi,

Our customer has got a peculiar problem and describes as told below:

There is a DB2-COBOL program that uses a cursor to fetch data from a table based upon some condition. If the internal table reaches a said limit that program abends. We can't predict the number of entries coming into the internal table, so, the program abends every now and then and cusomer is very unhappy.

We suggested a dynamic array (occurs depending on) but he asks how to set the maximum value because of unknown entries coming for a particular day.

Can anybody help me out please........this is very urgent...... :shock:

Please let me know if you need more details.

Thank you very much......... :roll:

Best Regards. :)
Arr Bee
-------------
?My joy in learning is partly that it enables me to teach? - Seneca(Roman philosopher, mid-1st century AD)

User avatar
Krishna
Site Admin
Posts: 1052
Joined: Fri Jan 27, 2006 7:50 am

Post by Krishna » Thu Mar 06, 2008 4:53 pm

Hi ArrBee,

DEPENDING ON Clause in COBOL.. is not fully dynamic...
i.e. you need to define the range.


If you want to use DEPENDING ON clause... you should now
how many records you will get between range ...

Ex. If you are expecting... your no of records from cursor is always
between a range. ex. 1000 to 2000. then you can define
internal table using DEPENDING ON.


In your case, i suggest, use SELECT count(*)... before fetching records from cursor.... to know number of records you are going to fetch from cursor.

so that... before fetch records from cursor... you can set the index value to
that no. of records value....

User avatar
arrbee
Active Member
Posts: 144
Joined: Fri Feb 24, 2006 11:33 am

would you please elaborate.

Post by arrbee » Thu Mar 06, 2008 5:46 pm

Krishna,

Thank you very much for the solution.

would you please explain me the following lines in detail:
In your case, i suggest, use SELECT count(*)... before fetching records from cursor.... to know number of records you are going to fetch from cursor.

so that... before fetch records from cursor... you can set the index value to
that no. of records value....
Thanks.
Arr Bee
-------------
?My joy in learning is partly that it enables me to teach? - Seneca(Roman philosopher, mid-1st century AD)

User avatar
Krishna
Site Admin
Posts: 1052
Joined: Fri Jan 27, 2006 7:50 am

Post by Krishna » Fri Mar 07, 2008 7:53 pm

Hi Arr Bee,

Please find more details on my points.


In your case, i suggest, use SELECT count(*)... before fetching records from cursor.... to know number of records you are going to fetch from cursor.
In addition to existing cursor, you need to add one more Select query similar to
your cursor. i.e. this select query contains same where clause as your cursor.
But in select you will use COUNT(*).

Using this query you can know... how many records your cursor is going to return.

so that... before fetch records from cursor... you can set the index value to
that no. of records value....
Once you get the no. of records from the select count query.
Set this value to DEPENDING ON clause variable.
Continue with your existing cursor open.. fetch... logic...
it will work fine.


Let me know, if you have any other questions..

User avatar
arrbee
Active Member
Posts: 144
Joined: Fri Feb 24, 2006 11:33 am

Thanks

Post by arrbee » Wed Jun 25, 2008 8:36 pm

Yeah.........nice idea.....

thx.
Arr Bee
-------------
?My joy in learning is partly that it enables me to teach? - Seneca(Roman philosopher, mid-1st century AD)

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others