View previous topic :: View next topic
|
Author |
Message |
Nike123
New User
Joined: 13 Mar 2008 Posts: 3 Location: Mumbai
|
|
|
|
Code: |
PERFORM WITH TEST BEFORE
VARYING fda-pure-ind FROM fda-pure-max BY -1
UNTIL
(fda-pure-ind < 2)
OR
(pure-from-date IN tpapure (fda-pure-ind)
<= prerec-today IN CSCDATE2)
END-PERFORM |
Please let me know how I can replace this piece of code by search verb |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello Nike and welcome to the forums,
You need to post the code showing the array definition as well as anything else that will hrlp us understand your requirement (i.e. why does the current process work from the highest entry to the lowest?
Yes, you probably can get what you want using SEARCH or SEARCH ALL. |
|
Back to top |
|
|
Nike123
New User
Joined: 13 Mar 2008 Posts: 3 Location: Mumbai
|
|
|
|
Hi Dick,
The layout of the table is as follows
Code: |
01 CSCPPURE.
03 FDA-PURE-MAX PIC S9(4) COMP.
03 FDA-PURE-IND PIC S9(4) COMP.
03 TPAPURE OCCURS 1000 TIMES
DEPENDING ON FDA-PURE-MAX
IN CSCPPURE
ASCENDING PUAG-SEQ-NO
IN TPAPURE
IN CSCPPURE
ASCENDING RES-CODE
IN TPAPURE
IN CSCPPURE
ASCENDING POAU-CODE
IN TPAPURE
IN CSCPPURE
DESCENDING PURE-FROM-DATE
IN TPAPURE
IN CSCPPURE
INDEXED BY TPAPURE-IX.
05 PUAG-SEQ-NO PIC S9(4) COMP-3.
05 RES-CODE PIC X(4).
05 POAU-CODE PIC X(10).
05 PURE-FROM-DATE PIC S9(8) COMP-3.
05 PURE-TO-DATE PIC S9(8) COMP-3.
05 PURE-REG-DATE PIC S9(8) COMP-3.
05 PURE-CHNG-DATE PIC S9(8) COMP-3. |
I feel since the date is in descending order, the row with the latest date satisfying the criteria is to be picked up. Please let me know, is it possible thru search in cobol without changing the sort order.
Thanks for all ur help. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
If you would bother to read the documentation, you would find that if the table is sorted (according to your keys), then a binary search (search all) would work.
Depending upon the number of items in your internal cobol table, a SEARCH ALL would be more efficient that suffeling thru. But, if all you hits are within the first (or last) 10 or 20, suffeling would probably be faster.
but, you would have to test, your environment, your data. |
|
Back to top |
|
|
Nike123
New User
Joined: 13 Mar 2008 Posts: 3 Location: Mumbai
|
|
|
|
Hi,
Search All will not work since the index is one of the search criterias. Also the second criteria of pure-from-date is "<=", which cannot be taken while usin search all.
I need to decrease the index of the table in a reverse order. I am not aware if we can do this. I have already tried.
Is the reversing of sort order only the way out.
Please pitch in with ur ideas
Thanks |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
since FDA-PURE-IND does/will not change during a search of the internal cobol table, why are you wasting time interrogating it inside your search loop?
you can increment and decrement internal cobol table indexes.
what is your problem? |
|
Back to top |
|
|
|