Domaine

Question:
Hi ALV-freaks,
In a normal listviewer report one column is showing the number 1 or 2.
My intention is not to show 1 or 2 but the text for it defined in the domaine.
How to do it automatically when calling ALV (no long-winded reading the domaine properties in my report)?
Ralf
Answer:
Hi Ralf,
faced the same problem and didn't got a solution.
ALV fieldcat does not provide a listbox option.
if you watch SE16-ALV-Grids, it's the same behavior....
As workaround - as you mentioned - use DD_DOMVALUE_TEXT_GET anf fill text in a new column.
any better solutions are welcome...
Cheers
carsten
Answer:
You can use a conversion exit several ways to change the data that is displayed. A conversion exit is a function module (FM) that converts data on input and on output. A common conversion exit is CONVERSION_EXIT_ALPHA_INPUT and CONVERSION_EXIT_ALPHA_OUTPUT. This is referred to as conversion exit ALPHA, i.e the rest of the FM name is fixed.
You can assign a conversion exit to a field via a domain. For example, if you look at domain AUFNR (4.6C), on the Definition Tab under Output Characteristics you will see Convers. Routine ALPHA which will invoke the 2 FMs listed above.
For the field where you want 1,2, etc to be converted to text, you can define a domain with your own conversion exit. You must create both an INPUT and an OUTPUT function module even if you will only be using the OUTPUT function module. Copy the ALPHA FMs to help you get the interface correct. You can use the FM DD_DOMVALUE_TEXT_GET mentioned in an earlier post to get the values. As long as your ALV grid is displayed using a structure that includes the domain you created, then the conversion exit will happen.
Your other choice is to invoke the conversion exit via the ALV field catalog. You can generate a field catalog from a dictionary structure using FM LVC_FIELDCATALOG_MERGE. You can then alter the field catalog to invoke the conversion exit. For example:
    LOOP AT t_fieldcat INTO wa_fieldcat
      WHERE fieldname = 'TEL_NUMBER'.
      wa_fieldcat-edit_mask = '==ZCDF'.
      MODIFY t_fieldcat FROM wa_fieldcat
        TRANSPORTING edit_mask.
    ENDLOOP.
In this example, for the field TEL_NUMBER, conversion exit ZCDF will be invoked. That will be FM CONVERSION_EXIT_ZCDF_OUTPUT when the grid is displayed.
In your call to display the ALV grid, you must use the field catalog instead of the dictionary structure. For example:
CALL METHOD alv_grid_1->set_table_for_first_display
         EXPORTING
                   is_variant       = w_is_variant1
                   is_layout         = w_is_layout1
                   i_save            = 'A'
         CHANGING 
                   it_outtab         = t_user
                   it_fieldcatalog  = t_fieldcat.
Email me and let me know how this works for you. cfolwell@csc.com

Good luck!

More Articles:

Quick Q. Cleared/Open Items (FI/ABAP)?
using BAPI_NETWORK_MAINTAIN function module?
Creating Tables and Table entries?
User Exit problem for Sales Document?
Automating variants?
Radio Buttons - Screen Updates?