View previous topic :: View next topic
|
Author |
Message |
pravinmaliye
New User
Joined: 28 Aug 2006 Posts: 9 Location: pune
|
|
|
|
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 |
|
|
MFRASHEED
Active User
Joined: 14 Jun 2005 Posts: 186 Location: USA
|
|
|
|
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 |
|
|
pravinmaliye
New User
Joined: 28 Aug 2006 Posts: 9 Location: pune
|
|
|
|
it is possible using inspect
but can it possible using search all |
|
Back to top |
|
|
MFRASHEED
Active User
Joined: 14 Jun 2005 Posts: 186 Location: USA
|
|
|
|
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 |
|
|
surya_pathaus
Active User
Joined: 28 Aug 2006 Posts: 110
|
|
|
|
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 |
|
|
pravinmaliye
New User
Joined: 28 Aug 2006 Posts: 9 Location: pune
|
|
|
|
thanks a lot |
|
Back to top |
|
|
|