09-10-2008 2:34 AM
Hi experts.
I need to convert technical type P to string and convert back to P.
I have a given a example at below.
Data : val(12) type p decimals 2 value '192.68'.
I need to convert to string so i can add (192.68).
Later i need to convert back to P and updated into a internal table.
Thank you very much.
regards,
saravannan.s
09-10-2008 3:03 AM
data: amt_c(20) type c.
parameters amt type p decimals 2.
write amt to amt_c.
write:/ amt_c.
clear amt.
move amt_c to amt.
write:/ amt.
09-10-2008 3:03 AM
data: amt_c(20) type c.
parameters amt type p decimals 2.
write amt to amt_c.
write:/ amt_c.
clear amt.
move amt_c to amt.
write:/ amt.
09-10-2008 3:11 AM
HI Booh.
Please refer to the below program.
data: amt_c(20) type c.
parameters: amt type p decimals 2.
write amt to amt_c.
write:/ amt_c.
concatenate '(' amt_c into amt_c.
clear amt.
move amt_c to amt.
write:/ amt.
but it is now giving me the error and it is getting terminated.
Please guide me.
09-10-2008 3:18 AM
you cant move string/character type to data type amt.
only numbers, . and negative sign
when writing use amt_c
Edited by: -=Bo0h=- on Sep 10, 2008 4:21 AM
09-10-2008 3:22 AM
Hi Booh ,
Do u have any idea how to solved it.
Because my requirment is i need to remove the negative and add a ( ) to the value.
But the original value is in type P and how to add bracket ( ) to the value.
Please guide me if you have any idea.
regards,
09-10-2008 3:27 AM
where are you using the amt type p? in display? if yes use the type c in displaying report. but if in calculation no way you can use this because you'll be encountering run-time.
09-10-2008 3:24 AM
1. For conversion of P to string you can simply move the value P to char field.
2. For converting char field back to P use FM RRBA_CONVERT_PACKED_NUMBER. Pass I_DECIMALS - No. of decimals you need, I_DECIMAL_MARK as default decimal notation( for EU users decimal notation is usually a Comma so be careful).
Hope this helps.
Amandeep