Automate

 View Only
  • 1.  Tip of the Week - Conversion Exits in Query

    Employee
    Posted 07-29-2024 17:55

    Hello Automate Community! 

    If you are not an ABAP developer, it is possible that you have never heard of a 'Conversion Exit'.

    But if you work with data extration and loading, you may have experienced some pain and frustration in finding your expected record and get no results even if you know that record exists. Then you learned to put the exact number of leading zeroes or spaces in the front to get a result or you learned the German codes for those fields. Sound familiar? This is typically because there is a conversion exit at play. 

    So what is a Conversion Exit? 

    The conversion exit is a set of 2 function modules (input and output routines) that get executed every time you interact with the field on the SAP UI.

    This coding practice is very common in legacy SAP modules (FICO, MM etc) where SAP tries to show a user-friendly value on the UI, but stores it differently in the database in a normalized manner or using internal codes etc.

    There are thousands of fields where a conversion exit may be defined. It is also possible for ABAP developers to create custom conversion routines as well. 

    In the Data Dictionary (Tcode: SE11), you can find it by navigating to the Table-> field definition -> Data Element -> Domain -> Definition 

    The 5 letter code defined under Routine is the Conversion exit code. The corresponding input and output function modules can be found in SE37 by replacing the string 'XXXXX' with this routine name - CONVERSION_EXIT_XXXXX_INPUT and CONVERSION_EXIT_XXXXX_OUTPUT

    Here is a notorious example: Partner Functions!

    So if you want to query partner functions for a given customer, you might expect these values: 

     

    However, your Query from the table KNVP returns an output like this with internal codes for the partner function. 

    This output will not be understandable to the business users. And because we are directly reading from the DB table, the conversion exit does not get triggered the same way if we were looking at this value in the UI. 

    You can force the conversion routine to execute in Studio, however it will degrade the query performance, so use this option wisely. 

    Here is the same output with "Conversion Exit" feature turned on. 

    So how do we turn this "Conversion Exit" on? 

    In the workspace tab, make sure you have picked all the output fields first. Then click on "Conversion Exit" in the top right.

    You will see a pop-up with a warning like shown below.  Then select from the available conversion exits to turn them on. 

    The system shows available conversion exits for your chosen output fields: 

    These are commonly used examples and some recommendations on how to handle these fields in Studio. Wherever possible, I recommend using the standard padding options when you see an ALPHA conversion exit, because we can avoid running the routine in SAP and not compromise on performance. 

    Table / Field Description  Example Value Stored in the database as  Example Value displayed in the UI as Conversion Routine Notes / Recommendation
    MARA-MATNR Material Number  000000000000001873                       1873 ALPHA Recommendation: Use padding options in Studio
    ACDOCA-BELNR
    BKPF-BELNR
    Accounting document number 0300000015 300000015 ALPHA Recommendation: Use padding options in Studio
    MARA-MEINS
    ACDOCA-RUNIT
    Base Unit of Measure ST
    CV
    FA
    PC - Piece
    CS - Case
    °F - Fahrenheit
    CUNIT SAP shows the commercial unit on the UI, but stores the internal unit of measure. Tables in the T006* series have the mapping.
    Recommendation: Use the Conversion exit feature in Query
    Many tables Language Key E EN ISOLA Table T002 has the translation between internal language codes and the ISO standard language code.
    Recommendation: Studio automatically handles it via the AFM, no need for conversion exit
    ACDOCA-KOSTL
    ACDOCA-PRCTR
    BSEG-KOSTL
    BSEG-PRCTR
    KNA1-KUNNR
    LFA1-LIFNR
    Cost Center
    Profit Center
    Customer Number
    Vendor Number
    0000005100 5100 ALPHA Recommendation: Use padding options in Studio
    KNVP-PARVW Partner Function WE
    AG
    SH - Ship to party
    SP - Sold To Party
    PARVW SAP stores the German Partner function while it shows the language dependent value on the UI.
    The tables TPAR &TPAUM have definitions & the language specific mapping.
    Recommendation: Use the conversion exit feature in Query

    I hope this was helpful. The example script is attached.

    I welcome any other examples for fields where you think a Conversion Exit is at play and causing heartache! :)

    #Studio #Query



    ------------------------------
    Jayasri Varyani
    SE
    Precisely Software Inc.
    ------------------------------

    Attachment(s)



  • 2.  RE: Tip of the Week - Conversion Exits in Query

    Posted 21 days ago

    WOW! Wish I knew this before. I had done other work arounds to convert partner functions. Thank you for sharing this.



    ------------------------------
    Benjamin Kielas
    Supervisor SAP Master Data
    Generac Power Systems, Inc.
    WAUKESHA WI
    ------------------------------