Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: How to covert data from x (18) to s9(15)99?
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: 757
Location: Germany

PostPosted: Fri Jan 05, 2007 3:19 pm    Post subject:
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    Post subject:
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    Post subject: Re: How to covert data from x (18) to s9(15)99?
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    Post subject:
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    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 Paasing symbolic parameter to instrea... Anirudh Anand JCL & VSAM 0 Thu Jul 27, 2017 1:22 pm
No new posts Passing data from REXX to C programme... chong.zhou CLIST & REXX 3 Wed Jul 26, 2017 9:11 pm
No new posts Passing data from REXX to C programme... chong.zhou All Other Mainframe Topics 0 Wed Jul 26, 2017 4:55 pm
No new posts copying data without knowing location arunsoods DFSORT/ICETOOL 8 Thu Jul 20, 2017 1:03 pm
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us