View previous topic :: View next topic
|
Author |
Message |
RAMA12
New User
Joined: 18 Aug 2006 Posts: 2
|
|
|
|
i created a working storage table and loading this table from Db2.
Below code for the working storage table.
[1) working storage table declaration.
01 WS-PRODCODE-BUILD-AREA.
05 WS-PRODCODE-BUILD-WORK.
10 FILLER PIC X(1506).
05 WS-PRODUCT-CODE REDEFINES WS-PRODCODE-BUILD-WORK.
10 WS-TABLE-PARMS.
15 WS-TP-IN-CTR PIC S9(04) COMP.
15 WS-TP-OCCURS PIC S9(04) COMP.
15 WS-TP-MAX-OCCURS PIC S9(04) COMP.
10 WS-PC-TABLE.
15 WS-PC-TBL-ENTRY OCCURS 250 TIMES
ASCENDING KEY IS WS-PROD-CODE
INDEXED BY WS-PC-NDX.
20 WS-PROD-CODE PIC X(02).
20 WS-PROD-EXTERN-TYPE PIC X(01).
20 WS-PROD-ACE-TYPE PIC X(02).
20 WS-PROD-NPSL-IN PIC X(01).
2)Reading the values from the table
PERFORM VARYING WS-PC-NDX FROM 1 BY 1 UNTIL
WS-PC-NDX GREATER THAN 250 OR NO-MORE-PROD-CODE-RECS
EXEC SQL
FETCH CURPRCD
INTO :TSPROD-PROD-CODE,
:TSPROD-EXTERN-TYPE,
:TSPROD-ACE-TYPE,
:TSPROD-NPSL-IN
END-EXEC
3)Binary search condition .
i am not at all able to enter in to the when condition. i.e. WHEN condition is not satisfying if the both values all equal
PERFORM VARYING WS-PC-NDX FROM 1 BY 1 UNTIL WS-PC-NDX > 250
SEARCH ALL WS-PC-TBL-ENTRY
AT END SET PROD-CODE-NT-FND TO TRUE
WHEN WS-PROD-CODE(WS-PC-NDX) = CBE-TSYS-PRODUCT-CODE
IF WS-PROD-NPSL-IN(WS-PC-NDX) = 'Y'
IF (WS-PROD-EXTERN-TYPE(WS-PC-NDX) = 'E' AND
WS-PROD-ACE-TYPE(WS-PC-NDX) = 'MC' OR
'PL' OR 'VC')
MOVE 'C' TO M2-PORTFOLIO
ELSE
MOVE 'O' TO M2-PORTFOLIO
END-IF
END-IF
END-SEARCH
END-PERFORM.
Query :- I am not at all able to enter in to the when condition. i.e. WHEN condition is not satisfying if the both values all equal |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
RAMA12 wrote: |
i created a working storage table and loading this table from Db2.
PERFORM VARYING WS-PC-NDX FROM 1 BY 1 UNTIL WS-PC-NDX > 250
END-PERFORM.
|
1. Is the data being loaded into the table in sequence, is there an order by clause on your cursor? What if you load less than 250 entries into the table?
2. Why are you performing the search 250 times, WS-PC-INDX is the index that the search all will use to conduct it's search? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Is the data being loaded into the table in sequence |
Is the data being loaded into the table at all? The perform with the fetch increments the index, but i see no table entry "loaded". The variables from the db2 fetch would have data, but how does it get into the array?
FWIW - i may misunderstand something, but when you use SEARCH ALL, you should not need to iterate in your code (as Craig mentioned). |
|
Back to top |
|
|
RAMA12
New User
Joined: 18 Aug 2006 Posts: 2
|
|
|
|
Thanks for you r suggestion really it was very helpful for me.
_Krishna |
|
Back to top |
|
|
smitha T
New User
Joined: 04 Jun 2008 Posts: 2 Location: Hyderabad
|
|
|
|
Hi all,
iam facing similar problem while using binary search.
Here is the code:
2225-SEARCH-WS-EVENT.
MOVE 'N' TO WZBET-TBL-EOF-IND
SET ET-NDX TO 1
SEARCH ALL WZBET-TBL-ENTRY
AT END
MOVE 'Y' TO WZBET-TBL-EOF-IND
MOVE WZBET-TEST-DFLT TO WS-ZBET-SINGLE-ROW-X
WHEN WZBET-TBL-KEY(ET-NDX)
= WSET-TBL-KEY
MOVE WZBET-TBL-ENTRY(ET-NDX)
TO WS-ZBET-SINGLE-ROW
END-SEARCH.
Here WZBET-TBL-ENTRY is loaded with table values using cursor. Order by clause is used for it. When i replaced search all with Search, it worked fine.
SEARCH WZBET-TBL-ENTRY VARYING ET-NDX
AT END
MOVE 'Y' TO WZBET-TBL-EOF-IND
MOVE WZBET-TEST-DFLT TO WS-ZBET-SINGLE-ROW-X
WHEN WZBET-TBL-KEY(ET-NDX)
= WSET-TBL-KEY
MOVE WZBET-TBL-ENTRY(ET-NDX)
TO WS-ZBET-SINGLE-ROW
END-SEARCH. Can somebody tell me what is the error in using binary search?Pls let me know if i need to provide any data. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
you need to start a new thread. and learn how to use BBcode |
|
Back to top |
|
|
|