cancel
Showing results for 
Search instead for 
Did you mean: 

Purchase order line items

Former Member
0 Kudos

Hi,

I tried to add Purchase order line items to POR1 table.

It shows "[POR1] , 'Error (-1004) encountered.'" This is my code below. Please help

Dim oPurchaseLine As SAPbobsCOM.Document_Lines

oPurchaseLine = pCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders)

For j = 1 To oMatrix1.VisualRowCount

oMatrix1.GetLineData(j)

If sCode = oForm.DataSources.UserDataSources.Item("us_col11").Value Then

oPurchaseLine.Lines.BaseEntry = nDocNum

oPurchaseLine.Lines.BaseLine = k

oPurchaseLine.Lines.BaseType = 22

oPurchaseLine.Lines.ItemCode = oForm.DataSources.UserDataSources.Item("us_col13").Value

sQuery = " select itemname from oitm where itemcode ='" & oForm.DataSources.UserDataSources.Item("us_col13").Value & "'"

rs.DoQuery(sQuery)

If Not rs.EoF Then

oPurchaseLine.Lines.ItemDescription = rs.Fields.Item("itemname").Value

End If

oPurchaseLine.Lines.Quantity = oForm.DataSources.UserDataSources.Item("us_col14").Value

oPurchaseLine.Lines.Price = oForm.DataSources.UserDataSources.Item("us_col14").Value

oPurchaseLine.Lines.Add()

k = k + 1

End If

Next

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

A small correction in my code..

I tried to add Purchase order line items to POR1 table.

It shows "[POR1] , 'Error (-1004) encountered.'" This is my code below. Is it correct?

Please help

Dim oPurchaseLine As SAPbobsCOM.Document

oPurchaseLine = pCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders)

For j = 1 To oMatrix1.VisualRowCount

oMatrix1.GetLineData(j)

If sCode = oForm.DataSources.UserDataSources.Item("us_col11").Value Then

oPurchaseLine.Lines.BaseEntry = nDocNum

oPurchaseLine.Lines.BaseLine = k

oPurchaseLine.Lines.BaseType = 22

oPurchaseLine.Lines.ItemCode = oForm.DataSources.UserDataSources.Item("us_col13").Value

sQuery = " select itemname from oitm where itemcode ='" & oForm.DataSources.UserDataSources.Item("us_col13").Value & "'"

rs.DoQuery(sQuery)

If Not rs.EoF Then

oPurchaseLine.Lines.ItemDescription = rs.Fields.Item("itemname").Value

End If

oPurchaseLine.Lines.Quantity = oForm.DataSources.UserDataSources.Item("us_col14").Value

oPurchaseLine.Lines.Price = oForm.DataSources.UserDataSources.Item("us_col14").Value

oPurchaseLine.Lines.Add()

k = k + 1

End If

Next

Former Member
0 Kudos

Hi,

Maybe you've solved it by this time...

If I read your code correctly, you're always adding a line to the purch.doc. You're even adding one right at the end and then you're doing nothing with that one.

I suspect that you're adding a final, empty line in nthe last iteration of your loop.

If I recall correctly, the first lines-object does not have to be added, but every next one does need to be added before entering values into it.

Hth,

Jacques