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

Put comma separator to a string

Former Member
0 Likes
4,345

Hello everyone!

When I execute this:


DATA: myAmount TYPE p DECIMAL 2, myString TYPE string.

myAmount = 1234567.89.
myString = myAmount.

WRITE: myAmount, ' ; ', myString.

The output is 1,234,567.89 ; 1234567.89

How can I put back the comma separators to the string? Is there a built-in function that can do this or do I need to write my own?

Thanks a lot guys!

Message was edited by:

Ricardo Caliolio

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,816

hi,

u have to put comma by ur own.

Regards,

NRT

15 REPLIES 15
Read only

Former Member
0 Likes
2,816

Hi,

You can set the currency defaults in Syetem => User Profilr => Own Data.

This currency format will be used for display.

regards

Read only

0 Likes
2,816

> Hi,

> You can set the currency defaults in Syetem => User

> Profilr => Own Data.

> This currency format will be used for display.

>

> regards

Hello. But this only applies to numerical data types and not strings... _

Thanks!

Read only

Former Member
0 Likes
2,816

Instead of this :

myString = myAmount.

Use this :

WRITE myAmount To myString .

Hope this helps you.

Read only

0 Likes
2,816

> Instead of this :

>

> myString = myAmount.

>

> Use this :

>

> WRITE myAmount To myString .

>

> Hope this helps you.

This is not working when I tried it but this one do:

MOVE myAmount TO myString.

However, it has the same result as:

myString = myAmount.

Thanks!

Read only

Former Member
0 Likes
2,816

hi,

goto System => User Profile => Set Data.

then output data for string variables displayed as u get for ur programs.

if helpful reward some points.

with regards,

suresh.

Read only

Former Member
0 Likes
2,816

hi

how did u get the output with ur code..

it gives dump...

Read only

0 Likes
2,816

> hi

> how did u get the output with ur code..

> it gives dump...

I think it is just a dummy code.. But the logics is there so just try to modify it a little.. _

Thanks!

Read only

Former Member
0 Likes
2,817

hi,

u have to put comma by ur own.

Regards,

NRT

Read only

0 Likes
2,816

> hi,

> u have to put comma by ur own.

> Regards,

> NRT

I think I am already starting to believe this... _

Thanks!

Read only

Former Member
0 Likes
2,816

Hi,

The write statement has an formatting extension

USING EDIT MASK (mask)

This should solve your problem 7 if so Plz be generous with points...

Regards,

Gaurav

Read only

0 Likes
2,816

> Hi,

>

> The write statement has an formatting extension

>

> USING EDIT MASK (mask)

>

> This should solve your problem 7 if so Plz be

> generous with points...

>

>

> Regards,

> Gaurav

I'm sorry but I am not yet used to using this.. Can you please elaborate? Thanks a lot! _

Read only

former_member196280
Active Contributor
0 Likes
2,816

Hi Ricardo,

Here is the solution for your question.

DATA: myAmount TYPE p DECIMALS 2, myString(15).

myAmount = '1234567.89'.

WRITE myAmount TO myString . <b>"Using this statement will automatically give,</b>

WRITE: myamount ,myString.

MOVE myAmount TO myString . "<b>SImilar to myString = myAmount.</b>

WRITE: myamount ,myString.

So, now the output for this code is

MyAmount Mystring

1,234,567.89 1,234,567.89 -->Using WRITE ...TO

1,234,567.89 1234567.89 --> Using MOVE... TO or Equals

Reward points for all useful answers.

Regards,

SaiRam

Read only

0 Likes
2,816

> Hi Ricardo,

> Here is the solution for your question.

>

> DATA: myAmount TYPE p DECIMALS 2, myString(15).

>

> myAmount = '1234567.89'.

> WRITE myAmount TO myString . <b>"Using this

> statement will automatically give,</b>

> WRITE: myamount ,myString.

>

> MOVE myAmount TO myString . "<b>SImilar to myString

> = myAmount.</b>

> WRITE: myamount ,myString.

>

> So, now the output for this code is

> MyAmount Mystring

> 1,234,567.89 1,234,567.89 -->Using WRITE ...TO

>

> 67.89 1234567.89 --> Using MOVE... TO or

> Equals

>

> Reward points for all useful answers.

>

> Regards,

> SaiRam

Hello. I think this is a good idea but it conflicts with my another problem. I posted this with the title "How to remove spaces when printing amounts" in this same forums.

Thanks!

Read only

Former Member
0 Likes
2,816

Hi ,

we can't assign a value 1,234,567.85 to a packed number directly.

How did you assign it and got the output.

It is giving errors know?

Regards,

Balakrishna.N

Read only

Former Member
0 Likes
2,816

Comma should be put manually to strings.