Connect to SAP from .NET

Hi Techies! :)

Aim of this article is to show how to connect your .NET front-end with SAP.

Example scenario is such that SAP will act as the server and .NET application as the client. .NET application calls RFC "MONTH_NAMES_GET" exporting language parameter and import the names of the months.

Prerequisite:
1. SAP.NET connector should be available. You should have the following ".dll" files to proceed.
- rscp4n.dll
- sapnco.dll
- sapnco_utils.dll

2. Make sure the RFC you are calling is remote enabled. You can check this using transaction se37. if this option is not enabled, you will not be able to call the BAPI with an RFC call.

If the prerequisites are met, create the .NET application as below.
Create application project and add the references.











Select the ".dll" files.


Follow the below coding blocks to use the added libraries to connect to SAP system and access available BAPIs.

Add the libraries

Assign server details
Create RFC destination object

Create the repository object.

Create function object.

Set parameters of the function. 
LANGUAGE is the import parameter and MONTH_NAMES is a table parameter that returns names of the months.
"language" is a string variable with "EN" as default value.

Finally invoke the RFC.

You can use the variable "itab" which returns the names to do any other processing.















Labels: , , , , , , , ,