2006 Nov 13 3:37 PM
Hello,
I´m trying to change the description of a document by using the BAPI "DOCUMENT_CHANGE2" in VBA. Logon to SAP and creating a local instance of the "DRAW" object work. But whem I´m trying to initially set the objects for the import parameter "documentdata" and "documentdatax", these objects get the Value "Error 0". I`m still able to set Values to these Objects (e.g. description). And the BAPI method "change2" is executed without an Error, but the description field hasn´t change. And i think that results of the "Error 0" message. For a better understanding here my VBA-Code:
Public Sub DocumentChange()
dim oBapiCtrl As Object
Dim oLogonCtrl As Object
Dim oDocument As Object
Dim oDocumentData As Object
Dim oDocumentDatax As Object
Dim oReturn As Object
'-----------------------------------------------------------------------------
' Logon SAP
'-----------------------------------------------------------------------------
Set oBapiCtrl = CreateObject("SAP.BAPI.1")
oBapiCtrl.Connection.client = txtClient.Value
oBapiCtrl.Connection.user = txtUser.Value
oBapiCtrl.Connection.Password = txtPassWord.Value
oBapiCtrl.Connection.Language = txtLang.Value
oBapiCtrl.Connection.hostname = txtServer.Value
oBapiCtrl.Connection.systemnumber = txtSysNumber.Value
If Not oBapiCtrl.Connection.Logon(0, True) Then
MsgBox "Logon error."
End If
'-----------------------------------------------------------------------------
' creating a local instance of the "DRAW" object
'-----------------------------------------------------------------------------
Set oDocument = oBapiCtrl.GetSAPObject("DRAW", strDocType, strDocNumber, strDocVersion, strDocPart)
'-----------------------------------------------------------------------------
' set the objects for the import parameter
'-----------------------------------------------------------------------------
Set oDocumentData = oBapiCtrl.DimAs(oDocument, "Change2", "DOCUMENTDATA")
Set oDocumentDatax = oBapiCtrl.DimAs(oDocument, "Change2", "DOCUMENTDATAX")
'-----------------------------------------------------------------------------
' set values to parameter
'-----------------------------------------------------------------------------
oDocumentData.Value("DOCUMENTNUMBER") = strDocNumber
oDocumentDatax.Value("DOCUMENTNUMBER") = "X"
oDocumentData.Value("DOCUMENTTYPE") = strDocType
oDocumentDatax.Value("DOCUMENTTYPE") = "X"
oDocumentData.Value("DOCUMENTPART") = strDocPart
oDocumentDatax.Value("DOCUMENTPART") = "X"
oDocumentData.Value("DOCUMENTVERSION") = strDocVersion
oDocumentDatax.Value("DOCUMENTVERSION") = "X"
oDocumentData.Value("DESCRIPTION") = strDocDescriptionChange
oDocumentDatax.Value("DESCRIPTION") = "X"
'-----------------------------------------------------------------------------
' execute change2 method
'-----------------------------------------------------------------------------
oDocument.Change2 _
DOCUMENTDATA:=oDocumentData, _
DOCUMENTDATAX:=oDocumentDatax, _
RETURN:=oReturn
If oReturn("TYPE") = "" Then
MsgBox "successful"
ElseIf oReturn("TYPE") = "W" Then
MsgBox "successful with warning:" & vbCrLf & vbCrLf & oReturn("Message")
Else
MsgBox "not successful:" & vbCrLf & vbCrLf & oReturn("Message")
End If
End SubHas anybody an idea what this error message will tell me?
Thanks
Robert Barnebeck
Hello,
I´m trying to change the description of a document by using the BAPI "DOCUMENT_CHANGE2" in VBA. Logon to SAP and creating a local instance of the "DRAW" object work. But whem I´m trying to initially set the objects for the import parameter "documentdata" and "documentdatax", these objects get the Value "Error 0". I`m still able to set Values to these Objects (e.g. description). And the BAPI method "change2" is executed without an Error, but the description field hasn´t change. And i think that results of the "Error 0" message. For a better understanding here my VBA-Code:
Public Sub DocumentChange()
dim oBapiCtrl As Object
Dim oLogonCtrl As Object
Dim oDocument As Object
Dim oDocumentData As Object
Dim oDocumentDatax As Object
Dim oReturn As Object
'-----------------------------------------------------------------------------
' Logon SAP
'-----------------------------------------------------------------------------
Set oBapiCtrl = CreateObject("SAP.BAPI.1")
oBapiCtrl.Connection.client = txtClient.Value
oBapiCtrl.Connection.user = txtUser.Value
oBapiCtrl.Connection.Password = txtPassWord.Value
oBapiCtrl.Connection.Language = txtLang.Value
oBapiCtrl.Connection.hostname = txtServer.Value
oBapiCtrl.Connection.systemnumber = txtSysNumber.Value
If Not oBapiCtrl.Connection.Logon(0, True) Then
MsgBox "Logon error."
End If
'-----------------------------------------------------------------------------
' creating a local instance of the "DRAW" object
'-----------------------------------------------------------------------------
Set oDocument = oBapiCtrl.GetSAPObject("DRAW", strDocType, strDocNumber, strDocVersion, strDocPart)
'-----------------------------------------------------------------------------
' set the objects for the import parameter
'-----------------------------------------------------------------------------
Set oDocumentData = oBapiCtrl.DimAs(oDocument, "Change2", "DOCUMENTDATA")
Set oDocumentDatax = oBapiCtrl.DimAs(oDocument, "Change2", "DOCUMENTDATAX")
'-----------------------------------------------------------------------------
' set values to parameter
'-----------------------------------------------------------------------------
oDocumentData.Value("DOCUMENTNUMBER") = strDocNumber
oDocumentDatax.Value("DOCUMENTNUMBER") = "X"
oDocumentData.Value("DOCUMENTTYPE") = strDocType
oDocumentDatax.Value("DOCUMENTTYPE") = "X"
oDocumentData.Value("DOCUMENTPART") = strDocPart
oDocumentDatax.Value("DOCUMENTPART") = "X"
oDocumentData.Value("DOCUMENTVERSION") = strDocVersion
oDocumentDatax.Value("DOCUMENTVERSION") = "X"
oDocumentData.Value("DESCRIPTION") = strDocDescriptionChange
oDocumentDatax.Value("DESCRIPTION") = "X"
'-----------------------------------------------------------------------------
' execute change2 method
'-----------------------------------------------------------------------------
oDocument.Change2 _
DOCUMENTDATA:=oDocumentData, _
DOCUMENTDATAX:=oDocumentDatax, _
RETURN:=oReturn
If oReturn("TYPE") = "" Then
MsgBox "successful"
ElseIf oReturn("TYPE") = "W" Then
MsgBox "successful with warning:" & vbCrLf & vbCrLf & oReturn("Message")
Else
MsgBox "not successful:" & vbCrLf & vbCrLf & oReturn("Message")
End If
End SubHas anybody an idea what this error message will tell me?
Thanks
Robert Barnebeck
2006 Nov 14 8:32 AM
Hello,
i have the same problem with this BAPI. Give it a chance of answer? Please.
best regards
Frank
2006 Dec 04 8:05 AM
Hello,
sorry for pushing this topic back to the top of the forum, but I still didn´t found a solution or a good documentation of this BAPI and this topic is really important to me. So again the awnser, if anybody has a tip for me how to use the BAPI "DocumentChange2" in the right way?
Regards,
Robert Barnebeck