project QadFinancials > class BFRWAnalysisCode > method ValidateComponentPreFRWAnCodeInfo
Description
This method calculates value for Analysis Code Info field. This field is used in some of the original browsers implemeted in operational.
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bfrwanalysiscode.p)
/* ========================================================================================= *
* Preconditions *
* ========================================================================================= */
if not available t_sFRWAnCode
then do:
assign vcMessage = #T-33'Internal record is missing.':255(33090436)T-33#.
<M-11 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-812596':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFRWAnalysisCode>
assign oiReturnStatus = -1.
return.
end.
/* ========================================================================================= *
* Let's do the calculation only if any changes happend *
* ========================================================================================= */
assign vlIsDefinitionChanged = t_sFRWAnCode.tc_Status <> '':U.
if not vlIsDefinitionChanged
then do:
for each t_sFRWAnCodeElem where
t_sFRWAnCodeElem.tc_ParentRowid = t_sFRWAnCode.tc_Rowid:
if t_sFRWAnCodeElem.tc_Status <> '':U or
can-find(first t_sFRWAnCodeElemDet where
t_sFRWAnCodeElemDet.tc_ParentRowid = t_sFRWAnCodeElem.tc_Rowid and
t_sFRWAnCodeElemDet.tc_Status <> '':U)
then do:
assign vlIsDefinitionChanged = true.
leave.
end.
end. /* foreach t_sFRWAnCodeElem where */
end.
if not vlIsDefinitionChanged
then return.
empty temp-table tFRWAnCodeElemDetTemp.
/* ========================================================================================= *
* Calculate new value for Info field *
* ========================================================================================= */
case t_sFRWAnCode.FRWAnCodeAnalyseType:
when {&FRWANALYSISTYPE-SUBTOTAL}
then assign vcInfo = {&FRWANALYSISTYPE-SUBTOTAL-TR}.
when {&FRWANALYSISTYPE-CALCULATION}
then assign vcInfo = substitute("&1: &2":U,
{&FRWANALYSISTYPE-CALCULATION-TR},
t_sFRWAnCode.FRWAnCodeCalcElement).
when {&FRWANALYSISTYPE-TEXT}
then assign vcInfo = substitute("&1: &2":U,
{&FRWANALYSISTYPE-TEXT-TR},
t_sFRWAnCode.FRWAnCodeAnalyseText).
when {&FRWANALYSISTYPE-ANALYSIS}
then do:
assign viElemCount = 0.
for each t_sFRWAnCodeElem where
t_sFRWAnCodeElem.tc_ParentRowid = t_sFRWAnCode.tc_Rowid and
t_sFRWAnCodeElem.tc_Status <> "D":U
break by t_sFRWAnCodeElem.tc_ParentRowid:
assign viElemCount = viElemCount + 1
vcInfo = substitute("&1&2: ":U,
vcInfo,
<M-50 GetFRWAnalysisCOATypeTranslation (input t_sFRWAnCodeElem.FRWAnCodeElemCOAType (icFRWAnalysisCOAType)) in BFRWAnalysisCode>).
if t_sFRWAnCodeElem.FRWAnCodeElemMask <> "":U and
t_sFRWAnCodeElem.FRWAnCodeElemMask <> ?
then assign vcInfo = substitute("&1&2: &3 ":U,
vcInfo,
#T-77'Begins with':255(880782370)T-77#,
t_sFRWAnCodeElem.FRWAnCodeElemMask).
else if (t_sFRWAnCodeElem.FRWAnCodeElemMaskRange1 <> "":U and
t_sFRWAnCodeElem.FRWAnCodeElemMaskRange1 <> ?) or
(t_sFRWAnCodeElem.FRWAnCodeElemMaskRange2 <> "":U and
t_sFRWAnCodeElem.FRWAnCodeElemMaskRange2 <> ?)
then assign vcInfo = substitute("&1&2: &3-&4 ":U,
vcInfo,
#T-68'Range':255(296951518)T-68#,
t_sFRWAnCodeElem.FRWAnCodeElemMaskRange1,
t_sFRWAnCodeElem.FRWAnCodeElemMaskRange2).
else do:
assign viDetCount = 0.
for each t_sFRWAnCodeElemDet where
t_sFRWAnCodeElemDet.tc_ParentRowid = t_sFRWAnCodeElem.tc_Rowid and
t_sFRWAnCodeElemDet.tc_Status <> "D":U
break by t_sFRWAnCodeElemDet.tc_ParentRowid
by t_sFRWAnCodeElemDet.FRWAnCodeElemDetCode:
create tFRWAnCodeElemDetTemp.
buffer-copy t_sFRWAnCodeElemDet to tFRWAnCodeElemDetTemp.
find first tFRWAnCodeElemDetTemp where
tFRWAnCodeElemDetTemp.tc_ParentRowid = t_sFRWAnCodeElem.tc_Rowid and
tFRWAnCodeElemDetTemp.tc_Status <> "D":U and
tFRWAnCodeElemDetTemp.FRWAnCodeElemDetCode = t_sFRWAnCodeElemDet.FRWAnCodeElemDetCode and
tFRWAnCodeElemDetTemp.FRWAnCodeElemDet_ID <> t_sFRWAnCodeElemDet.FRWAnCodeElemDet_ID no-error.
if available tFRWAnCodeElemDetTemp then next.
assign viDetCount = viDetCount + 1
vcInfo = substitute("&1&2&3&4":U,
vcInfo,
(if not first(t_sFRWAnCodeElemDet.tc_ParentRowid)
then ", ":U
else "":U),
t_sFRWAnCodeElemDet.FRWAnCodeElemDetCode,
(if last(t_sFRWAnCodeElemDet.tc_ParentRowid)
then " ":U
else if viDetCount = 4
then "... ":U
else " ":U)).
if viDetCount = 4
then leave.
end. /* for each t_sFRWAnCodeElemDet where */
end. /* else do: */
if viElemCount = 3
then do:
if not last(t_sFRWAnCodeElem.tc_ParentRowid)
then assign vcInfo = substitute("&1, ...":U,
vcInfo).
leave.
end. /* if viElemCount = 3 and */
end. /* for each t_sFRWAnCodeElem where */
end. /* when {&FRWANALYSISTYPE-ANALYSIS} */
end. /* case t_sFRWAnCode.FRWAnCodeAnalyseType: */
/* Store calculated value in the component data */
assign t_sFRWAnCode.FRWAnCodeInfo = substring(vcInfo,1,60,"CHARACTER")
t_sFRWAnCode.tc_Status = (if t_sFRWAnCode.tc_Status <> '':U
then t_sFRWAnCode.tc_Status
else "C":U).