11-19-2007 12:05 PM
Hi,
I use the recommended remote function "BAPI_STUDENT_CREATEFROMDATA3" through Excel VBA to import student data, which seems to run fine - it returns a success message and student's object ID generated, e.g. "TRUE, 00000795". However, whenever I check the Student file or PP01 for this newly created student, I can't find it.
Any ideas what can go wrong? I already tried to look up this student using different key dates - no success.
Sub TestStudentCreation()
Dim functionCtrl As Object 'Function Control (Collective object)
Dim sapConnection As Object 'Connection object
Dim theFunc As Object 'Function object
Set functionCtrl = CreateObject("SAP.Functions")
Set sapConnection = functionCtrl.Connection
sapConnection.Client = "020" 'Test client
sapConnection.user = "janek"
sapConnection.Language = "EN"
If sapConnection.logon(0, False) <> True Then
MsgBox ("No connection to R/3!")
Exit Sub
End If
Set theFunc = functionCtrl.Add("BAPI_STUDENT_CREATEFROMDATA3")
'Fills the structure with key required fields
Dim oStructure As Object
theFunc.Exports("STUDENTPERSONALDATA").Value("LAST_NAME") = "TestLastName"
theFunc.Exports("STUDENTPERSONALDATA").Value("FIRST_NAME") = "TestFirstName"
theFunc.Exports("STUDENTPERSONALDATA").Value("CORRESP_LANGUAGE") = "E" 'English
Dim returnFunc As Boolean
returnFunc = theFunc.Call
functionCtrl.Connection.logoff
MsgBox (returnFunc & " " & theFunc.Imports("OBJECTID").Value)
End Sub
11-19-2007 2:36 PM
A quick guess (without immediately having verified whether it is really true...): you may have to do a subsequent "commit" call, something like BAPI_TRANSACTION_COMMIT or so.
11-19-2007 2:36 PM
A quick guess (without immediately having verified whether it is really true...): you may have to do a subsequent "commit" call, something like BAPI_TRANSACTION_COMMIT or so.
11-19-2007 6:00 PM
11-19-2007 3:52 PM
We had the same problem with BAPI_CTRACDOCUMENT_CREATE, and we could only generate a document number but we could not found it. So we used the commit Joachim mentioned and we could post documents then
Cheers
Sergio