How to use a remote enabled function module in SAP BW with VBA

If you have created your own SAP function module, you can use this with the following VBA code.

 

Sub FunctionModule()

'Variables Definition

Dim MyFunc As Object

Dim E_INSERTED As Object

Dim E_MODIFIED As Object

Dim DATA As Object

Set MyFunc = R3.Add("Z_RSDRI_UPDATE_LCP") 'FunctionModule Name in SAP BW

Set E_INSERTED = MyFunc.imports("E_INSERTED") 'InsertFunction in SAP BW

Set E_MODIFIED = MyFunc.imports("E_MODIFIED") 'ModifyFunction in SAP BW

 

Set DATA = MyFunc.tables("I_T_DATA") 'Table to store data and write to BW.

 

'Add data

DATA.Rows.Add 'add new data

rowDATA.Value(1, 1) = Sheet1.Cells(1, 10).Value 'First Cell of the data table is filled with the value from Sheet1.Cells(1,10)

 

'Call Insert or Modify

Result = MyFunc.CALL

 

'Message to the User

If Result = True Then

MsgBox "Insert Rows: " & E_INSERTED.Value & " Modify Rows: " & E_MODIFIED.Value, vbInformation

Else

MsgBox MyFunc.EXCEPTION 'Exception

End If

End Sub

Write a comment

Comments: 0