Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Index in Search all

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
rammraju

New User


Joined: 05 Mar 2005
Posts: 65
Location: Hyderabad

PostPosted: Thu Oct 23, 2008 6:11 am    Post subject: Index in Search all
Reply with quote

Hi,
Can someone please let me know if the index variable used in a SEARCH ALL resets to the initial value when the WHEN condition satisfies?

I intend to use the occurence number when the conditon satisfies, is there way for this?

My Working Storage
Code:
01 WS-ARRAY.
   05 WS-TABLE-DATA OCCURS 50 TIMES
                      ASCENDING KEY IS WS-DATA-ITEM1,
                                       WS-DATA-ITEM2
                      INDEXED BY WS-INDEX.
      10 WS-DATA-ITEM1      PIC X(10)  VALUE SPACES.
      10 WS-DATA-ITEM2      PIC X(10)  VALUE SPACES.
      10 WS-DATA-ITEM3      PIC X(01)  VALUE SPACES.


My Search all

Code:
SEARCH ALL WS-TABLE-DATA
   AT END
      PERFORM PROCESS-DATA-NOT-FND
   WHEN WS-DATA-ITEM1(WS-INDEX) = WS-DATA-ITEM1 AND
        WS-DATA-ITEM1(WS-INDEX) = WS-DATA-ITEM2
        PERFORM WRITE-CONTROL-RPT
END-SEARCH

WRITE-CONTROL-RPT.
   MOVE 'X'              TO  WS-DATA-ITEM3(WS-INDEX1).

WRITE-EXIT.
   EXIT.


I am trying to move "X" to WS-DATA-ITEM3 in the occurence when there is a hit, but the program is not behaving the way I am expecting. No matter what the occurence is, the program is always populating "X" in a particular position.

Can someone help in how to populate "X" in WS-DATA-ITEM3 in the occurence when there is a hit?

Thanks in advance
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Oct 23, 2008 6:30 am    Post subject:
Reply with quote

Hello,

Maybe there is something i am missing, but if the SEARCH is successful the position in the array that satisfied the WHEN is left in the index for use in processing.

If the search fails, the value in the index should not be used - it is not predictable.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Thu Oct 23, 2008 7:20 am    Post subject:
Reply with quote

Unless you "typo'd", you have duplicate names assigned to your table fields and the ones you're comparing to. I'm assuming a typo, since I believe what you have keyed would give you a compile error. Your coding looks correct other than that. What happens in PROCESS-DATA-NOT-FND? You don't reference the index do you as Dick noted? Please paste the exact code.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8165
Location: East Dubuque, Illinois, USA

PostPosted: Thu Oct 23, 2008 7:58 am    Post subject:
Reply with quote

Your code segment didn't come from a working program, surely. You are testing the same variables with and without WS-INDEX (not to mention you use the WS-DATA-ITEM1 (WS-INDEX) twice) and then you're using another index variable WS-INDEX1 to set WS-DATA-ITEM3 so the code cannot work as presented.

Furthermore, if the code is exactly as presented, you're going to get some very unpredictable results since after the SEARCH ALL is done, the code falls through to the next statement ... which happens to set WS-DATA-ITEM3 to an X -- unless the search failed in which case who knows which occurrence of WS-DATA-ITEM3 gets set to X (or possibly none of them).

When you post code, post the exact code being used. You don't have to post extra code -- extract only the data definitions and PROCEDURE DIVISION statements that are relevant; if you don't include enough we'll let you know. But don't post something you've munged up from the original code.
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 HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Search for a string in many PDS KARTHIGADEVI CLIST & REXX 5 Fri Sep 08, 2017 2:32 pm
No new posts Confusion b/w index and subscript Deepak kumar25 Mainframe Interview Questions 7 Thu Aug 31, 2017 6:50 am
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us