MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem using search all even when table sorted

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
sinduja
Beginner


Joined: 20 Jun 2005
Posts: 29
Topics: 14

PostPosted: Thu May 11, 2006 9:54 am    Post subject: Problem using search all even when table sorted Reply with quote

Hi all,

I am using a SEARCH ALL in my program. There are 2 ascending keys in the table being searched. The working storage table is loaded from a DB2 table. I have selected the fields from the DB2 table giving an order by clause and then loaded it to the working storage table. But when I do a search, the when condition fails for some fields (even though the searched field is present in the table).

Can some one please tell me where i am going wrong?

Code:


01  WS-TEMP-TABLE.                                           
    05 WS-FIELD-DESC-TBL    OCCURS 500 TIMES                 
                            ASCENDING WS-TBL-GENESYS-FIELD-ID
                                      WS-TBL-FIELD-TYPE     
                            INDEXED BY WS-FIELD-DES-TBL-IND.
        10 WS-TBL-GENESYS-FIELD-ID  PIC X(04)  VALUE SPACES.
        10 WS-TBL-FIELD-DESC        PIC X(48)  VALUE SPACES.
        10 WS-TBL-FIELD-TYPE        PIC X(01)  VALUE SPACES.

* table loaded from the cursor below
EXEC SQL                                 
DECLARE FIELD_DESC_CSR CURSOR FOR         
SELECT                                   
         DISTINCT F.GENESYS_FIELD_ID     
         ,F.FIELD_DESC                   
         ,F.FIELD_TYPE                   
FROM     BK_FIELD_DESC F                 
WHERE    F.GENESYS_FIELD_ID > ' '         
AND      F.INC_CLIAUD_REPORT = 'A'       
ORDER BY F.GENESYS_FIELD_ID, F.FIELD_TYPE
END-EXEC                 

SEARCH ALL WS-FIELD-DESC-TBL AT END                                                     
   CONTINUE                                               
WHEN WS-TBL-GENESYS-FIELD-ID(WS-FIELD-DES-TBL-IND) =       
                           DCL-CHGHST-PRT-FIELD-ID         
     AND WS-TBL-FIELD-TYPE(WS-FIELD-DES-TBL-IND) = 'P'     
   MOVE DCL-CHGHST-PRT-CTRN-GRP-NUMBER                     
                                 TO CLNT-MAINT-GROUP       
   MOVE DCL-CHGHST-PRT-FIELD-ID                           
                                 TO CLNT-MAINT-MNEMONIC   
   MOVE DCL-CHGHST-PRT-TRAN-KEY                           
                                 TO CLNT-MAINT-TRAN-KEY   
   MOVE WS-TBL-FIELD-DESC(WS-FIELD-DES-TBL-IND)           
                                 TO CLNT-MAINT-DESCRIPTION
   MOVE DCL-CHGHST-PRT-CHANGE-FROM-TXT                     
                                 TO CLNT-MAINT-OLD-VALUE   
END-SEARCH
 


FIELD_TYPE may have values 'P' or 'N'
some values like ZAT1, ZAT2, ZAT3 in the DCL-CHGHST-PRT-FIELD-ID cause the when condition to fail.

regards,
sinduja
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu May 11, 2006 10:01 am    Post subject: Reply with quote

sinduja

You are selecting distinct values from your DB2 table on 3 fields and your internal table is having just 2 fields and you are checking only 1 field in your search criteria. You need to have equal no: of key fields.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Mervyn
Moderator


Joined: 02 Dec 2002
Posts: 415
Topics: 6
Location: Hove, England

PostPosted: Thu May 11, 2006 2:26 pm    Post subject: Reply with quote

You also need to initialise any unused table entries to HIGH-VALUES.
_________________
The day you stop learning the dinosaur becomes extinct
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group