Supplier Invoice Number validation on Purchase Invoice Screen

By | August 30, 2021

In Sage X3, Supplier Document Number Field is available on purchase invoice screen in management tab. It is a mandatory field which means while creating entry we can’t skip this field. We have to enter data in this field then only we can proceed further.

We had a requirement from client that data entered in supplier document field should not be repeated in current fiscal year and also we have to handle this with upper case and lower case letter condition. Fiscal year will be calculated on the basis of “supplier inv. Date”.

Ex, suppose for Supplier A user created 1st entry and entered “TEST1” as supplier document number. After that user is creating 2nd entry for the same supplier and trying to enter “test1” as supplier document no. then it should not allow user to create the entry as the document no is same, doesn’t matter it is in lower case or upper case.

New Stuff: Data flow from Payment screen to Journal entry on Posting using Automatic Journal

BPRVCR(Supplier doc No.)
BPRVCR(Supplier doc No.)
Purchase Invoice - 1st Entry
Purchase Invoice – 1st Entry

For the 1st entry, Supplier is SD0014 and the user entered “sd08” in Supplier Doc no and fiscal year is 2021-2022.

For the 2nd entry, Supplier is SD0014 and the user entered “SD08” in supplier doc no and fiscal year is 2021-2022.

Purchase Invoice - 2nd Entry
Purchase Invoice – 2nd Entry

Then the system will not allow to create this entry. And pop-up message will be generated “This Supplier document number SD08 already entered” as shown in the below screenshot.

Pop-up Message
Pop-up Message

For this purpose, we did a customization on Purchase Invoice screen. Refer below code:

####################################################################

IF [M:PIH1]BPRVCR<>””
Local Char REQUEST1(255)(8)
REQUEST1(0) = ” SELECT NUM_0 FROM “+nomap+”.PINVOICE P “
REQUEST1(1) = ” WHERE P.BPR_0='”+[PIH0]BPR+”‘ AND UPPER(P.BPRVCR_0)=UPPER(‘”+[PIH1]BPRVCR+”‘) and “
REQUEST1(2) = ” P.BPRDAT_0 BETWEEN DateFromParts((CASE WHEN MONTH(‘”+[M:PIH1]BPRDAT+”‘) IN(1,2,3) THEN (YEAR(‘”+[M:PIH1]BPRDAT+”‘)-1) ELSE YEAR(‘”+[M:PIH1]BPRDAT+”‘) END),04,01) “
REQUEST1(3) = ” and DateFromParts((CASE WHEN MONTH(‘”+[M:PIH1]BPRDAT+”‘) NOT IN(1,2,3) THEN (YEAR(‘”+[M:PIH1]BPRDAT+”‘)+1) ELSE YEAR(‘”+[M:PIH1]BPRDAT+”‘) END),03,31)”

FOR (Char DTEXTE_0) FROM “5” Sql REQUEST1 As [YCHD]
IF [M:PIH0]NUM =[YCHD]DTEXTE_0
ELSE
INFBOX “This Supplier Document number ” +num$([M:PIH1]BPRVCR)+” already enteredon invoice “+[YCHD]DTEXTE_0
OK =0
GOK = 0
GPE = 1
ENDIF
NEXT
ENDIF

####################################################################

and add above code on VERIF_CRE and VERIF_MOD in SPEPIH script. Validated the script.

Now, if the user tries to create another new entry for same supplier and same fiscal year but diffrent supplier document no. then only system will allow to create entry.