Skip to Content
0
Former Member
Jan 19, 2008 at 05:13 AM

Coding Error

79 Views

Hi Experts

Regarding Create Sales order in SAP through VB, i have done the following code which collected from the forum.

Now it gives the run time error as 'Object Required' in the line

Set boOrder = oBAPICtrl.GetSAPObject("SalesOrder")

What could be the reason actually, pls help me on this issue.

Do i need SalesOrder object to be defined here, if so how and where pls help me.

Coding

Dim boOrder As Object 'Business object SalesOrder

Dim oPartners As Object 'Parameter OrderPartners of BAPI method

Dim oHeader As Object 'Parameter OrderHeaderIn of BAPI method

Dim oItemsIn As Object 'Parameter OrderItemsIn of BAPI method

Dim oReturn As Object 'Parameter Return of BAPI method

Private Sub Form_Load()

'Connect to business object SalesOrder

'(this creates an anonymous object with an empty key field):

Set boOrder = oBAPICtrl.GetSAPObject("SalesOrder")

'Get structure/table objects:

Set oPartners = oBAPICtrl.DimAs(boOrder, "CreateFromData", "OrderPartners")

Set oHeader = oBAPICtrl.DimAs(boOrder, "CreateFromData", "OrderHeaderIn")

Set oItemsIn = oBAPICtrl.DimAs(boOrder, "CreateFromData", "OrderItemsIn")

'Fill header:

oHeader.Value("DOC_TYPE") = "TA" 'Standard order

oHeader.Value("SALES_ORG") = "0001" 'Sales organization

oHeader.Value("DISTR_CHAN") = "01" 'Sales channel

oHeader.Value("DIVISION") = "01" 'Division

oHeader.Value("PO_NUMBER") = "" 'Customer purchase orderNumber

oHeader.Value("PRICE_DATE") = Now 'Date

'Fill partners:

oPartners.Rows.Add

oPartners.Value(1, "PARTN_ROLE") = "AG" 'PartnerRoll: Person posting the order

oPartners.Value(1, "PARTN_NUMB") = "0000010096" 'Customer number

'Fill items:

oItemsIn.Rows.Add

oItemsIn.Value(1, "REQ_QTY") = "0000000010000" 'Quantity

oItemsIn.Value(1, "MATERIAL") = "BERLINER" 'Product ID

oItemsIn.Value(1, "COND_VALUE") = "1432" 'Rate

'Call the method:

boOrder.CreateFromData OrderHeaderIn:=oHeader, _

OrderPartners:=oPartners, _

OrderItemsIn:=oItemsIn, _

Return:=oReturn

'Free the business objects:

Set boOrder = Nothing

End Sub

Thanks in advance.

Regards

Rajaram