| opPrimeKey | output | longchar | Primary Key field value of loaded record(s). Keys are chr(4) separated. Key fields are chr(2) separated. |
| oiReturnStatus | output | integer | Return status of the method. |
for each t_sBusComponent
by rowid(t_sBusComponent)
on error undo, throw:
/* ============================ */
/* Lookup object by logical key */
/* ============================ */
assign vcFreeform = "for each BusComponent where BusComponent.BusComponentCode = '" + t_sBusComponent.BusComponentCode + "'".
<M-1 run DataLoad
(input '' (icRowids),
input '' (icPkeys),
input '' (icObjectIds),
input vcFreeform (icFreeform),
input true (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BBusinessComponent>
if viFcReturnSuper >= 0
then find first tBusComponent where
tBusComponent.BusComponentCode = t_sBusComponent.BusComponentCode
no-error.
/* ============================================= */
/* When in delete mode, ignore input data. */
/* When object not found, do not return an error */
/* ============================================= */
if t_sBusComponent.tc_Status = "D"
then do:
if viFcReturnSuper = -4
then do:
for each t_sBusActivity where
t_sBusActivity.tc_ParentRowid = t_sBusComponent.tc_Rowid:
delete t_sBusActivity.
end.
delete t_sBusComponent.
end.
else do:
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
/* ====================================== */
/* Update input to allow correct matching */
/* ====================================== */
if opPrimeKey <> ""
then assign opPrimeKey = opPrimeKey + chr(4).
assign t_sBusComponent.BusComponent_ID = tBusComponent.BusComponent_ID
t_sBusComponent.tc_Rowid = tBusComponent.tc_Rowid
t_sBusComponent.tc_ParentRowid = ""
opPrimeKey = opPrimeKey + string(tBusComponent.BusComponent_ID).
end.
next.
end.
if viFcReturnSuper = -4
then do:
/* ========================================================= */
/* When object not found and in modify mode, return an error */
/* ========================================================= */
if t_sBusComponent.tc_Status = "C"
then do:
<M-2 run SetMessage
(input trim(#T-1'Object with key $1 does not exist.':100(8887)T-1#) (icMessage),
input t_sBusComponent.BusComponentCode (icArguments),
input 'tBusComponent.BusComponentCode' (icFieldName),
input t_sBusComponent.BusComponentCode (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input t_sBusComponent.tc_Rowid (icRowid),
input 'BLF-223':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBusinessComponent>
assign oiReturnStatus = -1.
return.
end.
/* ================================================== */
/* When object not found or in create mode, create it */
/* ================================================== */
<M-3 run AddDetailLine
(input 'BusComponent' (icTable),
input '' (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BBusinessComponent>
/* ====================================== */
/* Update input to allow correct matching */
/* ====================================== */
assign t_sBusComponent.tc_Status = "N".
end.
else do:
/* ====================================== */
/* Update input to allow correct matching */
/* ====================================== */
assign t_sBusComponent.tc_Status = "C".
end.
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
/* ====================== */
/* Delete existing detail */
/* ====================== */
for each tBusActivity where
tBusActivity.tc_ParentRowid = tBusComponent.tc_Rowid:
assign tBusActivity.tc_Status = "D".
end.
/* =================== */
/* Update / add detail */
/* =================== */
for each t_sBusActivity where
t_sBusActivity.tc_ParentRowid = t_sBusComponent.tc_Rowid:
if t_sBusActivity.tc_Status = "N"
then do:
<M-4 run AddDetailLine
(input 'BusActivity' (icTable),
input tBusComponent.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BBusinessComponent>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end.
else do:
find first tBusActivity where
tBusActivity.tc_ParentRowid = tBusComponent.tc_Rowid and
tBusActivity.BusActivityCode = t_sBusActivity.BusActivityCode
no-error.
if not available tBusActivity
then do:
<M-5 run SetMessage
(input trim(#T-2'Activity $1 not found for component $2.':255(733755856)T-2#) (icMessage),
input t_sBusActivity.BusActivityCode + chr(2) + t_sBusComponent.BusComponentCode (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'BLF-239':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBusinessComponent>
assign oiReturnStatus = -1.
return.
end.
end.
/* =========================================== */
/* Override value for identity fields in input */
/* Update input to allow correct matching */
/* =========================================== */
assign t_sBusActivity.BusActivity_ID = tBusActivity.BusActivity_ID
t_sBusActivity.BusComponent_ID = tBusActivity.BusComponent_ID
t_sBusActivity.tc_Rowid = tBusActivity.tc_Rowid
t_sBusActivity.tc_ParentRowid = tBusComponent.tc_Rowid.
<I-47 {UpdateTransString
&TABLE = "BusActivity"}>
end.
<I-25 {UpdateTransString
&TABLE = "BusComponent"}>
/* =========================================== */
/* Override value for identity fields in input */
/* Update input to allow correct matching */
/* =========================================== */
if opPrimeKey <> ""
then assign opPrimeKey = opPrimeKey + chr(4).
assign t_sBusComponent.BusComponent_ID = tBusComponent.BusComponent_ID
t_sBusComponent.tc_Rowid = tBusComponent.tc_Rowid
t_sBusComponent.tc_ParentRowid = ""
opPrimeKey = opPrimeKey + string(tBusComponent.BusComponent_ID).
end.