4.3 Perform Logic for A/P Invoice Duplicates

Hi All, 

I recently upgraded a client from MAS200 4.05 to version 4.30.  In 4.05 they had an import for AP Invoice entry with perform logic to search AP4 for duplicate invoices. Here is the old logic that worked:

0010 IF AP4_CHN<>0 THEN GOTO 0030

0020 OPEN (HFN)"../MAS_TST/APTST"+"/AP4TST.SOA";AP4_CHN=LFO
0030 READ (AP4_CHN,KEY=AP5$(1,19),DOM=0050)
0040 AP5$(1,19)=DIM(19);PRE_AP5$=AP5$
0050 EXIT

I'm trying to create the logic for the version 4.30 by taking the above and updating with the new file names.  When the import tests or runs I get an error 47 referencing line 0030 

0010 IF AP_OpenInvoice_CHN<>0 THEN GOTO 0030
0020 OPEN (HFN)"../MAS_"+CCOMP$+"/AP"+CCOMP$+"/AP_OpenInvoice.M4T";AP_OpenInvoice_CHN=LFO
0030 READ (AP_OpenInvoice_CHN,KEY=AP_InvoiceHeader$(1,19),DOM=0050)
0040 AP_InvoiceHeader$(1,19)=DIM(19);PRE_AP_InvoiceHeader$=AP_InvoiceHeader$
0050 EXIT 

Perform Type:  After Assign

File Type:  Header

Table Name:  AP_Invoiceheader

Column Name:  InvoiceNo

Sequence:  001

Command:  ..\VI\dup.txt

Can anyone see a problem with the Perform Logic above?  I've searched the old Talk forums and these Community Forums and can't find this logic noted anywhere for version 4.20 or higher. 

Thanks in advance for any suggestions!

 Bryce

Parents
  • Here is the perform logic for preventing AP invoice records from import. This checks the invoice history file for existing invoices (Div+VendorNo+InvoiceNo) and was developed by Alnoor Cassim for v4.30 but still works for 2017.

    Step 1: copy the text below into notepad and save the file as "AP_VISkipDuplicateInvoices.m4p"

    Step2: place file AP_SkipDuplicateInvoices.m4p into the AP directory

    Step3: add VI perform logic as follows:

       JobName: (whatever your VI job name is)

       Perform Type: Before Assign

       File Type: Header

       Table Name: AP_InvoiceHeader

       Column Name: InvoiceNo

       Sequence: 001

       Command:  ..\AP\AP_VISkipDuplicateInvoices.m4p;ENTRY_POINT

    ----- copy the text below into notepad and name the file AP_VISkipDuplicateInvoices.m4p --------

    ! 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) THEN {
    coInvcHistHdr = NEW("AP_InvoiceHistoryHeader_Svc",%SYS_SS)
    }

    InvoiceNo$ = VAR$

    retExists =coInvcHistHdr'CheckInvoiceHistory(APDivisionNo$, VendorNo$, InvoiceNo$)

    IF retExists THEN { VAR$=$$ }

    EXIT

  • in reply to dvincent

    Thanks this helped me out

Reply Children
  • in reply to Bvulliamy

    Glad that worked out @Bvulliamy . That one was for v4.40 originally. The idea was to set an invalid value for the InvoiceNo if it existed already. That way it would both prevent a incoming duplicate from your import file and appear in the import job log. Today, there are newer variations of this Perform Logic where in the log you can see the Invoice No that duplicated. Also other fields in your import file (e.g. Invc Date) could be shown to help you identify at a glance which invoices duplicated.