Add a Validation
In this scenario, you add additional validation logic. This is done by adding logic to the Pre Save Update user exit program. There can be validations on any field, whether it's a field that is already implemented in the MSW/PSW—for example, Release Date, Remarks—or a field to be implemented—for example, wo__chr04.
The validation logic works like any other validation in the MSW/PSW work order save logic: that is, when the validation fails, the:
• Save request is rejected
• Red error icon is displayed in the MSW/PSW
• Reason message is added to the icon's tooltip text.
In this example, a validation is added to the work order Remarks (wo_rmks) field to ensure that it is always non-blank.
/* woscpreupdatex.p - MSW/PSW Personalization Architecture user exit program */
/* Copyright 1986 QAD Inc. All rights reserved. */
/* $Id:: woscpreupdatex.p 4721 2013-04-04 20:52:09Z wug $: */
/*V8:ConvertMode=NoConvert */
/*
* Pre Save Update user exit program
*
*/
define variable svnId{&SEQUENCE} as character no-undo initial "svnId $Id: woscpreupdatex.p 4721 2013-04-04 20:52:09Z wug $".
{mfdeclre.i}
{wodstt.i}
/*THE INPUT-OUTPUT PARAMETER DATASET REFERS TO A DATASET
*THAT IS DEFINED BY wodstt.i. THE TEMP-TABLES DEFINED IN
*THIS DATASET (tt-wo_mstr, tt-wod_det etc) CAN BE REFERENCED
*STATICALLY. THIS DATASET IS WHAT IS USED AS INPUT TO THE
*WO UPDATE API*/
define input parameter ipDomain as character no-undo.
define input parameter ipLot as character no-undo.
define input-output parameter dataset for dsWorkOrder.
define output parameter opSuccessful as logical no-undo initial true.
/*hdswoscwxad REFERS TO THE DATASET THAT IS SENT BY THE
*CLIENT. IT CONTAINS THE TEMP-TABLES tt-wo_mstr (defined
*BY woscwo.i/woscwox.i), tt-wod_det (defined by
*woscwod.i/woscwodx.i), and tt-wr_route (defined by
*woscwr.i). THE CONTENTS OF THIS DATASET WAS PREVIOUSLY
*LOADED INTO THE INPUT-OUTPUT PARAMETER DATASET.*/
define shared variable hdswoscwxad as handle no-undo.
/*hbtt-wo_mstr IS A HANDLE REFERENCING tt-wo_mstr. THE CONTENTS
*OF tt-wo_mstr CAN BE ACCESSED USING DYNAMIC TECHNIQUES. IT
*WOULD BE POSSIBLE TO TYPECAST hbtt-wo_mstr TO A PROCEDURE
*USING THE TABLE-HANDLE MECHANISM IF YOU WANTED TO USE THE
*woscwo.i/woscwox.i ETC STATIC DEFINITIONS.*/
define variable hbtt-wo_mstr as handle no-undo.
hbtt-wo_mstr = hdswoscwxad:get-buffer-handle("tt-wo_mstr").
/*your code goes here*/
find tt-wo_mstr where tt-wo_mstr.wo_domain = ipDomain
and tt-wo_mstr.wo_lot = ipLot
no-error.
if available tt-wo_mstr
and (row-state(tt-wo_mstr) = ROW-CREATED or row-state(tt-wo_mstr) = ROW-MODIFIED)
and tt-wo_mstr.wo_rmks = ""
then do:
/*NOTE: SET &FIELDNAME='oid_wo_mstr' TO APPLY THE MESSAGE
*TO ONLY THE ROW ERROR ICON*/
/*MESSAGE 40="BLANK NOT ALLOWED"*/
{pxmsg.i
&MSGNUM=40 &ERRORLEVEL=3 &MSGARG1='' &FIELDNAME='wo_rmks'
&CALLINGPGM=execname &CONTEXT=ipLot}
/*THIS CAUSES THE UPDATE TO BE CANCELLED*/
opSuccessful = false.
return.
end.
opSuccessful = true.