| 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.
DATALOADBLOCK:
for each t_sMirroringJournal on error undo, return:
/* ================================================================= */
/* Lookup object by logical key */
/* When in create mode, skip lookup. */
/* ================================================================= */
if vcActivityCode <> "Create":U
then do:
if not vlstarted
then do:
<Q-2 run MirroringJournalPrim (Start) in BMirroringJournal >
assign vlstarted = true.
end.
/* =============================================== */
/* Get the MirroringJournal_ID based on the logical key */
/* =============================================== */
if(t_sMirroringJournal.MirroringJournal_ID = 0 or
t_sMirroringJournal.MirroringJournal_ID = ?) and
t_sMirroringJournal.tcSourceJournalCode <> '' and
t_sMirroringJournal.tcSourceJournalCode <> ? and
t_sMirroringJournal.tcMirrorJournalCode <> '' and
t_sMirroringJournal.tcMirrorJournalCode <> ?
then do:
<Q-3 run MirroringJournalPrim (all) (Read) (Cache)
(input viCompanyId, (CompanyId)
input t_sMirroringJournal.tcSourceJournalCode, (SourceJournalCode)
input t_sMirroringJournal.tcMirrorJournalCode, (MirrorJournalCode)
input viDomainID, (DomainID)
input ?, (MirroringJournalID)
output dataset tqMirroringJournalPrim) in BMirroringJournal >
find first tqMirroringJournalPrim where
tqMirroringJournalPrim.tcSourceJournalCode = t_sMirroringJournal.tcSourceJournalCode and
tqMirroringJournalPrim.tcMirrorJournalCode = t_sMirroringJournal.tcMirrorJournalCode no-error.
if available tqMirroringJournalPrim
then assign t_sMirroringJournal.MirroringJournal_ID = tqMirroringJournalPrim.tiMirroringJournal_ID.
end. /* if (t_sMirroringJournal.MirroringJournal_ID = 0 or */
if t_sMirroringJournal.MirroringJournal_ID = 0 or
t_sMirroringJournal.MirroringJournal_ID = ?
then assign viFcReturnSuper = -4.
else do:
<M-4 run DataLoad
(input '':U (icRowids),
input string(t_sMirroringJournal.mirroringJournal_ID) (icPkeys),
input '':U (icObjectIds),
input '':U (icFreeform),
input true (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BMirroringJournal>
end. /* if t_sMirroringJournal.MirroringJournal_ID = 0 or */
if viFcReturnSuper >= 0
then find first tMirroringJournal where tMirroringJournal.MirroringJournal_ID
= t_sMirroringJournal.MirroringJournal_ID no-error.
end. /* if vcActivityCode <> "Create":U */
/* ================================================================= */
/* 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_sMirroringJournal.
else do:
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave DATALOADBLOCK.
/* ================================================================= */
/* Update input to allow correct matching */
/* ================================================================= */
assign t_sMirroringJournal.tc_Rowid = tMirroringJournal.tc_Rowid
t_sMirroringJournal.tc_ParentRowid = ""
opPrimeKey = (if opPrimeKey = "" then "" else opPrimeKey + chr(4))
+ string(tMirroringJournal.MirroringJournal_ID).
end.
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(substitute(#T-1'Object with key $1 does not exist.':100(48021)T-1#,
string(t_sMirroringJournal.MirroringJournal_ID)))
oiReturnStatus = -1.
<M-5 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tMirroringJournal.MirroringJournal_ID':U (icFieldName),
input string(tMirroringJournal.MirroringJournal_ID) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sMirroringJournal.tc_Rowid (icRowid),
input 'QadFin-7674':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BMirroringJournal>
leave DATALOADBLOCK.
end. /* if vcActivityCode = "Modify":U */
/* ================================================================= */
/* When object not found or in create mode, create it. */
/* ================================================================= */
<M-6 run AddDetailLine
(input 'MirroringJournal':U (icTable),
input '':U (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BMirroringJournal>
/* ================================================================= */
/* Update input to allow correct matching */
/* ================================================================= */
assign t_sMirroringJournal.tc_Status = "N":U.
end.
else do:
/* ================================================================= */
/* Update input to allow correct matching */
/* ================================================================= */
assign t_sMirroringJournal.tc_Status = "C":U.
end.
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
/* ================================================================= */
/* override value for identity fields in input */
/* ================================================================= */
assign
t_sMirroringJournal.MirroringJournal_ID = tMirroringJournal.MirroringJournal_ID
t_sMirroringJournal.tc_Rowid = tMirroringJournal.tc_Rowid
t_sMirroringJournal.tc_ParentRowid = tMirroringJournal.tc_ParentRowid
opPrimeKey = (if opPrimeKey = "" then "" else opPrimeKey + chr(4))
+ string(tMirroringJournal.MirroringJournal_ID).
end. /* for each t_sMirroringJournal on error undo, return: */
if vlStarted
then do:
<Q-7 run MirroringJournalPrim (Stop) in BMirroringJournal >
end.
if oiReturnStatus = -98
then oiReturnStatus = 0.