How to validate alphanumeric date field in Sage X3?

By | February 9, 2016

There can be occasions when you want to accept date input in an alphanumeric field in grid. As, alphanumeric field does not have calendar control so you need to validate the entry section by writing our own code. Here we are describing how to achieve same via code.

Below is the code we have written after changing event of alphanumeric date field

Subprog AM_DATASW10(VALEUR)

Variable Char    VALEUR()

Global Char XDATE:XDATE = ”

Call DATEVALIDATE(VALEUR)

If VALEUR <> ” and XDATE = ”

  mkstat=2

ELSE

   [M:ZTEC]DATASW10(nolign-1)=xdate

   Affzo [M:ZTEC]DATASW10(nolign-1)

Endif

XDATE = ”

End

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

subprog datevalidate(VALEUR)

global char xdate:xdate=”

local char LC2:LC2=”

xdate = format$(“DD2”,VALEUR)

LC2= format$(“DD2″,”gfdbf”)

if xdate = LC2

 infbox ‘Invalid date’

 xdate = ”

endif

end

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