Skip to Content
0
Former Member
Jan 30, 2008 at 09:14 AM

Object variable not set error in SAP-VB Connect.

52 Views

This is the coding part i have used for connecting SAP and VB for creating the Sales Order in SAP.

But it gives the error in the line

oheader.Value("DOC_TYPE") = Text1(0)

as Object variable or With block variable not set.

What could be the reason, pls advise me.

Dim bapictrl As Object

Dim boOrder As Object

Dim oPartner As Object

Dim oItemin As Object

Dim oheader As Object

Dim oreturn As Object

Dim oconnection As Object

Private Sub Command1_Click()

Dim x As String

oheader.Value("DOC_TYPE") = Text1(0)

oheader.Value("SALES_ORG") = Text1(1)

oheader.Value("DISTR_CHAN") = Text1(2)

oheader.Value("DIVISION") = Text1(3)

oheader.Value("PRICE_DATE") = Text1(4)

oheader.Value("PURCH_NO") = Text1(5)

oPartner.rows.Add

oPartner.Value(1, "PARTN_ROLE") = Text1(6)

oPartner.Value(1, "PARTN_NUMB") = Text1(7)

oItemin.rows.Add

oItemin.Value(1, "REQ_QTY") = Text1(8)

oItemin.Value(1, "MATERIAL") = Text1(9)

oItemin.Value(1, "COND_VALUE") = Text1(10)

boOrder.createfromdata orderheaderin:=oheader, orderitemsin:=oItemin, orderpartners:=oPartner, return:=oreturn

x = oreturn.Value("message")

If x = "" Then

MsgBox "Transactin Complete"

Else

MsgBox x

End If

End Sub

Private Sub Form_Load()

Text1(4) = Format(Now, "mm/dd/yyyy")

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

Set oconnection = bapictrl.Connection

oconnection.logon

Set boOrder = bapictrl.GetSAPObject("SalesOrder")

'Set boOrder = bapictrl.GetSAPObject("BUS2032")

Set oPartner = bapictrl.DimAs(boOrder, "CreateFromData", "orderpartners")

Set oPartner = bapictrl.DimAs(boOrder, "CreateFromData", "orderitemsin")

Set oPartner = bapictrl.DimAs(boOrder, "CreateFromData", "orderheaderin")

End Sub

Thanks in advance

Regards

Rajaram