IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

88 Level with Multiple Value in WHERE Clause


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 310
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Tue Nov 12, 2013 2:40 pm
Reply with quote

Hi All,

Can I use an 88 Level variable which can have multiple values in a WHERE clause.
For Ex: My 88 Level variable definition is as:

Code:
05  WS-STATUS                             PIC S9(2) COMP-3.   
    88  WS-VALID-STATUS                   VALUES +01, +02, +03,
                                                 +04, +05, +08,
                                                 +09, +10, +11
                                                 +12.         
    88  WS-INVALID-STATUS                 VALUES +06, +07.


I know, I can use WHERE VALUE IN, but I was just wondering if I can use it like this:
Code:
            SET WS-VALID-STATUS           TO TRUE.

And in SQL Query as:
Code:
            WHERE STATUS = :WS-STATUS.


I just can't test it now, that's why I'm posting here.

Thanks
Neeraj.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Tue Nov 12, 2013 2:56 pm
Reply with quote

No
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 310
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Tue Nov 12, 2013 3:39 pm
Reply with quote

Thanks GuyC
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7310
Location: Inside the Matrix

PostPosted: Tue Nov 12, 2013 6:55 pm
Reply with quote

When you SET ... TO TRUE the data-name gets the first value from the 88, so that the 88 will be "true". The data-name can only have one value.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 310
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Tue Nov 12, 2013 7:41 pm
Reply with quote

Thanks Bill.
But then how does this work in IF statements.

Code:
           MOVE +2                                TO WS-STATUS.

           IF WS-VALID-STATUS
           .......................
           .......................
           ELSE
           .......................
           .......................
           END-IF.


I used it like below and it's working.
Code:
            WHERE STATUS IN ( :WS-STATUS)


Thanks.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Tue Nov 12, 2013 8:04 pm
Reply with quote

Hello,

Quote:
I used it like below and it's working.

For which values of :ws-status?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8569
Location: Dubuque, Iowa, USA

PostPosted: Tue Nov 12, 2013 10:56 pm
Reply with quote

You have made a fairly common mistake. WS-VALID-STATUS and WS-INVALID-STATUS are not variable in COBOL They are called conditionals and cannot be considered variables. Hence you cannot use one as a host variable. If you expand your IF statement by using the LIST option in your COBOL compile, you will see your IF WS-VALID-STATUS actually expands into a series of pseudo-assembler statements, each one comparing the value of WS-STATUS against one of the values the conditional references.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 310
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Wed Nov 13, 2013 10:44 am
Reply with quote

Thanks everyone for your valuable suggestions.

I didn't get a chance to test properly. May be I have missed tsomething. We are having some problem with the Changeman. Yesterday they fixed the problem, but that was momentary. So currently I can't compile or bind, until the problem is resolved.

I will do a proper testing and update my results here.

Thanks again.
Neeraj.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Nov 13, 2013 2:27 pm
Reply with quote

only thing that slightly looks like what you want is :

Code:
01  WS-VALID-STATUS-INLIST.
    05  WS-VS-01        PIC S9(4)  COMP value +04.
    05  WS-VS-02        PIC S9(4)  COMP value +05.
    05  WS-VS-03        PIC S9(4)  COMP value +08.
    05  WS-VS-04        PIC S9(4)  COMP value +09.
    05  WS-VS-05        PIC S9(4)  COMP value +10.
    05  WS-VS-06        PIC S9(4)  COMP value +11.
    05  WS-VS-07        PIC S9(4)  COMP value +12.
...
EXEC SQL
   ...
   WHERE STATUS IN (:WS-VALID-STATUS-INLIST)
END-EXEC
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 310
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Mon Nov 18, 2013 1:05 pm
Reply with quote

Hi All,
Quote:
I used it like below and it's working.
Code:
            WHERE STATUS IN ( :WS-STATUS)

Finally the Changeman problem was resolved and I tested my program. I was wrong. It was not giving me desired output.

I used the way GuyC has suggested and it's working fine.

Thank you all for your help and guidance.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Mon Nov 18, 2013 7:37 pm
Reply with quote

Good to hear it is working - thank you for the testing and followup icon_smile.gif

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Selecting multiple constant records DB2 3
No new posts Creating a single-record file with CO... DFSORT/ICETOOL 8
No new posts Read 4MB message and split into multi... COBOL Programming 9
No new posts NOT IN clause in COBOL pgm COBOL Programming 8
No new posts Multiple Sums in one File SYNCSORT 2
Search our Forums:

Back to Top