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

Removing comma from a table field.

Former Member
0 Likes
2,555

Hi People,

I have to remove comma from the currency and weight fields How can do that? Can somebody please help? Also if I have to round off a number how can I do that?

Thanks & regards,

AM

1 ACCEPTED SOLUTION
Read only

viveksagar_sareen
Product and Topic Expert
Product and Topic Expert
0 Likes
1,575

Hi ,

There are couple ways of doing it

The best one is to use 'REPLACE' command .... check the syntax by pressing F1 , and replace comma by space and then use 'CONDENSE' statement.

Regards ,

vivek

7 REPLIES 7
Read only

viveksagar_sareen
Product and Topic Expert
Product and Topic Expert
0 Likes
1,576

Hi ,

There are couple ways of doing it

The best one is to use 'REPLACE' command .... check the syntax by pressing F1 , and replace comma by space and then use 'CONDENSE' statement.

Regards ,

vivek

Read only

Former Member
0 Likes
1,575

To round:

type "round" in your ABAP.

Put your cursor over "round".

Press F1

Read only

Former Member
0 Likes
1,575

Please understand that commas / decimals are displayed in currency amount / qty fileds are displayed as per the user profile defaults ...and does not exactly exist in database tables ...in db table it is kept simply as a number with no comma / decimal only when you display it using any utility SE16 / Se11 / your programs...then you see the comma / decimals as per your user profile defaults.

In case you want the comma to be removed within your program , you can copy the amount value into a char variable and then use REPLACE.

You can check ROUND , FLOOR or CEIL function commands and check which one is suitable for your case.

Press F1 to see the details of these commands.

Cheers,

Ram

Read only

0 Likes
1,575

The 'TRANSLATE' statement is very useful, especially for what you have to do.

TRANSLATE w_amount using ', '.

Regards,

Erwan.

Read only

Former Member
0 Likes
1,575

Hi,

Try this out

REPORT demo_data_function .

  • numeric datatypes

DATA n TYPE p DECIMALS 2.

DATA m TYPE p DECIMALS 2 VALUE '-5.55'.

n = abs( m ). WRITE: 'ABS: ', n.

n = sign( m ). WRITE: / 'SIGN: ', n.

n = ceil( m ). WRITE: / 'CEIL: ', n.

n = floor( m ). WRITE: / 'FLOOR:', n.

n = trunc( m ). WRITE: / 'TRUNC:', n.

n = frac( m ). WRITE: / 'FRAC: ', n.

Try excuting this program.

Read only

Former Member
0 Likes
1,575

Hi,

Try this out

REPORT demo_data_function .

  • numeric datatypes

DATA n TYPE p DECIMALS 2.

DATA m TYPE p DECIMALS 2 VALUE '-5.55'.

n = abs( m ). WRITE: 'ABS: ', n.

n = sign( m ). WRITE: / 'SIGN: ', n.

n = ceil( m ). WRITE: / 'CEIL: ', n.

n = floor( m ). WRITE: / 'FLOOR:', n.

n = trunc( m ). WRITE: / 'TRUNC:', n.

n = frac( m ). WRITE: / 'FRAC: ', n.

Try excuting this program.

Also try this one to round off

DATA: pack TYPE p DECIMALS 0.

pack = 1 / 3 * 3.

WRITE pack.

O/p will be 1.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,575

Hi,

Check this sample.

data v type mara-ntgew value '56.6'.

data cur(15) value '56,000'.

data int type i.

<b>int = v.</b>

write int.

<b>replace ',' with '' into cur.</b>

write cur.