project QadFinancials > class BCompany > method SharedSetSynchronise
Description
This method synchronises the domain shared sets to company level
Parameters
| t_sDomainSharedSet | input | temp-table | contains the shared sets for a domain |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program2/bcompany.p)
assign oiReturnStatus = -98.
for each t_sDomainSharedSet where t_sDomainSharedSet.tc_status = "C":U
break by t_sDomainSharedSet.Domain_ID:
/* load the company and the sharedset */
if first-of(t_sDomainSharedSet.Domain_ID) then do:
<Q-14 run CompanyByDomain (all) (Read) (NoCache)
(input '', (CompanyId)
input t_sDomainSharedSet.Domain_ID, (DomainId)
input ?, (Active)
output dataset tqCompanyByDomain) in BCompany >
for each tqCompanyByDomain:
<M-5 run DataLoad (input '' (icRowids),
input string(tqCompanyByDomain.tiCompany_ID) (icPkeys),
input '' (icObjectIds),
input '' (icFreeform),
input true (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BCompany>
if viFcReturnSuper <> 0 then do:
assign vcMessage = trim(subst(#T-9'The system cannot load entity &1.':50(45570)t-9#, string(tqCompanyByDomain.tiCompany_ID)))
oiReturnStatus = viFcReturnSuper.
<M-10 run SetMessage (input vcMessage (icMessage),
input string(tqCompanyByDomain.tiCompany_ID) (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input '' (icType),
input 1 (iiSeverity),
input '' (icRowid),
input '-154':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCompany>
return.
end.
end.
end.
end.
/* Verify if there are any companies linked to the domain */
/* if there are no linked companies stop processing */
find first tqCompanyByDomain no-error.
if available tqCompanyByDomain then
for each t_sDomainSharedSet where t_sDomainSharedSet.tc_status = "C":U
break by t_sDomainSharedSet.Domain_ID:
for each tCompany where tCompany.Domain_ID = t_sDomainSharedSet.Domain_ID
break by tCompany.Company_ID:
find tCompanySharedSet where tCompanySharedSet.Company_ID = tCompany.Company_ID and
tCompanySharedSet.tcSharedSetTypeCode = t_sDomainSharedSet.tcSharedSetTypeCode
no-error.
if not available tCompanySharedSet then do:
<M-7 run AddDetailLine (input 'CompanySharedSet':U (icTable),
input tCompany.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BCompany>
if viFcReturnSuper <> 0 then do:
assign vcMessage = trim(subst(#T-13'Shared set &1 cannot be copied to entity &2.':75(4223)t-13#, tCompanySharedSet.tcSharedSetTypeCode, string(tqCompanyByDomain.tiCompany_ID)))
oiReturnStatus = viFcReturnSuper.
<M-11 run SetMessage (input vcMessage (icMessage),
input string(tqCompanyByDomain.tiCompany_ID) (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input '' (icType),
input 1 (iiSeverity),
input '' (icRowid),
input '-155':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCompany>
return.
end.
assign tCompanySharedSet.tc_status = "N":U.
end.
else do:
assign tCompanySharedSet.tc_status = t_sDomainSharedSet.tc_status.
end.
assign tCompanySharedSet.tcSharedSetCode = t_sDomainSharedSet.tcSharedSetCode.
if last-of (tCompany.Company_ID) then do:
/*find first tCompanyPropertyRef where tCompanyPropertyRef.tc_ParentRowid = tCompany.tc_Rowid no-error.
if available tCompanyPropertyRef then do:
if iiCurrencyID <> 0 and tCompanyPropertyRef.Currency_ID <> iiCurrencyID then do:
assign tCompanyPropertyRef.Currency_ID = iiCurrencyID
tCompanyPropertyRef.tc_Status = "C":U.
end.
end.*/
assign tCompany.tc_Status = 'C':U.
end.
end.
end.
assign oiReturnStatus = 0.