Skip to Content
0
Mar 13 at 01:11 PM

How to add or remove from stock?

82 Views Last edit Mar 14 at 07:13 PM 2 rev

Hi!

I want to add and remove items from stock with VBA.

The database-tables I can access with the DI:

*** Items ***
Tables: OITM ITM10

Code:


Dim oItem As New SAPbobsCOM.Items
Set oItem = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems)

Dim KeyVorhanden As Boolean

keyExists = oItem.GetByKey(theKey) ' theKey = OITM.ItemCode / ITM10.ItemCode
oItem.Update

------------------------

** BusinessPartner***
Table: OCRD

Code:

Dim oBP As New SAPbobsCOM.BusinessPartners
Set oBP = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners)

Dim KeyVorhanden As Boolean

keyExists = oBP.GetByKey(theKey) ' theKey = OCRD.CardCode
oBP.Update / oBP.Add

--------------------

*** Orders ***
Tables: ORDR RDR1

Code:

Dim oOrder As SAPbobsCOM.Documents
Set oOrder = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)

keyExists = oOrder.GetByKey(theKey) ' theKey = ORDR.CardCode
oOrder.Update

--------------

But now I want to add to stock. The tables are OBTN and OBTQ.
Or adding transactions. The tables are OITL and ITL1

How to access them?

With

Dim oST As New SAPbobsCOM.StockTransfer
Set oST = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer)

KeyVorhanden = oST.GetByKey(??)


???

Any idea?