I will explain how to create an RFC, using AMDP, with a practical example, from the analysis of the standard tables, the creation of the structure and type of output table, the creation of the RFC, the AMDP and finally the tests
Analysis of the Table to consult.
We begin by identifying the tables and fields we need for the RFC. For this we enter the se11, se11n, se16 or se16n to consult the columns of the tables:
Analysis of the Table to consult.
We begin by identifying the tables and fields we need for the RFC. For this we enter the se11, se11n, se16 or se16n to consult the columns of the tables:
We will use the tables MARA (Matnr, Mtart, Meins) and MAKT (Maktx).
Creation of output structure.
We select Structure:
We enter a name for our structure and the fields that our structure will have with their respective data elements:
We save, activate, in indicate in which package the created object will be stored:
We created an OT to subsequently make the pass to the other constituents:
We go back to the se11 and create the table type:
We select Type Table:
In the Line type tab, we enter the structure previously created, Save and activate:
Creation of AMDP.
We enter Eclipse and in our Abap Project, we select the package where our class will be, we select Source Code Library and in classes, we select New Abap Class:
We enter a Name and Description for our Class:
We select or create a new OT, for the transport to the other constituents, the fields of the query must coincide with the Table Type Created:
We enter the following code in which, we define the method that we will use in the RFC:
CLASS xxxxx DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES: if_amdp_marker_hdb.
CLASS-METHODS get_xxx
IMPORTING VALUE(im_begda) TYPE begda
VALUE(im_endda) TYPE endda
EXPORTING VALUE(tt_result) TYPE Tipo Tabla Creado
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS xxxxx IMPLEMENTATION.
METHOD get_xxx BY DATABASE PROCEDURE
FOR HDB
LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY
USING mara makt.
TT_RESULT = SELECT M.MATNR, M.MTART, MT.MAKTX, M.MATKL, MEINS
FROM MARA AS M
INNER JOIN MAKT AS MT ON M.MATNR = MT.MATNR AND SPRAS = 'S' AND MT.MANDT = SESSION_CONTEXT('CLIENT')
WHERE (CASE WHEN M.LAEDA = '00000000' THEN '19500101' ELSE M.LAEDA END BETWEEN IM_BEGDA AND IM_ENDDA) AND M.MANDT = SESSION_CONTEXT('CLIENT')
ORDER BY M.MATNR;
ENDMETHOD.
ENDCLASS.
Creation of RFC.
We enter the se80, select Function Group and enter a name for our Function Group:
We enter a description for the Function Group:
Right click on Modules functions and click on Create:
We enter a name and description for the function module:
In the Attributes tab, we select Remote Access Module:
In the Import tab, we enter the parameters of our RFC:
In the Export tab we indicate our type output table:
In the tab of Code. fte. We enter the following ABAP code, where xxxx is the name of our Class and get_xxx is the name of our created method:
xxxx=>get_xxx( EXPORTING im_begda = im_begda im_endda = im_endda IMPORTING tt_result = tt_result )
Tests.
We execute the RFC, enter the parameters and verify the result:
No comments:
Post a Comment