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
 
find no. of times entry exist in table using search all

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: find no. of times entry exist in table using search all
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    Post subject: Re: find no. of times entry exist in table using search all
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    Post subject: Re: find no. of times entry exist in table using search all
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    Post subject: Re: find no. of times entry exist in table using search all
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    Post subject:
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    Post subject: Re: find no. of times entry exist in table using search all
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    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 Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm
No new posts how to see when the last read access ... Mike 1304 DB2 1 Tue Sep 12, 2017 7:52 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 PC (UTF-8) -> z/OS (EBCDIC) -> ... prino All Other Mainframe Topics 4 Fri Sep 01, 2017 1:47 am
No new posts Repeat part of record multiple times Learncoholic DFSORT/ICETOOL 4 Tue Aug 29, 2017 11:33 am

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