Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to declaer the Table size dynamically

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Pons

New User


Joined: 25 May 2007
Posts: 61
Location: Coimbatore

PostPosted: Thu Apr 03, 2008 9:42 pm    Post subject: How to declaer the Table size dynamically
Reply with quote

Hi All,

My requirement is to find table of string from the file.
The file is not sorted. So i need to open a file for each search and have close it. It is an Sequential file. So i plan to move all the file things to array and using that array (Table) for searching.

My question is how to determine the array size (Table size), the file records may vary from each run. So how to find out the total number of records and how to declare the table accordingly...

Please advice.
Back to top
View user's profile Send private message

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Apr 03, 2008 9:45 pm    Post subject:
Reply with quote

You can't!
Back to top
View user's profile Send private message
Pons

New User


Joined: 25 May 2007
Posts: 61
Location: Coimbatore

PostPosted: Thu Apr 03, 2008 10:44 pm    Post subject: Reply to: How to declaer the Table size dynamically
Reply with quote

Hi,

Then how to handle my requirement. What logic can i follow..
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 785
Location: Chennai, India

PostPosted: Thu Apr 03, 2008 10:52 pm    Post subject:
Reply with quote

This might not good one, but...

Read PS two times...
One for counting records,
The OCCURS DEPENDING ON clause specifies variable-length tables.
One for moving to table...
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Thu Apr 03, 2008 11:25 pm    Post subject: Re: Reply to: How to declaer the Table size dynamically
Reply with quote

Pons wrote:
Then how to handle my requirement. What logic can i follow..
Assuming multiple search strings, I'd read them in and format an "A" record and release them to sort. Then I'd read the file to be searched and format a "B" record and release them to sort.
I'd then retreive the sorted records easily checking the "B" record following an "A" record to see if the sort key string matches.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Apr 03, 2008 11:32 pm    Post subject:
Reply with quote

gnanas wrote:
This might not good one, but...

Read PS two times...
One for counting records,
The OCCURS DEPENDING ON clause specifies variable-length tables.
One for moving to table...


The table is still defined (allocated) for the max size so why bother with two reads. Set the depending on to the max, load the table and set the depending on to the actual count, just one read loop is all you need.
Back to top
View user's profile Send private message
tushar.zibbu

New User


Joined: 08 Mar 2007
Posts: 6
Location: Assam

PostPosted: Fri Apr 04, 2008 12:57 pm    Post subject: Re: How to declaer the Table size dynamically
Reply with quote

Hello Pons,
If I have understood the requirement, the solution is very simple. While uploading the records into an ARRAY, you can keep a COUNT for the number of records loaded (lets say WS-IN-REC-COUNT). Then the same variable (WS-IN-REC-COUNT) can be used in Working-Storage Section while declaring the ARRAY (Depending on WS-IN-REC-COUNT).
I guess that has answered your question. If not, please let me know.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Fri Apr 04, 2008 6:04 pm    Post subject:
Reply with quote

As noted earlier - DEPENDING ON is not dynamic allocation - you still must specify at compile time the max size.

If you must do this dynamically - here's how:

1. Set up a template COBOL program to do what you want, with a placeholder token (e.g., <asize>) for the array size.
2. Have another program count the file size, then copy the template to a temp file, replacing <asize> with the actual value for this run.
3. Input the temp file into the compile/link/run proc.
4. Assuming you don't blow a compile limit, you're OK.
5. Note that this is an unusual production job, in that you are executing a program (this instance of the template) which has strictly speaking not undergone a formal production turnover except as the template, so some installations might balk.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Apr 04, 2008 6:22 pm    Post subject:
Reply with quote

Another stupid design problem.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri Apr 04, 2008 6:48 pm    Post subject:
Reply with quote

What's wrong with defining the table in linkage after a getmain?
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Fri Apr 04, 2008 7:03 pm    Post subject:
Reply with quote

Craq - To what are you referring?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Apr 04, 2008 8:11 pm    Post subject:
Reply with quote

