Sage 100

  • 1.  Revisiting AP duplicate invoice during import

    Posted 03-15-2019 10:59
    Edited by alan niergarth 03-15-2019 12:12
    Since I can't delete the message I will state that I got the following VI perform to work.  
    ! AP_VISkipDuplicateInvoices.m4p

    ! Prevent duplicate InvoiceNo from being imported into AP_InvoiceHeader
    ! Check AP Invoice History if InvoiceNo already exists for Div and VendorNo
    ! If so, skip to next record
    ! In V/I Import Job set the PERFORM to run on 
    ! BEFORE ASSIGN of Header on table AP_InvoiceHeader column InvoiceNo! Command = ..\AP\AP_VISkipMissingInvoices.m4p;ENTRY_POINT

    ENTRY_POINT:
    Static coinvcHistHdr
    IF NOT(coInvcHistHdr) THEN { coInvcHistHdr = NEW("AP_InvoiceHistoryHeader_Svc",%SYS_SS)  }
    InvoiceNo$ = VAR$
    retExists =coInvcHistHdr'CheckInvoiceHistory(APDivisionNo$, VendorNo$, InvoiceNo$)
    IF retExists THEN { VAR$=$$ }
    EXIT

    also tried original variation which used to work...
    ! AP_VISkipExistingInvoices.m4p v1.01
    ! AP_VISkipExistingInvoices.m4p v1.01
    ! Check AP Invoice History if InvoiceNo already exists for Div and VendorNo
    ! If so, skip to next record! PERFORM set to run on BEFORE ASSIGN! By CallForHelp.biz! Rev 1.01 - 2011-05-07 Initial prog


    ------------------------------
    alan niergarth
    Velosio LLC
    ------------------------------


  • 2.  RE: Revisiting AP duplicate invoice during import

    Posted 03-15-2019 14:23
      |   view attached
    Alan, 
    I just tested my version and it works.  You didn't say what happens. is the perform logic set to run before assign on the field invoice number 

    your code looks correct, mine is a little different - I assign "duplicate invoice" to the invoice number so the user can see why it failed, but the logic is the same. below is my code (originally from @Alnoor Cassim


    ! Prevent duplicate InvoiceNo from being imported into AP_InvoiceHeader
    ! Check AP Invoice History if InvoiceNo already exists for Div and VendorNo
    ! If so, skip to next record

    ! In V/I Import Job set the PERFORM to run on
    ! BEFORE ASSIGN of Header on table AP_InvoiceHeader column InvoiceNo
    ! Command = ..\AP\AP_VISkipDuplicateInvoices.m4p;ENTRY_POINT

    ENTRY_POINT:
    IF NOT(coInvcHistHdr) {
    coInvcHistHdr = NEW("AP_InvoiceHistoryHeader_Svc",%SYS_SS)
    }

    InvoiceNo$ = var$ ! Field value is passed in for us as var$
    retExists = coInvcHistHdr'CheckInvoiceHistory(APDivisionNo$, VendorNo$, InvoiceNo$)

    IF retExists {
    var$ = "Duplicate Vendor: " + VendorNo$ + " Invc: " + InvoiceNo$
    ! var$+= " Amt: $" + IMP$[n] - optionally add InvoiceAmt from source file. Change n to match column number is source file.
    ! Force dictionary error of length exceeded. Causes Fail entry in Import Job Log.
    }


    EXIT




    ------------------------------
    David Overholt
    DWD Technology Group
    ------------------------------



  • 3.  RE: Revisiting AP duplicate invoice during import

    Posted 03-15-2019 14:46
    Exactly exactly what @David Overholt said. If it's not working, 2 fundamental things to verify:

    1. Set the Perform to run just like David's screenshot: BEFORE ASSIGN of Header for table AP_InvoiceHeader for column InvoiceNo

    2. At then end where it says IF retExists make sure what you put in for var$ exceeds 20 digits b/c 20 is the length of the InvoiceNo. We are actually forcing a length exceeded error which causes in the failed log entry. IOW, if you don't exceed 20 it never fails and duplicates will come in as adjustments. Something like this could work:

      var$ = "Duplicate Invoice: " + InvoiceNo$ + " for Vendor No: " + VendorNo$


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

    Free Agent Developer and Consultant
    CallForHelp.biz
    Email: alnoor@callforhelp.biz
    Orange County, CA
    ------------------------------