Skip to Content
0
Oct 28, 2019 at 09:49 AM

how to create a RFC to return data

337 Views

I create a RFC function module in SE38 with table parameter COMPANY_LIST and import parameter companyID

the code is like below

FUNCTION BAPI_COMPANY_GETDETAIL1.

CLEAR COMPANY_LIST.
 CLEAR T880.
*authority check: S_TABU_DIS V_T001
 PERFORM CHECK_AUTHORITY_T880 CHANGING RETURN.
 CHECK RETURN IS INITIAL.
 SELECT SINGLE RCOMP NAME1 FROM T880 INTO COMPANY_LIST WHERE RCOMP = COMPANYID.
 IF SY-SUBRC NE 0.
 CLEAR MESSAGE.
 MESSAGE-MSGTY = 'E'.
 MESSAGE-MSGID = 'FN'.
 MESSAGE-MSGNO = 030.
 MESSAGE-MSGV1 = COMPANYID.
 PERFORM SET_RETURN_MESSAGE USING MESSAGE
 CHANGING RETURN.
 IF 1 = 2. " Für Verwendungsnachweis Messages
 MESSAGE E030(FN) WITH COMPANYID.
* Die Gesellschaft & ist nicht vorhanden
 ENDIF.
 ENDIF.
 CHECK RETURN IS INITIAL.ENDFUNCTION.

then I called the function with below code and nothing returned.

REPORT Z_LOKI_TEST07.
DATA :
 companyid TYPE BAPI0014_2-COMPANY,
 li_clist TYPE BAPI0014_1,
 l_clist TYPE STANDARD TABLE OF BAPI0014_1.
companyid = '001000'.
CALL FUNCTION 'BAPI_COMPANY_GETDETAIL1'
 EXPORTING
 COMPANYID = companyid
 TABLES
 COMPANY_LIST = l_clist.
READ TABLE l_clist INTO li_clist INDEX 1.

I debugged and the COMPANY_LIST has data in the module. But the after calling the l_clist table is empty. What's the reason?can someone help? Thx.