Skip to Content
0
Former Member
May 26, 2005 at 07:13 PM

BAPI DimAs problem

76 Views

You have to excuse my question if this is a simple problem but I'm just getting into BAPIs.

I have been tasked with creating an application that will create goods movements in SAP through watching a database table. That in and of itself isn't that big of a task (I believe).

So using the SAP documentation on BAPIs I created a little test driver to try and do some test transactions on our company's test system. So I have the following code:

Set oBAPICtrl = CreateObject("SAP.BAPI.1")

Set oLogonCtrl = CreateObject("SAP.LogonControl.1")

oBAPICtrl.LogLevel = 9

oBAPICtrl.BAPIExceptionCodes = True

Set oBAPICtrl.Connection = oLogonCtrl.NewConnection

oBAPICtrl.Connection.Client = "800"

oBAPICtrl.Connection.Destination = TESTSYSTEM

oBAPICtrl.Connection.Language = "E"

oBAPICtrl.Connection.User = USERNAME

oBAPICtrl.Connection.Password = PASSWORD

oBAPICtrl.Connection.Logon 0, True

Set oGM = oBAPICtrl.GetSAPObject("GoodsMovement")

From there I started out testing against the GetItems which worked exactly as expected. So I next started working with the CreateFromData function and this is where I've encountered a problem that I'm having problems solving.

When I try to use the DimAs method to create the objects for the parameters sent in the CreateFromData method, 3 of the 5 calls fail.

i.e. take the following code

Set oGM_CFD_Code = oBAPICtrl.DimAs(oGM, "CreateFromData", "GoodsmvtCode")

Set oGM_CFD_Header = oBAPICtrl.DimAs(oGM, "CreateFromData", "GoodsmvtHeader")

Set oGM_CFD_Item = oBAPICtrl.DimAs(oGM, "CreateFromData", "GoodsmvtItem")

Set oGM_CFD_Return = oBAPICtrl.DimAs(oGM, "CreateFromData", "Return")

Set oGM_CFD_HeaderRet = oBAPICtrl.DimAs(oGM, "CreateFromData", "GoodsmvtHeadret")

Setting using DimAs against GoodsmvtCode, GoodsmvtHeader, and GoodsmvtHeadret fails and instead sets the corresponding objects to "Error 0"

I've turned on tracing to the highest level and still don't see anything that may lead to why these 3 calls are failing. At first I thought that there may be some form of typo, so I copied the named directly out of the tracing file and still the same result.

Can anyone give me some ideas as to why these are failing?