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

Purchase order line items

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Dec 17, 2004 at 12:47 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

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.