BOI Retrieving Invoice Line Serial Numbers

On sales order invoice items can successfully use BOI to retrieve the SO_Invoice items, and for each item access the lines, however have not been able to collect item serial numbers for each line. For reference a screen capture showing these serial numbers in the UI. Using C#, however an example showing how to access these for any language would be most helpful. Our basic flow is:

  • Create the authenticated session
  • Set the session date to today, the module to "S/O", the session program to "SO_Invoice_ui" (using sess.nLookupTask("SO_Invoice_ui")), 
  • Create the BOI object using var comObject = sess.oNewObject("SO_Invoice_bus") - using the business object here as want to retrieve lines as well
  • Select the desired invoice using comObject.nFind("my-full-key"); -- collect the desired header field values from here
  • Select the lines collection using
    • comObject.oLines.nSetBrowseFilter(comObject.sGetKey()); -- this gives me access to the collection of lines from this invoice, then
    • comObject.oLines.nMoveFirst(); -- collecting the desired line field values -- then calling comObject.oLines.nMoveNext(); -- repeat for all lines

All this works well, can get all needed data from header and line level. However for each line want to collect the serial number(s). So, have tried like this 

  • Get a reference to the distribution object, which I believe to be the place to source serial numbers from:
    • var comDistributionObject = comObject.oLines.oDistribution;
  • Set the browse filter to try to get the collection of distribution rows for this line:
    • int nSetBrowseFilterForDists = comDistributionObject.nSetBrowseFilter(comLinesObject.sGetKey());
  • Moving to the first distribution record:
    • int nMoveNextDists = comDistributionObject.nMoveFirst();

At this point the  comDistributionObject always reports EOF (i.e. comDistributionObject.nEOF is always = 1) even though the UI shows distributions for this invoice line.

Have attempted many variations when setting the browse filter on the Distribution object, trying using the line key key padded/not padded/truncated to 7+6=13 characters, by explicitly setting the index using nSetIndex, hard coding the nSetBrowseFilter value to a 13 char string that represents the zero padded 7 char invoice number with the 0 padded 6 char line number. Seem to get the EOF and message on the comDistributionObject reports:

The file is empty or does not match filter.

At this stage I suspect my strategy for retrieving these serial numbers is incorrect. How can I get them? Thanks!

  • 0

    You can simplify your steps.

    Change comObject.nFind("my-full-key") to comObject.nSetKey("my-full-key")

    Use the SetKey() method and not Find(), the header business object will then do all of the work for you loading the line detail specific to that entry and all of the lot/serial distributions for those detail lines.  There is no need to do either of the SetBrowseFilter() method calls.

    You can use MoveFirst(), MoveNext() through the line detail and when a detail line has lot/serial distributions you can then MoveFirst(), MoveNext() through the distributions for that detail line.

    You have the correct object handles for the line detail and the distributions you are just missing the SetKey() which will do all of the work for you.

  • 0 in reply to Steve Passmore

    Thanks for the suggestion Steve. I just tried that approach:

    • Callling nSelectBatch("my batch number") and then nSetKey("my invoice key") on the invoices comObject
    • This allowed me to loop through the comObject.oLines using MoveFirst(), MoveNext()
    • However I have the same issue when proceed to try to loop through the comObject.oLines.oDistribution using MoveFirst(), MoveNext()

    E.g. have called comObject.oLines.MoveFirst() and retrieve the expected field values for the line however, with the first line still selected, the call comObject.oLines.oDistribution.MoveFirst() returns an EOF response with the error is "The file is empty or does not match filter."

    I feel like I am missing a key step here, any further suggestions appreciated.