SAP ALV Tutorial – Currency/Quantity field
If the field in ALV output table is for currency or quantity, we need to do some effort to display it in our ALV. you must assign these fields to a currency or unit. There are three ways how you can do this in the field catalog:
- Reference to a Currency or Unit Field
- Value or Unit for the Entire Column
- Format the value field manually
Reference to a Currency or Unit Field
If you define your output table as an structure in DDIC, you need to provide corrsponding reference table and field for currency/quantity field when you activate it. The reference field can be used to display values in the correct user-specific format.
When you read the whole field catalog of the output table using function module ‘REUSE_ALV_FIELDCATALOG_MERGE’, you can automatically fill the field CFIELDNAME or QFIELDNAME in field catalog structure. That means you can fill above two field maually if your output table type is defined in the program not in DDIC.
It is also very useful when you want to have subtotal according to different currency or unit.The field catalog also contains an entry for the unit field. If you do not want to display the unit as a column in the list and do not want to allow users to interactively show it as a column, you can mark the field catalog entry for the unit field as a technical field by setting field TECH. This makes sense, for example, if the unit is always unique and therefore explicitly output in the list header by the caller.
For initial value or currency fields, you must consider the following points:
Totals calculation and display of value fields
Below is an example when vlaue of value field is initial. It displays value ‘o.oo’ or space according to the value of reference unit field.
When we have value in reference unit field, the value field displays as ‘o.oo’. But if we set field ‘NO_ZERO’ in field catlog, the output should be space.
If the reference unit field is initial and value field is also initial, the output is space.
Value or Unit for the Entire Column
For fields that use the same quantity or currency unit for all column values, the field catalog contains fieldsCURRENCY QUANTITY see below). You use these fields to determine a unit for your value field (such as USD or KG ). This makes sense, for example, if there is only one unit or currency for the entire column (which has been entered by the user, for example). In this case, the output table does not need any additional fields.
Format the value field manually
Fields in field catalog structure DECIMALS_O , EDIT_MASK , EXPONENT , NO_SIGN and ROUND correspond to WRITE additions DECIMALS , USING EDIT MASK , EXPONENT , NO-SIGN and ROUND . We set proper value in above field to display custom format of value without setting reference field. You can find SAP standard document about how to use these fields here:
http://help.sap.com/saphelp_erp2004/helpdata/EN/12/904f42d5f811d2b469006094192fe3/frameset.htm