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

  • Bryce,

     

    In Legacy Modules for MAS 90 and MAS 200 (excluding MAS 200 SQL) a data file is comprised of a single string column containing all the string data and then individual columns for the numeric data.  For Business Framework Modules, we have normalized the database so all the data is in discreet columns.  This means that your substring reference of AP5$(1,19) is valid in MAS 90 4.05 but is no longer valid in MAS 90 4.30 where the data is normalized.  Instead, you need to reference the columns from the table that contain the data for the key. You can get a visual of this by looking at the Table in Data File Display and Maintenance

     

    Try changing your code to the following:

    0030 READ (AP_OpenInvoice_CHN,KEY=APDivisionNo$:VendorNo$:InvoiceNo$,DOM=0050)

    Thank you,

    Kent Mackall

    Sage

  • Thanks Kent!  That makes a lot of sense and it got me past the line 0030 error.  After that change when I ran the import it errored out on line 0040 

     

    0040 AP_InvoiceHeader$(1,19)=DIM(19);PRE_AP_InvoiceHeader$=AP_InvoiceHeader$

     

    So I tried what you described for line 0030 to fix this line too.  Here is what I changed it to:

     

    0040 AP_InvoiceHeader$(APDivisionNo$="XX":VendorNo$="DUPLICT":InvoiceNo$="XXXXXXXXX");PRE_AP_InvoiceHeader$=AP_InvoiceHeader$

     

    I no longer get an error but...  The idea of the old logic was to blank out the division, vendor and invoice number so with all those fields blank that particular record would fail.  In the new line 0040 I'm trying to assign the division as "XX" the vendor number as DUPLICT and invoice number as XXXXXXXX.  Because division XX and vendor DUPLICT aren't on file it would fail.  The problem is that my perform logic isn't assigning these fields as I expected.  The import is successful and the division, vendor and invoice number pull from the source file I'm using.

     

    I'm I missing something in that line to correctly assign those three fields?

     

    Thanks again for any suggestions.

     

    Bryce

  • Bryce,

     

    I don;t think your line 40 is correct.  You are still trying to assign the data to a single string. Remember, now that the data is normalized, the data is in discreet columns.  I haven't tested this in V/I but try something like:

     

    0040 PRE_APDivisionNo$="XX", PRE_VendorNo$="DUPLICT", PRE_InvoiceNo$="XXXXXXXXX"

     

    If that doesn't work, please contact Customer Support for more assistance. 

     

    Thanks,

    Kent Mackall 

     

  • Thanks Kent, but Sage Support understandably won't help with Perform Logic.

     

    I ended up modifying the AP Invoice register to read the AP_OpenInvoice file.  Granted the user has to go back in and manually delete the duplicates but this will work.

     

    Bryce

  • 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

  • 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.