Add a Calculated Display-Only Field
In this scenario, the field does not exist in the schema for either the wo_mstr or the wod_det database tables. Instead, it is defined in the temp-table definition and is populated using processing code in user exits. This description uses as an example the following field:
• Field name: wo_release_day
• Column label: Release Day
• Data Type: character
• Content: the day of the week of the work order's Release Date, i.e. Monday, Tuesday, Wednesday, …
1 Add the field definition to the include file woscwox.i (tt-wo_mstr extensions):
field wo_release_day as character
2 Recompile the code that references the include files woscwo.i (tt-wo_mstr):
• woscrtrv.p
• woscpm.p
• woscttps.p
5 In the Post Search Read user exit, add code to populate the new field and compile it:
/* woscrtrvx.p - MSW/PSW Personalization Architecture user exit program */
/* Copyright 1986 QAD Inc. All rights reserved. */
/* $Id:: woscrtrvx.p 4721 2013-04-04 20:52:09Z wug $: */
/*V8:ConvertMode=NoConvert */
/*
* Post search read user exit program
*
*/
define variable svnId{&SEQUENCE} as character no-undo initial "svnId $Id: woscrtrvx.p 4721 2013-04-04 20:52:09Z wug $".
{mfdeclre.i}
define input parameter dataset-handle hdsInputData.
define input parameter ipTodaysDate as date no-undo.
define input parameter ipStartDate as date no-undo.
define input parameter ipEndDate as date no-undo.
define input parameter ipSequencingHorizon as integer no-undo.
define input parameter ipIncludeItemsWithNoSupplyDemand as logical no-undo.
define input parameter ipRetrieveRoutingRecords as logical no-undo.
define input parameter ipCACEngineEnabled as logical no-undo.
define input-output parameter dataset-handle iphdsinout.
define variable whtt-wo_mstr as handle no-undo.
define variable whtt-wod_det as handle no-undo.
/*THE INPUT-OUTPUT PARAMETER DATASET-HANDLE REFERS TO A DATASET
*THAT IS DEFINED BY woscrtds.i. THE CODE BELOW GETS
*A HANDLE TO THE tt-wo_mstr AND tt-wod_det TEMP-TABLES.
*YOU CAN CALL A PROCEDURE USING THE TABLE-HANDLE CONSTRUCT IF
*YOU WANT TO ACCESS THESE TABLES STATICALLY.*/
whtt-wo_mstr = iphdsinout:get-buffer-handle("tt-wo_mstr").
whtt-wo_mstr = whtt-wo_mstr:table-handle.
whtt-wod_det = iphdsinout:get-buffer-handle("tt-wod_det").
whtt-wod_det = whtt-wod_det:table-handle.
/*your code goes here*/
/* RESOURCE TYPE CONSTANTS */
&SCOPED-DEFINE PRODUCTION_LINE 0
&SCOPED-DEFINE WORK_CENTER 1
{gplabel.i}
{woscwo.i}
define variable wWeekdays as character extent 7.
wWeekdays[1] = getTermLabel("SUNDAY", 60).
wWeekdays[2] = getTermLabel("MONDAY", 60).
wWeekdays[3] = getTermLabel("TUESDAY", 60).
wWeekdays[4] = getTermLabel("WEDNESDAY", 60).
wWeekdays[5] = getTermLabel("THURSDAY", 60).
wWeekdays[6] = getTermLabel("FRIDAY", 60).
wWeekdays[7] = getTermLabel("SATURDAY", 60).
run process_tt-wo_mstr(input-output table-handle whtt-wo_mstr by-reference).
procedure process_tt-wo_mstr:
define input-output parameter table for tt-wo_mstr.
for each tt-wo_mstr:
tt-wo_mstr.wo_release_day = wWeekdays[weekday(tt-wo_mstr.wo_rel_date)].
end.
end procedure.
6 In the Post Save Read user exit, add code to populate the new field and compile it. Notice that it is almost exactly the same as the Post Search Read user exit code:
/* woscupdatereadx.p - MSW/PSW Personalization Architecture user exit program */
/* Copyright 1986 QAD Inc. All rights reserved. */
/* $Id:: woscupdatereadx.p 4721 2013-04-04 20:52:09Z wug $: */
/*V8:ConvertMode=NoConvert */
/*
* Post update read user exit program
*
*/
define variable svnId{&SEQUENCE} as character no-undo initial "svnId $Id: woscupdatereadx.p 4721 2013-04-04 20:52:09Z wug $".
{mfdeclre.i}
define input-output parameter dataset-handle iphdsinout.
define input parameter ipTodaysDate as date no-undo.
define input parameter ipStartDate as date no-undo.
define input parameter ipEndDate as date no-undo.
define input parameter ipSequencingHorizon as integer no-undo.
define input parameter ipIncludeItemsWithNoSupplyDemand as logical no-undo.
define input parameter ipRetrieveRoutingRecords as logical no-undo.
define input parameter ipCACEngineEnabled as logical no-undo.
/*THE INPUT-OUTPUT PARAMETER DATASET-HANDLE REFERS TO THE DATASET
*THAT IS SENT BACK TO 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 CODE BELOW GETS A HANDLE TO THE tt-wo_mstr
*AND tt-wod_det TEMP-TABLES. YOU CAN CALL A PROCEDURE
*USING THE TABLE-HANDLE CONSTRUCT IF YOU WANT TO ACCESS
*THESE TABLES STATICALLY.*/
define variable whtt-wo_mstr as handle no-undo.
define variable whtt-wod_det as handle no-undo.
whtt-wo_mstr = iphdsinout:get-buffer-handle("tt-wo_mstr").
whtt-wo_mstr = whtt-wo_mstr:table-handle.
whtt-wod_det = iphdsinout:get-buffer-handle("tt-wod_det").
whtt-wod_det = whtt-wod_det:table-handle.
/*your code goes here*/
/* RESOURCE TYPE CONSTANTS */
&SCOPED-DEFINE PRODUCTION_LINE 0
&SCOPED-DEFINE WORK_CENTER 1
{gplabel.i}
{woscwo.i}
define variable wWeekdays as character extent 7.
wWeekdays[1] = getTermLabel("SUNDAY", 60).
wWeekdays[2] = getTermLabel("MONDAY", 60).
wWeekdays[3] = getTermLabel("TUESDAY", 60).
wWeekdays[4] = getTermLabel("WEDNESDAY", 60).
wWeekdays[5] = getTermLabel("THURSDAY", 60).
wWeekdays[6] = getTermLabel("FRIDAY", 60).
wWeekdays[7] = getTermLabel("SATURDAY", 60).
run process_tt-wo_mstr(input-output table-handle whtt-wo_mstr by-reference).
procedure process_tt-wo_mstr:
define input-output parameter table for tt-wo_mstr.
for each tt-wo_mstr:
tt-wo_mstr.wo_release_day = wWeekdays[weekday(tt-wo_mstr.wo_rel_date)].
end.
end procedure.