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
 
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: 120
Location: USA

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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Where is output from PARM ABEXIT (SNA... packerm CA Products 3 Thu Sep 28, 2017 4:06 pm
No new posts MQ command in option 6 of ISPF! Vignesh Sid All Other Mainframe Topics 3 Tue Sep 26, 2017 6:01 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am

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