Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

 


h2. Introduction


The aim of this weblog is to show how to call an Abap

          mapping in SAP XI through a RFC Call using the functionalities of JCO.

          Why should one ever need this? I don't know, but the the need was born

          during the development and testing phase of the unit test tool for XI

          mapping called Detroubulator: Call for beta testers.

          With the collaboration of http://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/u/10354 [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] we've implemented this new feature (which was "On
The Horizon" in Detroubulator readme file). For depth info go to
the detroubulator home
page
.


You can find here an interesting Detroubulator A Complete Walkthrough


 


 


h2. Requirements


- SAP JCo libraries installed on your system. Can be dowloaded

  here.

FUNCTION zxi_dtrb_abap_mapping_execute.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(MAPPING) TYPE SEOCLSNAME

*" VALUE(PARAMS) TYPE MPP_PARAM_TAB OPTIONAL

*" VALUE(SOURCE) TYPE XSTRING OPTIONAL

*" VALUE(SOURCE_STR) TYPE STRING OPTIONAL

*" EXPORTING

*" VALUE(RESULT) TYPE XSTRING

*" VALUE(RESULT_STR) TYPE STRING

*" VALUE(RETURN) TYPE BAPIRET2

*"----


DATA: li_mapping TYPE REF TO if_mapping,

li_param TYPE REF TO cl_mapping_param,

li_trace TYPE REF TO cl_mapping_trace,

lv_src TYPE xstring,

lx_root TYPE REF TO cx_root,

lv_pname TYPE syrepid,

lv_iname TYPE syrepid,

lv_srcli TYPE i,

ls_param TYPE LINE OF mpp_param_tab.

  • Map params

CREATE OBJECT li_param

EXPORTING

params = params.

  • We wanna deal with string, so convert

IF source_str IS SUPPLIED.

CALL FUNCTION 'ECATT_CONV_STRING_TO_XSTRING'

EXPORTING

im_string = source_str

im_encoding = 'UTF-8'

IMPORTING

ex_xstring = lv_src.

ELSE.

lv_src = source.

ENDIF.

  • Create the mapping guy and run it

CREATE OBJECT li_mapping TYPE (mapping).

TRY.

CALL METHOD li_mapping->execute

EXPORTING

SOURCE = lv_src

param = li_param

trace = li_trace

IMPORTING

RESULT = RESULT.

CATCH cx_root INTO lx_root.

  • Ooops, error! Collect data and fill return structure.

return-type = 'E'.

return-message = lx_root->if_message~get_text( ).

return-message_v1 = lx_root->cx_root.

CALL METHOD lx_root->get_source_position

IMPORTING

program_name = lv_pname

include_name = lv_iname

source_line = lv_srcli.

return-message_v2 = lv_pname.

return-message_v3 = lv_iname.

return-message_v4 = lv_srcli.

EXIT.

ENDTRY.

  • We wanna deal with string, so convert

IF source_str IS SUPPLIED.

CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'

EXPORTING

im_xstring = result

im_encoding = 'UTF-8'

IMPORTING

ex_string = result_str.

ENDIF.

ENDFUNCTION.

</textarea>

3 Comments