Application Development and Automation 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: 
Read only

Any Function Module to convert from string to Packed Decimal.

dhinesh_thirugnanam
Contributor
0 Likes
1,720


Hi,

Any Function module to convert from String to Packed decimal?

String value : "15-.00"

2 REPLIES 2
Read only

Former Member
0 Likes
1,055

Hi,


you could check for some conversion FM, e.g. BAPI_CURRENCY_CONV_TO_EXTERNAL / INTERNAL, or PP_CATT_CONVERT_DECIMAL_POINT.



BR,

EH

Read only

rajkumarnarasimman
Active Contributor
0 Likes
1,055

Hi Dhinesh,

Here in the string Negative sign comes inbetween the value looks like the below.

15-.00

  • First replace the sign to the front as shown below.

Ex:


data Str_value type string value "15-.00".

data dec_value type p decimals 2.

"Check whether negative sign in the variable

if str_value CA '-'.

     "Replace Negative sign

     REPLACE ALL OCCURRENCES OF '-' IN str_value WITH ``.

   

     "Add the sign value into the first place

     concatenate '-' str_value into str_value.

endif.

Output

-15.00

  • And then convert the string to Decimal value

"Remove Empty space

condense str_value.

"Convert the value

dec_value = str_value.

Regards

Rajkumar.