Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

how to execute Goodsmovement using VB


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 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.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>


'''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


MsgBox "Create Successfully!Material Document No is:" + strmatdoc

End If

end sub



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

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question