Sage 100 BOI Script to Create Inventory Transactions

SOLVED

I'm writing a BOI script to create Inventory Adjustment Transactions.  I want to use the next available entry number so I have the GetNextEntryNo(refNo$) function in my script.  What I can't figure out is what the "refNo$" needs to be.  Does anyone have a listing of the valid values?  I tried "6" but that doesn't work.  It returns a "0" to my variable.  Thanks.

  • 0

    The refNo$ is actually the string that will be returned with the next entry number.  Set, your transaction type first "6"=Adjustment, and then call the GetNextEntryNo(sNextNum).  Then use that variable to set the Transaction Number.

    E

  • 0 in reply to jepritch

    Thanks for the quick response.  Still no dice.  Here's part of my code:

    If Not (IsObject(oIM)) Then
    retVal = oSS.nSetProgram(oSS.nLookupTask("IM_Transaction_ui"))
    Set oIM = oScript.NewObject("IM_Transaction_bus", oSS)
    End If

    vNextEntryNo = ""

    retVal = oIM.nSetKeyValue("EntryType$", "6")
    retVal = oIM.nGetNextEntryNo(vNextEntryNo)

    At this point vNextEntryNo still = ""

  • 0 in reply to Ray P
    verified answer

    I think the variable name for your SetKeyValue() should be TransactionType$.

    retVal = oIM.nSetKeyValue("TransactionType$", "6")

  • +1 in reply to jepritch
    verified answer

    Good catch!  That worked.  Thank you.

  • 0 in reply to Ray P

    Hi Ray P, if the above suggested answer helped, please do mark it as verified White check mark for the benefit of others in this forum :). Thank you!

     Also, if you have a minute, tell us about your great experience on Sage City, take this short survey

  • 0

    Hello, how were you able to complete the transaction? I'm trying, but I always receive the error "The distribution is out of balance."

    using DispatchObject oLines = new(invTransactionEntry.GetProperty("oLines"));
    retVal = (int)oLines.InvokeMethod("nAddLine");
    string error2 = (string)oLines.GetProperty("sLastErrorMsg");
    retVal = (int)oLines.InvokeMethod("nSetValue", "ItemCode$", adjustment.ItemId);
    retVal = (int)oLines.InvokeMethod("nSetValue", "UnitOfMeasure$", adjustment.UomId);
    retVal = (int)oLines.InvokeMethod("nSetValue", "TransactionQty", adjustment.Quantity);
    retVal = (int)oLines.InvokeMethod("nWrite");
    string error5 = (string)oLines.GetProperty("sLastErrorMsg");
    retVal = (int)invTransactionEntry.InvokeMethod("nWrite");
  • 0 in reply to rcdev

    It looks like your item code is a lot/serial item.  You need to do lot/serial distribution.

  • 0 in reply to Natasha Chang

    How? Do you have any examples?"

    I'm trying this but now it's giving this error: 'You cannot set unless transaction type is sales or issues.'

    using DispatchObject oLines = new(invTransactionEntry.GetProperty("oLines"));

    using DispatchObject oDistribution = new(oLines.GetProperty("oDistribution"));

    retVal = (int)oDistribution.InvokeMethod("nSetValue", "TransactionQty", adjustment.Quantity);

    string error3 = (string)oDistribution.GetProperty("sLastErrorMsg");

    retVal = (int)oDistribution.InvokeMethod("nSetValue", "LotSerialFullyDistributed$", "Y");

    retVal = (int)oDistribution.InvokeMethod("nWrite"); string error4 = (string)oLines.GetProperty("sLastErrorMsg");

  • 0 in reply to rcdev

    This works for me.  The is ProvideX syntax but you get the idea.

    o = new("IM_Transaction_bus", %sys_ss)

    r = o'SetKeyValue("TransactionType$","6")
    r = o'SetKeyValue("EntryNo$","00000011")
    r = o'SetKey()
    if r = 2 {
          r = o'Lines'AddLine()
          r = o'Lines'SetValue("ItemCode$", "2480-8-50")
          r = o'Lines'SetValue("WarehouseCode$", "000")
          r = o'Lines'SetValue("TransactionQty", 1)
          r = o'Lines'Distribution'AddDistributionLine("101")
          r = o'Lines'Distribution'SetValue("TransactionQty", 1)
          r = o'Lines'Distribution'Write()
          r = o'Lines'Write()
          r = o'Write()
    }