In this blog we will fetch data using RFC.
Create RFC using transaction code SE37. ZTEST_RFC_ODATA.
Tables.
Source Code.
FUNCTION ZTEST_RFC_ODATA.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(CARRID) TYPE S_CARR_ID
*" TABLES
*" ZTEST_RFC_TAB STRUCTURE ZTEST_RFC OPTIONAL
*"----------------------------------------------------------------------
data: wa_sCARR type sCARR,
scarr type TABLE OF scarr,
ZTEST_RFC TYPE ZTEST_RFC,
sflight type TABLE OF sflight WITH HEADER LINE.
select * from scarr into TABLE scarr where CARRID = CARRID.
select * from sflight INTO TABLE sflight WHERE CARRID = CARRID.
LOOP AT Sflight.
ZTEST_RFC-CARRID = sflight-CARRID.
ZTEST_RFC-CONNID = sflight-CONNID.
ZTEST_RFC-FLDATE = sflight-FLDATE.
READ TABLE SCARR INTO wa_sCARR WITH KEY CARRID = ZTEST_RFC-CARRID .
IF SY-SUBRC = 0.
ZTEST_RFC-CARRNAME = wa_scarr-CARRNAME.
ZTEST_RFC-CURRCODE = wa_scarr-CURRCODE.
ZTEST_RFC-URL = wa_scarr-URL.
ENDIF.
append ztest_rfc to ztest_rfc_tab.
CLEAR ztest_rfc.
ENDLOOP.
ENDFUNCTION.
Select RFC in attribute.
After creating RFC go to Transaction code SEGW. Create Project.
There will be four folders like displayed below.
Click on Data Model . Import -> RFC/BOR Interface.
Give Entity name and fill entries like displayed below.
Click on next of above image and select check boxes below. Look at assign structure column don’t tick checkbox. Keep same as below.
Select key field.
Click on finish and then go to Service Implementation Folder in it go to structure and right click on GetEntitySet and select Map Data Source.
Select proper inputs like below.
Below screen will appear click on propose maping.
It will be display like below.
Now add one row and do mapping like below.Select entry from Data Source Column.
Do mapping like below.
Now Save and Generate project.
Now execute transaction code /iwfnd/maint_service. Click on Add Services.
Fill data like below.
Select entry displayed in above image.
Navigate back to /iwfnd/maint_service screen. Select service go to ICF Node and Activate it.
Now click in SAP Gateway Client, and Execute.
Now select entity set and apply relevant filters.
Execute and you will able to see data.
Link for reference – /sap/opu/odata/sap/ZTEST_RFC_TEST_SRV/RFCDEMOSet?$filter=Carrid eq ‘AA’