04-25-2006 10:37 AM
hello,
I want to do goods movement using visual basic.
when i testing the following code, an error occured while call the method CreateFromData . I debug the program,it seems no value in oHeader....
Could you give me any suggestion,thanks a lot!
'''******add sapbapicontrol from menu project-->component
Sub test()
dim oConnection
Set oConnection = SAPBAPIControl1.Connection
oConnection.client = "800"
oConnection.User = "SAPUSER"
oConnection.language = "EN"
If oConnection.Logon(0, False) <> True Then 'Logon with dialog
Set oConnection = Nothing
MsgBox "No access to R/3 System", vbOKOnly, APPID
End
Else
End If '''*** connect to sap R/3 ok
Dim oGMV
Dim oHeader
Dim oItem
Dim oHeaderRet
Dim oSer
Dim oReturn As Object
Dim j
Dim mvtCode
Dim strmatdoc
mvtCode = "04"
'
Set oGMV = SAPBAPIControl1.GetSAPObject("GoodsMovement")
<b>Set oHeader = SAPBAPIControl1.DimAs(oGMV, "CreateFromData", "GoodsmvtHeader")</b>
Set oItem = SAPBAPIControl1.DimAs(oGMV, "CreateFromData", "GoodsmvtItem")
Set oSer = SAPBAPIControl1.DimAs(oGMV, "CreateFromData", "GoodsmvtSerialnumber")
Set oHeaderRet = SAPBAPIControl1.DimAs(oGMV, "CreateFromData", "GoodsmvtHeadret")
<b>oHeader.Value("PSTNG_DATE") = "04.25.2006"
oHeader.Value("DOC_DATE") = "04.25.2006"</b>
oItem.Rows.Add
oItem.Value(j, "MATERIAL") = "Z11"
oItem.Value(j, "PLANT") = "1000"
oItem.Value(j, "MOVE_TYPE") = "301"
oItem.Value(j, "STGE_LOC") = "0001"
oItem.Value(j, "ENTRY_QNT") = 11
oItem.Value(j, "MOVE_MAT") = "Z11"
oItem.Value(j, "MOVE_PLANT") = "1100"
oItem.Value(j, "MOVE_STLOC") = "0001"
If Err.Number <> 0 Then
MsgBox "Create Data Error"
Exit Sub
End If
<b> oGMV.CreateFromData GOODSMVT_HEADER:=oHeader, GOODSMVT_CODE:=mvtCode, MATERIALDOCUMENT:=strmatdoc, GOODSMVT_ITEM:=oItem, GOODSMVT_SERIALNUMBER:=oSer, Return:=oReturn</b>
<i><b>
'''show runtime error 448 while running the program</b></i>
If Not oReturn Is Nothing Then
If oReturn("Type") <> "" And oReturn("Type") <> "S" Then
MsgBox oReturn("Type") + oReturn("Code") + vbCrLf + oReturn("Message"), vbOKOnly
Exit Sub
End If
Else
MsgBox "Create Successfully!Material Document No is:" + strmatdoc
End If
end sub
04-25-2006 12:30 PM
hi,
I haven't worked much on this topic.But I have some Docu which may be useful to u.
Send Me ur email ID at vinay.swarup@wipro.com
regards
Vinay swarup
04-25-2006 12:30 PM
hi,
I haven't worked much on this topic.But I have some Docu which may be useful to u.
Send Me ur email ID at vinay.swarup@wipro.com
regards
Vinay swarup
04-25-2006 1:11 PM
Hello Jie,
Can u point out the exact error. It could be that one of the header field which is mandetory is not filled because of which it is giving u error.
04-26-2006 4:04 AM
hi Abhijit,
the error description is : Named argument not found
i test the bapi:BAPI_GOODSMVT_CREATE with the same parameters but it can works , so i think the header field is ok.
ps:i try to call method like this:
oGMV.CreateFromData GOODSMVT_HEADER:=oHeader, GOODSMVT_CODE:=mvtCode, GoodsmvtHeadret:=oHeaderRet, GOODSMVT_ITEM:=oItem, Return:=oReturn
but the same error occured
04-26-2006 4:10 AM
Hi,
Can you try passing the value for the field HEADER_TXT in the HEADER strcuture?
Regards,
Ravi
Note :Please mark all the helpful answers
04-26-2006 4:40 AM
hello,
I try to pass the value for HEADER_TXT ,but still the same error message.
I add watch on oHeader, it shows error--no value
04-26-2006 5:47 AM
Hi Wu,
Reviewing your code in realtion to the error youu meinationed i don't see any row addition in oheader table .
Besiddes this I have used the following bapi;'s in the ASP.NET using C# and they all work fine
BAPI_GOODSMVT_CANCEL
BAPI_GOODSMVT_CREATE
BAPI_GOODSMVT_GETDETAIL
BAPI_GOODSMVT_GETITEMS
Regards
Kamran Ellahi
04-26-2006 6:20 AM
hello Kamran,
yes,I just want to know how to add data to oheader table,can you tell me? thanks!!
Regards
jie wu