Description
This method is used for finalizing of shared set merge.
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program6/bsharedsetmerge.p)
/* =================================================================================================== */
/* Method : MergeSharedSetFinish */
/* Desc : This method is used for finalizing of shared set merge. */
/* - delete of redundant shared set (translations, profile references) */
/* - trigerring of synchronization towards Mfg regarding changed records */
/* - startup of synchronization daemon */
/* =================================================================================================== */
assign oiReturnStatus = -98
viLocalReturn = 0
viExternalReturnStatus = 0.
MAIN_BLOCK:
do:
/* =================================================================================================== */
/* Delete redundant shared set */
/* =================================================================================================== */
<M-22 run StartPersistence
(output vhFcComponent (ohPersistence),
output viFcReturnSuper (oiReturnStatus)) in BSharedSetMerge>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viLocalReturn < 0 then leave MAIN_BLOCK.
/* first delete all profile links pointing to redundant shared set. There still remains with non-valid */
/* relation to elements from redundant shared set */
assign vcStatement = 'for each ProfileLink where ':U +
'ProfileLink.SharedSet_ID = &1':U
vcStatement = substitute(vcStatement, viRedundantSharedSetId ).
<M-8 run WriteDirect
(input 'ProfileLink':U (icTableName),
input vcStatement (icPrepare),
input '':U (icFieldList),
input 'i,i':U (icFieldListDataTypes),
input '':U (icAbsolute),
input '':U (icIncremental),
input {&TARGETPROCEDURE} (ihClass),
input vcUserLogin (icUserLogin),
output viFcReturnSuper (oiReturnStatus)) in Progress>
if viFcReturnSuper = -4 then assign viFcReturnSuper = 0.
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viLocalReturn < 0 then leave MAIN_BLOCK.
/* Just now delete shared set itself */
assign vcKey = 'Primary=':U + string(viRedundantSharedSetId).
<I-6 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "false"
&CLASS = "BSharedSet"}>
<M-3 run apiDeleteInstance
(input vcKey (icKey),
output viFcReturnSuper (oiReturnStatus)) in BSharedSet>
assign viExternalReturnStatus = viFcReturnSuper.
<I-7 {bFcCloseAndStopInstance
&CLASS = "BSharedSet"}>
if viExternalReturnStatus < 0 or viExternalReturnStatus > 0 and viLocalReturn = 0 then assign viLocalReturn = viExternalReturnStatus.
if viLocalReturn < 0 then leave MAIN_BLOCK.
/* =================================================================================================== */
/* Log finishing of the merge */
/* =================================================================================================== */
<I-9 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "false"
&CLASS = "BSharedSetMergeLog"}>
<M-12 run LogEndMerge
(input vcMasterSharedSetCode (icMasterSharedSet),
input vcRedundantSharedSetCode (icRedundantSharedSet),
output viFcReturnSuper (oiReturnStatus)) in BSharedSetMergeLog>
assign viExternalReturnStatus = viFcReturnSuper.
/* Close instance of BDomain component */
<I-11 {bFcCloseInstance
&CLASS = "BSharedSetMergeLog"}>
if viExternalReturnStatus < 0 or viExternalReturnStatus > 0 and viLocalReturn = 0 then assign viLocalReturn = viExternalReturnStatus.
if viLocalReturn < 0 then leave MAIN_BLOCK.
/* =============================================================================================== */
/* Create request for replication daemon (synchronization to MFg) only when any of non-mandatory */
/* fields has different value */
/* =============================================================================================== */
for each tSharedSetMergeMasterData:
create tReplicaDaemonQueueSSM.
assign tReplicaDaemonQueueSSM.tcDaemonQueueRef = vcSharedSetMergeSharedSetType + chr(4) + trim(string(viMasterCompanyId))
tReplicaDaemonQueueSSM.tcDaemonQueueRefDescription = trim(string(tSharedSetMergeMasterData.tiMasterObjectId))
tReplicaDaemonQueueSSM.tiDaemonQueuePriority = 9.
/* (Start and) open BReplicaDaemonQueue */
<I-74 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "false"
&CLASS = "BReplicaDaemonQueue"}>
<M-1 run ApiCreateReplicationDaemonQueue
(input tReplicaDaemonQueueSSM (tReplicationDaemonQueue),
output viExternalReturnStatus (oiReturnStatus)) in BReplicaDaemonQueue>
<I-69 {bFcCloseAndStopInstance
&CLASS = "BReplicaDaemonQueue"}>
if viExternalReturnStatus < 0 or viExternalReturnStatus > 0 and viLocalReturn = 0 then assign viLocalReturn = viExternalReturnStatus.
if viLocalReturn < 0 then leave MAIN_BLOCK.
end. /* for each tSharedSetMergeMasterData */
/* =================================================================================================== */
/* Start repplication daemon */
/* =================================================================================================== */
<I-15 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "no"
&CLASS = "BReplicaDaemon"}>
<M-18 run APIStart
(output viFcReturnSuper (oiReturnStatus)) in BReplicaDaemon>
assign viExternalReturnStatus = viFcReturnSuper.
if viExternalReturnStatus < 0
then do:
assign vcMessage = #T-20'The shared set merge is completed. The data must be replicated but the Replication daemon has failed to start. Contact the system administrator.':255(64772)T-20#.
viExternalReturnStatus = 1.
<M-19 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-6814':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BSharedSetMerge>
end.
<I-17 {bFcCloseAndStopInstance
&CLASS = "BReplicaDaemon"}>
if viExternalReturnStatus < 0 or viExternalReturnStatus > 0 and viLocalReturn = 0 then assign viLocalReturn = viExternalReturnStatus.
if viLocalReturn < 0 then leave MAIN_BLOCK.
end. /* end of MAIN_BLOCK */
/* =================================================================================================== */
/* Return */
/* =================================================================================================== */
assign oiReturnStatus = viLocalReturn.