!--a11y-->
Calling RFC .NET Server from SAP
Programs 
To execute our .NET server stub application from the SAP system we need to execute the ABAP command Call function X Destination Y. This report calls our proxy and writes the results to screen. Alternatively, you can use the SAP function module’s single test capability with the TRFC destination for your .NET server stub.
To create a TRFC destination for the SAP .NET server stub create a destination of type T (TRFC) in transaction code SM59. The program ID in your server stub is case sensitive.
Example
|
*&--------------------------------------------------------------------- *& Report ZRFCSERVERCALL *& **&-------------------------------------------------------------------- *& This program can be used with the RFCServerConsole sample *& Source is available in %\RFCServerConsole\ABAPProgram *&---------------------------------------------------------------------
REPORT ZRFCSERVERCALL . DATA: TBLCUST like BRFCKNA1 occurs 0 with header line. PARAMETERS: P_CUSTNO like KNA1-KUNNR, P_CUSTNA like KNA1-NAME1, P_DEST(15) TYPE C.
CALL FUNCTION 'RFC_CUSTOMER_GET' DESTINATION P_DEST EXPORTING KUNNR = P_CUSTNO NAME1 = P_CUSTNA TABLES CUSTOMER_T = TBLCUST EXCEPTIONS NOTHING_SPECIFIED = 1 NO_RECORD_FOUND = 2 OTHERS = 3.
CASE SY-SUBRC. WHEN 0. LOOP AT TBLCUST. WRITE: / SY-TABIX, TBLCUST-KUNNR, TBLCUST-NAME1, TBLCUST-ORT01. ENDLOOP.
WHEN 1. WRITE: / 'You need to specify a value ', SY-MSGV1.
WHEN 2. WRITE: / '.NET component didnt find anything ', SY-MSGV1. WHEN 3. WRITE: / 'Some other error occurred ', SY-MSGV1. WHEN OTHERS. WRITE: / 'Something is wrong if we get here'. ENDCASE. |

The entry point in the C# method is the method with the function module name being called from the SAP system (for example, RFC_CUSTOMER_GET). In Microsoft Visual Studio, you can set a breakpoint here and examine the input values from the SAP system. This provides a similar idea to the ABAP_DEBUG functionality that is provided in the client proxy.