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?
Joined: 30 Dec 2006 Posts: 20 Location: Kolkata, India
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.