Skip to Content

how to create a RFC to return data

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.

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    Posted on Oct 28, 2019 at 06:03 PM

    Not sure how you've managed to create an FM that doesn't start with Z (and why?) but, as others said, the SELECT statement in FM doesn't fill in the table.

    I don't see it mentioned in the question that you've already debugged the FM and confirmed that it actually finds any data though. The calling program does not analyze any error messages returned by FM, so there could be any number of errors (e.g. authorization check) occurring without the calling program doing anything about it.

    As a side note, if this FM just reads one record for one company code then it should be returning a structure, not a table. Just like the BAPI without "1" does. It also doesn't make any sense to have CHECK statement as the last command in any block of code. Might want to use Extended Check tool.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 28, 2019 at 10:29 AM

    Something strange, your SELECT statement used INTO instead of INTO TABLE, that means the COMPANY_LIST is used as a structure

    Maybe your data stay in the header line of hte internal table

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 28, 2019 at 10:54 AM

    Hi,

    I think you have to use INTO TABLE insted of INTO

     SELECT SINGLE RCOMP NAME1 FROM T880 INTO TABLE COMPANY_LIST WHERE RCOMP = COMPANYID.
    
    
    
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.