project QadFinancials > class BSaf > method ValidateComponent
Description
Write here all tests on database update (new / modify / delete) that cannot be coded with a validation mask.
The type of update can be found in tc_status (N/C/D).
If you find incorrect data, you must write an entry in tFcMessages (using SetMessage) and set the return status of this method to either +1 or -1.
Return status +1 = data will still be accepted.
Return status -1 = data will not be accepted.
This method is run from SetPublicTables, before transferring the received data into the class temp-tables.
Parameters
oiReturnStatus | output | integer | |
Internal usage
unused
program code (program/bsaf.p)
<ANCESTOR-CODE>
if oiReturnStatus < 0 or
viPreValidateReturnStatus <> 0
then do:
if oiReturnStatus = 0 or
oiReturnStatus = ?
then assign oiReturnStatus = viPreValidateReturnStatus.
return.
end.
for each t_sSaf where
t_sSaf.tc_Status <> "":U:
/*initially loaded data known inly for Changed or Deleted records*/
if t_sSaf.tc_Status <> "N":U
then do:
find first tFcRowidConvert where
tFcRowidConvert.tcFcOldRowid = t_sSaf.tc_Rowid no-error.
if available tFcRowidConvert
then find first t_iSaf where
t_iSaf.tc_Rowid = tFcRowidConvert.tcFcNewRowid no-error.
else find first t_iSaf where
t_iSaf.tc_Rowid = t_sSaf.tc_Rowid no-error.
if not available t_iSaf
then do:
assign vcMessage = "t_iSaf not available.":U + chr(10) + program-name(1)
oiReturnStatus = -1.
<M-4 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'D':U (icType),
input 1 (iiSeverity),
input '':U (icRowid),
input 'QadFin-9535':U:U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BSaf>
return.
end.
end.
/*SafConcept cannot be changed if Saf is already used in SafX,*/
/*if Saf.SafIsActive is changed from true to false and Saf is already used in SafX, then give a warning*/
if available t_iSaf and
((t_iSaf.SafConcept_ID <> t_sSaf.SafConcept_ID) or
(t_iSaf.SafCode <> t_sSaf.SafCode) or
(t_iSaf.SafIsActive = true and
t_sSaf.SafIsActive = false)) and
t_sSaf.tc_Status = "C":U
then do:
assign vcMessage = "":U.
/*SafX*/
<Q-1 assign vlFcQueryRecordsAvailable = PostingBySafID (NoCache) (input t_sSaf.Saf_ID, (Saf_ID)) in BPosting >
if vlFcQueryRecordsAvailable or
vlFcQueryRecordsAvailable = ?
then assign vcMessage = if vcMessage = "":U
then "SafX":U
else vcMessage + ", SafX":U.
/*SafConcept was changed*/
if vcMessage <> "":U and
t_iSaf.SafConcept_ID <> t_sSaf.SafConcept_ID
then do:
assign vcMessage = substitute (trim(#T-8'Cannot modify the concept for SAF &1.':200(3648)T-8#) + chr(10) + trim(#T-9'SAF is used in the following tables:':200(3649)T-9#), t_sSaf.SafCode)
+ chr(10) + vcMessage + chr(10) + program-name(1)
oiReturnStatus = -1.
<M-3 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-2':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BSaf>
end.
/*SafCode was changed*/
if vlFcQueryRecordsAvailable <> false and
t_iSaf.SafCode <> t_sSaf.SafCode
then do:
assign vcMessage = substitute (trim(#T-11'You cannot change the code for the SAF &1.':200(42791)T-11#) + chr(10) + trim(#T-12'SAF is used in the following tables:':200(3649)T-12#), t_sSaf.SafCode)
+ chr(10) + vcMessage + chr(10) + program-name(1)
oiReturnStatus = -1.
<M-13 run SetMessage
(input vcMessage (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'QadFin-5018':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BSaf>
end.
if oiReturnStatus < 0
then return.
/*SafIsActive was changed from true to false*/
if vcMessage <> "":U and
t_iSaf.SafIsActive = true and
t_sSaf.SafIsActive = false
then do:
assign vcMessage = substitute (trim(#T-10'The SAF &1 you want to make inactive is used in these tables:':200(3650)T-10#), t_sSaf.SafCode)
+ chr(10) + vcMessage + chr(10) + program-name(1)
oiReturnStatus = 1.
<M-5 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-9536':U:U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BSaf>
end.
end.
/* check the use of FDS code in budget */
if available t_iSaf and
t_sSaf.tc_Status = "C":U and
(t_sSaf.SafCode <> t_iSaf.SafCode or
t_sSaf.BudgetGroup_ID <> t_iSaf.BudgetGroup_ID)
then do:
assign vhFcComponent = ?.
<M-7 run CheckBudgetFDSWBS
(input {&BUDGETFDSTYPE-SAF} (icFDSType),
input t_sSaf.BudgetGroup_ID (iiNewFDSID),
input t_sSaf.SafCode (icNewFDSCode),
input t_iSaf.BudgetGroup_ID (iiOldFDSID),
input t_iSaf.SafCode (icOldFDSCode),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus >= 0)
then assign oiReturnStatus = viFcReturnSuper.
end.
/* Active flag FIN-1706 Temporar workaround ============================= *
* Active flag cannot be changed, if there is any posting in transient layer *
* This is just workaround to ensure, once this posting is transferred from *
* transient layer into official one, GL account stays active. Today during *
* this transfer, no validation for active account is executed. Therefore we *
* prevent user to change Activity flag in this case *
* ========================================================================= */
if t_sSaf.tc_Status ="C":U and
t_sSaf.SafIsActive <> t_iSaf.SafIsActive and
t_sSaf.SafIsActive <> true
then do:
<Q-15 assign vlFcQueryRecordsAvailable = PostingSafForValSafTrans (NoCache)
(input ?, (CompanyId)
input {&LAYERTYPECODE-TRANSIENT}, (LayerTypes)
input ?, (SafStructure_ID)
input t_sSaf.Saf_ID, (Saf_ID)) in BPosting >
if vlFcQueryRecordsAvailable <> false
then do:
assign vcMessage = #T-14'SAF Code &1 cannot be deactivated, until there are pending postings in Transient layer which can be transferred into official layer.':255(73427742)T-14#
vcMessage = substitute(vcMessage, t_sSaf.SafCode).
<M-16 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tSaf.SafIsActive':U (icFieldName),
input string(t_sSaf.SafIsActive) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sSaf.tc_Rowid (icRowid),
input 'QadFin-9496':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BSaf>
assign oiReturnStatus = -1.
end.
end.
end.