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: 

Object variable not set error in SAP-VB Connect.

Former Member
0 Kudos

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

1 REPLY 1

Former Member
0 Kudos

I hope someone can help with this... I have discovered that systems with SAP GUI 7.2 installed properly recognize oHeader.Value("DOC_TYPE")

But, my system, with SAPGUI 7.4 installed does not!

I would still like to used named object references, but if they're unreliable, where can we turn?