QAD 2017 Enterprise Edition > User Guides > Planning and Scheduling Workbenches Administration > Personalization Architecture > Customization Scenarios > Add an Editable Calculated Column to a Default Column Display List and Save Updates
  
Add an Editable Calculated Column to a Default Column Display List and Save Updates
In this scenario, the field does not exist in the schema for the wo_mstr table. Instead, it is defined in the temp-table definition. It is also defined as an editable field.
Field name: moveDates
Column label: Move Dates
Data Type: character
Content: blank. When you enter Yes in this field, seven days are added to the Work Order Release Date and Due Date fields before saving.
1 Add the field definition to the include file woscwox.i (tt-wo_mstr extensions):
field moveDates as character
2 Recompile the code that references the include files woscwo.i (tt-wo_mstr):
woscrtrv.p
woscpm.p
woscttps.p
3 Add the field moveDates to the additional default display and edit fields list as described in Specifying Additional Columns.
4 Add a column label for the field as described above in Specifying Additional Columns.
5 In the Pre Update user exit, add code to check the value of moveDates, and when set to Yes, add seven days to the work order Release Date and Due Date fields:
 
/* 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*/
 
define variable moveDates as character no-undo.
define variable newreldate as date no-undo.
define variable newduedate as date no-undo.
 
/*LOOK AT ROW STATE TO DETERMINE ADD/MODIFY/DELETE*/
 
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 then do:
if row-state(tt-wo_mstr) = ROW-MODIFIED or row-state(tt-wo_mstr) = ROW-CREATED
then do:
/*hbtt-wo_mstr IS A HANDLE THAT REFERS TO THE tt-wo_mstr TEMP-TABLE
*THAT'S IN THE PRODATASET SENT BY THE CLIENT. THIS TEMP-TABLE
*IS DEFINED IN woscwo.i/woscwox.i. HERE WE ARE ACCESSING
*ITS FIELD VALUES USING DYNAMIC CODING TECHNIQUES. IT WOULD BE
*POSSIBLE TO TYPECAST hbtt-wo_mstr TO AN INTERNAL PROCEDURE
*USING THE TABLE-HANDLE MECHANISM IF YOU WANTED TO USE THE
*woscwo.i/woscwox.i STATIC DEFINITION.*/
hbtt-wo_mstr = hdswoscwxad:get-buffer-handle("tt-wo_mstr").
 
hbtt-wo_mstr:find-first("where tt-wo_mstr.wo_domain = " + quoter(ipDomain)
+ " and tt-wo_mstr.wo_lot = " + quoter(ipLot), NO-LOCK).
 
moveDates = hbtt-wo_mstr:buffer-field("moveDates"):buffer-value().
if moveDates begins "y" then do:
newreldate = hbtt-wo_mstr:buffer-field("wo_rel_date"):buffer-value().
newduedate = hbtt-wo_mstr:buffer-field("wo_due_date"):buffer-value().
/*NOTE THAT THE tt-wo_mstr TEMP-TABLE REFERENCED IN THE FOLLOWING
*FIELD ASSIGNMENTS IS DEFINED IN wodstt.i. wodstt.i DEFINES THE
*PRODATASET USED AS INPUT TO THE WO API PROGRAM (wowoxr.p). WHAT HAPPENS
*BEFORE THE API IS INVOKED IS THAT TEMP-TABLE CONTENTS IN THE PRODATASET
*SENT BY THE CLIENT ARE COPIED INTO THE TEMP-TABLES DEFINED IN wodstt.i.*/
tt-wo_mstr.wo_rel_date = newreldate + 7.
tt-wo_mstr.wo_due_date = newduedate + 7.
end.
end.
end.
else do:
/*THERE IS NO AFTER-IMAGE RECORD SO THERE MUST BE A BEFORE-IMAGE RECORD
*IN OTHER WORDS, IT'S A DELETE REQUEST.*/
find tt-wo_mstr-before where tt-wo_mstr-before.wo_domain = ipDomain
and tt-wo_mstr-before.wo_lot = ipLot
no-error.
if available tt-wo_mstr-before then do:
end.
else do:
end.
end.
 
opSuccessful = true.