问题描述
目标 创建一个简单的Excel应用程序以发布SAP中多个物料文档的“退货交货”。
我的假设是我将需要使用BAPI“ BAPI_GOODSMVT_CREATE”。
'------'
'logon to SAP
'------'
Dim sapConn As Object ' Declare variant
Set sapConn = CreateObject("SAP.Functions") ' Create ActiveX object
With sapConn.Connection
.Destination = "somehost"
.ApplicationServer = "someserver.com"
.Client = "someclient"
.User = "someuser"
.Password = "somepassword"
.SystemNumber = "somesystem"
End With
If sapConn.Connection.logon(1,False) <> True Then 'Try logon
MsgBox "Cannot Log on to SAP"
End If
然后我定义函数
'------'
'Define function
'------'
Dim objRfcFunc As Object
Set objRfcFunc = sapConn.Add("BAPI_GOODSMVT_CREATE")
现在,这一切都停止了。我通过在工作表迭代(查看单元格值)中填充该方法来运行其他BAPI。
If objRfcFunc.Call = False Then
MsgBox "Call failure" + objRfcFunc.Exception
End If
我真正不明白的是,执行BAPI所需的 minimum (最小数)字段是什么? 我需要填写什么BAPI字段?
如果我通过MIGO事务在SAP中手动执行此操作,则需要: 物料凭证和物料凭证年度。
我选择的功能是“退货”->“物料单”。
很明显,我缺少一些代码来填充数据,但是我根本不知道从哪里开始。 我已经完成了this个帖子,没有任何运气。 任何帮助或指向正确方向的指针都将不胜感激。
解决方法
获取具体的物料凭证编号(或多个,如果可能的话)
不可能。 BAPI_GOODSMVT_CREATE 文档在第一行中表示了这一点,您每次调用该方法时只能创建一个物料文档。
您应使用GM_CODE 01进行货物移动122(退货),并且BAPI文档在此GM_CODE的必填字段之后列出:
- 购买订单
- 购买订单项
- 运动类型
- 运动指示器
- 进入单位的数量
- ISO代码的计量单位,用于输入或 数量建议
对于已知的PO:
可能必须填充以下字段(这不是完整的列表):
- Reason for movement (if set up in the system)
- Batch (if the material is handled in batches and no automatic batch assignment has been set up)
- Storage location (if no storage location us specified in the purchase order item)
可以填充以下字段(这不是完整的列表):
- Item text
- Unloading point
- Delivery completed indicator
不得填充以下字段(这不是完整的列表):
- Reservation
- Receiving/issuing material
- Receiving/issuing plant
- Receiving/issuing storage location
这完全取决于采购订单的已知/未知以及是否应创建。只是RTFM。
要填写的绝对最小字段:
**Header**
DOC_DATE = 20050513 | Document date in document BLDAT
REF_DOC_NO = 345060A| Reference document number XBLNR
PR_UNAME = JOHNDOE | User name UNAME
GM_CODE = 01 | Assign code to transaction for BAPI goods movement
**Item**
MOVE_TYPE = 122 | Movement type (inventory management)
VENDOR = 1008056 | Vendor’s account number
ENTRY_QNT = 1.00 | Quantity in unit of entry
ENTRY_UOM = EA | Unit of entry
PO_NUMBER = ASA99834| Purchase order number
PO_ITEM = 00001 | Item Number of Purchasing Document
MVT_IND = B | Goods movement for purchase order Movement indicator