IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Doubt on SEARCH ALL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Gethyl george kurian

New User


Joined: 11 Sep 2008
Posts: 5
Location: bangalore

PostPosted: Sat Apr 25, 2009 8:43 am
Reply with quote

Hi everyone, this is my first post so sorry if i get something wrong.

This is wht i am supposed to do i need to check is VAR1 is present in any of the occurences of TABLE1(occurs 1000 times) if it is present then MOVE VAR2 to TABLE1-ELEMENT1 else MOVE VAR3 to TABLE1-ELEMENT2

Ok here comes my doubt,
1) Can you guys suggest me the best way to handle this scenario? With a code snippet if possible.
2) my idea was to SORT the TABLE1 first. Then use SEARCH ALL as shown below
SEARCH ALL TABLE1
AT END MOVE VAR3 to TABLE1-ELEMENT2(index)

WHEN TABLE1-ELEMENT1(index) = VAR1
MOVE VAR2 TO TABLE1-ELEMENT1(index)
END-search

But here my doubt is AT END state what value will index have?

Please reply to both at the earliest. Thanks.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sat Apr 25, 2009 9:08 am
Reply with quote

Hello and welcome to the forum,

If your SEARCH ALL reached AT END, do not use the index. . .

Suggest you sort the table before loading it.

The code posted will not do what you want.

At the top of the page is a link to "IBM Manuals". Suggest you look at the example binary search in the manual.
Back to top
View user's profile Send private message
Gethyl george kurian

New User


Joined: 11 Sep 2008
Posts: 5
Location: bangalore

PostPosted: Sat Apr 25, 2009 9:31 am
Reply with quote

ok So can you help me out and give me a better suggestion on how to implement this code. If i use a perform statement starting from IND = 1 to 1000...Performance wise it will b very bad... Also this table thing i am supposed to implement for around 8 tables. So doing 1 to 1000 isnt a wise idea from my point.

These are the only 2 ideas coming to my mind.

Help me out on this.

Thanks in Advance to all
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sat Apr 25, 2009 9:47 am
Reply with quote

Hello,

You need to take some time and explain what you are trying to accomplish in more detail. It will help if you use real-world names instead of things like var1 and table1-element1.

The way you have proposed to implement the code, "search all" will probably only work until the first "at end" condition. For "search all" to work correctly, the array must be in order and if you append items as you encounter "not found" values, the table will no longer be binary searchable.

Quote:
These are the only 2 ideas coming to my mind.
Often things like this are done using either a vsam file or a database table. . .
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Apr 25, 2009 9:48 am
Reply with quote

Your posts are not clear about what you're trying to do. Is there one table, two tables, or three tables? Use BBcode to post the exact variable definitions for TABLE1, VAR1, VAR2, VAR3, TABLE1-ELEMENT1 and TABLE1-ELEMENT2. Why are you using index on TABLE1-ELEMENT1 and TABLE1-ELEMENT2? Where is this index coming from?

For 1000-element tables, SEARCH ALL will typically be faster than a sequential search. However, the greater question is why are you so concerned about performance before getting something working? Performance issues should be addressed when they occur, since you may be worrying about something that is not an issue. Tests I've done in the last few years indicate 10 million COBOL statements per second of CPU time is very possible -- and the machine I'm running on is several years behind the current technology. Sequentially searching 8,000 table elements probably will add less than 1/100 of one second of CPU time to your program total CPU time; if you're not running a few million records through the search you probably won't notice the difference.
Back to top
View user's profile Send private message
Gethyl george kurian

New User


Joined: 11 Sep 2008
Posts: 5
Location: bangalore

PostPosted: Sat Apr 25, 2009 9:58 am
Reply with quote

@ dick scherrer

Hey i am pasting the part of the design so that it becomes more understanding. ( i have used google translator as my design was in SPANISH)

If MVA-COD-EMISAC is matching with one of the fields in WS-COD-EMITTER-OTC
Table of WS-TABLE-OTC (ind1 Be the index)
Calculate WS-IMP-INVERSION-OTC (ind1) = WS-IMP-INVERSION-OTC
(ind1) + ITC-IMP-VALEUBD
If not, add at the end of WS-TABLE-OTC:
Move MVA-COD-EMISAC to WS-COD-EMISOR-OTC (ind1)
Move ITC-IMP-VALEUBD to WS-IMP-INVERSION-OTC (ind1)


Here the Table is WS-TABLE-OTC under which i have the following sub elements WS-COD-EMISOR-OTC & WS-IMP-INVERSION-OTC & the table is indexed by IND1

So Scherrer, how do i implement this code?

and about the other post u have send.. I was planning to sort the table after each time i encounter AT END icon_smile.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sat Apr 25, 2009 10:02 am
Reply with quote

Hello,

Quote:
as my design was in SPANISH
Language differences surely do lead to some adventures here icon_smile.gif

Quote:
I was planning to sort the table after each time i encounter AT END
Re-sorting the table over and over will most likely require much more cpu than serially searching the table. . .

Quote:
So Scherrer, how do i implement this code?
If this was my requirement, i would use a database table. Probably a temporary table that was created and dropped in this program.
Back to top
View user's profile Send private message
Gethyl george kurian

New User


Joined: 11 Sep 2008
Posts: 5
Location: bangalore

PostPosted: Sat Apr 25, 2009 10:05 am
Reply with quote

Quote:
If this was my requirement, i would use a database table. Probably a temporary table that was created and dropped in this program.


Thats the problem we get the design from the CLIENT, we can't add a new table. All that we are supposed to do is to code whats given in design.

So here i have no other go but to stick to internal tables asked to use by them.

No u still havent helped me icon_cry.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sat Apr 25, 2009 10:13 am
Reply with quote

Hello,

Then just use serial lookups and append new entries to the end of the table(s).

You might also alert the client that using a db2 table to support this process may save considerable cpu usage. Of course, you would need to do both to show the difference.

As Robert mentoned earlier, the amount of cpu used may be trivial if the volume of records to be processed is not huge.
Back to top
View user's profile Send private message
Gethyl george kurian

New User


Joined: 11 Sep 2008
Posts: 5
Location: bangalore

PostPosted: Sat Apr 25, 2009 10:15 am
Reply with quote

alrite then i will do the good old manual way of performing the loop from IND =1 to 1000

Hey a special THANX to you and to Robert for spending time on this issue.

You guys have a gr8 day. CHEERS!! icon_exclaim.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sat Apr 25, 2009 10:18 am
Reply with quote

You're welcome - good luck icon_smile.gif

Have a gr8 day yourself icon_wink.gif

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Search two or more word with FILEAID Compuware & Other Tools 15
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts first column truncated in search result IBM Tools 13
No new posts ISRSUPC search utility - using high l... TSO/ISPF 2
No new posts To search DB2 table based on Conditio... DB2 1
Search our Forums:

Back to Top