Skip to Content
author's profile photo Former Member
Former Member

Error Creating an Order via VB by calling a BAPI

Hi Friends,

I am trying to create an Order in SAP in the PM Module. I am using the following code.

Private Sub Form_Load()

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

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

Set oBAPICtrl.Connection = oLogonCtrl.NewConnection

With oBAPICtrl.Connection

.Client = "xxx"

.ApplicationServer = ""

.SystemNumber = "01"

.Language = "en"

.User = "xxxxxx"

.Password = "xxxxxx"

.System = "01"

End With

If oBAPICtrl.Connection.Logon(0, False) = False Then

MsgBox "R/3 connection failed"



MsgBox "R/3 Connected"

End If

Set oMaintenanceOrder = oBAPICtrl.GetSAPObject("MaintenanceOrderBAPI")

Set oItMethods = oBAPICtrl.DimAs(oMaintenanceOrder, "OrderMaintain", "ItMethods")


oItMethods.Value(1, "REFNUMBER") = "1"

oItMethods.Value(1, "OBJECTTYPE") = "HEADER"

oItMethods.Value(1, "METHOD") = "CREATE"

oItMethods.Value(1, "OBJECTKEY") = "%00000000001"


oItMethods.Value(2, "REFNUMBER") = "1"

oItMethods.Value(2, "OBJECTTYPE") = "OPERATION"

oItMethods.Value(2, "METHOD") = "CREATE"

oItMethods.Value(2, "OBJECTKEY") = "%000000000010010"


oItMethods.Value(3, "OBJECTTYPE") = "OPERATION"

oItMethods.Value(3, "METHOD") = "DELETE"

oItMethods.Value(3, "OBJECTKEY") = "%000000000010020"


oItMethods.Value(4, "OBJECTTYPE") = ""

oItMethods.Value(4, "METHOD") = "SAVE"

oItMethods.Value(4, "OBJECTKEY") = "%00000000001"

Set oItHeader = oBAPICtrl.DimAs(oMaintenanceOrder, "OrderMaintain", "ItHeader")


oItHeader.Value(1, "ORDERID") = "%00000000001"

oItHeader.Value(1, "ORDER_TYPE") = "PM01"

oItHeader.Value(1, "PLANT") = "0001"

oItHeader.Value(1, "PLANPLANT") = "0001"

oItHeader.Value(1, "BUS_AREA") = "0001"

oItHeader.Value(1, "MN_WK_CTR") = "EXEC.BOA"

oItHeader.Value(1, "EQUIPMENT") = "000000000010007253"

oItHeader.Value(1, "SHORT_TEXT") = "Test"

Set oItHeaderUp = oBAPICtrl.DimAs(oMaintenanceOrder, "OrderMaintain", "ItHeaderUp")


oItHeaderUp.Value(1, "ORDERID") = "%00000000001"

'oItHeaderUp.Value(1, "ORDER_TYPE") = "X"

oItHeaderUp.Value(1, "PLANT") = "X"

oItHeaderUp.Value(1, "BUS_AREA") = "X"

oItHeaderUp.Value(1, "MN_WK_CTR") = "X"

oItHeaderUp.Value(1, "EQUIPMENT") = "X"

oItHeaderUp.Value(1, "SHORT_TEXT") = "X"

Set oItOperation = oBAPICtrl.DimAs(oMaintenanceOrder, "OrderMaintain", "ItOperation")


oItOperation.Value(1, "ACTIVITY") = "10"

oItOperation.Value(1, "WORK_CNTR") = "EXEC.BOA"

oItOperation.Value(1, "PLANT") = "0001"

oItOperation.Value(1, "CONTROL_KEY") = "PM01"

oItOperation.Value(1, "DESCRIPTION") = "TEST"


oItOperation.Value(2, "ACTIVITY") = "20"

oItOperation.Value(2, "WORK_CNTR") = "EXEC.BOA"

oItOperation.Value(2, "PLANT") = "0001"

oItOperation.Value(2, "CONTROL_KEY") = "PM01"

oItOperation.Value(2, "DESCRIPTION") = "TEST 1"

Set oItOperationUp = oBAPICtrl.DimAs(oMaintenanceOrder, "OrderMaintain", "ItOperationUp")


oItOperationUp.Value(1, "ACTIVITY") = "X"

oItOperationUp.Value(1, "WORK_CNTR") = "X"

oItOperationUp.Value(1, "PLANT") = "X"

oItOperationUp.Value(1, "CONTROL_KEY") = "X"

oItOperationUp.Value(1, "DESCRIPTION") = "X"

oMaintenanceOrder.OrderMaintain ItMethods:=oItMethods, _

ItHeader:=oItHeader, _

ItHeaderUp:=oItHeaderUp, _

ItOperation:=oItOperation, _

ItOperationUp:=oItOperationUp, _

Return:=oReturn, _


MsgBox oReturn.Value(1, "MESSAGE")

MsgBox oReturn.Value(1, "NUMBER")

MsgBox oReturn.Value(1, "ROW")

MsgBox oReturn.Value(1, "FIELD")

MsgBox oReturn.Value(1, "SYSTEM")

MsgBox oReturn.Value(1, "LOG_MSG_NO")

End Sub

The code is executing without any errors. But the Order is not getting generated. The value of oReturn.Value(1, "MESSAGE") is

<b> Error reading the standard sequence from the document tables</b>

When i consulted a person he is saying that "this isnt an error but this is purely on functional error because of some customizing sequence or some logic is there for some of the objects to be read hierarchicaly"

I am relly stuck up with this. Could any one of you suggest how to proceed.



Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Oct 19, 2005 at 07:17 AM

    the best way to check is to go to transaction se37 in SAP and run the FM with the same parameters. if you get the same errors there as well, then you need to figure out with the help of the functional consultant what that error means.



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.