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

Error rounding document line AP Invoice DI API

Hello experts. I have an error adding the price AP.Lines When I add for example the price of GS 8200 in a bill that is inserted through the code that is posted below. When I look at SAP it appears that the amount of the price is 8201 which corresponds to a rounding problem. There is some method to add correctly and the price entered by the DI API correctly displayed.?


For Each row In Grilla.Rows
                If Grilla.Rows(row.Index).Cells("cod_articulo").Value = "GRA" Then
                    GRPO.Lines.BaseType = "-1"
                    GRPO.Lines.ItemDescription = row.Cells("descripcion").Value
                    GRPO.Lines.AccountCode = "11030101"
                    GRPO.Lines.Quantity = CInt(row.Cells("cant_fp").Value)
                    GRPO.Lines.PriceAfterVAT = row.Cells("precio_fp").Value
                Else
                    GRPO.Lines.BaseLine = row.Cells("Nro_Linea").Value
                    GRPO.Lines.BaseEntry = CInt(txtdocentry.Text)
                    GRPO.Lines.BaseType = 22
                    If Grilla.Rows(row.Index).Cells("cod_articulo").Value = "OTGRA" Then
                        GRPO.Lines.AccountCode = "11030101"
                    End If
                End If
                GRPO.Lines.ItemCode = row.Cells.Item("cod_articulo").Value
                GRPO.Lines.TaxCode = row.Cells.Item("IVA").Value
                If row.Cells.Item("IVA").Value = "IVA_10" Then
                    If txtmoneda.Text = "USD" Then
                        GRPO.Lines.DiscountPercent = row.Cells("desc_linea").Value
                        'GRPO.Lines.UnitPrice = row.Cells("preciobruto").Value / "1,1"
                        GRPO.Lines.LineTotal = row.Cells("total_line").Value
                        GRPO.Lines.Currency = txtmoneda.Text
                    Else
                        GRPO.Lines.DiscountPercent = row.Cells("desc_linea").Value
                        '  GRPO.Lines.UnitPrice = row.Cells("preciobruto").Value / "1,1"
                        GRPO.Lines.PriceAfterVAT = row.Cells("preciobruto").Value
                        '   GRPO.Lines.RowTotalFC = row.Cells("total_line").Value
                        GRPO.Lines.Currency = txtmoneda.Text
                    End If
                End If
                GRPO.Lines.Add()
            Next
            GRPO.Comments = txtcomentario.Text
            ' GRPO.DocTotal = txttotalfinal.Text
            If txtmoneda.Text = "USD" Then
                GRPO.DocTotalFc = txttotalfinal.Text
            Else
                '   GRPO.DocTotal = txttotalfinal.Text
            End If
            errNum = GRPO.Add
Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Jul 20, 2016 at 06:46 AM

    Hi Adolfo,

    Setting all values (UnitPrice, LineTotal, Discount, ...) may lead to that kind of situation. You can try to leave the calculation of the total to SAP B1, by setting the UnitPrice, Quantity and Discount. B1 will calculate the total based on the other criteria.

    If you have to set the total and the unit price, don't set the discount (B1 will calculate a discount amount to match the criteria).

    In the end it requires a bit of playing around to check which data you should set and which to let B1 calculate.


    Pedro Magueija


    LinkedIn Logo View Pedro Magueija's profile on LinkedIn
    Follow @pedromagueija on Twitter

    If this answer is helpful or correct, marking it as such is a form of saying thank you.

    Add a comment
    10|10000 characters needed characters exceeded

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.