Skip to Content

XI/PI: Easy ABAP mapping tests – no more SXI_MAPPING_TEST

If you like ABAP mappings I’m sure you always wonder: “why do I need to create the whole scenario in Integration Directory just to test my mapping?”. If you do I’m sure you will like my blog. I prepared a little abap program that will make your life much easier as you will be able to test ABAP mappings without any ID configuration. In order to do that at first copy class CL_MAPPING_PARAM to ZCL_MAPPING_PARAMmappingand change the body of SET method of your ZCL_MAPPING_PARAM class to:   DATA:    l_parameter TYPE mpp_param.    l_parameter-name  = name.    l_parameter-value = value.    DELETE TABLE me->params WITH TABLE KEY name = name.    APPEND l_parameter TO me->params.  Now we’re ready to create the report that we will use to test our mappings.  REPORT  Z_MAPPING_TEST.  ***ABAP mapping tests by Michal Krawczyk***  DATA: target_xml type xstring. DATA: target_xml_string type string. DATA: PARAMONE TYPE REF TO ZCL_MAPPING_PARAM. DATA: TRACESTART TYPE REF TO CL_MAPPING_TRACE. DATA: xms_trace type ref to IF_XMS_TRACE. DATA: source_xml TYPE xstring. DATA: LOC_CONV TYPE REF TO CL_ABAP_CONV_IN_CE. DATA:    begin of itab occurs 0,          raw(255) type x,          end of itab . DATA: sender_service type string. DATA: receiver_service type string. DATA: GENERICMAPPING TYPE REF TO data. DATA: INTERFACEMAP type ref to IF_MAPPING. FIELD-SYMBOLS: EXECUTE   EXPORTING     SOURCE                = source_xml     PARAM                 = PARAMONE     TRACE                 = TRACESTART *    DYNAMIC_CONFIGURATION =    IMPORTING      RESULT                = target_xml     . * CATCH CX_MAPPING_FAULT . *ENDTRY.    *   Convert xstring to string CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE   EXPORTING     INPUT       = target_xml     ENCODING    = ‘UTF-8’     REPLACEMENT = ‘?’     IGNORE_CERR = ABAP_TRUE   RECEIVING     CONV        = LOC_CONV.  TRY.     CALL METHOD LOC_CONV->READ       IMPORTING         DATA = target_xml_string.   CATCH CX_SY_CONVERSION_CODEPAGE.   CATCH CX_SY_CODEPAGE_CONVERTER_INIT.   CATCH CX_PARAMETER_INVALID_TYPE.   CATCH CX_PARAMETER_INVALID_RANGE. ENDTRY.  write: target_xml_string.   When you run the report you will see that you need to give 4 inputs: a) Sender Service – put your sender service name (or leave the default) b) Receiver Service – put your receiver service name (or leave the default) c) filename – here you need to put the name of your source file (that you want to map) d) ABAP mapping class name – this is the most important – you need to put here the name of your ABAP mapping class (from SE24)mapping
You must be Logged on to comment or reply to a post.