| 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. |
if oiReturnStatus = 0
then oiReturnStatus = -98.
for each t_sCorporateGroup on error undo, return:
/* ================================================================= */
/* Lookup object by logical key */
/* When in create mode, skip lookup. */
/* ================================================================= */
if vcActivityCode <> "Create":U
then do:
/* ==================================================== */
/* Get the CorporateGroup_ID based on the logical key */
/* ==================================================== */
if (t_sCorporateGroup.CorporateGroup_ID = ? or
t_sCorporateGroup.CorporateGroup_ID = 0) and
t_sCorporateGroup.CorporateGroupCode <> "" and
t_sCorporateGroup.CorporateGroupCode <> ?
then do:
<Q-6 run CorporateGroupPrim (all) (Read) (NoCache)
(input t_sCorporateGroup.CorporateGroup_ID, (CorporateGroup_ID)
input t_sCorporateGroup.CorporateGroupCode, (CorporateGroupCode)
output dataset tqCorporateGroupPrim) in BCorporateGroup >
find tqCorporateGroupPrim where
tqCorporateGroupPrim.tcCorporateGroupCode = t_sCorporateGroup.CorporateGroupCode
no-lock no-error.
if available tqCorporateGroupPrim
then assign t_sCorporateGroup.CorporateGroup_ID = tqCorporateGroupPrim.tiCorporateGroup_ID.
end. /* if t_sCorporateGroup.CorporateGroup_ID = ? or */
/* ========================== */
/* Load/Create CorporateGroup */
/* ========================== */
if t_sCorporateGroup.CorporateGroup_ID = ? or
t_sCorporateGroup.CorporateGroup_ID = 0
then assign viFcReturnSuper = -4.
else do:
<M-2 run DataLoad
(input '' (icRowids),
input string(t_sCorporateGroup.CorporateGroup_ID) (icPkeys),
input '' (icObjectIds),
input '' (icFreeform),
input yes (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BCorporateGroup>
end. /* else do */
if viFcReturnSuper >= 0
then find first tCorporateGroup where
tCorporateGroup.CorporateGroup_ID = t_sCorporateGroup.CorporateGroup_ID
no-error.
end.
/* ================================================================= */
/* When in delete mode, ignore input data. */
/* When object not found, do not return an error. */
/* ================================================================= */
if vcActivityCode = "Delete":U
then do:
if viFcReturnSuper = -4
then delete t_sCorporateGroup.
else do:
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
/* ================================================================= */
/* Update input to allow correct matching */
/* ================================================================= */
assign t_sCorporateGroup.tc_Rowid = tCorporateGroup.tc_Rowid
t_sCorporateGroup.tc_ParentRowid = ""
opPrimeKey = (if opPrimeKey = "" then "" else opPrimeKey + chr(4))
+ string(tCorporateGroup.CorporateGroup_ID).
end. /* else do */
next.
end. /* if vcActivityCode = "Delete":U */
if vcActivityCode = "Create":U or
viFcReturnSuper = -4
then do:
/* ================================================================= */
/* When object not found and in modify only mode, return an error. */
/* ================================================================= */
if vcActivityCode = "Modify":U
then do:
assign
vcMessage = trim(#T-5'Object with key $1 does not exist.':100(48021)T-5#).
<M-3 run SetMessage (input vcMessage (icMessage),
input t_sCorporateGroup.CorporateGroupCode (icArguments),
input 'tCorporateGroup.CorporateGroupCode':U (icFieldName),
input t_sCorporateGroup.CorporateGroupCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCorporateGroup.tc_Rowid (icRowid),
input 'QadFin-7972':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCorporateGroup>
assign oiReturnStatus = -1.
return.
end. /* if vcActivityCode = "Modify":U */
/* ================================================================= */
/* When object not found or in create mode, create it. */
/* ================================================================= */
<M-4 run AddDetailLine (input 'CorporateGroup':U (icTable),
input '' (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BCorporateGroup>
/* ================================================================= */
/* Update input to allow correct matching */
/* ================================================================= */
assign t_sCorporateGroup.tc_Status = "N":U.
end. /* if vcActivityCode = "Create":U or */
else do:
/* ================================================================= */
/* Update input to allow correct matching */
/* ================================================================= */
assign t_sCorporateGroup.tc_Status = "C":U.
end. /* else do */
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
/* insert code for subtables here: */
<I-90 {UpdateTransString
&TABLE = "CorporateGroup"}>
/* ================================================================= */
/* override value for identity fields in input */
/* Update input to allow correct matching */
/* ================================================================= */
assign t_sCorporateGroup.CorporateGroup_ID = tCorporateGroup.CorporateGroup_ID
t_sCorporateGroup.tc_Rowid = tCorporateGroup.tc_Rowid
t_sCorporateGroup.tc_ParentRowid = ""
opPrimeKey = (if opPrimeKey = "" then "" else opPrimeKey + chr(4))
+ string(tCorporateGroup.CorporateGroup_ID).
end. /* for each t_sCorporateGroup on error undo, return: */
if oiReturnStatus = -98
then oiReturnStatus = 0.