Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Regarding Search Option in COBOL

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

Active User


Joined: 01 Feb 2007
Posts: 113
Location: India

PostPosted: Wed Apr 11, 2007 8:55 am    Post subject: Regarding Search Option in COBOL
Reply with quote

05 WS-ARRAY-NAME.
10 WS-ARRAY-VALUES PIC X(04) OCCURS 100 TIMES
INDEXED BY WS-INDEX

And this array may have any number of values.

I had some constants like AB01, AB02, AB03, AB04, AB05, AB06

I want to search these constants in this array.
It should first search for AB01 in this array. If AB01 found no need to search for the other constants.
If CO01 not found, search for AB02. If AB02 found, no need to search for the other constants.
And Continues

I am using search option to search constant.

SET FOUND TO TRUE
Search WS-ARRAY-NAME
AT END SET NOT-FOUND TO TRUE
WHEN WS-ARRAY-VALUES(WS-INDEX) = AB01
MOVE AB01 TO WS-OUTPUT
END-SEARCH

If NOT-FOUND
SET FOUND TO TRUE
Search WS-ARRAY-NAME
AT END SET NOT-FOUND TO TRUE
WHEN WS-ARRAY-VALUES(WS-INDEX) = AB02
MOVE AB02 TO WS-OUTPUT
END-SEARCH
END-IF

If NOT-FOUND
SET FOUND TO TRUE
Search WS-ARRAY-NAME
AT END SET NOT-FOUND TO TRUE
WHEN WS-ARRAY-VALUES(WS-INDEX) = AB03
MOVE AB03 TO WS-OUTPUT
END-SEARCH
END-IF

Like this continues......
I want to make use of perform until by taking constants into an array so that the same code won't repeat.

But i not getting idea how to use PERFORM UNTIL as there will be two indexes.

TELL ME IF YOU HAD ANY IDEAS.......
Back to top
View user's profile Send private message

prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Wed Apr 11, 2007 9:27 am    Post subject: Re: Regarding Search Option in Mianframes
Reply with quote

bhaskar_kanteti wrote:
Hi,

05 WS-ARRAY-NAME.
10 WS-ARRAY-VALUES PIC X(04) OCCURS 100 TIMES
INDEXED BY WS-INDEX

And this array may have any number of values.

I had some constants like AB01, AB02, AB03, AB04, AB05, AB06

I want to search these constants in this array.
It should first search for AB01 in this array. If AB01 found no need to search for the other constants.
If CO01 not found, search for AB02. If AB02 found, no need to search for the other constants.
And Continues

I am using search option to search constant.

SET FOUND TO TRUE
Search WS-ARRAY-NAME
AT END SET NOT-FOUND TO TRUE
WHEN WS-ARRAY-VALUES(WS-INDEX) = AB01
MOVE AB01 TO WS-OUTPUT
END-SEARCH

If NOT-FOUND
SET FOUND TO TRUE
Search WS-ARRAY-NAME
AT END SET NOT-FOUND TO TRUE
WHEN WS-ARRAY-VALUES(WS-INDEX) = AB02
MOVE AB02 TO WS-OUTPUT
END-SEARCH
END-IF

If NOT-FOUND
SET FOUND TO TRUE
Search WS-ARRAY-NAME
AT END SET NOT-FOUND TO TRUE
WHEN WS-ARRAY-VALUES(WS-INDEX) = AB03
MOVE AB03 TO WS-OUTPUT
END-SEARCH
END-IF

Like this continues......
I want to make use of perform until by taking constants into an array so that the same code won't repeat.

But i not getting idea how to use PERFORM UNTIL as there will be two indexes.

TELL ME IF YOU HAD ANY IDEAS.......


I have not tried this but have you tried using OR operator after WHEN
WHEN WS-ARRAY-VALUES(WS-INDEX) = AB01 OR AB02 OR AB03
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Wed Apr 11, 2007 9:52 am    Post subject:
Reply with quote

Hi there,

U can Populate an array with AB01, AB02, AB03, AB04, AB05, AB06 lets take its table A

Then u can use following code

Code:
PERFORM VARYING I FROM 1 BY 1 UNTIL I>6 OR FOUND
   PERFORM VARYING J FROM1 BY 1 UNTIL J>100 OR FOUND
          IF  WS-ARRAY-VALUES[J] = A[I]
               SET FOUND TO TRUE
          END-IF
   END-PERFORM
END-PERFORM. 
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 Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts BWO option in VSAM blayek CICS 3 Sat Nov 05, 2016 10:47 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us