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

find no. of times entry exist in table using search all


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

New User


Joined: 28 Aug 2006
Posts: 9
Location: pune

PostPosted: Wed Oct 11, 2006 11:21 pm
Reply with quote

can we find no of times entry exist in table using search all

we can find it using search verb
because there we can use " set index up by 1"
can we use it in search all?
Back to top
View user's profile Send private message
MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Thu Oct 12, 2006 12:15 am
Reply with quote

You can use INSPECT

for example if table is declared as:


Code:

01  WS-STR-DEFN-TBL.                                 
    05  WS-STR-DEFN-FLD      OCCURS 5 TIMES.         
        10  WS-STR-DEFN      PIC X(30) VALUE SPACES. 


Code:

 PERFORM                                   
     VARYING WS-NDX FROM 1 BY 1           
     UNTIL WS-NDX > 6                     
                                           
         INSPECT WS-STR-DEFN(WS-NDX)       
             TALLYING WS-TALLY-CTR FOR     
                 ALL 'X'                   
 END-PERFORM


WS-TALLY-CTR will give you no. of occurance of the 'X'.
Back to top
View user's profile Send private message
pravinmaliye

New User


Joined: 28 Aug 2006
Posts: 9
Location: pune

PostPosted: Thu Oct 12, 2006 7:23 pm
Reply with quote

it is possible using inspect
but can it possible using search all
Back to top
View user's profile Send private message
MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Thu Oct 12, 2006 9:32 pm
Reply with quote

SEARCH ALL is a Binary search and table need to have ordered elements.
Only one WHEN clause can be used with SEARCH ALL.
Search condition can only be EQUAL.
If this search is for a particular string for the length of the field in the KEY field, then Yes otherwise NO.I don't think you can search for a string in whole table using SEARCH ALL.

Even with SEARCH, you can have WHEN clause for length of the field but cannot search whole table. From my example this condition will not work
WHEN WS-STR-DEFN-FLD(TAB-INDX) EQUAL 'X' as field is defined as 30 bytes. So if we redefine each element to be equal to search string length then it will work.

Hope i am clear.
Back to top
View user's profile Send private message
surya_pathaus

Active User


Joined: 28 Aug 2006
Posts: 110

PostPosted: Fri Oct 13, 2006 7:10 pm
Reply with quote

Hi Pravin,

I think this can work.

Perform "search all" until max-indx which is declared in depending on clause of table.

TABLE WILL BE DECLARED AS:
Code:
05 WS-TABLE OCCURS 1 TO 9999 TIMES     
                   DEPENDING ON MAX-IDX
                   ASCENDING KEY IS KEY     
                   INDEXED BY TABLE-IDX.         

PERFORM TABLE UNTIL TABLE-INDX >= MAX-INDX
   SEARCH ALL
        WHEN KEY(TABLE-INDX) = STRING
                  ADD 1             TO COUNT
   END-SEARCH
    set table-indx          up by 1
END-PERFORM.

Once "Search all" completes table-indx will be set to the indx where your string is found. Next time when "Search all" performed it will start search from the next indx.
Back to top
View user's profile Send private message
pravinmaliye

New User


Joined: 28 Aug 2006
Posts: 9
Location: pune

PostPosted: Sun Oct 15, 2006 10:21 pm
Reply with quote

thanks a lot
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 Load new table with Old unload - DB2 DB2 6
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 Pulling a fixed number of records fro... DB2 2
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top