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

grouping decimal numbers

0 Likes
4,769

I have a value like dmbtr = 8000000.00 . So i need to write it to document in ths form ' 8 000 000.00 ' ,Can anyone please give any suggestions.
thanks in advance.

I have a value like dmbtr = 8000000.00 . So i need to write it to document in ths form ' 8 000 000.00 ' ,Can anyone please give any suggestions.
thanks in advance.

14 REPLIES 14
Read only

lenastodal
Product and Topic Expert
Product and Topic Expert
0 Likes
4,641

Hi and welcome to the SAP Community!

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers (if you haven't already), as it provides tips for preparing questions that draw responses from our members. For example, you can outline what steps you took to find answers (and why they weren't helpful) and share screenshots of what you've seen/done. The more details you provide, the more likely it is that members will be able to assist you.
Should you wish, you can revise your question by selecting Actions, then Edit (although once someone answers your question, you'll lose the ability to edit the question -- but if that happens, you can leave more details in a comment).

Finally, if you're hoping to connect with readers, please consider adding a picture to your profile as it encourages readers to respond to you. Here's how you do it: https://www.youtube.com/watch?v=F5JdUbyjfMA&list=PLpQebylHrdh5s3gwy-h6RtymfDpoz3vDS.

Best,
Lena

SAP Community Moderator


Join or subscribe to SAP Community Groups to stay up-to-date, including SAP TechEd Group.
Read only

FredericGirod
Active Contributor
4,641

is this layout correspond to the parameters of your users (trans. SU3) or this layout should be always like that what ever the user specify in this parameters ?

Read only

sabarna17
Contributor
0 Likes
4,641

I have assumed you are writting in ABAP

1. Use "write" syntax to change the format of DMBTR

2. Then use REPLACE Statement to replace the "," with space.

- or else use spilt command and use "Conact statement seperated by space".

Read only

0 Likes
4,641

bro if use write syntax , there write conv i(xxxx) to data(text), decimal part is lost. what i need to get is that '8 000 000.00'
yes i am coding in ABAP.

Read only

bharatpemmireddy
Participant
4,641

1) SET COUNTRY 'US'. is the most important step otherwise the WRITE statement will convert based on user parameters

2) Also note the ` ` back quotes in REPLACE otherwise it will not insert a blank

Tried with below code in my system and seems to be working.

Data: lv_dmbtr1 type dmbtr,

lv_conv type char50.
SET COUNTRY 'US'.
lv_dmbtr1 = ' 8000000.00'.

write lv_dmbtr1 to lv_conv.
CONDENSE lv_conv.

REPLACE ALL OCCURRENCES OF ',' IN lv_conv WITH ` `.

write lv_conv.

Read only

0 Likes
4,641

but outcome is 8 000 000 accroding your code, you can also check it out. code is skipping decimal part. output should be ' 8 000 000

.00'

Read only

0 Likes
4,641

Here is the output in my system for the above code

Read only

0 Likes
4,641

i changed decimal notation to this form, but still outcome si the same in MS word .

no grouping .

Read only

0 Likes
4,641

@frdric.girod yes for all users.

Read only

Sandra_Rossi
Active Contributor
0 Likes
4,641

This should be done automatically via user settings, not ABAP -> please answer Frederic question. If you have difficulties, can you explain what rendering technology you use? ("write" to what?)

Read only

Sandra_Rossi
Active Contributor
0 Likes
4,641

T005X-XDEZP = "Y" is not what the OP expects, it corresponds to the format:

8 000 000,00

SAP does not propose a number format for this format:

8 000 000.00
Read only

Sandra_Rossi
Active Contributor
0 Likes
4,641

Answer almost like Bharat, and see Sergei ABAP link for more information about string templates:

DATA(dmbtr_text) = replace( val = |{ dmbtr COUNTRY 'US' }| sub = ',' with = '.' ).

(make sure that US country has the format "# ### ###,##" in SM30 V_T005 - For information the number format of countries is stored internally in column XDEZP of table T005X, and value 'Y' is format "# ### ###,##")

Read only

0 Likes
4,641

I just optimized idea(code) of Bharat Pemmiredy.

data : lv_amount type dmbtr VALUE '8000000.00',
       lv_num TYPE char50 .
write lv_amount to lv_num DECIMALS 2.
condense lv_num.
write:/ lv_num.
Read only

0 Likes
4,641

In your code I don't see the SET COUNTRY statement.