cancel
Showing results for 
Search instead for 
Did you mean: 

How to print space as thousand seperator and comma as decimal seperator

Former Member
0 Kudos

Hi All,

I have requirement where I need to print the amounts with space as thousand seperator and comma as decimal seperator.

I have a field wrshb which is of type mhnd-wrshb. currently I am printing this. In the adobe layout I have declared this coloumn as Decimal field.

Now in the output it is printing as comma as thousand seperator and dot as decimal seperator.

For example ,currently the value is printing as 32,811.41

but I want the amount as 32 811,41

I have declared the variable as char16,  using write statement in the interface I moved the value from currency field to char field.

Then in debugging i checked the value comes as 32,811.41 and it goes to dump with teh reason-cannot interpret as a number.

Can anyone help me in fixing this?

Thanks and Regards,

Karthik Ganti.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Karthik,

You don't need a variable, simply add the decimal field to your form and in the object pallete under field tab there is a pattern pushbox, there you can change the way your value will be displayed.

Former Member
0 Kudos

Hi Adam,

Thank you. I have tried using that already. But still it didnot work.

If I use number.integer, it  gives output as rounding value, will not give exact value

If I use number.decimal, it  gives output as . as thousand and , as decimal seperator

If I use number.currency, it  gives prints currency symbol before the amount or after the amount

If I use number.percent, it  gives prints % symbol after the amount.

Thanks and Regards,

Karthik Ganti.

Former Member
0 Kudos

Use a custom pattern, for instance:

num{z zzz zz9.zzz}

And change the Locale to one that uses comma in their decimal spot, for instance italian.

I believe that will give you the desired output

Former Member
0 Kudos

Hi Adam,

When i try to use the above pattern, it says invalid pattern

Could you pelase be more specific on the pattern ?

Amount should be printed as 32 811,41.

Thanks and Regards,

Karthik Ganti.

Former Member
0 Kudos

Hi Karthik,

Please apply the following steps:

- Click on Patterns

- Under display->select type: choose a type that looks similar to your desired output, meaning one that has thousands and a decimal point. notice that the pattern on the right hand side of the window changes as you change types.

- Change the pattern so that the rightmost period "." will stay unchanged and the next comma you should change to space.

- After that change the Locale to one that uses commas instead of periods in the decimal spot.

In the end your window should look like this:

My cursor in the picture is pointing at the type i used as base.

If you add a default value to your field then you'll be able to see the sample field change as you change the pattern which will help you.

Former Member
0 Kudos

Hi Adam,

Thank you. I have selected the locale as viewers lcoale and given the above format.

I am getting the correct format. But the amount is getting round off.

Actual amount  in debuggin is 68083.67. It should be printed as 68 083,67.

But now it is pritning as 68,084 which is wrong.

I have given the pattern which you have pasted above.

Thanks and Regards,

Karthik Ganti.

Former Member
0 Kudos

Can you post a screenshot of the pattern window? itll be easier for me to find out whats wrong.

Former Member
0 Kudos

Please find the above screenshot. Output values are getting round off as i said above.

Please help me out.

Thanks and Regards,

Karthik Ganti.

Former Member
0 Kudos

After the number 9 change from comma to period and it will work.

Former Member
0 Kudos

Hi I have changed it to perod from comma after 9.

Some values are correct, but some are not pritning correctly. Please find the below screenshot.

In the above 60 083.67 is printing correctly. but if you see value 633,312.00. Actually it should be 633 312.00.

But also in the above values comma should be decimal seperator but not the period.

Please help me out.

Former Member
0 Kudos

I do not mean to be offensive but you are not using your head.

Try to understand the tool which youve just used!

Look at the pattern you created: zz zz9.zzz

What does it mean?

Each z and the 9 represents a number that can be entered. This pattern has 5 numbers, then a decimal point, then 3 more numbers.

Your output is bigger than 5 numbers, simply increase the number of z to your expected output.

For instance if i knew my output will be 9 123 456 789,1234 My corresponding pattern would be:

z zzz zzz zz9.zzzz

Former Member
0 Kudos

Hi Adam,

In the above screen shot the first value is different and last 2 row values are different.

The format which is printed in the first row is correct. but still , should be there instead of period.

Can you please tell me why those values are printing different?

Thanks and Regards,

Karthik Ganti.

Former Member
0 Kudos

Let me repeat my previous post

Your output is bigger than 5 numbers, simply increase the number of z to your expected output.

For instance if i knew my output will be 9 123 456 789,1234 My corresponding pattern would be:

z zzz zzz zz9.zzzz

any number smaller than 9 123 456 789,1234 Will still fit into the pattern.

Your pattern should be as large as your largest expected output.

Please reward points if I was helpful

Adam

Former Member
0 Kudos

