Skip to Content

Issue in Currency Formatting in ALV Display

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)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Jun 29, 2017 at 05:17 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 15, 2017 at 10:46 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 15, 2017 at 11:15 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • 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)
  • avatar image
    Former Member
    Jun 30, 2017 at 10:07 AM

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

    Add comment
    10|10000 characters needed characters exceeded