Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

conversion

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

6 REPLIES 6

Former Member
0 Kudos

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.

0 Kudos

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.

0 Kudos

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

0 Kudos

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,

0 Kudos

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.

Former Member
0 Kudos

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