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

How to covert data from x (18) to s9(15)99?


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

New User


Joined: 01 May 2006
Posts: 9

PostPosted: Fri Jan 05, 2007 2:02 pm
Reply with quote

Hi,

There is a feild amount defined with pic x(18). This amount is then passed to another variable which is defined with pic s9(15)v99. But, the amount is not passed from 1st feild to second. What is the solution?

Thanks
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Fri Jan 05, 2007 3:19 pm
Reply with quote

Hi !

S9(15)V9(02) could import only 17 numerics. 15 before & 2 after the comma. For 9(18) use S9(16)V9(02) please.

And if you use X(18) think of perhaps getting S0C7 !

Regards, UmeySan
Back to top
View user's profile Send private message
tangentray

New User


Joined: 30 Dec 2006
Posts: 20
Location: Kolkata, India

PostPosted: Fri Jan 05, 2007 5:27 pm
Reply with quote

I think just moving from an X(18) to a s9(15)V99 will work fine as long as the data contained in X(18) is all numeric. but there will be a justification issue as well as truncation issue.
As pointed by UmeySan since ur numeric variable will contain only 17 numeric bytes so one byte will be truncated.
Again X is left justified and 9 is right justified from decimal so when u move there will be a truncation issue.
If u take a similar example where u move a X(6) to a s9(3)v99:
when u have 999 in X(6) it actually conatains 999$$$ where $=space
after moving also the s9(3)v99 will contain 999$$$ and if u perform an arthmatic operation it will give SOC7.
But if your X(6) has 999999 then your s9(3)v99 will have 99999 and u will not get an error.
One other thing if you cosider size-wise then X(18) is 18 bytes and s9(15)v99 is also of 18 bytes (17 + 1 for the sign).
The best way is to avoid moving X to 9 but if it cannot be avoided then u can use the following psedocode to handle:
unstring X(18) delimited by space in another X(18) var
move the second X(18) var to s9(16)v9
check s9(16)v99 is numeric or not before further action.
Back to top
View user's profile Send private message
perez_a

New User


Joined: 02 Feb 2006
Posts: 25
Location: Italy

PostPosted: Fri Feb 02, 2007 5:01 pm
Reply with quote

Hi niharika,
if you put in your x(18) var a number with the comma
ex: 123456789112345,12
you can use this code:

01 x-num pic x(18).

01 x-num-red redefines x-num.
05 x-num-int pic x(15).
05 filler pic x(01).
05 x-mun-dec pic x(02).

01 w-int pic 9(15).
01 w-dec-temp pic 9(2).
01 w-dec pic 9v9(02).

01 number pic 9(15)v9(2).

procedure division.

move '123456789112345,12' to x-num
move x-num-int to w-int
move x-num-dec to w-dec-temp
compute w-dec = w-dec-temp / 100
compute number = x-num-int + w-dec


Alex
Back to top
View user's profile Send private message
sachin_star3
Warnings : 1

New User


Joined: 30 Sep 2006
Posts: 78
Location: pune

PostPosted: Mon Feb 05, 2007 2:10 am
Reply with quote

YOU CANT MOVE THE ALPHANUMERIC TO NUMERIC BUT VICE-VERSA IS NOT POSSIBLE,BUT THE ALPHANUMERIS CONTAINS ONLY NUMERIS THEN IT CAN POSSIBLE

EXAMPLE:
01 ABC PIC X(18).
01 DEF REDEFINES ABC PIC S9(15)V9(2)
==================================
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 How to save SYSLOG as text data via P... All Other Mainframe Topics 2
No new posts Store the data for fixed length COBOL Programming 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top