Sage 100

 View Only
  • 1.  BOI Code issue

    Posted 02-13-2026 16:35

    HI Folks

        Have a client that just upgraded from 2021 to 2024 premium.   The admin there is a very capable in SQL and VB.   He has an "external" application that creates Receipts of Invoice for PO.s    He is reporting that it is no longer working.  If anyone has any suggestions, it would be much appreciated. 

                                errorflag = oAPOrder.nSetValue("ReceiptType$", "I")
                                If Convert.ToDateTime(po.invoicedate).Month = Today.Month Then
                                    oAPOrder.nSelectbatch("MMD")
                                Else
                                    oAPOrder.nSelectbatch("MMDP")
    
     
                                End If
    
                                errorflag = oAPOrder.nSetValue("ReceiptType$", "I")
    
                                ' errorflag = oAPOrder.nSetValue("APDivisionNo$", "00")
    
                                errorflag = oAPOrder.nGetNextReceiptNo(myNewPONo)
    
                                errorflag = oAPOrder.nSetKeyValue("ReceiptNo$", myNewPONo)
    
                                errorflag = oAPOrder.nSetKeyValue("ReceiptType$", "I")
    
                                errorflag = oAPOrder.nSetKey()
    
                                 erromesg = oAPOrder.sLastErrorMsg
    
      
    
                                errorflag = oAPOrder.nSetValue("PurchaseOrderno$", po.purchaseorderno)
    
     
                                '   oAPOrder.nGetValue("ReceiptNo$", rr)
    
                                '   If Not (CBool(errorflag)) Then MsgBox "SetKey Err: " & oPOEntry.sLastErrorMsg
    
     
    
                                errorflag = oAPOrder.nSetValue("APDivisionNo$", "00")
    
                                errorflag = oAPOrder.nSetValue("VendorNo$", "LEGAV01")
    
                                errorflag = oAPOrder.nSetValue("Invoiceno$", po.invoiceno)
    
                                errorflag = oAPOrder.nSetValue("invoicedate$", CDate(po.m_invoicedate).ToString("yyyyMMdd"))
    
     
    
                                '   errorflag = oAPOrder.nApplyPurchaseOrderUpdate(po.purchaseorderno, "N", "N", "N")
    
                                '   errorflag = oAPOrder.nSetValue("Batchno", "SPK")
    
                                '   errorflag = oAPOrder.ApplyPurchaseOrderAdd(po.purchaseorderno)
    
                                '   errorflag = oAPOrder.nApplyPurchaseOrderCopyLines(noofcopy)
    
     
    
                                errorflag = oAPOrder.nSetValue("ShipVia$", po.shipvia)
    
                                errorflag = oAPOrder.nSetValue("DiscountAmt", CDbl(po.discountamt))
    
                                errorflag = oAPOrder.nSetValue("FreightAmt", CDbl(po.freightamt))
    
     
    
    
                            errorflag = oAPOrder.oLines.nAddLine()                       
    
                            ' errorflag = oAPOrder.oLines.sGetKey()
    
                            errorflag = oAPOrder.oLines.nSetValue("LineKey$", po.orderlinekey)
    
                            erromesg = oAPOrder.oLines.sLastErrorMsg
    
                            errorflag = oAPOrder.oLines.nSetValue("OrderLineKey$", po.orderlinekey)
    
                            commentsku = po.itemcode.Replace("""", "").Replace("_", " ").Trim()
    
                            errorflag = oAPOrder.oLines.nSetValue("ItemCode$", commentsku)
    
                            'errorflag = oAPOrder.oLines.nSetValue("OrderLineKey$", po.orderlinekey)
    
     
    
                            ' errorflag = oAPOrder.oLines.nSetValue("AppliedPurchaseOrderNo$", po.purchaseorderno)
    
                            errorflag = oAPOrder.oLines.nSetValue("OriginalOrderQty", CDbl(po.originalorderqty))
    
                            errorflag = oAPOrder.oLines.nSetValue("QuantityInvoiced", CDbl(po.quantityinvoiced))
    
     
                            errorflag = oAPOrder.oLines.nSetValue("UnitCost", CDbl(po.unitcost))
    
                            errorflag = oAPOrder.oLines.nSetValue("ExtensionAmt", po.extensionamt)
    
                            errorflag = oAPOrder.oLines.nSetValue("CommentText$", po.commenttext)
    
     
    
                            '   oPOOrder.oLines.nSetValue("CommentText$", po.commenttext)
    
     
    
                            Dim sResult As String = oAPOrder.oLines.nWrite()


    ------------------------------
    Bob Osborn
    Senior Consultant
    DSD
    7142645278
    ------------------------------


  • 2.  RE: BOI Code issue

    Posted 02-14-2026 11:41
    Edited by Steve Iwanowski 02-14-2026 11:41

    What is the error or output?

    First blush looks OK to me, but what is the structure of "po" and is there a myNewPONo = "" above all that somewhere?  

    Can we see more code?  What is the definition of oAPOrder?



    ------------------------------
    Steve Iwanowski, NextStep Technology Advisors, aka DSD Lancaster PA ¯\_(ツ)_/¯
    ------------------------------



  • 3.  RE: BOI Code issue

    Posted 02-14-2026 20:31

    In addition to Steve's request for the rest of the code, since the admin is very capable, ask him to identify the exact point of failure and if any related object's ".LastErrorMsg" has a value if his error flag is unexpected.



    ------------------------------
    Dan Burleson
    Software Consultant
    Connex Software
    Corvallis OR
    541-829-1054
    ------------------------------



  • 4.  RE: BOI Code issue

    Posted 02-16-2026 17:17

    HI All.

      @Alnoor Cassim had sent some thoughts on this.  The client reported that the program is working now.  Not sure what changes he made..

    Try commenting out these lines as these fields are set by the business object automatically already:
    errorflag = oAPOrder.oLines.nSetValue("LineKey$", po.orderlinekey)
    errorflag = oAPOrder.oLines.nSetValue("OriginalOrderQty"CDbl(po.originalorderqty))
     
    Add some error handling on this line to get the sLastErrorMsg
    Dim sResult As String = oAPOrder.oLines.nWrite()
     
    I would move this line to after the block where the Lines are written. This is a Header field but usually it's set after all the Lines are written:
    errorflag = oAPOrder.nSetValue("FreightAmt"CDbl(po.freightamt))


    ------------------------------
    Bob Osborn
    Senior Consultant
    DSD
    7142645278
    ------------------------------



  • 5.  RE: BOI Code issue

    Posted 02-17-2026 01:23

    Wow! There's nothing artificial about Alnoor. He has gone beyond AI and can just send real thoughts to resolve issues!



    ------------------------------
    Dan Burleson
    Software Consultant
    Connex Software
    Corvallis OR
    541-829-1054
    ------------------------------



  • 6.  RE: BOI Code issue

    Posted 02-17-2026 06:48

    I think that was the original meaning of AI - @Alnoor Cassim Intelligence!!!



    ------------------------------
    Jeff Schwenk
    Owner
    Bottomline Software, Inc.
    Waynesboro VA
    (540) 221-4444

    Improving bottom lines for over 25 years!
    ------------------------------