Hi Adam,

Thanks a lot, it is working.Now I am able to print the value as  68 083.67.

But i need the output as 68 083,67. I mean comma should be the decimal operator.

Is it possible ?

Also one more thing i wanted to print till 2 decimals. for example in my screenshot there is a

value 2 373.8.

Is it possible to make it as 2373,80 ?

I have learnt many things here, will surely reward you for the knowledge which you have shared.

Thanks and Regards,

Karthik Ganti.

Former Member
0 Kudos

Hi Adam,

Could you please kindly help me out in the above case.

Thanks and Regards,

Karthik Ganti.

Former Member
0 Kudos

Hello Gurus,

Can anyone help me out to print the value correctly with leading zeros in adobe form.

I need the output as 68 083,67. I mean comma should be the decimal operator.

Is it possible ?

Also one more thing i wanted to print till 2 decimals. for example in my screenshot there is a

value 2 373.8

Is it possible to make it as 2 373,80 ?

As of now I am using  pattern z zzz zzz zz9.zzzz. If i make it to z zzz zzz zz9,zzzz then the values are getting round off. for eample 68 083,67 is getting round off to 68 084.

Thanks and Regards,

Karthik Ganti.

Former Member
0 Kudos

Hi Karthis.

In order to change the period to comma you have to change the locale in the pattern window.

Try your locale first and if that doesn't work I know that Italian works.

and for the zero after the decimal point: Change the pattern to z zzz zzz zz9.99zz

The 9 means that if there is no input the value 0 will be shown.

Former Member
0 Kudos

Hi Adam,

Great...!!!! It is working.

It was working with Italian Locale. But one thing I wanted to know apart from this is, how do we know that which lcoale to be selected, when a particular pattern needs to be printed for us.

For example I wanted comma as a decimal seperator, you suggested me to go for Italian Locale or my lcoale.

Is it a trial and Error method ?

Thanks a lot, It was a good learning experience for me in this area for which I was new.

Thanks and Regards,

Karthik Ganti.

Former Member
0 Kudos

Hi again Karthik,

Glad to hear its working.

As for the locale, for me it was trial and error.

Former Member
0 Kudos

Hi Adam,

As per initial requirement, I have set the format such that the amount is printing in below format as required.

Locale---Italian.

Space as thousand seperator and comma as decimal seperator.

for example 1 234,45

As some of the Currencies will not have decimals, now users would like to print amount without decimals. For example in my case amount  printing in KRW ( Korean currency ) is also similar to the above format which is wrong.

for example Now amount is printing as 55 000,00. But actually it should be 550 000. Similarly for JPY currency also, as it doesnot haves decimals ( checked in TCURX table ).

I have written some logic in the interface. below is the logic.

WRITE:

    wa_mhnd1-wrshb to wa_item-wrshb CURRENCY WA_ITEM-WAERS.

*READ TABLE lt_tcurx INTO lwa_tcurx WITH KEY currkey = wa_item-waers BINARY SEARCH.

  IF sy-subrc  = 0.

  IF lwa_tcurx-currdec = '0'.

  REPLACE ',' WITH SPACE INTO WA_ITEM-WRSHB.

  REPLACE ',' WITH SPACE INTO WA_ITEM-WRSHB.
  else.
   REPLACE ',' WITH SPACE INTO WA_ITEM-WRSHB.
    REPLACE ALL OCCURRENCES OF '.' in  wa_item-wrshb WITH ','.
endif.

ENDIF.


a. when the write statement gets executed amount will be in ,. ( 1,234.45 )format. Then my logic gets executed correctly. In this company code is CH10 ( EUR ) and KR10.

b. But sometimes after the write statement gets executed amount will be in ., format ( 1.234.45 ). In this case my logic works, but gives the wrong value. In this case company code is VN10 ( EUR )

In both the cases currency is EUR.

Will the decimal format change accordingly based on the company code code currency.Can you please tell me why write statement behaved differently.

Do I need to change any locale in the adobe form, or any other logic to be written in interface. ?  I am trying it out from long time, but not able to fix it.

Can  you please help me how to achieve this ?

Thanks and Regards,

Karthik Ganti.

Answers (1)

Answers (1)

former_member206650
Active Participant
0 Kudos

hi  Karthik ,

go to su01 and check the Decimal Notation in defaults....





hope it helps .....

Former Member
0 Kudos

Hi Vishnu,

Thanks..I have already changed into the format which i require. But it is not working.

Thanks and Regards,

Karthik Ganti.

former_member206650
Active Participant
0 Kudos

hi,

have you tried to log off and on log in.....then check the value....

hope it helps....

Former Member
0 Kudos

Hi Vishnu,

Thanks. I tried, but still not working.

Thanks and Regards,

Karthik Ganti.