SIC and SAP CreateFunction from ERPConnectStandard20.dll

NicolasArgente
Valued Contributor

Hi there!

I am using OS v8.1 and SIC with latest ERPConnectStandard20.dll and the other dlls.
I can connect to SAP and retrieve data using READTABLE.

Now I am trying to use CreateFunction but I am struggling.
In my Smart Integration Function I have this : 

Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Common
Imports System.Globalization
Imports System.IO
Imports System.Linq

'Added for SAP ERP Connect
Imports Microsoft.VisualBasic
Imports ERPConnect
Imports ERPConnect.Utils


Namespace OneStream.BusinessRule.SmartIntegrationFunction.SAPTest8
	Public Class MainClass
		Public Shared Function RunOperation() As DataTable
			Dim r3Conn = New R3Connection("1.1.1.1", "00", "user", "pass", "EN", "224")
			r3Conn.Protocol = ClientProtocol.NWRFC
			r3Conn.Open()

			Dim r3Func As RFCFunction = r3Conn.CreateFunction("BAPI_MATERIAL_GET_DETAIL")
			r3Func.Exports("MATERIAL").ParamValue = "1001"
			r3Func.Execute()

			Return r3Func.Imports("MATERIAL_GENERAL_DATA").ToTable()

		End Function
	End Class
End Namespace

And in the Connector BR I have this line : 

Dim rDto As RemoteRequestResultDto = BRApi.Utilities.ExecRemoteGatewayBusinessRule(si, remoteBusinessRule, remoteFunctionArguments, sicGatewayName, sicRemoteRuleFunction, String.Empty, False, sicTimeout)

It is not working as the ToADOTable is not working anymore.

Return r3Func.Imports("TOTALS_SPL").ParamValue.ToADOTable()

Can someone help me on this SIF to return the datatable? 
And then to make it read by the Connector BR.

Thanks



Connect with me on:
LinkedIn: https://www.linkedin.com/in/nicolas-argente/
Website: https://aiqos.io
If you want to lift yourself up, lift up someone else.
1 ACCEPTED SOLUTION

NicolasArgente
Valued Contributor

Problem solved. All my code was fine, the mistake was on the client side. It was missing an error an export field! We had to use ABAP debugger to find out.
Thanks guys!

Connect with me on:
LinkedIn: https://www.linkedin.com/in/nicolas-argente/
Website: https://aiqos.io
If you want to lift yourself up, lift up someone else.

View solution in original post

7 REPLIES 7

RobbSalzmann
Valued Contributor

Hi @NicolasArgente , how do you know the datatable is not being returned?
Did you try to assign it from the return value:

Dim dataTable as DataTable = rDto.ResultSet

 

NicolasArgente
Valued Contributor

Hi Robb! Yes I tried that too. I believe there is a kind of bug with this new way of doing. FYI, I tried to return all the below : 


'Return r3Func.Imports("MATERIAL_GENERAL_DATA").ParamValue.ToADOTable()
'Return r3Func.Imports("MATERIAL_GENERAL_DATA").ToTable()
'Return r3Func.Tables.Item("MATERIAL_GENERAL_DATA").ToADOTable()
'Return r3Func.Tables("MATERIAL_GENERAL_DATA").ToADOTable()

On the SAP side, we see the call, but the call is extremely fast. And at the end it returns nothing.

If anyone has ever used CreateFunction on OS v8.0 or 8.1. Please share your code of the SIF.

Thanks

Connect with me on:
LinkedIn: https://www.linkedin.com/in/nicolas-argente/
Website: https://aiqos.io
If you want to lift yourself up, lift up someone else.

NicolasArgente
Valued Contributor

Problem solved. All my code was fine, the mistake was on the client side. It was missing an error an export field! We had to use ABAP debugger to find out.
Thanks guys!

Connect with me on:
LinkedIn: https://www.linkedin.com/in/nicolas-argente/
Website: https://aiqos.io
If you want to lift yourself up, lift up someone else.

KKGamer
New Contributor III

Hi Nicolas, I have build below code for SIF function. The table can be connected and should have data. But when I using another rule to call SIF function there is no data returned. do you know the reason?

 

Public Shared Function RunOperation() As DataTable                                                           
   'Build connection                       
Dim r3Conn = New R3Connection(v_host, v_instanceID, v_username, v_password, "EN", v_client)
           r3Conn.Protocol = ClientProtocol.NWRFC
r3Conn.Open()
Dim r3Table As New ReadTable(r3Conn)
r3Table.TableName = "/BIC/XXXXXXXX"
 
r3table.SetCustomFunctionName("Z_XTRACT_IS_TABLE")
r3Table.Addfield("COMPANY_CODE")
        r3Table.Run()
Return r3Table.result
End Function

@KKGamer It all seems good.
Just for testing, take away the Addfield. And check with the SAP team on their side. Also If they can trace info in the SAP debugger...

Connect with me on:
LinkedIn: https://www.linkedin.com/in/nicolas-argente/
Website: https://aiqos.io
If you want to lift yourself up, lift up someone else.

KKGamer
New Contributor III

The ERPConenct code is working in V7 to extract data from same table so i believe it's fine from SAP side. And below is the code I used to call the SIF function, is there anything wrong on return the datatable? Thanks.

    Dim rDto As RemoteRequestResultDto = BRApi.Utilities.ExecRemoteGatewayBusinessRule(si, "SAPConnection",Nothing, "sapdevtest", "RunOperation")
							
	If (rDto.RemoteResultStatus = RemoteMessageResultType.Success) Then
		BRAPI.ErrorLog.LogMessage(si,"Connect success")
		BRApi.ErrorLog.LogMessage(si, "Data Returned: " & rDto.ResultSet.Rows.Count)
		Dim dt As DataTable															
		dt = rDto.ResultSet								
		Return dt
	Else
		If (Not (rDto.remoteException Is Nothing)) Then
		BRAPI.ErrorLog.LogMessage(si,"Connect failed")
		Throw ErrorHandler.LogWrite(si, New XFException(si, rDto.remoteException))
		End If
	End If

 

Krishna
Valued Contributor

@NicolasArgente  - Could you please let me know what are the other DLL's are required apart from ERPConnect ? moreover could you please let me know what was the issue at SAP side ? I am using 8.3 & SIC and similar issue it is not returning any data.

Dim r3Conn = New R3Connection(SAPHost, SAPSysNum, SAPUser, SAPPwd, SAPLang, SAPClient)
Dim rfcFunction As New RFCFunction(r3Conn, "FUNNAME")

            ' Set the import parameters (if any)
            rfcFunction.Exports("YR").ParamValue = "2021"
	rfcFunction.Exports("MON").ParamValue = "01"
  rfcFunction.Execute()
				Dim data As DataTable = rfcFunction.Imports("TB").ParamValue.ToADOTable()
				Return data

 

Thanks
Krishna