Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Doubt on SEARCH ALL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Doubt on SEARCH ALL
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

Site Director


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

PostPosted: Sat Apr 25, 2009 9:08 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Sat Apr 25, 2009 9:47 am    Post subject:
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: 8165
Location: East Dubuque, Illinois, USA

PostPosted: Sat Apr 25, 2009 9:48 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Sat Apr 25, 2009 10:02 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Sat Apr 25, 2009 10:13 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Sat Apr 25, 2009 10:18 am    Post subject: Reply to: Doubt on SEARCH ALL
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    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 HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Search for a string in many PDS KARTHIGADEVI CLIST & REXX 5 Fri Sep 08, 2017 2:32 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts Doubt in MFS abdulrafi IMS DB/DC 2 Fri Oct 21, 2016 3:09 pm
No new posts Search a Load Module sreekanth1984 TSO/ISPF 8 Tue Jun 07, 2016 8:45 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us