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

How to write a currency into a string?

schmelto
Active Participant
0 Likes
7,324

I want to execute following line:

write gs_header-wt_qsshh to detail-tax_base.
  • `gs_header-wt_qsshh` type wt_bs -> curr(32,2)
  • `detail-tax_base` type c length 27

In the ABAP Custome Code check there is a warning (WRITE TO type conflict).

How I can resolve this since `detail-tax_base` has to be a char.

1 ACCEPTED SOLUTION
Read only

matt
Active Contributor
7,053

Char is correct. But currency 32.2 isn't going to fit in a char field of length 27. Btw, you should use the CURRENCY keyword when output currency

WRITE amount CURRENCY 'GBP' TO output.

will give a different output to

WRITE amount CURRENCY 'HUF' TO output.

But both outputs will be correct. Currency values are held to 2dp regardless of the decimals of the currency.

I want to execute following line:

write gs_header-wt_qsshh to detail-tax_base.
  • `gs_header-wt_qsshh` type wt_bs -> curr(32,2)
  • `detail-tax_base` type c length 27

In the ABAP Custome Code check there is a warning (WRITE TO type conflict).

How I can resolve this since `detail-tax_base` has to be a char.

3 REPLIES 3
Read only

MateuszAdamus
Active Contributor
7,053

Hello 6e829fd780204f76b10f492049a3773c

Have a look at addition CURRENCY of the WRITE keyword: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abapwrite_to_options.htm#!ABAP_ADDITION_6...

Basically you need to know what currency the amount is in, to format it correctly.

I'm not sure about the length of the target field in your case, though...

Kind regards,
Mateusz

Read only

matt
Active Contributor
7,054

Char is correct. But currency 32.2 isn't going to fit in a char field of length 27. Btw, you should use the CURRENCY keyword when output currency

WRITE amount CURRENCY 'GBP' TO output.

will give a different output to

WRITE amount CURRENCY 'HUF' TO output.

But both outputs will be correct. Currency values are held to 2dp regardless of the decimals of the currency.

Read only

schmelto
Active Participant
0 Likes
7,053

yes with a length of 35 it works thank you