Skip to Content
0

Issue in Currency Formatting in ALV Display

Jun 15, 2017 at 07:38 AM

556

avatar image

Hi Experts,

I am facing an issue in displaying Price in corresponding currency format in ALV.

I am using set_table_for_first_display for ALV in a Custom container inside a screen.

In field catalog, I have used LVC_FIELDCATALOG_MERGE to create field catalog from dictionary structure (ZTR_S_DEAL_IMPORT). I have explicitly used it to create field catalog and modified the properties as amount field is not showing properly.

There is a currency column ( BUY_CURRENCY ) in the structure.

LOOP AT gt_fcat ASSIGNING <lfs_fcat> WHERE fieldname EQ 'BUY_AMOUNT'.

     <lfs_fcat>-cfieldname = 'BUY_CURRENCY'.
     <lfs_fcat>-ref_field = 'BUY_AMOUNT'.
     <lfs_fcat>-ref_table = 'ZTR_S_DEAL_IMPORT'.

CLEAR: <lfs_fcat>-decimals, <lfs_fcat>-decimals_o.

ENDLOOP.

After doing this, it is not showing properly for Currency IDR.

It should show like below.

I have also tried with below code. But no hope.

<lfs_fcat>-cfieldname = 'WAERK'.

Using below code in a test program is working fine.

WRITE <amount_field_name> CURRENCY <currency_field_name>.

Quick help will be appreciated.

Thanks in Advance,

Manoj

capture.png (2.5 kB)
capture.png (697 B)
10 |10000 characters needed characters left characters exceeded

Do not ask for "quick help", it's a fast route to getting your question deleted. Everyone wants quick help - why should you get priority?

1

Apologize.

0
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Sandra Rossi Jun 29, 2017 at 05:17 AM
0

Hi Manoj,

In the CSV, you must have the currency amounts from the user perspective, 1370411175 IDR, i.e. the real amount. But as soon as it's read by a program, it must be converted into internal value which will be 13704111.75 IDR if the field has 2 decimals (or 13704.11175 IDR if the field has 5 decimals, etc.) It's only when the amount is displayed again, or sent to a non-SAP system, that the amount must be converted back to the real amount, i.e. 1370411175 IDR. When you call the ALV, pass the internal value + the currency code, and the ALV will convert it and will display the real amount.

Share
10 |10000 characters needed characters left characters exceeded
Evgeny Gubenko Jun 15, 2017 at 10:46 AM
1

hi!

did you check decimal places of amount field? If it has no decimals, it well be shown like in your ALV example. So if in internal format you have 1370411175.00 it will convert it into 137.041.117.500. You can try to set your data in variable without decimal places.

Evgeny

Show 15 Share
10 |10000 characters needed characters left characters exceeded

Hi Evgeny,

It has Length 13 Decimal 2 Places.

How it is possible. As the value is a amount, how i can store it in a variable with zero decimal places.

If i will do that, then ALV property for price display format w.r.t currency wont work.

Thanks,

Manoj

0

Evgeny, could you convert your comment into an answer so that we can upvote it? Thanks!

@Manoj, Evgeny is right, IDR is a currency code with 0 decimals, it's exactly what he said, that's a fundamental concept in SAP for currency amounts, the technical decimals are superseded by the currency decimals at output time. See transaction OY04 (list of currency codes with decimals different from 2):

f0yuc.png (9.5 kB)
0

Hello Sandra,

I have tried to do in your way though it seems unconventional to me.

I have added one more field to the output( BUY_AMOUNT_NO_DEC ).

It has type CHAR16 and i have transferred amount to this field.

After this also, it is not displaying as per requirement.

It is unconventional as why to use a data type without any decimal format only to display it is ALV. ALV has the in built feature to display amt as per the currency key. Example for Currency IDR, it should display without any currency as showed in standrd screen given in my 1st thread.

Thanks in advance,

Manoj

untitled.png (17.0 kB)
0

Use the correct type, not a char field. If it's a currency, then use a currency. And what Sandra is saying is not unconventional. She is saying that in SAP config, INR is defined without any decimal places, not that it should be put in a char field and expected to display properly.

1

Hi Richard,

I have done that already. Please go through thread from start.

Thanks in advance,

Manoj

0

I guess your issue is not about the ALV, but it's about how you stored a currency amount in table Z_DEAL_IMPORT. If you store technically 15.00 IDR, SAP will output this amount as 1500 IDR. It's not smart to store 1500.00 as the digits after decimal point are always zero, so you lose 2 digits that you could use for storing high amounts. If the field has a total of 6 digits, then it's better to be able to store 999 999 IDR, rather than being limited to 9 999.00 IDR.

