Loop though Sales Order Tier Distribution???

SOLVED

I am trying to look through the records in the following business object with the code below.

However it is failing at the MoveFirst call. This same logic has worked for other files IM_ItemCost, AR_Customer...

is there an issue with this object or another way to do this.

SO_SalesOrderTierDistribution_bus

Set oTier = oSession.AsObject(oSession.GetObject("SO_SalesOrderTierDistribution_bus"))

retVal = oTier.MoveFirst() ‘this is where it fails

Do until cBool(oTier.Eof)

retVal = oTier.GetValue("LotSerialNo$", SerialNoTier)

msgbox SerialNoTier

retVal = oTier.MoveNext()

loop

It looks like the same error is received when trying to loop though the SO_InvoiceTierDistributuion

ERROR 40 - DIVIDE CHECK OR NUMERIC OVERFLOW

PROGRAM: CI_COMMONTIERDISTRIBUTION.PVC

STATEMENT: 1549

CLASS: SO_INVOICETIERDISTRIBUTION_BUS

METHOD: SETCURRENTKEY

Thanks in advance for an assistance.

  • 0

    What happens if you remove the movefirst? Usually when you first open a recordset you are already starting with the first record.

  • 0 in reply to kdb
    verified answer

    You need to loop through header and detail too in order to by pass the error 40.  Here is my quick test:

    o = new("SO_Invoice_bus", %sys_ss)

    retval = o'movefirst()

    while not(o'eof)

       retval = o'lines'movefirst()

       while not(o'lines'eof)

           retval = o'lines'getvalue("Valuation$", valuation$)

           if valuation$ = "5" or valuation$ = "6" {

               retval = o'lines'distribution'movefirst()

               while not(o'lines'distribution'eof)

                   retval = o'lines'distribution'getvalue("LotSerialNo$", lotserial$); msgbox lotserial$

                   retval = o'lines'distribution'movenext()

               wend

          }

           retval = o'lines'movenext()

       wend

       retval = o'movenext()

    wend

    drop object o

    end

  • 0 in reply to kdb

    when the movefirst is removed the GetValue does not grab any  data and the same error is received when the MoveNext line is reached.

    Thanks for your response.

  • 0 in reply to Natasha Chang

    If i set this up,  how do i call the distribution table?

    The first two work and I can loop through the header and detail files, but the line below does not

    retval = oTier.MoveFirst() returns a 0

    do while oTier.EOF <> 1

     never enters the loop

    Loop

    Set oHead = oSession.AsObject(oSession.GetObject("SO_SalesOrder_bus"))

    Set oLines = oHead.AsObject(oHead.Lines)

    Set oTier = oLines.AsObject(oLines.Distribution)

    thanks in advanced