Calling enaio® data2s
Calling an RFC-enabled Function Module
enaio® data2s is used to call an RFC-enabled function module in an SAP system as seen in the following example:
' data2s initialisieren
Dim axData2Sap
Set axData2Sap = CreateObject("axData2SAP.ComServer.MainApp")
' Parameter-Objekt erzeugen
Dim oParameters
Set oParameters = CreateObject("Scripting.Dictionary")
' Eingabeparameter (EXPORTING) füllen
oParameters.Add "BUSINESSPARTNER","COL001"
' Aufruf Funktionsbaustein
Dim oFunc
Set oFunc = axData2Sap.ExecuteFunction("Testsystem", "BAPI_BUPA_CENTRAL_GETDETAIL", oParameters)
' Return-Code auswerten (z.B. SAP-System nicht verfügbar, etc.)
If oFunc is Nothing Then ' Lizenzfehler
MsgBox "Keine Lizenz für data2s vorhanden"
Elseif oFunc.ReturnCode <> 0 Then ' Kommunikationsfehler
MsgBox oFunc.ReturnCode & " " & oFunc.Exception
Else
' Meldungen aus dem BAPI auswerten
Dim errortype
errortype = ""
For Each ret in oFunc.Tables("RETURN").Rows
If ret("TYPE") = "E" or ret("TYPE") = "A" or _
ret("TYPE") = "X" Then
' Eine Fehlermeldung:
MsgBox ret("TYPE") & " " & ret("MESSAGE")
errortype = ret("TYPE")
End If
Next
If errortype = "" Then
' Daten auswerten
Dim oDetail
Set oDetail = oFunc.Imports("CENTRALDATAORGANIZATION")
'MsgBox TypeName(oDetail)
MsgBox oDetail("NAME1")
End If
End If
When enaio® data2s calls the 'ExecuteFunction' function, this returns an SAP function object that provides access to the return values of the function call via its properties.
It is also possible to transfer structures as input parameters and table parameters (TABLES) as seen in the example below:
' Array für Positionstabelle erzeugen
Dim aPositions(0)
' Objekt für eine Position erzeugen
Set oEntry = CreateObject("Scripting.Dictionary")
' Positionsdaten füllen
oEntry("Feld1") = "Wert1"
' Position in Array anhängen
Set aPositions(0) = oEntry
' Positionen zu Parameterobjekt hinzufügen
oParameters.Add "POSITIONS",aPositions
' Oder Struktur zu Parameterobjekt hinzufügen
oParameters.Add "STRUCTURE",oEntry
Call to Generate a Document Link
After a request has been generated, both the underlying document and a log to be created should be reported to SAP and linked to the associated request in the attachment list. This is done by calling the 'DocConnect' function of enaio® data2s as seen in the following example:
' data2s initialisieren
Dim axData2Sap
Set axData2Sap = CreateObject("axData2SAP.ComServer.MainApp")
' Funktionsaufruf
set oRet = axData2Sap.DocConnect(19620, "Testsystem", "OS",
"BKPF", "100019000000172012", "FIIINVOICE")
' Fehler auswerten
If oRet is Nothing Then ' Lizenzfehler
MsgBox "Keine Lizenz für data2s vorhanden"
Elseif oRet.ReturnCode <> 0 Then ' Kommunikationsfehler
MsgBox oRet.ReturnCode & " " & oRet.Exception
Else
MsgBox "Alles OK"
end if
The sample script contains fixed sample data and only basic error analysis. Data must be obtained and appropriate actions taken in response to errors that occur as part of the client's involvement in the overall project.
The 'DocConnect' function has the following parameters:
Parameter |
In the example above |
Comment |
---|---|---|
Object ID |
19620 |
enaio® object ID of the filed document or log |
SAP configuration |
"Testsystem" |
SAP target system ID (see section SAP Configuration) |
Content repository |
"OS" |
Name of target repository from SAP (see section DocConnect Settings) |
SAP object type |
"BKPF" |
BFPK is the object type for posting documents |
Object key |
"100019000000172012" |
SAP object key formed as per the SAP object type. The key consists of the company code, receipt number, and fiscal year in this example. |
SAP document type |
"FIIINVOICE" |
The document type must be maintained in SAP Customizing. |
The return value of the function call is also an SAP function object that gives access to the return values 'ReturnCode' and 'Exception' via its properties.
The document type used must be linked to the SAP object type and the content repository in SAP Customizing (OAC3).
The following activities are performed as part of this function call:
-
The SAP configuration and content repository from the central configuration file (section Configuring enaio® data2s) are used to determine which technical cabinet will be used.
-
The document with the transferred object ID is moved to this technical cabinet, and a reference document is created in its place (or vice versa if the accompanying box is not ticked). The document receives a generated GUID as the SAP DocID in the technical cabinet.
The task of enaio® data2s is to take a real document in a non-technical cabinet and create a pair of one document and one reference document in the non-technical and technical cabinet. enaio® data2s is not required to process additional references. However, be careful to ensure that there are no unauthorized references to references.
-
Via RFC, a document link is created in the SAP target system between the SAP object defined according to the object type and object key (here: a specific posting) and the new document in the technical cabinet. As a result, the document can be searched in the object's attachment list.
Interaction with enaio® data2ecm
If the enaio® data2ecm component is also enabled at the same time in the SAP target system, an action could be triggered to immediately write data from SAP to enaio® by creating the document link if the appropriate customized settings are in place. To avoid this, the 'DocConnect' function can be used instead of the 'DocConnectSAP' function, which has the identical parameters and functionality. The difference is that the enaio® data2ecm component ignores the generated link and does not automatically process it.
The 'DocConnectSAP' is only available if the transport for enaio® data2ecm exists in the SAP target system.