Can't access lines of receipt of invoice

SUGGESTED

I created a receipt of invoice, applied PO to it, changed some info- and in the end I called

record.nWrite();

where record is the pvxDynamic representing PO_Receipt_bus. I know that after the write, I have a new receipt in Sage and it's valid

right after the call to write I want to go through the lines of the invoice I just created.

If I call record.oLines I get the error - "You cannot select a purchase order number that has not been applied to this entry."

If I call record.oLines after calling setKeyValue for ReceiptType$ and ReceiptNo$ (followed by setKey()), I get the error - "Missing or Invalid Header".

Does anyone know why does it happen and how to fix it?

  • 0

    The header object should handle the lines object so if you want to loop through the lines after the write, you need to use the header's SetKeyValue and SetKey and you should then be able to loop through the lines.  

    But I have to say that it doesn't make sense to me to want to loop after the write, why not loop before the write (unless the loop is conditioned on the write being successful but you could instead loop before, gather what you need and then test the write and if successful, proceed with the next action)?

  • 0 in reply to David Speck

    Like I said, if after the write I use the header's SetKeyValue and SetKey I then try to loop through the lines, I get the error "Missing or Invalid Header".

    About the other question, I am trying to create the receipt of invoice, add lines, change quantities, and I want to get the ExtensionAmt of each line I write, but for some reason after the writing of a line, I can't get that value. When I check in a debug mode, I see that the record of the header is created, but the detail records aren't. They are created for some reason only after the writing of the header record.

  • 0 in reply to tamir david
    SUGGESTED

    Not sure what you mean when you refer to "check in debug mode", if you mean DFDM, you are correct, the lines are not written to the physical file until the header write because they are maintained in a *Memory* table until the header write is successful.

    Regardless, the ExtensionAmt should be calculated after you set the quantity and/or cost.  In the FLOR, i do see a local method called CalculateExtension that you could try to call but I'm not positive that it will be exposed to the lines object handle you are getting from the header object.

    Another thing you could try is after your header write, try following it up with the nClear method, and then try using SetKeyValue and SetKey.  

    You may also want to try the header's nSetCurrentKey method after the SetKey, you should be able to pass the returned value of the header's sGetKeyPadded() method to it