Description
Write here all tests on database update (new / modify / delete) that cannot be coded with a validation mask.
The type of update can be found in tc_status (N/C/D).
If you find incorrect data, you must write an entry in tFcMessages (using SetMessage) and set the return status of this method to either +1 or -1.
Return status +1 = data will still be accepted.
Return status -1 = data will not be accepted.
This method is run from SetPublicTables, before transferring the received data into the class temp-tables.
Parameters
oiReturnStatus | output | integer | |
Internal usage
unused
program code (program/bmfgcosting.p)
/* first of all stop all external instances to be sure, we are starting */
/* from blank */
<M-2 run StopExternalInstances
(output viFcReturnSuper (oiReturnStatus)) in BMfgCosting>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
/* recalculate total cost for all changed records */
/* developer has two possibilities how to change cost. He can adjust cost on header (sct_det) and */
/* then update cost of details - this is applied for non-logistical charges. Or he can adjust */
/* cost element details (spt_det) - this is applied for logistical charges */
/* Go through all loaded cost simulation records */
for each t_ssct_det where
t_ssct_det.tc_Status <> 'D':U:
/* Check, whether spt_det record was updated -> recalculate header */
if can-find( t_sspt_det where
t_sspt_det.tc_ParentRowid = t_ssct_det.tc_Rowid and
((t_sspt_det.tc_Status = 'C':U) or
(t_sspt_det.tc_Status = 'N':U and
(t_sspt_det.spt_cst_tl <> 0 or t_sspt_det.spt_cst_ll <> 0))))
then do:
assign t_ssct_det.sct_mtl_tl = 0
t_ssct_det.sct_mtl_ll = 0
t_ssct_det.sct_lbr_tl = 0
t_ssct_det.sct_lbr_ll = 0
t_ssct_det.sct_bdn_tl = 0
t_ssct_det.sct_bdn_ll = 0
t_ssct_det.sct_ovh_tl = 0
t_ssct_det.sct_ovh_ll = 0
t_ssct_det.sct_sub_tl = 0
t_ssct_det.sct_sub_ll = 0
t_ssct_det.tc_Status = (if t_ssct_det.tc_Status = '':U
then 'C':U
else t_ssct_det.tc_Status).
for each t_sspt_det where
t_sspt_det.tc_ParentRowid = t_ssct_det.tc_Rowid and
t_sspt_det.tc_Status <> 'D':U:
case int(truncate(t_sspt_det.spt_pct_ll,0)):
when 1 /* material */
then assign t_ssct_det.sct_mtl_tl = t_ssct_det.sct_mtl_tl + t_sspt_det.spt_cst_tl
t_ssct_det.sct_mtl_ll = t_ssct_det.sct_mtl_ll + t_sspt_det.spt_cst_ll.
when 2 /* labour */
then assign t_ssct_det.sct_lbr_tl = t_ssct_det.sct_lbr_tl + t_sspt_det.spt_cst_tl
t_ssct_det.sct_lbr_ll = t_ssct_det.sct_lbr_ll + t_sspt_det.spt_cst_ll.
when 3 /* bourden */
then assign t_ssct_det.sct_bdn_tl = t_ssct_det.sct_bdn_tl + t_sspt_det.spt_cst_tl
t_ssct_det.sct_bdn_ll = t_ssct_det.sct_bdn_ll + t_sspt_det.spt_cst_ll.
when 4 /* overhead */
then assign t_ssct_det.sct_ovh_tl = t_ssct_det.sct_ovh_tl + t_sspt_det.spt_cst_tl
t_ssct_det.sct_ovh_ll = t_ssct_det.sct_ovh_ll + t_sspt_det.spt_cst_ll.
when 5 /* subcontract */
then assign t_ssct_det.sct_sub_tl = t_ssct_det.sct_sub_tl + t_sspt_det.spt_cst_tl
t_ssct_det.sct_sub_ll = t_ssct_det.sct_sub_ll + t_sspt_det.spt_cst_ll.
end case.
end. /* of for each t_sspt_det where */
assign t_ssct_det.sct_cst_tot = t_ssct_det.sct_mtl_tl + t_ssct_det.sct_mtl_ll
+ t_ssct_det.sct_lbr_tl + t_ssct_det.sct_lbr_ll
+ t_ssct_det.sct_bdn_tl + t_ssct_det.sct_bdn_ll
+ t_ssct_det.sct_ovh_tl + t_ssct_det.sct_ovh_ll
+ t_ssct_det.sct_sub_tl + t_ssct_det.sct_sub_ll
t_ssct_det.sct_cst_date = today.
end.
else if t_ssct_det.tc_Status = 'C':U or
t_ssct_det.tc_Status = 'N':U
then do:
assign t_ssct_det.sct_cst_tot = t_ssct_det.sct_mtl_tl + t_ssct_det.sct_mtl_ll
+ t_ssct_det.sct_lbr_tl + t_ssct_det.sct_lbr_ll
+ t_ssct_det.sct_bdn_tl + t_ssct_det.sct_bdn_ll
+ t_ssct_det.sct_ovh_tl + t_ssct_det.sct_ovh_ll
+ t_ssct_det.sct_sub_tl + t_ssct_det.sct_sub_ll
t_ssct_det.sct_cst_date = today.
/* update cost element detail records */
for each t_sspt_det where
t_sspt_det.tc_ParentRowid = t_ssct_det.tc_Rowid and
t_sspt_det.tc_Status <> 'D':U:
if t_sspt_det.spt_pct_ll = 1 /* material */
then do:
if t_sspt_det.spt_cst_tl <> t_ssct_det.sct_mtl_tl or
t_sspt_det.spt_cst_ll <> t_ssct_det.sct_mtl_ll
then assign t_sspt_det.spt_cst_tl = t_ssct_det.sct_mtl_tl
t_sspt_det.spt_cst_ll = t_ssct_det.sct_mtl_ll
t_sspt_det.tc_Status = (if t_sspt_det.tc_Status = '':U
then 'C':U
else t_sspt_det.tc_Status).
end.
else if t_sspt_det.spt_pct_ll = 2 /* labour */
then do:
if t_sspt_det.spt_cst_tl <> t_ssct_det.sct_lbr_tl or
t_sspt_det.spt_cst_ll <> t_ssct_det.sct_lbr_ll
then assign t_sspt_det.spt_cst_tl = t_ssct_det.sct_lbr_tl
t_sspt_det.spt_cst_ll = t_ssct_det.sct_lbr_ll
t_sspt_det.tc_Status = (if t_sspt_det.tc_Status = '':U
then 'C':U
else t_sspt_det.tc_Status).
end.
else if t_sspt_det.spt_pct_ll = 3 /* bourden */
then do:
if t_sspt_det.spt_cst_tl <> t_ssct_det.sct_bdn_tl or
t_sspt_det.spt_cst_ll <> t_ssct_det.sct_bdn_ll
then assign t_sspt_det.spt_cst_tl = t_ssct_det.sct_bdn_tl
t_sspt_det.spt_cst_ll = t_ssct_det.sct_bdn_ll
t_sspt_det.tc_Status = (if t_sspt_det.tc_Status = '':U
then 'C':U
else t_sspt_det.tc_Status).
end.
else if t_sspt_det.spt_pct_ll = 4 /* overhead */
then do:
if t_sspt_det.spt_cst_tl <> t_ssct_det.sct_ovh_tl or
t_sspt_det.spt_cst_ll <> t_ssct_det.sct_ovh_ll
then assign t_sspt_det.spt_cst_tl = t_ssct_det.sct_ovh_tl
t_sspt_det.spt_cst_ll = t_ssct_det.sct_ovh_ll
t_sspt_det.tc_Status = (if t_sspt_det.tc_Status = '':U
then 'C':U
else t_sspt_det.tc_Status).
end.
else if t_sspt_det.spt_pct_ll = 5 /* subcontract */
then do:
if t_sspt_det.spt_cst_tl <> t_ssct_det.sct_sub_tl or
t_sspt_det.spt_cst_ll <> t_ssct_det.sct_sub_ll
then assign t_sspt_det.spt_cst_tl = t_ssct_det.sct_sub_tl
t_sspt_det.spt_cst_ll = t_ssct_det.sct_sub_ll
t_sspt_det.tc_Status = (if t_sspt_det.tc_Status = '':U
then 'C':U
else t_sspt_det.tc_Status).
end.
end. /* for each t_sspt_det where */
end. /* else if t_ssct_det.tc_Status = 'C':U or */
end. /* for each t_ssct_det where */
<ANCESTOR-CODE>