Sage 100

 View Only
  • 1.  Adding perform logic to skip out of balance Invoices during the write to the PO_ReceiptHeader

    Posted 09-27-2021 20:34
    I am attempting to find a way to skip the write on a VI import to import PO Invoices. in PO RECEIPTHEADER.  The import is working great expect unfortunately the PO ROI doesn't;t have the AP Invoice total so I can't compare them and fail the records.  I added a UDF with the Invoice Total attempted to compare it to the invoice imported total on the invoice.  

    Here is my perform logic that I am running as a "Before Write"  Perlorm logic

    ! Perform logic to check for totals
    CHECKTOTAL:
    IF TAXABLEAMT+NONTAXABLEAMT+FREIGHTAMT<>UDF_INVOICEAMT_DL THEN { RETURN RETFAILURE }
    EXIT



    The question is what do I need to do to skip the write, write the fail to the VI Error log  and move to the next invoice?

    Anyone run into this before?

    ------------------------------
    Jim Woodhead
    DSD Business Systems
    619-990-3946
    ------------------------------


  • 2.  RE: Adding perform logic to skip out of balance Invoices during the write to the PO_ReceiptHeader

    Posted 09-28-2021 10:26
    I'm not sure how to do that with PERFORM logic because I don't know how the VI programs handle returned values after PERFORM'ing on an event like "Before Write" but you could easily do this with a table event script using the pre write event and use GetValue on each field and evaluate them, if out of balance, you would then use oScript.SetError and pass it a string to indicate why you are setting the error, i.e. "Unable to create out of balance invoice.".  The message you pass will show up as the reason for failure in the VI job log.

    ------------------------------
    David Speck II
    Tennessee Software Solutions
    ------------------------------



  • 3.  RE: Adding perform logic to skip out of balance Invoices during the write to the PO_ReceiptHeader

    Posted 09-28-2021 14:41
    Edited by Alnoor Cassim 09-28-2021 15:42
    For Before Write, probably you can invalidate a header variable in scope for a required field. E.g. I'm not sure if InvoiceNo$ is in play but it could be say:

    CHECKTOTAL:
    IF (TAXABLEAMT+NONTAXABLEAMT+FREIGHTAMT) <> UDF_INVOICEAMT_DL {
      InvoiceNo$ = DIM(21,"X") ! Change InvoiceNo to 21 Xs to force a dictionary error and write to log
    }


    You could also try VendorNo$ = DIM(8,"X") knowing max length is 7. It may even fail because it's a brand new vendor.
    Just play with it.

    ------------------------------
    Alnoor Cassim

    Email: alnoor@asifocus.com
    Ph: 949-689-9887
    Orange County, CA
    ------------------------------



  • 4.  RE: Adding perform logic to skip out of balance Invoices during the write to the PO_ReceiptHeader

    Posted 09-29-2021 00:32
    Edited by Jim Woodhead 09-29-2021 00:33
    Update:    The pre-write script added to the PO Receipt of Good was the answer..  Also the VI log is much more descriptive too.  Says Invoice out of balance!!


    Here is the Pre-write Script  added to the PO Receipt
    ********************************************************************
    'Pre-write added to PO_RECEIPTHEADER
    'Pre-Write script exit if not from VI import
    'Get values from PO and compare to imported total  Set erroe to Fail is out of balance
    ' skip  perform is imported total is 0 

    If Left(UCase(oSession.StartProgram),4) = "VIWI" Then

    'Init VARs'
    NTaxableAmt=0:NNontaxableAmt=0:NSalesTaxAmt=0:NFreightAmt=0:
    NUDF_INVOICEAMT_DL=0:nnvoicetotal=0:outofbalance=""

    'Get Values'
    retVal = oBusObj.GetValue("TaxableAmt", NTaxableAmt)
    retVal = oBusObj.GetValue("NonTaxableAmt", NNontaxableAmt)
    retVal = oBusObj.GetValue("SalesTaxAmt", NSalesTaxAmt)
    retVal = oBusObj.GetValue("FreightAmt", NFreightAmt)
    retVal = oBusObj.GetValue("UDF_INVOICEAMT_DL", NUDF_INVOICEAMT_DL)

    'Calculate totals and check balance
    ninvoicetotal=NTaxableAmt+NNontaxableAmt+NSalesTaxAmt+NFreightAmt

    if ninvoicetotal<>NUDF_INVOICEAMT_DL then
    outofbalance= "Y"
    Else
    outofbalance= "N"
    End IF

    'Setr SMsg and to Fail Write

    If NUDF_INVOICEAMT_DL>0 and outofbalance= "Y" Then
    sMSG= "Invoice total doesn't match DocLink"
    retVal = oScript.SetError(sMSG)
    End If

    End If
    Exit

    *************************************************************​

    ------------------------------
    Jim Woodhead
    DSD Business Systems
    619-990-3946
    ------------------------------