Phrzby Phil wrote:
Craq - To what are you referring?


The original requirements.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Fri Apr 04, 2008 8:17 pm    Post subject:
Reply with quote

I skipped that part and went right to the more interesting part of actually doing a dynamic COBOL array, albeit in several steps.

I make no representation that dynamic arrays are the way to solve the op's problem.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Apr 04, 2008 9:16 pm    Post subject: Re: How to declaer the Table size dynamically
Reply with quote

I had put something together at the following post which may help -

http://ibmmainframes.com/viewtopic.php?t=29067&highlight=

Regards,

Bill
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Apr 04, 2008 9:30 pm    Post subject:
Reply with quote

Hello,

If you post some sample data and how you want the process to work, we can probably offer better suggestions. . .
Back to top
View user's profile Send private message
Pons

New User


Joined: 25 May 2007
Posts: 61
Location: Coimbatore

PostPosted: Mon Apr 07, 2008 11:02 pm    Post subject: Reply to: How to declaer the Table size dynamically
Reply with quote

Thanks a lot for your advices.

Dick my requirement:

1. From the PS file i need to read the LOB (Line of business), is it H (HOME) then i need to update the table.

2. If that particular key have an LOB as A (AUTO) also, then i need to add these home and auto values and need to update the table.

3. Here the file is not sorted. For that i need to search each and every key from the file for AUTO or HOME LOB is present.

As per my knowledge,

I try to read the file first and get the key, after that i try to use the array to find the auto lob for that key; For this search i need the solution.

How can i handle this.... Please give the soluction using cobol program. I cant change the job and i cant sort the file....

Sample data's:

XXHXXXXX XXXXX100.AAAAAAAA.AA - 1 RECORED
XXHXXXXX XXXXX200.BBBBBBBB.BB - 2 RECORED
XXAXXXXX XXXXX100.CCCCCCC.CC - 3 RECORED
XXHXXXXX XXXXX200.DDDDDDD.DD - 4 RECORED
XXAXXXXX XXXXX300.AAAAAAAA.AA - 5 RECORED
XXAXXXXX XXXXX100.XXXXXXXX.XX - 6 RECORED

See here 1st recored and 5th recored have the same key and so i need to add 100 and 300 = 400 and need to update this 400 to table for both H and A.

But 2nd recored have only one recored H so i just want to update the 200 in to table for H.

I hope you got my point. If not let me know...
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Mon Apr 07, 2008 11:26 pm    Post subject: Re: Reply to: How to declaer the Table size dynamically
Reply with quote

Pons wrote:
I cant change the job and i cant sort the file....
You should not need to 'change the job' to do an internal sort.....
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Apr 08, 2008 12:04 am    Post subject:
Reply with quote

Hello,

Quote:
Please give the soluction using cobol program. I cant change the job and i cant sort the file....
If you use cobol, that would be changing the job wouldn't it?

What reason is there that you can't sort a copy of the original file for use in your process? As was already mentioned, what reason is there that you cannot use an internal sort of the file withn your process?

The original file would remain unchanged, but you would have a file that you could use without wasting so much development time as well as system resources. Processing the sorted data (regardless of how the sort is done) will make the code much more straight forward (which means it will be running sooner), as well as running much faster.

You do not want to open/close the file over and over in your process.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Need Rexx Program to Load in to DB2 T... Hareesh Verma CLIST & REXX 22 Tue Sep 20, 2016 2:59 pm
No new posts Increase the screen size after split mistah kurtz TSO/ISPF 2 Fri Sep 02, 2016 6:39 pm
No new posts how to DYNAMICALLY write sort cond to... mohamedmubee COBOL Programming 13 Fri Aug 26, 2016 11:46 pm
No new posts Command UNIQUE CONSTRAINT on any tabl... rohanthengal DB2 2 Thu Aug 18, 2016 3:48 pm
No new posts Updating online Db2 table kishpra DB2 3 Fri Aug 12, 2016 2:44 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us