cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI Help Required with GETSTATUS

0 Kudos

I have been extensively using SAP GUI Scripting for many years now. I am looking to replace this functionality with BAPI functions to improve the user feel of the interfaces I develop.

I have hit a bit of a problem and after extensive searching I have been unable to find a working example. I can connect, I can read the data retrieved within most key fields and attributes. The example I have been using is the Functional Location BAPI. I will need to read the system and user status's of this object. I have successfully used Dimas to call GetStatus but I believe DImas is used more for passing data to SAP and not retrieving.

Whether using DImas or getting the floc object to call getStatus I am still left with the question. How can I retrieve the data.

My Code below is only a test code to see how this all works.

Dim floc As Object

Dim Sstatus, Ustatus, oReturn, statusVals, sys, col, row As Object

Dim somthing As String

Dim obctrl As New SAPBAPIControlLib.SAPBAPIControl

obctrl.Connection.System = "Sys"

obctrl.Connection.Client = "400"

obctrl.Connection.User = "user"

obctrl.Connection.Password = "pwd"

obctrl.Connection.Language = "EN"

'obctrl.Connection = logCtrl.NewConnection

obctrl.Connection.Logon(0, True)

On Error GoTo errorhandler

Err.Clear()

floc = obctrl.GetSAPObject("FunctionalLocation", "3001-320-2553")

Sstatus = obctrl.DimAs(floc, "GetStatus", "SystemStatus")

statusVals = obctrl.DimAs(floc, "GetStatus", "Return")

Ustatus = obctrl.DimAs(floc, "GetStatus", "UserStatus")

floc.GetStatus(SystemStatus:=Sstatus, UserStatus:=Ustatus, Return:=oReturn)

Any assisstance with this and the use/purpose of dimas would be helpful.

Regards

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Solved it in the end. Hope this helps someone else.

The method is as follows.

Create your SAP persistant object.

The fields and some attributes are directly accessable with the . method.

To get GetStatus to work first call dimAs to get the system status and user status. and storing these into objects

Then call the getstatus function from the equip passing in these structure objects.

The results can then be quireid using the value ("PARAMETER NAME") or value (1,"PARAMETER NAME").

floc = obctrl.GetSAPObject("FunctionalLocation", "3001-320-2553")

MsgBox(floc.FunctLocation)

MsgBox(floc.Description)

Sstatus = obctrl.DimAs(floc, "GetStatus", "SystemStatus")

Ustatus = obctrl.DimAs(floc, "GetStatus", "UserStatus")

floc.GetStatus(SystemStatus:=Sstatus, UserStatus:=Ustatus)

MsgBox(Sstatus.value(1, "STATUS"))

MsgBox(Sstatus.value(1, "TEXT"))

MsgBox(Sstatus.value(1, "DESCRIPTION"))