Tuesday, March 8, 2022

Where to find Conversion Routines and how to use them

This will help mostly the new ABAP developers. Experienced ones should already be familiar with this. 

There are two types of representation for data types that can be seen in SAP Tables. DB format and Display format. We can observe them in SE16N transaction with Value and Value unconverted header.

 

Function Modules for Conversion Routines have predefined naming conventions. 

It goes as - 

CONVERSION_EXIT_XXXXX_OUTPUT - Converts the value to display format

CONVERSION_EXIT_XXXXX_INPUT - Converts the value to DB format

And the Conversion routine itself is 5 character length. Conversion routine is assigned through Domain.

Let's check how we can find the routine for a particular data type. We will check for MATNR. 

Goto Transaction se11 and put  matnr in data type field. and open it in Display mode.

 

Double click on the Domain name. If you know the domain name already, you can access it directly from SE11.

 

 

Find the Highlighted Routine Field. Here is the routine for MATNR. This way you can find the routine used for any Data Type.

Double Click on the highlighted routine name like above screen. And you will find the Conversion routine FMs.

  

 Check the below demonstration- 

DATA lv_matnr TYPE matnr VALUE '1300000081'.

WRITE:  | Before conversion{ lv_matnr } |.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
  EXPORTING
    input  lv_matnr
  IMPORTING
    output lv_matnr
*   EXCEPTIONS
*   LENGTH_ERROR       = 1
*   OTHERS = 2
  .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
WRITE:/  | After using input FM conversion{ lv_matnr } |.


CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
  EXPORTING
    input         lv_matnr
 IMPORTING
   OUTPUT        lv_matnr
          .

WRITE:/  | After using output FM conversion{ lv_matnr } |.
 

 Output:



How to Find Implemented BADIs for a Tcode in SAP

  Simple way to find implemented BADI for a TCode in SAP  First We have to find the Package for the transaction. 1.      Go to that par...