Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI DimAs problem

Former Member
0 Kudos

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?

8 REPLIES 8

Former Member
0 Kudos

bump

0 Kudos

Did I post this in the wrong forum or just have everyone stumped on this like I am?

0 Kudos

I think you need to consult a VB specialist

Sorry, can't help you there, but maybe a search on service.sap.com on the relevant technologies might reveal something.

0 Kudos

Hi Joe,

There isn't really a good forum to post this question. So failing that, the ABAP forum is probably the best as it attracts the most people.

In my experience, not many people who are doing much VB integration with SAP (I am sure there are lots, but I mean relative to Java,COM,XML,etc.), so I guess there isn't a deep pool of people who can address your question (as demonstrated by the lack of responses).

I did check the parameters of the BAPI to see if there was anything different with the three that failed, but they seem to be pretty straight forward to me.

As you had success with the Getlist, its clear that all your software layers are put together ok, the only possible explanation that comes to mind is some non-obvious bug in your code. All I can suggest doing is to cut out your code and start again. Sometimes typos are incredibly hard to spot (and not just in the parameter names), and it could be something is just missing somewhere. If the second time works then you can compare old with new.

Not really a very encouraging response but the best I can come up with at this point.

Brad

0 Kudos

Hi Joe,

Try also the .NET forum:

Maybe someone there can help you out.

Brad

0 Kudos

Thanks for the responses and I tried the code again from scratch with the same result. I also tried it against a different version of SAPGui. (still same result) Found out a couple things along the way (typos in the parameters will generate an exception thrown through the BAPI control).

Thanks for the suggestions.

0 Kudos

Joe,

Are you still having problems with your BAPI? All of the BAPI's that I've ever called, whether it VB or ASP, have all been the same when using the DIMAS statement to reference structures/tables. They all referenced, whether local or global, an "ADODB.Recordset". For instance, your goods movement code structure for GOODSMVT_CODE (oGM_CFD_Code) may need to be declared before you reference it.


DIM oGM_CFD_Code as ADODB.Recordset

Of course, I'm using a SAP DCOM object, so it maybe different in your case. It looks as if yours may need to be dimmed as an object, from the manner in which you create your BAPI object.

Regards,

Terry

Former Member
0 Kudos

Hi!

GoodsmvtCode, GoodsmvtHeader, and GoodsmvtHeadret - is a structure.

call data from structures:

GoodsmvtHeader("PSTNG_DATE")

GoodsmvtHeader("DOC_DATE")

GoodsmvtSerialnumber, GoodsmvtItem - is a table.

call data from tables:

For i = 1 To GoodsmvtSerialnumber.RowCount

MsgBox GoodsmvtSerialnumber(i, "MATDOC_ITM") &

GoodsmvtSerialnumber(i, "SERIALNO")

Next i