‎2008 Jul 10 5:17 PM
Dear gurus,
Can i move the value from string type variable to type p variable with decimal.
scenario is i want move the value is ( -102334) from string type to the variable type p decimal 2.
Regards
R.Rajendran
‎2008 Jul 10 5:21 PM
Hi,
Yes you can.
data: str type string value '-1245',
p1 type p decimals 2.
p1 = str.
write:/ 'String = ', str,
/ 'Packed = ', p1.Output:
String = -1245
Packed = 1,245.00-
Regards,
Subramanian
‎2008 Jul 10 5:21 PM
‎2008 Jul 10 5:21 PM
Hi,
Yes you can.
data: str type string value '-1245',
p1 type p decimals 2.
p1 = str.
write:/ 'String = ', str,
/ 'Packed = ', p1.Output:
String = -1245
Packed = 1,245.00-
Regards,
Subramanian
‎2008 Jul 10 5:34 PM
if the computation done it is not working
data: str type string ,
strr type p decimals 2.
strr = 1234.
strr = strr * ( -1 ).
str = strr.
write:/ 'String = ', str,
/ 'Packed = ', strr.
Regards
‎2008 Jul 10 5:50 PM
Hi,
data: str type string ,
strr type p decimals 2.
strr = 1234.
str = strr.
strr = strr * ( -1 ).
write:/ 'String = ', str,
/ 'Packed = ', strr.You cannot compute on string. first convert to packed decimal and then do the computation.
Regards,
Subramanian
Edited by: Subramanian PL on Jul 10, 2008 9:50 AM
‎2008 Jul 10 5:23 PM
Hello Rajendra,
Yes you can move a value from String to a packed field with decimals 2.
Here is the code :
data: w_string type string value '-102334',
w_pack type p decimals 2.
w_pack = w_string.
After this assignment statement the value in w_pack = 102334.00-
I hope this answers your question.
Thanks,
Sushil Joshi
‎2008 Jul 10 5:28 PM
You can do this, but the assignment should be done within try..endtry block to capture error.
data: val_str type string.
data: val_p type p decimals 2.
val_str = `-102334`.
try.
val_p = val_str.
catch cx_root.
For error handling
endtry.
Write: val_p.
Regards,
Joy.