MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Type Casting

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
edkir98
Beginner


Joined: 27 Aug 2007
Posts: 102
Topics: 42
Location: Chennai

PostPosted: Wed Apr 22, 2009 1:19 pm    Post subject: Type Casting Reply with quote

not sure if this is a very basic question..but suppose i have a variable VAR1 defined as X(12) which extracts data from the table stored as a number value 9(8)V9(4). So in my program can i use the following

Code:
01 WS-CAST-AS-NUMBER.
   10 WS-NUMBER-X                     PIC X(8).
   10 WS-NUMBER      REDEFINES WS-NUMBER-X      PIC 9(8).
   10 WS-DOT                         PIC X(01).
   10 WS-DEC-X                   PIC X(04).
   10 WS-DEC         REDEFINES WS-DEC-X    PIC 9(04).


Code:
MOVE VAR1 TO WS-CAST-AS-NUMBER


So WS-NUMBER have the whole number part and WS-DEC have the decimal part correctly?
Will this work..
_________________
Thanks
Back to top
View user's profile Send private message Yahoo Messenger
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Wed Apr 22, 2009 1:21 pm    Post subject: Reply with quote

What happened when you tried it?
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
edkir98
Beginner


Joined: 27 Aug 2007
Posts: 102
Topics: 42
Location: Chennai

PostPosted: Wed Apr 22, 2009 1:47 pm    Post subject: Reply with quote

Its working.. because all values in the table are having 8 whole numbers/4 decimal numbers and i'm not authorised to edit a value in the table. but i just wanted to confirm if it would work for others as well... such as when it is 123.44 i would want WS-NUMBER to have 123 and WS-DEC to have 44
_________________
Thanks
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Apr 22, 2009 2:54 pm    Post subject: Reply with quote

edkir98 wrote:
I have a variable VAR1 defined as X(12) which extracts data from the table stored as a number value 9(8)V9(4)


Does the table store explicit decimal point? You are retrieving 12 bytes but if it has an explicit decimal point, the length is 13 (8+1+4). Also you are retrieving the table data into a character field it is left justified.

what happens if your your input is

Code:

1.1234
12.1234                                                           
123.1234
1234.1234
12345.1234
123456.1234
1234567.1234


Does your redefine work for it?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Terry_Heinze
Supermod


Joined: 31 May 2004
Posts: 391
Topics: 4
Location: Richfield, MN, USA

PostPosted: Sat Apr 25, 2009 2:29 pm    Post subject: Reply with quote

If VAR-1 is defined as a DB2 data type DECIMAL (12,4), then you need to MOVE VAR-1 TO WS-NUMBER where
Code:
01.
    05  WS-NUMBER              PIC S9(8)V9(4).
    05  redefines WS-NUMBER.
        10  WS-NUMBER-INTEGER  PIC  9(8).
        10  WS-NUMBER-DECIMAL  PIC S9(4).
You need to study the PICTURE and USAGE clauses and MOVE statements in the Language Reference manual.
_________________
....Terry
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group