It's a matter of significant digits. A technical field has a constant number of digits (before + after decimal point) and it must be able to store amounts of any currency code. A surprising thing is that the highest realistic currency amount for a currency with 0 decimals will have the same number of digits than

the highest currency amount for a currency with 2 decimals, i.e. 99 999 999 IDR, and 999 999.99 USD. Based on this situation, SAP has decided to "ignore" the decimal point of table fields when an amount is output, and place it according to the number of decimals of the corresponding currency code.

0

Hi Sandra,

That only not happening in my case. Any reason why it is beaving like this ?

0

Either I need to cross the Ts or I didn't understand your question. We all say the behavior you're experiencing is normal, and we explain you why (and so you should be able to correct the situation).

Please let me summarize your issue : your database table has technical value 1370411175.00. You link it to currency IDR. So it outputs 137041117500 (it's normal). But you say the technical value represents exactly the real value, so it should output 1370411175.00.

The workaround is : correct the way you store amounts in the database table, because that's the wrong way (i.e. the SAP concept is to store 13704111.75 and link it to IDR, which means it's 1370411175 IDR, and it will output 1370411175). If you can't, then you can't use the standard way of linking amounts to currencies, so don't link the amounts to currency fields, by defining the table field with type DEC instead of CURR (you may also use the DF16 or DF34 family), hence the output value will be the same as the database table value.

2

Hang On - You're not talking about Crore are you ????

0

@Richard, nope, I was talking about Octal !

0

Hello Sandra,

Sorry for late reply.

I understood what you are telling.

This program is a upload program which takes input from *.CSV file. In that file, Buy amount and Buy Currency are given as 1370411175 and IDR respectively.

Now i am not understanding, what will be this amount in IDR Currency ?

At the end, the ALV data will be passed to FM BAPI_FTR_FXT_CREATE to create FTR_EDIT transaction.

This program is passing buy amount as 1370411175.00 to the FM. After creation of transaction in FTR_EDIT, standard is displaying this amount as showed in my earlier post.

It is creating problem for end user to match these two values that is, one on standard screen and other in the report.

Thanks in advance,

Manoj

0
Show more comments

I've converted it to an answer. Feel free to notify a moderator if a comment needs to be converted to an answer (or vice versa)

1

Note, however, that comments can be converted to answers, but replies to comments and answers cannot.

0

Hi Manoj,

In the CSV, you must have the currency amounts from the user perspective, 1370411175 IDR, i.e. the real amount. But as soon as it's read by a program, it must be converted into internal value which will be 13704111.75 IDR if the field has 2 decimals (or 13704.11175 IDR if the field has 5 decimals, etc.) It's only when the amount is displayed again, or sent to a non-SAP system, that the amount must be converted back to the real amount, i.e. 1370411175 IDR. When you call the ALV, pass the internal value + the currency code, and the ALV will convert it and will display the real amount.

In fact, this is what Evgeny Gubenko tried to explain initially.

Please mark his answer as correct.

Thanks

0
Raymond Giuseppi
Jun 15, 2017 at 11:15 AM
0

Are BUY_AMOUNT actually a data of type CURR and BUY_CURRENCY a data of type CUKY (Look at field DATATYPE in field catalog during an ALV constistency check or debug)

Even if ZTR_S_DEAL_IMPORT has been a table and not as structure you could have checked its display thru SE16n or SE16. Perform some comparision with standard reports to insure internal format is already correct in your internal table.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hello Raymond,

Thanks for your quick reply.

Yes. Field data types are correct. Below are the screen shots of the field catalog at run time.

ZTR_S_DEAL_IMPORT is a structure.

I did consistency check as per below link. There is no inconsistency in alv.

https://help.sap.com/doc/saphelp_crm700_ehp02/7.0.2.17/en-US/d6/23253963143e6ae10000000a11402f/content.htm

Thanks in advance,

Manoj

capture.png (13.6 kB)
capture.png (13.6 kB)
capture.png (9.2 kB)
0

Why did you change the field catalog and not just define correctly the structure with currency reference fields so LVC_FIELDCATALOG_MERGE return a correct field catalog?

and don't change the default values for decimals/decimals_o if you don't actually need something unusual (usual values are ' ' and '00002' especially for currency code without any decimal customizing.)

structure.jpg (27.7 kB)
fieldcatalog.jpg (28.0 kB)
fieldcatalog2.jpg (20.7 kB)
0
avatar image
Former Member Jun 30, 2017 at 10:07 AM
0

try to give the AMOUNT field data element for the required field

Share
10 |10000 characters needed characters left characters exceeded