Sapass

 Simplify SAP R/3 development with Excel VBA/VB RFC  
Home> Sap_Active_X>Call SAP RFC Function 2 (Dynamic)



Index

Call SAP RFC Function 2 (Dynamic)

This is just an alternative expreression on the RFC call.

(A) Declaration of Function
Same as static RFC call function, after you logged on through SAP.Functions logon method, you can add Function as written below.
Dim sapConn As Object 'Declare variant
Dim objData As Object
Set sapConn = CreateObject("SAP.Functions") 'Create ActiveX object

If sapConn.Connection.Logon(0, False) <> True Then 'Try Logon
  msgbox "Cannot Log on to SAP"
End If
'Define function
Dim objRfcFunc As Object
If Not sapConn.RFC_READ_TABLE(exception, QUERY_TABLE:="T001", _
      ROWCOUNT:=10, DATA:=objData) Then
   MsgBox "Call cannot be done"
End If
..'Retrieve data from objData


(B) Declaration of Export parameter
Unlike static RFC call (do with add method), you don't need to explicitly specify the parameter or structure to be used for the function if the import parameters are not in structure. You can just specify string or numbers directly as parameter.

(C) Declaration of Import parameter
Same as export parameter, you don't need to declare the parameter with referring to the function object. Simply you define the VB object (if it is structure or table), and include it in the dynamic call. After the call, the object will have the structure data as needed.

11-Nov-2005