A command can be specified against the Microsoft .NET provider for SAP to execute a Remote Function Call (RFC) or to execute a call against the SAP Business Application Programming Interfaces (BAPI).
The following examples show the syntax for EXEC statements.
The following EXEC statement executes a BAPI that has no input parameters.
EXEC BAPI_COMPANYCODE_GETLIST
The following EXEC statement executes an RFC that has one input parameter. The parameter specifies a name and a value.
EXEC RFC_CUSTOMER_GET @NAME1='Contoso'
The following EXEC statement executes an RFC that has an input parameter. No name is specified, only a value is used.
EXEC RFC_CUSTOMER_GET '1001'
The following EXEC statement executes an RFC that has an input parameter specified in a variable.
To execute this statement, you must create a SAPParameter object with name @var, set its value to 1001, and add it to the SAPCommand object corresponding to the query. The value of the variable must be 1001, because the first parameter for RFCRFC_CUSTOMER_GET corresponds to KUNNR.
EXEC RFC_CUSTOMER_GET @var
The following EXEC statement executes an RFC that uses two parameters. The value of the first parameter, KUNNR, is set to *, to indicate all customer numbers, and the second parameter, NAME1, is set to the value of the variable, @var1.
To execute this statement, you must create a SAPParameter object with the name @var1, specify its value, and add the new object to the SAPCommand object corresponding to the query. The direction of the SAPParameter object must be input.
RFC_CUSTOMER_GET @KUNNR='*',@NAME1=@var1
The following EXEC statement executes a BAPI that returns company names and information about each company.
To execute this statement, you must create a SAPParameter with the name @tableVar, specify its value, and add the SAPParameter to the SAPCommand object corresponding to the query. The direction of the SAPParameter object created must be inputoutput.
EXEC BAPI_COMPANYCODE_GETLIST @COMPANYCODE_LIST=@tableVar OUTPUT