project QadFinancials > class BPosting > method ValidateComponentPreAssignPosting1
Description
Validations & Assignments on t_sPosting before ancestor tag
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bposting.p)
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = -98
viLocalReturnStatus = 0
vlOpenPeriodInstance = false.
/* ================================================================================================= */
/* Assign t_sPosting.Period_ID, t_sPosting.PeriodMark_ID, t_sPosting.PeriodYearPeriod */
/* t_sPosting.CreatorUsr_ID, t_sPosting.PostingVerifyStatus, t_sPosting.PostingApproveStatus */
/* t_sPosting.tcLayerTypeCode, t_sPosting.PostingIsReversing, t_sPosting.PostingIsReplacement */
/* ================================================================================================= */
POSTINGBLOCK:
DO:
if t_sPosting.tc_Status = "C":U
then do:
find t_iPosting where
t_iPosting.tc_Rowid = t_sPosting.tc_Rowid
no-error.
if not available t_iPosting
then leave POSTINGBLOCK.
end. /* Get t_iPosting */
if t_sPosting.tc_Status = "N":U
then do :
assign t_sPosting.PostingCreationDate = today
t_sPosting.PostingCreationTimeString = string(time,"HH:MM:SS":U).
if t_sPosting.tcUsrLogin = ? or
t_sPosting.tcUsrLogin = ''
then assign t_sPosting.tcUsrLogin = vcUserLogin.
if t_sPosting.PostingVerifyStatus = ? or
t_sPosting.PostingVerifyStatus = ''
then assign t_sPosting.PostingVerifyStatus = {&APPROVESTATUSTRANS-INITIAL}.
if t_sPosting.PostingApproveStatus = ? or
t_sPosting.PostingApproveStatus = ''
then assign t_sPosting.PostingApproveStatus = {&APPROVESTATUSTRANS-INITIAL}.
end.
if t_sPosting.PostingYear <> 0 and
t_sPosting.PostingYear <> ? and
t_sPosting.PostingPeriod <> ? and
(t_sPosting.tc_Status = "N":U or
(t_sPosting.tc_Status = "C":U and
(t_sPosting.PostingYear <> t_iPosting.PostingYear or
t_sPosting.PostingPeriod <> t_iPosting.PostingPeriod or
t_sPosting.Period_ID = 0 or
t_sPosting.Period_ID = ?)))
then do:
<Q-16 run PeriodByYearPeriod (all) (Read) (Cache)
(input t_sPosting.Company_ID, (CompanyId)
input t_sPosting.PostingYear, (PeriodYear)
input t_sPosting.PostingPeriod, (PeriodPeriod)
input ?, (PeriodId)
output dataset tqPeriodByYearPeriod) in BPeriod >
find tqPeriodByYearPeriod where
tqPeriodByYearPeriod.tiCompany_ID = t_sPosting.Company_ID and
tqPeriodByYearPeriod.tiPeriodYear = t_sPosting.PostingYear and
tqPeriodByYearPeriod.tiPeriodPeriod = t_sPosting.PostingPeriod
no-error.
<Q-88 run JournalByJournalLayerType (all) (Read) (Cache)
(input 0, (JournalId)
input t_sPosting.tcJournalCode, (JournalCode)
input t_sPosting.Company_ID, (CompanyId)
input '':U, (LayerTypeCode)
output dataset tqJournalByJournalLayerType) in BJournal>
find first tqJournalByJournalLayerType where
tqJournalByJournalLayerType.tcJournalCode = t_sPosting.tcJournalCode
no-error.
/*Daybook Control of type Operational could not be Reversed*/
if available tqJournalByJournalLayerType and
tqJournalByJournalLayerType.tcJournalControl = {&JOURNALCONTROL-LOGISTIC} and
t_sPosting.PostingIsReversing = true
then do:
assign vcMessage = trim (#T-82'You are not allowed to reverse postings for operational daybooks':255(18900011)T-82#)
viLocalReturnStatus = -1.
<M-96 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPosting.tcJournalCode':U (icFieldName),
input t_sPosting.tcJournalCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'qadfin-337601':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end.
if available tqPeriodByYearPeriod and
available tqJournalByJournalLayerType and
tqJournalByJournalLayerType.tcJournalTypeCode <> {&JOURNALTYPE-YEARLYCLOSING}
then do:
<Q-5 run PeriodByPeriodStartEndDate (all) (Read) (Cache)
(input viCompanyId, (CompanyId)
input today, (Date)
input ?, (PeriodId)
input ?, (PeriodYear)
input ?, (PeriodPeriod)
output dataset tqPeriodByPeriodStartEndDate) in BPeriod>
find tqPeriodByPeriodStartEndDate where
tqPeriodByPeriodStartEndDate.ttPeriodStartDate <= today and
tqPeriodByPeriodStartEndDate.ttPeriodEndDate >= today
no-error.
/* Period must be open */
if (t_sPosting.tc_Status = "N":U or
tqPeriodByYearPeriod.tiPeriod_ID <> t_iPosting.Period_ID or
t_sPosting.tcJournalCode <> t_iPosting.tcJournalCode) and
(tqPeriodByYearPeriod.tcPeriodStatus <> {&PERIODSTATUS-OPEN} or
tqPeriodByYearPeriod.tlPeriodisPostingGLAllowed <> true) and
(if available tqPeriodByPeriodStartEndDate and
t_sPosting.PostingAutoReversalType = {&POSTINGAUTOREVERSALTYPE-REVERSING} and
t_sPosting.PostingIsAutoReversal = true
then t_sPosting.PostingYearPeriod <= tqPeriodByPeriodStartEndDate.tiPeriodYearPeriod
else true)
then do:
assign vcMsgExplanation = <M-97 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
if tqPeriodByYearPeriod.tcPeriodStatus <> {&PERIODSTATUS-OPEN}
then assign vcMessage = trim(#T-44'Only open GL periods are allowed.':250(16606)T-44#).
else if tqPeriodByYearPeriod.tlPeriodIsPostingGLAllowed <> true
then assign vcMessage = trim(#T-46'GL periods are not allowed.':40(999890178)T-46#).
assign viLocalReturnStatus = -1.
<M-42 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPosting.Period_ID':U (icFieldName),
input string(t_sPosting.PostingYear) + '/':U + string(t_sPosting.PostingPeriod) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'QadFin-8608':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end.
end.
if t_sPosting.PostingYearPeriod <> 0 and
t_sPosting.PostingYearPeriod <> ? and
t_sPosting.PostingYearPeriod <> (t_sPosting.PostingYear * 100 + t_sPosting.PostingPeriod)
then do:
assign vcMsgExplanation = <M-7 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(#T-69'Posting Year and Period should match with Posting YearPeriod':255(100382653)T-69#).
viLocalReturnStatus = -1.
<M-86 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPosting.PostingYearPeriod':U (icFieldName),
input t_sPosting.PostingYearPeriod (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'qadfin-362443':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
end.
/* ================================================================================= */
/* Check the Period Instance when the Year/Period could not be found in the database */
/* The viBPeriodPostingID variable could be entered in method AddPostingHeader */
/* ================================================================================= */
assign viPeriodID = 0
viPeriodMarkID = 0.
if not available tqPeriodByYearPeriod
then do:
if viBPeriodPostingID <> 0 and viBPeriodPostingID <> ?
then do:
if vlOpenPeriodInstance = false
then do:
<I-17 {bFcOpenInstance
&CLASS = "BPeriod"}>
assign vlOpenPeriodInstance = true.
end.
<M-18 run CheckPeriodExistence
(input t_sPosting.Company_ID (iiCompanyId),
input t_sPosting.PostingYear (iiPeriodYear),
input t_sPosting.PostingPeriod (iiPeriodPeriod),
output vlPeriodExists (olDoesExist),
output viPeriodID (oiPeriod_ID),
output viPeriodMarkID (oiPeriodMark_ID),
output vtStartDate (otStartDate),
output vtEndDate (otEndDate),
output vcPeriodTypeCode (ocPeriodTypeCode),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
end. /* if viBPeriodPostingID <> 0 and viBPeriodPostingID <> ? */
end. /* if not available tqPeriodByYearPeriod */
assign t_sPosting.Period_ID = if available tqPeriodByYearPeriod
then tqPeriodByYearPeriod.tiPeriod_ID
else viPeriodID
t_sPosting.PeriodMark_ID = if available tqPeriodByYearPeriod
then tqPeriodByYearPeriod.tiPeriodMark_ID
else viPeriodMarkID
t_sPosting.PostingYearPeriod = t_sPosting.PostingYear * 100 + t_sPosting.PostingPeriod
t_sPosting.tcPeriodTypeCode = if available tqPeriodByYearPeriod
then tqPeriodByYearPeriod.tcPeriodTypeCode
else vcPeriodTypeCode.
end. /* if t_sPosting. ... */
else
if t_sPosting.PostingYear = 0 or
t_sPosting.PostingPeriod = 0
then do:
assign vcMsgExplanation = <M-11 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcMessage = trim(#T-47'The Posting Date does not belong to an open period':255(733766723)T-47#).
viLocalReturnStatus = -1.
<M-48 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPosting.Period_ID':U (icFieldName),
input String(t_sPosting.PostingDate) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'QadFin-9482':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
leave POSTINGBLOCK.
end. /* t_sPosting.PostingYear = 0 */
/* Assign LayerTypeCode based on JournalType */
if t_sPosting.tcJournalCode <> "":U and
t_sPosting.tcJournalCode <> ? and
(t_sPosting.tc_Status = "N":U or
(t_sPosting.tc_Status = "C":U and
(t_sPosting.tcJournalCode <> t_iPosting.tcJournalCode or
t_sPosting.Journal_ID = ? or
t_sPosting.Journal_ID = 0 or
t_sPosting.tcLayerTypeCode = ? or
t_sPosting.tcLayerTypeCode = "":U or
t_sPosting.tiLayer_ID = ? or
t_sPosting.tiLayer_ID = 0 or
t_sPosting.tcJournalTypeCode = ? or
t_sPosting.tcJournalTypeCode = "":U)))
then do:
<Q-37 run JournalByJournalLayerType (all) (Read) (Cache)
(input 0, (JournalId)
input t_sPosting.tcJournalCode, (JournalCode)
input t_sPosting.Company_ID, (CompanyId)
input '':U, (LayerTypeCode)
output dataset tqJournalByJournalLayerType) in BJournal >
find first tqJournalByJournalLayerType where
tqJournalByJournalLayerType.tcJournalCode = t_sPosting.tcJournalCode
no-error.
if available tqJournalByJournalLayerType
then assign t_sPosting.tcLayerTypeCode = tqJournalByJournalLayerType.tcLayerTypeCod
t_sPosting.tiLayer_ID = tqJournalByJournalLayerType.tiLayer_ID
t_sPosting.tcJournalTypeCode = tqJournalByJournalLayerType.tcJournalTypeCode
t_sPosting.PostingSecondText = if t_sPosting.PostingSecondText = ? or t_sPosting.PostingSecondText = ""
then tqJournalByJournalLayerType.tcJournalSecondDescription
else t_sPosting.PostingSecondText.
end. /* Assign LayerTypeCode based on JournalType */
/* Reverse/Replace reference number */
if ( t_sPosting.PostingIsReversing = true or
t_sPosting.PostingIsReplacement = true ) and
( t_sPosting.PostingOriginatorReference = ? or
t_sPosting.PostingOriginatorReference = '':U )
then do:
assign vcMsgExplanation = <M-94 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign viLocalReturnStatus = -3.
<M-21 run SetMessage
(input #T-28'You must select the original reference posting when replacing or reversing.':255(999890492)T-28# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7263':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
leave POSTINGBLOCK.
end.
if t_sPosting.PostingOriginatorReference <> ? and
t_sPosting.PostingOriginatorReference <> '':U
then do:
if vcActivityCode = "Reverse":U
then assign t_sPosting.PostingIsReversing = true.
else
if vcActivityCode = "Create":U
then assign t_sPosting.PostingIsReplacement = true.
else
if vcActivityCode = "Modify":U and
t_sPosting.PostingIsReversing = false and
t_sPosting.PostingIsReplacement = false and
t_sPosting.PostingIsAutoReversal = false
then do:
assign vcMsgExplanation = <M-70 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign viLocalReturnStatus = -3.
<M-22 run SetMessage
(input #T-29'You must specify whether you are replacing or reversing the original reference posting.':100(59813)T-29# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7264':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
leave POSTINGBLOCK.
end. /* if vcActivityCode = "Modify":U and */
assign viFirstSlash = index(t_sPosting.PostingOriginatorReference, "/":U)
viSecondSlash = index(t_sPosting.PostingOriginatorReference, "/":U, viFirstSlash + 1)
viJournalCodeLength = viSecondSlash - viFirstSlash - 1
viStartPosition = viSecondSlash + 1
viOriginVoucher = Integer(substring(t_sPosting.PostingOriginatorReference, vistartposition,9,"CHARACTER"))
viOriginYear = Integer(substring(t_sPosting.PostingOriginatorReference,1,4,'CHARACTER')) no-error.
if ERROR-STATUS:ERROR
then do:
assign viLocalReturnStatus = -3.
vcMessage = trim(#T-30'An internal error occurred when parsing PostingOriginatorReference.':100(59782)T-30#) + chr(10) +
trim(#T-31'The structure of the originator reference field must be: <year>/<daybook>/<voucher>.':255(64007)T-31#).
if ERROR-STATUS:NUM-MESSAGES > 0
then assign vcMessage = vcMessage + chr(10) +
trim(substitute(#T-32'Detailed info: &1 (&2)':100(59780)T-32#,ERROR-STATUS:GET-MESSAGE(1),string(ERROR-STATUS:GET-NUMBER(1)))).
assign vcMsgExplanation = <M-40 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
<M-23 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-7265':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
leave POSTINGBLOCK.
end. /* if error-status:error */
<Q-50 run PostingByJournalCode (all) (Read) (NoCache)
(input t_sPosting.Company_ID, (CompanyId)
input substring(t_sPosting.PostingOriginatorReference,6,viJournalCodeLength,'CHARACTER'), (JournalCode)
input viOriginYear, (PeriodYear)
input viOriginVoucher, (PostingVoucher)
output dataset tqPostingByJournalCode) in BPosting >
find first tqPostingByJournalCode where
tqPostingByJournalCode.tiCompany_ID = t_sPosting.Company_ID and
tqPostingByJournalCode.tcJournalCode = substring(t_sPosting.PostingOriginatorReference,6,viJournalCodeLength,'CHARACTER') and
tqPostingByJournalCode.tiPostingYear = viOriginYear and
tqPostingByJournalCode.tiPostingVoucher = viOriginVoucher
no-error.
if available tqPostingByJournalCode
then do:
if t_sPosting.PostingDate < tqPostingByJournalCode.ttpostingdate
then do:
assign vcMsgExplanation = <M-76 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign vcDatetemp = <M-90 DisplayDate (input t_sPosting.PostingDate (itDate)) in BPosting>
vcDatetemp1 = <M-19 DisplayDate (input tqPostingByJournalCode.ttpostingdate (itDate)) in BPosting>.
assign vcMessage = trim(substitute(#T-49'The reversing date (&1) cannot be before the posting date (&2).':150(3524)T-49#, vcDatetemp, vcDatetemp1))
viLocalReturnStatus = -1.
<M-51 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 't_sPosting.PostingDate':U (icFieldName),
input vcDatetemp (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'QadFin-9485':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFCReturnSuper (oiReturnStatus)) in BPosting>
leave POSTINGBLOCK.
end. /*if t_sPosting.PostingDate < tqPostingByJournalCode.ttpostingdate*/
end. /*if available tqPostingByJournalCode*/
find first tPosting where
tPosting.Company_ID = t_sPosting.Company_ID and
tPosting.tcJournalCode = substring(t_sPosting.PostingOriginatorReference,6,viJournalCodeLength,'CHARACTER') and
tPosting.PostingYear = viOriginYear and
tPosting.PostingVoucher = viOriginVoucher
no-error.
if not available tPosting
then do:
if t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-REVALCREDITOR} and
t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-REVALCREDITORDOC} and
t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-REVALDEBTOR} and
t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-REVALDEBTORDOC} and
t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-REVALGL} and
( t_sPosting.PostingIsAutoReversal <> true and
t_sPosting.PostingIsReversing <> true ) /* not a reversal entry */
then do :
<Q-24 assign vlFcQueryRecordsAvailable = PostingPrim (NoCache)
(input t_sPosting.Company_ID, (CompanyId)
input substring(t_sPosting.PostingOriginatorReference,6,viJournalCodeLength,'CHARACTER'), (JournalCode)
input viOriginYear, (PeriodYear)
input viOriginVoucher, (PostingVoucher)
input ?, (PostingID)) in BPosting >
if vlFcQueryRecordsAvailable <> true
then do:
assign vcMsgExplanation = <M-63 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign viLocalReturnStatus = -3.
<M-25 run SetMessage
(input trim(#T-33'Invalid Posting Origin Reference':255(63994)T-33#) + ':':U + t_sPosting.PostingOriginatorReference (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7266':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
leave POSTINGBLOCK.
end. /* if vlFcQueryRecordsAvailable <> true */
end. /* if t_sPosting.tcJournalTypeCode <> {&JOURNALTYPE-REVALCREDITOR} and */
end. /*if not available tPosting*/
/* Raise warning in case there is already another posting that reverses the same posting (PostingOriginatorReference should then have the same value) */
if vcActivityCode = "Reverse":U
then do :
<Q-26 run PostingByReverseOriginatorRef (all) (Read) (Cache)
(input t_sPosting.Company_ID, (CompanyId)
input t_sPosting.PostingOriginatorReference, (PostingOriginatorReference)
input ?, (PostingIsReplacement)
input true, (PostingIsReversing)
input t_sPosting.tc_Rowid, (SkipRowid)
output dataset tqPostingByReverseOriginatorRef) in BPosting >
find first tqPostingByReverseOriginatorRef where
tqPostingByReverseOriginatorRef.tiCompany_ID = t_sPosting.Company_ID and
tqPostingByReverseOriginatorRef.tcPostingOriginatorReference = t_sPosting.PostingOriginatorReference
no-lock no-error.
if available tqPostingByReverseOriginatorRef
then do :
assign vcMsgExplanation = <M-828 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign viLocalReturnStatus = -1
vcMessage = trim(substitute(#T-34'Posting &1 has already been reversed by posting &2/&3/&4.':255(999890884)T-34#,t_sPosting.PostingOriginatorReference,string(tqPostingByReverseOriginatorRef.tiPostingYear),tqPostingByReverseOriginatorRef.tcJournalCode,string(tqPostingByReverseOriginatorRef.tiPostingVoucher))).
<M-27 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPosting.PostingOriginatorReference':U (icFieldName),
input t_sPosting.PostingOriginatorReference (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'QadFin-7267':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
leave POSTINGBLOCK.
end. /* if available tqPostingByReverseOriginatorRef */
end. /* if vcActivityCode = "Reverse":U */
end. /* if t_sPosting.PostingOriginatorReference <> ? and */
/* Additional GL Numbering date validation */
if t_sPosting.PostingAddGLNbrDate <> ?
and t_sPosting.PostingDate > t_sPosting.PostingAddGLNbrDate
then do:
assign vcMsgExplanation = <M-79 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign viLocalReturnStatus = -1
vcMessage = #T-56'Additional GL Numbering date cannot be earlier than posting date':255(522633188)T-56#.
vcDatetemp = <M-72 DisplayDate (input t_sPosting.PostingAddGLNbrDate (itDate)) in BPosting>.
<M-14 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPosting.PostingAddGLNbrDate':U (icFieldName),
input vcDatetemp (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'qadfin-629165':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
leave POSTINGBLOCK.
end.
if t_sPosting.tc_Status = "C":U
then do:
if t_sPosting.PostingAddGLNbrDate <> ?
and t_sPosting.PostingAddGLNbrDate <> t_iPosting.PostingAddGLNbrDate
then do:
<Q-6 run JournalByJournalLayerType (all) (Read) (Cache)
(input 0, (JournalId)
input t_iPosting.tcJournalCode, (JournalCode)
input t_sPosting.Company_ID, (CompanyId)
input '':U, (LayerTypeCode)
output dataset tqJournalByJournalLayerType) in BJournal>
find first tqJournalByJournalLayerType where
tqJournalByJournalLayerType.tcJournalCode = t_iPosting.tcJournalCode
no-error.
if available tqJournalByJournalLayerType and
tqJournalByJournalLayerType.tcLayerTypeCode = {&LAYERTYPECODE-TRANSIENT}
then assign vlNeedCheckCorrectionPeriod = no.
else assign vlNeedCheckCorrectionPeriod = yes.
/* If the original posting is on transient layer, let user modify numbering date */
if vlNeedCheckCorrectionPeriod
then do:
if vlOpenPeriodInstance = false
then do:
<I-98 {bFcOpenInstance
&CLASS = "BPeriod"}>
assign vlOpenPeriodInstance = true.
end.
<M-78 run CheckForCorrectionPeriod
(input t_sPosting.Company_ID (iiCompanyID),
input t_sPosting.PostingYearPeriod (iiYearPeriod),
output vlIsCorrPeriod (olIsCorrPrd),
output viFcReturnSuper (oiReturnStatus)) in BPeriod>
if not vlIsCorrPeriod
then do:
assign vcMsgExplanation = <M-41 GetErrorExplanation
(input t_sPosting.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BPosting>.
assign viLocalReturnStatus = -1
vcMessage = #T-91'Additional GL Numbering date cannot be changed out of a Correction Period':255(135371830)T-91#.
vcDatetemp = <M-71 DisplayDate (input t_sPosting.PostingAddGLNbrDate (itDate)) in BPosting>.
<M-45 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPosting.PostingAddGLNbrDate':U (icFieldName),
input vcDatetemp (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPosting.tc_Rowid (icRowid),
input 'qadfin-151391':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
leave POSTINGBLOCK.
end. /* if not vlIsCorrPeriod */
end. /* if vlNeedCheckCorrectionPeriod */
end. /* if t_sPosting.PostingAddGLNbrDate */
end. /* if t_sPosting.tcStatus */
/* Initialize default numbering date */
if t_sPosting.PostingAddGLNbrDate = ?
then assign t_sPosting.PostingAddGLNbrDate = t_sPosting.PostingDate.
/* If on a new posting the ReportingJournal is not filled and the Journal is filled then assign the ReportingJournal equal to the Journal */
if (t_sPosting.tcReportingJournalCode = "":U or
t_sPosting.tcReportingJournalCode = ?) and
t_sPosting.tcJournalCode <> "":U and
t_sPosting.tcJournalCode <> ? and
t_sPosting.tc_Status = "N":U
then assign t_sPosting.tcReportingJournalCode = t_sPosting.tcJournalCode.
end. /* POSTINGBLOCK */
if vlOpenPeriodInstance = true
then do:
<I-35 {bFcCloseInstance
&CLASS = "BPeriod"}>
assign vlOpenPeriodInstance = false.
end.
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = viLocalReturnStatus.