SAP RFC access from FactoryStudio VB .NET

Hi all.
We are investigating reworking an application from another product to FactoryStudio. Our original application uses SAP RFCs successfully via ActiveX, and we are trying to achieve the same within the FactoryStudio VB .NET environment … so far without success.

I’m hoping someone has already had the challenge of doing this, and will be able to provide some advice. I recall it also took quite some time to get the original interface working.

Any advice would be appreciated.

Regards,
Greg Shearer

Hi Greg,

We have interfaced to SAP, using several methods. From your post it sounds like you may be able to use the SAP .NET Connector 3.0 (NCO). We would be glad to talk to you in more detail as well as support your effort.

Thx - Harry McCollum Tatsoft
@HarryT

Hi Harry, and thanks so much for your response.

It confirms what we have seen through our initial investigations.
What we are not clear on is how to progress from here.

Our existing application makes use of an ActiveX (ocx file) which installs along with the SAP client.
I had expected that the .NET Connector 3.0 would also be installed as part of the SAP client.
Do you know if that is the case … or is this a separate installation requirement?
If so, we should be able to obtain it ok through our IT group.

We had found associated files (sapnco.dll and sapnco_utils.dll) on our installations.
So if these are the required files, what we are lacking is the correct method of connecting with SAP.
We have been trying to use our original coding … but I suspect this may not be suitable.
An example of our coding (for obtaining a confirmation balance) is outlined below in case it offers you any insight.
Could we expect this coding to work correctly if the .NET Connector is installed … or is the .NET coding totally different?
The code currently fails at the first hurdle …. Set MyFunc = oBAPICtrl.add(“SAP_transaction_name”)

The code below works fine within our current application.
Any advice you can provide on .NET requirements will be appreciated.
If what we are missing is the .NET Connector 3.0, we will be able to resolve this through our IT group.

Thanks again,
Greg Shearer

Dim oBAPICtrl
Dim MyFunc
Dim CONFIRM_NO
Dim PLANT
Dim RECORD
Dim Results

'logon Parameters Set For SAP.Functions
'*********************************************
$STRUCT_SAP.User = “XXXX”
$STRUCT_SAP.Pass = “XXXX”
$STRUCT_SAP.Client = “XXXX”
$STRUCT_SAP.Lang = “en”
$STRUCT_SAP.System_Id = “XXXX”
$STRUCT_SAP.HostName = “XXXX”
'*********************************************
'Connection Logon
Set oBAPICtrl = CreateObject(“SAP.Functions”)
oBAPICtrl.Connection.Client = $STRUCT_SAP.Client
oBAPICtrl.Connection.User = $STRUCT_SAP.User
oBAPICtrl.Connection.Language = $STRUCT_SAP.Lang
oBAPICtrl.Connection.Password = $STRUCT_SAP.Pass
oBAPICtrl.Connection.Hostname = $STRUCT_SAP.HostName
oBAPICtrl.Connection.Logon 1, True
'**********************************************

$SAP_response = “Logged on OK!!!”

Set MyFunc = oBAPICtrl.add(“SAP_transaction_name”)

Set CONFIRM_NO = MyFunc.exports(“CONFIRM_NO”)
Set PLANT = MyFunc.exports(“PLANT”)
CONFIRM_NO.value = confirmation
PLANT.value = $mach.plant

$Balance.LMNGA = 0
$Balance.WERKS = “”
$Balance.RUECK_1 = “”
$Balance.RUECK_2 = “”
$Balance.MEINH = “”

Set RECORD = MyFunc.Tables(“RECORD”)
Results = MyFunc.Call
If Results <> True Then
$SAP_response = MyFunc.exception
Else
$SAP_response = “Success”
$Balance.LMNGA = RECORD(1,“LMNGA”)
$Balance.WERKS = RECORD(1,“WERKS”)
$Balance.RUECK_1 = RECORD(1,“RUECK_1”)
$Balance.RUECK_2 = RECORD(1,“RUECK_2”)
$Balance.MEINH = RECORD(1,“MEINH”)
$Balance.MATNR = RECORD(1,“MATNR”)
$Balance.MAT_DESCR = RECORD(1,“MAT_DESCR”)
End If

oBAPICtrl.Connection.logoff
Set oBAPICtrl = Nothing

If anyone is able to provide any guidance on the use of SAP .NET Connector to access RFCs within FactoryStudio it would really be appreciated. We have been trying to follow coding examples obtained from several on-line sources, but are unfamiliar with .NET coding and have had no luck so far.

My current approach is to first develop a basic Console application with Visual Studio, and then migrate to FactoryStudio. So any SAP .NET Visual Studio examples would also be appreciated.

I have been surprised by how cryptic and varied C#/.NET coding can appear. Although finding many examples of essentially similar SAP interfacing examples … there has often been little recognisable code similarity.

I know this shouldn’t really be that hard :slight_smile:

Regards,
Greg Shearer

Hi again all.

Just letting you know that I managed to get our SAP connection working with a lot of help from this on-line VB .NET example. As hoped … at the end of the day it wasn’t that hard … although earlier code examples I had found had certainly made it seem that way :confused:

Nice you already found the solution and could make the connection between FactoryStudio and SAP.

We will post below just for the forum consult other ways to do that:

We did some research on that topic and we found this link with the downloads and tutorial from SAP:

We also found the link below:

The best way is to first try to create a simple example with VisualStudio and then it will be simple move it to FactoryStudio.

There is another option, if you are already familiar with ActiveX, create a wrapper in .Net and provide the same methods from ActiveX in a WPF Control and then just use this WPF Control inside FactoryStudio.

The link below give some tips and steps how to do that:

Best Regards,
Tatsoft Team.