project QadFinancials > class BPosting > method ValidateComponentPostPostingSaf
Description
Validate Component after ancestor tag for posting saf records.
Parameters
blQueryStartedSafConceptByCode | input-output | logical | |
blQueryStartedSafStructureLine | input-output | logical | |
bcPostingSafParentType | input-output | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bposting.p)
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
/* Manualy defined variable to be able to perform a case-sensitive test */
define variable vcPostingSafParentTypeCS as character case-sensitive.
POSTINGSAFBLOCK:
do:
if t_sPostingSaf.tc_Status <> "D":U and
t_sPostingSaf.tc_Status <> ""
then do:
/* ========================================== */
/* Check for the correct PostingSafParentType */
/* ========================================== */
case t_sPostingSaf.PostingSafParentType:
when {&POSTINGSAFPARENTTYPE-GL}
then if (t_sPostingLine.tcProjectCode <> "":U and
t_sPostingLine.tcProjectCode <> ?) or
(t_sPostingLine.tcCostCentreCode <> "":U and
t_sPostingLine.tcCostCentreCode <> ?)
then do:
assign vcMsgExplanation = <M-84 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(subst(#T-1'You can only specify SAF details on the GL level when a project and cost center are not specified on the same posting line (GL account &1).':250(16611)T-1#, t_sPostingLine.tcGLCode))
viLocalReturnStatus = -1.
<M-2 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPostingLine.tcGLCode':U (icFieldName),
input t_sPostingLine.tcGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'QadFin-7322':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end.
when {&POSTINGSAFPARENTTYPE-PROJECT}
then if t_sPostingLine.tcProjectCode = "":U or
t_sPostingLine.tcProjectCode = ?
then do:
assign vcMsgExplanation = <M-56 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(subst(#T-5'You can only specify SAF details on the project level when a project is specified on the posting line (GL account &1).':255(17699)T-5#, t_sPostingLine.tcGLCode))
viLocalReturnStatus = -1.
<M-3 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPostingLine.tcGLCode':U (icFieldName),
input t_sPostingLine.tcGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'QadFin-7323':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end.
when {&POSTINGSAFPARENTTYPE-COSTCENTRE}
then if t_sPostingLine.tcCostCentreCode = "":U or
t_sPostingLine.tcCostCentreCode = ?
then do:
assign vcMsgExplanation = <M-48 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(subst(#T-6'You can only specify SAF details on the cost center level when a cost center is specified on the posting line (GL account &1).':255(17700)T-6#, t_sPostingLine.tcGLCode))
viLocalReturnStatus = -1.
<M-4 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPostingLine.tcGLCode':U (icFieldName),
input t_sPostingLine.tcGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'QadFin-7324':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end.
end case.
/* ==================================================================================================== */
/* Check if both Cost Centre and Project use safs. If so, give a warning and remove project saf lines. */
/* ==================================================================================================== */
if t_sPostingSaf.PostingSafParentType = {&POSTINGSAFPARENTTYPE-PROJECT}
then do:
if can-find(first bsPostingSaf where
bsPostingSaf.PostingLine_ID = t_sPostingSaf.PostingLine_ID and
bsPostingSaf.tc_Status <> "D":U and
bsPostingSaf.PostingSafParentType = {&POSTINGSAFPARENTTYPE-COSTCENTRE})
then do:
assign vcMessage = trim(#T-35'Cost Center and Project can't both use SAFs on a single postingline. The project will be posted without SAFs.':255(710445455)T-35#) + chr(10) +
trim(substitute(#T-58'Posting / GL-Account: &1/&2/&3 &4':255(999890050)T-58#,trim(string(t_sPosting.PostingYear)),trim(t_sPosting.tcJournalCode),trim(string(t_sPosting.PostingVoucher)),t_sPostingLine.tcGLCode)) + chr(10) +
trim(substitute(#T-71'Cost Center / Project: &1 &2':255(928257361)T-71#, trim(t_sPostingLine.tcCostCentreCode), trim(t_sPostingLine.tcProjectCode))) + chr(10) +
trim(substitute(#T-90'Saf Concept / Saf Code: &1 &2':255(1905196)T-90#, trim(t_sPostingSaf.tcSafConceptCode), trim(t_sPostingSaf.tcSafCode)))
viLocalReturnStatus = (if viLocalReturnStatus < 0 then viLocalReturnStatus else 1).
<M-81 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPostingLine.tcprojectCode':U (icFieldName),
input t_sPostingLine.tcProjectCode (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'QadFin-807250':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if t_sPostingSaf.tc_Status = "N":U
then do:
find tPostingSaf where
tPostingSaf.tc_Rowid = t_sPostingSaf.tc_Rowid
no-error.
if available tPostingSaf
then delete tPostingSaf.
delete t_sPostingSaf.
end.
else assign t_sPostingSaf.tc_Status = "D":U.
leave POSTINGSAFBLOCK.
end. /* if can-find(first bsPostingSaf where */
end. /* if t_sPostingSaf.PostingSafParentType = {&POSTINGSAFPARENTTYPE-PROJECT} */
end. /* if t_sPostingSaf.tc_Status <> "D":U */
if t_sPosting.tc_Status <> "D":U and
t_sPostingLine.tc_Status <> "D":U and
(t_sPostingSaf.tc_Status = "N":U or
t_sPostingSaf.tc_Status = "C":U)
then do:
/* ============================================================================================= */
/* PostingSafParentType should be in uppercase because the UI (case-sensitive!!!) is based on it */
/* ============================================================================================= */
assign vcPostingSafParentTypeCS = caps(t_sPostingSaf.PostingSafParentType).
if vcPostingSafParentTypeCS <> t_sPostingSaf.PostingSafParentType
then do:
assign vcMsgExplanation = <M-88 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(subst(#T-18'The parent type of the SAF details for GL account &1 on the posting line should be in upper case.':255(3253)T-18#, t_sPostingLine.tcGLCode)) + chr(10) +
trim(subst(#T-19'Parent type: &1.':255(3254)T-19#, t_sPostingSaf.PostingSafParentType))
viLocalReturnStatus = -1.
<M-7 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPostingLine.tcGLCode':U (icFieldName),
input t_sPostingLine.tcGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingLine.tc_Rowid (icRowid),
input 'QadFin-7391':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end. /* if vcPostingSafParentTypeCS <> t_sPostingSaf.PostingSafParentType */
/* =================== */
/* Validat saf concept */
/* =================== */
if t_sPostingSaf.tcSafConceptCode <> ? and
t_sPostingSaf.tcSafConceptCode <> "":U
then do:
if blQueryStartedSafConceptByCode = false
then do:
<Q-25 run SafConceptByCode (Start) in BSafConcept >
assign blQueryStartedSafConceptByCode = true.
end. /* if blQueryStartedSafConceptByCode = false */
<Q-10 run SafConceptByCode (all) (Read) (Cache)
(input t_sPostingSaf.tcSafConceptCode, (SafConceptCode)
output dataset tqSafConceptByCode) in BSafConcept >
find first tqSafConceptByCode where
tqSafConceptByCode.tcSafConceptCode = t_sPostingSaf.tcSafConceptCode
no-error.
if not available tqSafConceptByCode
then do:
assign vcMsgExplanation = <M-89 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(substitute(#T-20'The SAF concept code &1 used on GL account &2 is invalid.':150(42759)T-20#, t_sPostingSaf.tcSafConceptCode, t_sPostingLine.tcGLCode))
viLocalReturnStatus = -1.
<M-11 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-7392':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end. /* if not available tqSafConceptByCode */
else do:
if tqSafConceptByCode.tlSafConceptIsActive <> true
then do:
assign vcMsgExplanation = <M-50 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(substitute(#T-21'The SAF Concept &1 is not active.':100(65727)T-21#, t_sPostingSaf.tcSafConceptCode))
viLocalReturnStatus = -1.
<M-12 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-7393':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end. /* if tqSafConceptByCode.tlSafConceptIsActive <> true */
end. /* else do */
end. /* if t_sPostingSaf.tcSafConceptCode <> ? ... */
/* ============================ */
/* Validate sequence of the saf */
/* ============================ */
if blQueryStartedSafStructureLine = false
then do:
<Q-26 run SafStructureLineByStructConc (Start) in BSafStructure >
assign blQueryStartedSafStructureLine = true.
end. /* if blQueryStartedSafStructureLine = false */
<Q-13 run SafStructureLineByStructConc (all) (Read) (Cache)
(input t_sPostingSaf.tcSafConceptCode, (SafConceptCode)
input t_sPostingSaf.SafStructure_ID, (SafStructureID)
output dataset tqSafStructureLineByStructConc) in BSafStructure >
find first tqSafStructureLineByStructConc where
tqSafStructureLineByStructConc.tiSafStructure_ID = t_sPostingSaf.SafStructure_ID and
tqSafStructureLineByStructConc.tcSafConceptCode = t_sPostingSaf.tcSafConceptCode
no-error.
if not available tqSafStructureLineByStructConc
then do:
assign vcMsgExplanation = <M-32 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(subst(#T-22'The combination of SAF structure &1 and SAF concept &2 is invalid.':150(3255)T-22#,t_sPostingSaf.tcSafStructureCode, t_sPostingSaf.tcSafConceptCode))
viLocalReturnStatus = -1.
<M-14 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPostingSaf.tcSafConceptCode':U (icFieldName),
input t_sPostingSaf.tcSafConceptCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingSaf.tc_Rowid (icRowid),
input 'QadFin-7394':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end. /* if not available tqSafStructureLineByStructConc */
else do:
if t_sPostingSaf.PostingSafInputSequence <> tqSafStructureLineByStructConc.tiSafStructureLineNumber
then do:
assign vcMsgExplanation = <M-74 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input t_sPostingLine.tc_Rowid (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(subst(#T-23'The line sequence &1 for the SAF structure &2 and SAF concept &3 is invalid.':255(3256)T-23#, string(t_sPostingSaf.PostingSafInputSequence), t_sPostingSaf.tcSafStructureCode, t_sPostingSaf.tcSafConceptCode)) + chr(10) +
trim(subst(#T-24'The expected line sequence based on the structure and concept is &1.':255(3257)T-24#, string(tqSafStructureLineByStructConc.tiSafStructureLineNumber)))
viLocalReturnStatus = -1.
<M-15 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPostingSaf.PostingSafInputSequence':U (icFieldName),
input string(t_sPostingSaf.PostingSafInputSequence) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPostingSaf.tc_Rowid (icRowid),
input 'QadFin-7395':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end. /* if t_sPostingSaf.PostingSafInputSequence <> tqSafStructureLineByStructConc.tiSafStructureLineNumber */
end. /* else do: */
end.
end. /* POSTINGSAFBLOCK: */
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = viLocalReturnStatus.