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

Setting 88 level for COMP variable


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

New User


Joined: 12 Jul 2006
Posts: 24

PostPosted: Tue Oct 06, 2009 9:38 am
Reply with quote

Hi,

I'm trying to validate a SMALLINT variable from a DB2 table in my cobol program. I'm fetching it to a S9(04) COMP variable and have to validate against numeric values. If this is possible is the below code valid?

05 WS-NBR-FLG PIC S9(04) COMP.
88 WS-OLD-NBR VALUE 1,2,3.
88 WS-NEW-NBR VALUE 4,5,6,7.

Thanks & Regards,
Lalitha.
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: Tue Oct 06, 2009 10:24 am
Reply with quote

It depends on what the code is you are using. You've shown the field definitions but not the code.
Back to top
View user's profile Send private message
lalitha_gld

New User


Joined: 12 Jul 2006
Posts: 24

PostPosted: Tue Oct 06, 2009 11:31 am
Reply with quote

If I declare a table - 'TABLE' as

CL# Column name Data type

1 NBR SMALLINT

With the field definitions i had given earlier, this is how am planning to set my code :

EXEC SQL
DECLARE CRSR CURSOR FOR
SELECT NBR FROM TABLE
END-EXEC.

EXEC SQL
OPEN CRSR
END-EXEC.

EXEC SQL
FETCH CRSR
INTO :WS-NBR-FLG
END-EXEC.

EVALUATE TRUE

WHEN WS-OLD-NBR
<PROCESS ONE>

WHEN WS-NEW-NBR
<PROCESS TWO>
WHEN OTHER
PROCESS ERROR PARA TO WRITE ERROR RECORD
END-EVALUATE.


Would this be valid.Pls let me know.

Tx,
Lalitha.
Back to top
View user's profile Send private message
Raghu navaikulam

Active User


Joined: 27 Sep 2008
Posts: 193
Location: chennai

PostPosted: Tue Oct 06, 2009 12:33 pm
Reply with quote

Hi Lalitha

Try to use THRU clause in the 88 level.
Code:
05 WS-NBR-FLG PIC S9(04) COMP.
    88 WS-OLD-NBR VALUE 1 THRU 3.
    88 WS-NEW-NBR VALUE 4 THRU 7.


Regards
Raghunath
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Tue Oct 06, 2009 2:53 pm
Reply with quote

Using THRU is exactly the same as specifying the individual values to COBOL -- so there's no difference between the original posted code and your "revision", Raghunath. Specifying the values one way or the other is merely a personal preference.
Back to top
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Tue Oct 06, 2009 3:47 pm
Reply with quote

Lalitha,
Thats valid. I believe you can easily test this.
Back to top
View user's profile Send private message
santy
Warnings : 1

New User


Joined: 19 Jul 2007
Posts: 22
Location: mumbai

PostPosted: Tue Oct 06, 2009 4:33 pm
Reply with quote

Lalitha,

The procedure you are using above is the correct one. It will work.
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts How to load to DB2 with column level ... DB2 6
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts ISRSUPC search utility - using high l... TSO/ISPF 2
Search our Forums:

Back to Top