project QadFinancials > class BFRWAnalysisCode > method ValidateAnCodeForUpdate

validation procedure


Parameters


icFRWChartCodeinputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BFRWAnalysisCode.UpdateFRWAnCode


program code (program1/bfrwanalysiscode.p)

define buffer bAnCode for tAnCodeForUpdate.

if icFRWChartCode = "":U or 
   icFRWChartCode = ? then
do:
    assign vcMessage = #T-23'Chart Code cannot be blank.':255(18129960)T-23#.
    <M-65 run SetMessage
        (input  vcMessage (icMessage), 
         input  '':U (icArguments), 
         input  'FRWAnCode.FRWAnCodeFRWChartCode':U (icFieldName), 
         input  '':U (icFieldValue), 
         input  'E':U (icType), 
         input  3 (iiSeverity), 
         input  '':U (icRowid), 
         input  'qadfin-298212':U (icFcMsgNumber), 
         input  '':U (icFcExplanation), 
         input  '':U (icFcIdentification), 
         input  '':U (icFcContext), 
         output viFcReturnSuper (oiReturnStatus)) in BFRWAnalysisCode>

    assign oiReturnStatus = -1.
    return.
end.

for each tAnCodeForUpdate:

    /* The Analysis Type is blank on line. This is not allowed. */
    if tAnCodeForUpdate.tcQAnAnalyseType = "":U then
    do:
        assign vcMessage = 
            substitute(#T-40'The Analysis Type is blank on Excel line &1.':255(461409408)T-40#, tAnCodeforUpdate.tiRowNbr).
        <M-66 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'FRWAnCode.FRWAnCodeAnalyseType':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  ? (icRowid), 
            input  'qadfin-697615':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BFRWAnalysisCode>
        assign oiReturnStatus = -1.
        return.
    end.

    /* The Analysis Type is S on line. But there are details in the following columns.
       This is not allowed. */
    if tAnCodeForUpdate.tcQAnAnalyseType = "S":U and
        (tAnCodeForUpdate.tcQAnCOAType <> "":U or
        tAnCodeForUpdate.tcQAnBegins <> "":U or
        tAnCodeForUpdate.tcQFrom <> "":U or
        tAnCodeForUpdate.tcQTo <> "":U or
        tAnCodeForUpdate.tiQListLength <> 0 or
        tAnCodeForUpdate.tcQAnCalcElement <> "":U) then
    do:
        assign vcMessage = 
            substitute(#T-38'The Analysis Type is S on Excel line &1, but there are details in the following columns.':255(724961824)T-38#, tAnCodeforUpdate.tiRowNbr).
        <M-15 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'FRWAnCode.FRWAnCodeAnalyseType':U (icFieldName), 
            input  tAnCodeForUpdate.tcQAnAnalyseType (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  ? (icRowid), 
            input  'qadfin-224413':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BFRWAnalysisCode>
        assign oiReturnStatus = -1.
        return.
    end.

    /* The Analysis Type is T on line. But there are details in the following columns.
       This is not allowed. */
    if tAnCodeForUpdate.tcQAnAnalyseType = "T":U and
        (tAnCodeForUpdate.tcQAnCOAType <> "":U or
        tAnCodeForUpdate.tcQAnBegins <> "":U or
        tAnCodeForUpdate.tcQFrom <> "":U or
        tAnCodeForUpdate.tcQTo <> "":U or
        tAnCodeForUpdate.tiQListLength <> 0 or
        tAnCodeForUpdate.tcQAnCalcElement <> "":U) then
    do:
        assign vcMessage = 
            substitute( #T-1'The Analysis Type is T on Excel line &1, but there are details in the following columns.':255(797472011)T-1#, tAnCodeforUpdate.tiRowNbr).
        <M-69 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'FRWAnCode.FRWAnCodeAnalyseType':U (icFieldName), 
            input  tAnCodeForUpdate.tcQAnAnalyseType (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  ? (icRowid), 
            input  'qadfin-694605':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BFRWAnalysisCode>
        assign oiReturnStatus = -1.
        return.
    end.

    /* There is Analysis Type A on line. But no List Element data. This is not allowed. */
    if tAnCodeForUpdate.tcQAnAnalyseType = "A":U and
        tAnCodeForUpdate.tcQAnBegins = "":U and
		tAnCodeForUpdate.tcQFrom = "":U and
		tAnCodeForUpdate.tcQTo = "":U and
		tAnCodeForUpdate.tiQListLength = 0 then
    do:
        assign vcMessage = 
            substitute(#T-76'The Analysis Type is A on Excel line &1, but no List Element data.':255(279006585)T-76#, tAnCodeforUpdate.tiRowNbr).
        <M-22 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'FRWAnCode.FRWAnCodeAnalyseType':U (icFieldName), 
            input  tAnCodeForUpdate.tcQAnAnalyseType (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  ? (icRowid), 
            input  'qadfin-253796':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BFRWAnalysisCode>
        assign oiReturnStatus = -1.
        return.
    end.

    /* There is Analysis Type A on line. But no COA link Type. This is not allowed. */
    if tAnCodeForUpdate.tcQAnAnalyseType = "A":U and
        tAnCodeForUpdate.tcQAnCOAType = "":U then
    do:
        assign vcMessage = 
            substitute(#T-29'The Analysis Type is A on Excel line &1, but no COA link Type.':255(960343821)T-29#, tAnCodeforUpdate.tiRowNbr).
        <M-18 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'FRWAnCode.FRWAnCodeAnalyseType':U (icFieldName), 
            input  tAnCodeForUpdate.tcQAnAnalyseType (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  ? (icRowid), 
            input  'qadfin-679982':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BFRWAnalysisCode>
        assign oiReturnStatus = -1.
        return.
    end.

	/* There is a Linked COA type on line. But no COA link details in the following columns.
	   Use <blank> in Element 1 to link to a blank code or change the Analysis Type to S if no link with COA is needed. */
    if tAnCodeForUpdate.tcQAnCOAType <> "":U and
		tAnCodeForUpdate.tcQAnBegins = "":U and
		tAnCodeForUpdate.tcQFrom = "":U and
		tAnCodeForUpdate.tcQTo = "":U and
		tAnCodeForUpdate.tiQListLength = 0 then
	do:
		assign vcMessage = 
                substitute(#T-51'There is a Linked COA type &1 on line &2, But no COA link details in the following columns. Use <blank> in Element 1 to link to a blank code or change the Analysis Type to S if no link with COA is needed.':255(564389786)T-51#,
                tAnCodeForUpdate.tcQAnCOAType , tAnCodeforUpdate.tiRowNbr).
        <M-16 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'FRWAnCode.FRWAnCodeAnalyseType':U (icFieldName), 
            input  tAnCodeForUpdate.tcQAnAnalyseType (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  ? (icRowid), 
            input  'qadfin-537207':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BFRWAnalysisCode>
        assign oiReturnStatus = -1.
        return.
    end.

	/* There is Analysis Type C on line. But the Calculation column is empty. This is not allowed. */
	if tAnCodeForUpdate.tcQAnAnalyseType = "C":U and
		tAnCodeForUpdate.tcQAnCalcElement = "":U then
	do:
		assign vcMessage = 
                substitute(#T-89'The Analysis Type is C on Excel line &1, but the Calculation column is empty.':255(452551552)T-89#, tAnCodeforUpdate.tiRowNbr).
        <M-55 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'FRWAnCode.FRWAnCodeAnalyseType':U (icFieldName), 
            input  tAnCodeForUpdate.tcQAnAnalyseType (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  ? (icRowid), 
            input  'qadfin-536035':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BFRWAnalysisCode>
		assign oiReturnStatus = -1.
		return.
	end.
	
	/* The file contains different Analyse Types for the same for Report Analysis Code. This is not allowed. */
	if tAnCodeForUpdate.tcQAnAnalyseType <> "":U and
		can-find (first bAnCode where
		bAnCode.tcQAnCode = tAnCodeForUpdate.tcQAnCode and
		bAnCode.tcQAnAnalyseType <> tAnCodeForUpdate.tcQAnAnalyseType and
		bAnCode.tcQAnAnalyseType <> "":U) then
	do:
		assign vcMessage = 
                substitute(#T-28'The file contains different Analysis Types for Report Analysis Code (Excel Line&1).':255(691430090)T-28#, tAnCodeforUpdate.tiRowNbr).
		<M-63 run SetMessage
     (input  vcMessage (icMessage), 
      input  '':U (icArguments), 
      input  'FRWAnCode.FRWAnCodeAnalyseType':U (icFieldName), 
      input  '':U (icFieldValue), 
      input  'E':U (icType), 
      input  3 (iiSeverity), 
      input  ? (icRowid), 
      input  'qadfin-66531':U (icFcMsgNumber), 
      input  '':U (icFcExplanation), 
      input  '':U (icFcIdentification), 
      input  '':U (icFcContext), 
      output viFcReturnSuper (oiReturnStatus)) in BFRWAnalysisCode>
		assign oiReturnStatus = -1.
		return.
	end.
	
     <Q-86 run FRWAnCodeByCodeChart (all) (Read) (NoCache)
        (input ?, (FRWChartId)
         input icFRWChartCode, (FRWChartCode)
         input ?, (FRWAnCodeId)
         input tAnCodeforUpdate.tcQAnCode, (FRWAnCodeCode)
         output dataset tqFRWAnCodeByCodeChart) in BFRWAnalysisCode>
    find first tqFRWAnCodeByCodeChart where tqFRWAnCodeByCodeChart.tcFRWAnCodeCode = tAnCodeforUpdate.tcQAnCode no-error.

	/* The file contains blank Analyse Type but the analysis code does not exist. This is not allowed. */
	if tAnCodeForUpdate.tcQAnAnalyseType = "" and
		not available tqFRWAnCodeByCodeChart then
	do:
		assign vcMessage =
            substitute(#T-80'The file contains a blank Analysis Type but the analysis code does not exist (Excel Line &1).':255(999370463)T-80#, tAnCodeforUpdate.tiRowNbr).
        <M-43 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'FRWAnCode.FRWAnCodeAnalyseType':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  ? (icRowid), 
            input  'qadfin-937635':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BFRWAnalysisCode>
		assign oiReturnStatus = -1.
		return.
	end.
    
    if tAnCodeforUpdate.tiQListLength <> 0 then
    do:
        do with viIndex = 1 to tAnCodeforUpdate.tiQListLength:
            assign vcCOACode = ENTRY(viIndex, tAnCodeforUpdate.tcQList).

            /* <blank> is only allowed for SAFs, Sub-Account, Cost Center, Interco and Saf1-10 */
            if not (tAnCodeforUpdate.tcQAnCOAType begins "SAF":U) and
                tAnCodeforUpdate.tcQAnCOAType <> "Sub-Account":U   and
                tAnCodeforUpdate.tcQAnCOAType <> "Cost Center":U   and
                tAnCodeforUpdate.tcQAnCOAType <> "Project":U       and
                tAnCodeforUpdate.tcQAnCOAType <> "Interco":U       and
                vcCOACode                     =  "":U
            then do:
                /*  <blank> is only allowed on Sub-Account, Cost Center, Project, Interco and Saf1-10 */
                <M-52 run SetMessage
                   (input  #T-3''blank' is only allowed on Sub-Account, Cost Center, Project, Interco and Saf1-10.':255(644449409)T-3# (icMessage), 
                    input  '':U (icArguments), 
                    input  'FRWAnCode.FRWAnCodeAnalyseType':U (icFieldName), 
                    input  tAnCodeforUpdate.tcQAnCOAType (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  ? (icRowid), 
                    input  'qadfin-185228':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BFRWAnalysisCode>
                assign oiReturnStatus = -1.
                return.
            end.
        
            /* Checking the duplicating elements */
            if vcCOACode <> ""
            then do:
                assign viIndexTemp = viIndex + 1.
                do with viIndexSec = viIndexTemp to tAnCodeforUpdate.tiQListLength:
                    if vcCOACode = ENTRY(viIndexSec, tAnCodeforUpdate.tcQList) or
                     ( vcCOACode = "" and ENTRY(viIndexSec, tAnCodeforUpdate.tcQList) = "":U )
                    then do:
                        assign vcMessage = 
                            substitute(#T-31'The COA code &1 already exists on Excel line &2.':255(265329515)T-31#, vcCOACode, tAnCodeforUpdate.tiRowNbr).
                        <M-25 run SetMessage
                           (input  vcMessage (icMessage), 
                            input  '':U (icArguments), 
                            input  'FRWAnCodeElem.FRWAnCodeElemCOAType':U (icFieldName), 
                            input  '':U (icFieldValue), 
                            input  'E':U (icType), 
                            input  3 (iiSeverity), 
                            input  ? (icRowid), 
                            input  'qadfin-827989':U (icFcMsgNumber), 
                            input  '':U (icFcExplanation), 
                            input  '':U (icFcIdentification), 
                            input  '':U (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BFRWAnalysisCode>
		                assign oiReturnStatus = -1.
                        return.
                    end.
                end.
            end.

            /* Check duplicate ListElement value in From-To and Begins */
            if vcCOACode <> "" and 
               (tAnCodeforUpdate.tcQFrom <> "":U or
                tAnCodeforUpdate.tcQto <> "":U or
                tAnCodeforUpdate.tcQAnBegins <> "":U) then
            do:
                assign vcMessage = 
                    substitute(#T-53'The ListElement has a value '&1' on Excel line '&2', and the From-To or Begins field also contains a value.':255(712129671)T-53#, 
                    vcCOACode, tAnCodeforUpdate.tiRowNbr).
                <M-46 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  'FRWAnCodeElem.FRWAnCodeElemCOAType':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  ? (icRowid), 
                    input  'qadfin-380950':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BFRWAnalysisCode>
                assign oiReturnStatus = -1.
                return.
            end.

            /* There is a Element with a value on line, but the COA Type linked column is blank. This is not allowed.". */
            if tAnCodeforUpdate.tcQAnCOAType = "":U and
               vcCOACode <> "":U then
            do:
                 assign vcMessage = 
                    substitute(#T-34'There is an Element with a value '&1' on Excel line '&2', but the COA Type linked column is blank.':255(147220197)T-34#,
                    vcCOACode, tAnCodeforUpdate.tiRowNbr).
                <M-12 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  'FRWAnCodeElem.FRWAnCodeElemCOAType':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  ? (icRowid), 
                    input  'qadfin-642500':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BFRWAnalysisCode>
                assign oiReturnStatus = -1.
                return.
            end.
        end. /* do with viIndex = 1 to tAnCodeforUpdate.tiQListLength */
    end. /* if tAnCodeforUpdate.tiQListLength <> 0 */
end.

assign oiReturnStatus = 0.