project QadFinancials > class BDivision > method ValidateComponentPreCOAMask
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program7/bdivision.p)
/* This method is used to do the validation on COA Mask Code */
empty temp-table tUpdateProfileDiv.
/* Start queries */
<Q-20 run DomainByDomainSharedSet (Start) in BDomain >
/* Get COAMaskDiv shared set id */
<Q-17 run DomainByDomainSharedSet (all) (Read) (NoCache)
(input viDomainID, (DomainID)
input ?, (SharedSetID)
input ?, (SharedSetCode)
input {&SHAREDSETTYPECODE-DIVISION-COAMASK}, (SharedSetType)
output dataset tqDomainByDomainSharedSet) in BDomain >
find first tqDomainByDomainSharedSet no-error.
if not available tqDomainByDomainSharedSet
then do:
assign vcMessage = #T-19'There is missing definition of Shared set for Sub-account COA Mask.':255(999890795)T-19#
vcContext = "Domain=&1|SharedSetType=&2":U
vcContext = replace(vcContext, "|":U, chr(2))
vcContext = substitute(vcContext, viDomainID, {&SHAREDSETTYPECODE-DIVISION-COAMASK}).
<M-18 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-9333':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDivision>
assign oiReturnStatus = -1.
return.
end.
assign viCOAMaskDivSharedSetId = tqDomainByDomainSharedSet.tiSharedSet_ID
vcCOAMaskDivSharedSetCode = tqDomainByDomainSharedSet.tcSharedSetCode.
/* Get some details about Sub-account shared set Id */
<Q-3 run DomainByDomainSharedSet (all) (Read) (NoCache)
(input viDomainID, (DomainID)
input ?, (SharedSetID)
input ?, (SharedSetCode)
input {&SHAREDSETTYPECODE-DIVISION}, (SharedSetType)
output dataset tqDomainByDomainSharedSet) in BDomain >
find first tqDomainByDomainSharedSet no-error.
if not available tqDomainByDomainSharedSet
then do:
assign vcMessage = #T-11'There is missing definition of Shared set for Division.':255(999890781)T-11#
vcContext = "Domain=&1|SharedSetType=&2":U
vcContext = replace(vcContext, "|":U, chr(2))
vcContext = substitute(vcContext, viDomainID, {&SHAREDSETTYPECODE-DIVISION}).
<M-10 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-9320':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDivision>
assign oiReturnStatus = -1.
return.
end.
assign vcDIVSharedSetCode = tqDomainByDomainSharedSet.tcSharedSetCode.
/* Create/Update profiles for divisions, which have or which had COAMask linked to it */
for each t_sDivision:
if t_sDivision.tc_Status = "C":U
then do:
find t_iDivision where
t_iDivision.tc_Rowid = t_sDivision.tc_Rowid
no-error.
end.
if t_sDivision.tc_Status = "D":U
then next.
if (t_sDivision.tc_Status = "N":U and t_sDivision.tcCOAMaskDivCode <> ? and t_sDivision.tcCOAMaskDivCode <> "":U) or
(t_sDivision.tc_status = "C":U and t_sDivision.tcCOAMaskDivCode <> t_iDivision.tcCOAMaskDivCode) or
t_sDivision.tc_status = "C":U
then do:
/* Validate entered mask code and get it's ID */
if t_sDivision.tcCOAMaskDivCode = "":U or
t_sDivision.tcCOAMaskDivCode = ?
then assign t_sDivision.tiCOAMaskDiv_ID = ?.
else do:
<Q-12 run COAMaskDivPrim (all) (Read) (NoCache)
(input t_sDivision.tcCOAMaskDivCode, (COAMaskDivCode)
input ?, (COAMaskDivID)
input viCompanyId, (CompanyId)
output dataset tqCOAMaskDivPrim) in BCOAMaskDiv >
find first tqCOAMaskDivPrim where
tqCOAMaskDivPrim.tcCOAMaskDivCode = t_sDivision.tcCOAMaskDivCode
no-error.
if not available tqCOAMaskDivPrim
then do:
<M-13 run SetMessage
(input #T-12'Invalid Sub-account COA Mask code.':255(999890782)T-12# (icMessage),
input '':U (icArguments),
input 'tDivision.tcCOAMaskDivCode':U (icFieldName),
input t_sDivision.tcCOAMaskDivCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sDivision.tc_Rowid (icRowid),
input 'QadFin-9321':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDivision>
assign oiReturnStatus = -1.
end.
else assign t_sDivision.tiCOAMaskDiv_ID = tqCOAMaskDivPrim.tiCOAMaskDiv_ID.
end.
/* Update profile with COA Mask for the division */
create tUpdateProfileDiv.
assign tUpdateProfileDiv.tcProfileCode = substitute("&1 (&2)":U, t_sDivision.DivisionCode, t_sDivision.Division_ID)
tUpdateProfileDiv.tcProfileCode = substring( tUpdateProfileDiv.tcProfileCode, 1, 20, "CHARACTER")
tUpdateProfileDiv.tcProfileTypeCode = {&PROFILETYPECODE-COAMASKDIV}
tUpdateProfileDiv.tiProfile_ID = t_sDivision.COAMaskDivProfile_ID
tUpdateProfileDiv.tiProfileLinkSharedSet_ID = viCOAMaskDivSharedSetId
tUpdateProfileDiv.tcProfileLinkSharedSetCode = vcCOAMaskDivSharedSetCode
tUpdateProfileDiv.tiProfileLinkObject_ID = t_sDivision.tiCOAMaskDiv_ID
tUpdateProfileDiv.tcProfileLinkObjectCode = t_sDivision.tcCOAMaskDivCode
tUpdateProfileDiv.tiParentObject_ID = t_sDivision.Division_ID.
end.
end.
/* Do real Profiles creation/update */
if can-find(first tUpdateProfileDiv)
then do:
if viBProfile8ID = 0 or viBProfile8ID = ?
then do:
<I-9 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "yes"
&CLASS = "BProfile"}>
end.
else do:
<I-8 {bFcOpenInstance
&CLASS = "BProfile"}>
end. /* if viBGLReportID = 0 or viBGLReportID = ? */
<M-2 run UpdateProfile
(input-output tUpdateProfileDiv (tUpdateProfile),
output viFcReturnSuper (oiReturnStatus)) in BProfile>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then do:
<I-23 {bFcCloseAndStopInstance
&CLASS = "BProfile"}>
return.
end.
else do:
<I-22 {bFcCloseInstance
&CLASS = "BProfile"}>
end.
end. /* can-find(first tUpdateProfileDiv) */
/* Assign the profile_id as zero when the subaccountmask code is set to null */
for each tUpdateProfileDiv,
each t_sDivision where
t_sDivision.Division_ID = tUpdateProfileDiv.tiParentObject_ID and
t_sDivision.tcCOAMaskDivCode = "":U :
assign tUpdateProfileDiv.tiProfile_ID = 0.
end.
/* Assign the Profile_ID back to the records */
for each tUpdateProfileDiv,
each t_sDivision where
t_sDivision.Division_ID = tUpdateProfileDiv.tiParentObject_ID:
assign t_sDivision.COAMaskDivProfile_ID = tUpdateProfileDiv.tiProfile_ID.
end. /* for each tUpdateProfileDiv: */
/* Stop queries */
<Q-21 run DomainByDomainSharedSet (Stop) in BDomain >