What is conversion exit in SAP ABAP ? Using conversion routine in SAP ABAP

What is a conversion routine in SAP ABAP ?, Using conversion exit in SAP ABAP, conversion exit in SAP ABAP

+ -

What is a conversion exit?

Conversion exit is a function module, which is used to convert a value from external format to SAP internal format and from internal format to external format.

If a screen field refers to a domain with a conversion routine, or is directly assigned a conversion routine in its attributes, the system automatically executes the function module ..._INPUT for every input in the relevant screen field and the function module ..._OUTPUT when the values are displayed in this screen field and uses the converted content in each case.

Conversion routines are identified by a five-place name and are stored as a group of two function modules. The function modules have a fixed naming convention. The following function modules are assigned to conversion routine xxxxx:

  • CONVERSION_EXIT_xxxxx_INPUT
  • CONVERSION_EXIT_xxxxx_OUTPUT
The INPUT module converts from display format to internal format, and the OUTPUT module converts from internal format to display format.

How to find conversion exit ?

Go to a table, field for which you want to find the conversion exit.

Double click on data element and double click on 'Domain'.

You can see the conversion exit at domain level ex: MATN1 for MARA-MATNR field.

Double click on conversion exit, you will find two function modules.

  • CONVERSION_EXIT_MATN1_INPUT
  • CONVERSION_EXIT_MATN1_OUTPUT

CONVERSION_EXIT_MATN1_INPUT is used to convert the external value into internal value.

CONVERSION_EXIT_MATN1_OUTPUT is used to convert the internal value into external value.

Scenario and example of using conversion exit in ABAP programs

Requirement: Develop an interactive report to display material basic details in basic list, material plant details in the secondary list for a material type input and display header and footer for primary and secondary list.

In the below example, when we are getting data from MARC table at line selection we are converting material external format to internal format.

REPORT ZSAPN_INTERACTIVE_REPORT LINE-COUNT 33(3) NO STANDARD PAGE HEADING. "leave some pages for footer and hide standard heading
DATA : IT_MARA TYPE TABLE OF MARA, "mara internal table
       WA_MARA TYPE MARA, "mara work area
       IT_MARC TYPE TABLE OF MARC, "marc internal table
       WA_MARC TYPE MARC. "marc work area

PARAMETERS P_MTART TYPE MARA-MTART. "selection screen element input field

INITIALIZATION. "initialization event

AT SELECTION-SCREEN. "at selection screen event to validate inputs
  PERFORM VALIDATE_INPUT. "Subroutine to validate input

START-OF-SELECTION.
  PERFORM GET_MATERIAL_DATA.
  PERFORM DISPLAY_MATERIALS.

TOP-OF-PAGE.
  PERFORM DISPLAY_HEADER.

END-OF-PAGE.
  PERFORM DISPLAY_FOOTER.

AT LINE-SELECTION.
  PERFORM GET_PLANT_DATA.
  PERFORM DISPLAY_PLANT_DATA.

TOP-OF-PAGE DURING LINE-SELECTION.
  PERFORM DISPLAY_LIST_HEADER.
FORM VALIDATE_INPUT .
  IF P_MTART IS INITIAL.
    MESSAGE 'Please enter input' TYPE 'E'.
  ENDIF.
ENDFORM.                    " VALIDATE_INPUT

FORM GET_MATERIAL_DATA .
  SELECT * FROM MARA
    INTO TABLE IT_MARA
    UP TO 50 ROWS
    WHERE MTART = P_MTART .
ENDFORM.                    " GET_MATERIAL_DATA
FORM DISPLAY_MATERIALS .
  LOOP AT IT_MARA INTO WA_MARA.
    WRITE:/ WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MATKL, WA_MARA-MBRSH.
    HIDE WA_MARA. "store line details in HIDE area
  ENDLOOP.
ENDFORM.                    " DISPLAY_MATERIALS
FORM DISPLAY_HEADER .
  WRITE : 'Material Basic Details' COLOR 5.
ENDFORM.                    " DISPLAY_HEADER

FORM DISPLAY_FOOTER .
  WRITE: 'Report Generated at:', SY-DATUM COLOR 1.
ENDFORM.                    " DISPLAY_FOOTER
FORM GET_PLANT_DATA .

  CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
    EXPORTING
      input      = WA_MARA-MATNR
    IMPORTING
      output       = WA_MARA-MATNR .


  SELECT * FROM MARC
    INTO TABLE IT_MARC
    WHERE MATNR = WA_MARA-MATNR.
ENDFORM.                    " GET_PLANT_DATA
FORM DISPLAY_PLANT_DATA .
  LOOP AT IT_MARC INTO WA_MARC.
    WRITE :/ WA_MARC-MATNR, WA_MARC-WERKS.
  ENDLOOP.
ENDFORM.                    " DISPLAY_PLANT_DATA

FORM DISPLAY_LIST_HEADER .
  WRITE: 'List of Plants for material:', WA_MARA-MATNR COLOR 6.
ENDFORM.                    " DISPLAY_LIST_HEADER

Learner Questions


No Questions by learners, be first one to ask ..!!

    Please Sign in to ask a question

    Was this lesson helpful to you? Yes No 32 People out of 33 think this lesson helpful


    Lesson Navigation

    ←Previous Chapter
    Next Chapter →