project QadFinancials > class BSharedSetMerge > method MergeInitClearReferencesSameTable
Description
This method clears all fields which can be used for creation of relation between records of the same table.
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bsharedsetmerge.p)
/* =================================================================================================== */
/* Method : MergeInitClearRerencesSameTable */
/* Desc : This method clears all fields which can be used for creation of relation between */
/* records of the same table (Like relation Debtor.BillToDebtor_ID -> Debtor). */
/* Existence of this relation cen lead to issues during delete of such debtor. */
/* --------------------------------------------------------------------------------------------------- */
/* Params: (H) MergeValidateTable This temporary table is used for definition of rules for merging */
/* of shared sets */
/* (H) MergeValidateField Definition of rules for fields merge */
/* =================================================================================================== */
assign oiReturnStatus = -98.
/* =================================================================================================== */
/* Go through all fields of main table and clear all established relation between records of the same */
/* table */
/* =================================================================================================== */
for first tMergeValidateTable where
tMergeValidateTable.tcParentTableName = '':U or
tMergeValidateTable.tcParentTableName = ?,
each tMergeValidateField where
tMergeValidateField.tc_ParentRowid = tMergeValidateTable.tc_Rowid and
tMergeValidateField.tlIsRelationToSameTable = true:
assign vcStatement = 'for each &1 where &1.&2 <> ? and &1.&2 <> 0 and &1.SharedSet_ID = &3':U
vcStatement = substitute(vcStatement,
tMergeValidateTable.tcTableName,
tMergeValidateField.tcRelationFieldName,
viRedundantSharedSetId).
<M-4 run StartPersistence
(output vhFcComponent (ohPersistence),
output viFcReturnSuper (oiReturnStatus)) in BSharedSetMerge>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
<M-2 run WriteDirect
(input tMergeValidateTable.tcTableName (icTableName),
input vcStatement (icPrepare),
input tMergeValidateField.tcRelationFieldName (icFieldList),
input 'i':U (icFieldListDataTypes),
input '0':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 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
end.
/* =================================================================================================== */
/* Return */
/* =================================================================================================== */
if oiReturnStatus = -98 then assign oiReturnStatus = 0.