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
 

 

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 how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
No new posts Join of more than one table dibyendumandal11111 DB2 6 Mon Feb 13, 2017 11:36 pm
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts How to find the first monday of the w... abdulrafi COBOL Programming 10 Fri Nov 25, 2016 3:24 pm


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