Skip to Content

Agreed! This topic is very old and a lot of information already available on SDN. But I realized during my pursue recently that most of the information in forum threads are abstract
and it takes quite long to gather all the information necessary form different sources (forum posts, help files etc) to develop a working solution.

And that prompted me to write this blog in which I am going to list out all the steps required to develop such a application.

Follow the steps as below and I am sure you will be having a working application at the end of it.

 

1. Create a blank RFC using transaction SE37 in SAP. For demo purpose, I have created RFC “Y_JIT_TEST_RFC” with only one input and one output parameter.
You can define the parameter type as you wish. I have selected the parameter types from the ones available on my system.

2. Use the transaction SM59 to create RFC destination. Select connection type “TCP/IP Connection” and click create icon. You can specify RFC Destination name as you like.

 

Create RFC destination

There are couples of things important here. And sometimes drives you to nuts if failed to be understood correctly.

Dos-

  • You can specify “Program ID” of your choice. Just ensure this is unique. To check other entries you may go to SMGW transaction menu -> Go to -> Logged Client. 
  • Gateway Host and Gateway Service values can be obtained from SAP Administrator.
  • Ensure Activation Type is “Registered Server Program”
  • Rest of parameters I had left untouched.

Don’ts-

  • Don’t try to click “Connection Test” or “Unicode Test” these will throw errors. Because first Dot Net program has to register itself on SAP Gateway. That will happen when you will
    run .NET application from VS2003. 

3. Create a Console application project in VS2003. Right click on the project “Add New Item” -> “SAP Proxy”. Add the proxy. And from Server explorer window drag and drop RFC on proxy wsdl designer (in my case it is “Y_JIT_TEST_RFC”).

4. Right click on the designer and select properties. Set ProxyType as Server. See in Solution Explorer SAPProxy1Impl.vb is generated. Save All the files and click ShowAllFiles icon in solution Explorer.

Visual Studio Server Stub settings

There are two method of utmost importance in SAPProxy1Impl.vb generated by NCo. First is Overrided one where you can write my own implementation of the RFC. And the Main(Args As String()) method which registers my .NET program to SAP Getway.

Overrides Protected Sub Y_Jit_Test_Rfc ( ByVal I_Year As String, ByRef E_Result As String)
‘ TODO: add your server code here    

End Sub

 

‘ Example Main function
    Shared Sub Main(Args As String())
      Const NumberOfServers As Integer = 3
      Dim Host As SAPServerHost = new SAPServerHost()

      ————————————————

      ———————————————— 

   End Sub

5. Now, pass ProgramID, Gateway Host, Gateway Service values (remember as we specified in SM59 when we created RFC destination) to Main(Args As String()) method and this method should execute first.

Either you can programmatically assign the values in code or may be define as command line argument settings under project -> Properties in Visual Studio.

Visual Studio App Runtime arguments

Now Execute the application and you should be able to see the screen as below.

Application Execution

If you have been able to assign the parameters correctly then I should be able to see my Program ID “APPID01” under SMGW monitor.

6. All set now.  Create a Report using SE38 and execute the RFC specifing destination created in SM59-

data: l_result type AAB_PROT_DETAIL_FIELDNAME.

CALL FUNCTION ‘Y_JIT_TEST_RFC’ destination ‘JITTEST’
 EXPORTING
   I_XXXX         = ‘2001’
 IMPORTING
   E_RESULT       = l_result.

write: l_result.

Execute the report. And overriden method in .NET should be executed and give you result back in your report depending upon method implementation 🙂

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

  1. Jerome Fortias
    I success to connect SAP from a .net application wrote with SAP .net connector, BUT I didn’t success to do the same from SAP MiniWAS to a RFC server built with SAP .net connector …  I did like you did MS SIDE, but I have not the same screen on SM59…  The name of my MINIWAS computer is vmminiwas. What’s the right parameters I should use on SM59… Now I have a no reacheable or a Timeout !!!
    (0) 

Leave a Reply