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/bqcrosscyposting.p)
/* =========================================================== */
/* Ancestor code is skipped. KriLae/WouAnt 20050929 */
/* As not necessary for deleting Q-tabling */
/* =========================================================== */
if not can-find (first t_sQCrossCyPosting where
t_sQCrossCyPosting.tc_status <> "D":U)
then do :
assign vlFcDataValidated = true.
Return.
end. /* if not can-find (first t_sQCrossCyPosting where */
/* ======================================================================================================================= */
/* Backwards-compatibility: Make sure some new mandatory fields get a default value in case they are still unknown */
/* This is needed as older callers may still use and interface that does not hold these fields although they are mandatory */
/* This is about these fields: tQCrossCyPosting.QCrossCyPostingIsWHT */
/* ======================================================================================================================= */
for each t_sQCrossCyPosting where
t_sQCrossCyPosting.tc_Status = "N":U or
t_sQCrossCyPosting.tc_Status = "C":U :
if t_sQCrossCyPosting.QCrossCyPostingIsWHT = ?
then assign t_sQCrossCyPosting.QCrossCyPostingIsWHT = false.
end. /* for each t_sQCrossCyPosting where */
<ANCESTOR-CODE>
assign vcJournalCode = "":U
vcMessage = "":U.
/* ======================================================================== */
/* Validations on newly created records; */
/* The company_ID should differ from the current company */
/* The originator company should match the current company */
/* Just 1 of the originator-fields (CI/DI/EI/OpenItemGL) should be filled */
/* ======================================================================== */
for each t_sQCrossCyPosting where
t_sQCrossCyPosting.tc_Status = "N":U
no-lock :
if t_sQCrossCyPosting.Company_ID = viCompanyId
then do :
assign vcMsgCrossCy = trim(#T-6'The new cross-company posting request cannot be created in the current entity.':255(3460)T-6#) + chr(10) +
trim(substitute(#T-7'Request on GL: &1.':255(3461)T-7#,string(t_sQCrossCyPosting.CrossCompanyGL_ID))) + chr(10) +
trim(substitute(#T-8'Entity of the cross-company posting request: &1.':255(3462)T-8#,string(t_sQCrossCyPosting.Company_ID))) + chr(10) +
trim(substitute(#T-9'Current entity: &1.':255(1297)T-9#,string(viCompanyId))).
oiReturnStatus = -1.
<M-1 run SetMessage
(input vcMsgCrossCy (icMessage),
input '':U (icArguments),
input 'tQCrossCyPosting.Company_ID':U (icFieldName),
input string(t_sQCrossCyPosting.Company_ID) (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input t_sQCrossCyPosting.tc_Status (icRowid),
input 'QADFIN-858':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BQCrossCyPosting>
end. /* if t_sQCrossCyPosting.Company_ID = viCompanyId */
if t_sQCrossCyPosting.OriginatorCompany_ID <> viCompanyId
then do :
assign vcMsgCrossCy = trim(#T-10'You must create the new cross-company posting request in the current entity.':255(3463)t-10#) + chr(10) +
trim(substitute(#T-11'Request on GL: &1.':255(3461)T-11#,string(t_sQCrossCyPosting.CrossCompanyGL_ID))) + chr(10) +
trim(substitute(#T-12'Originating entity: &1.':255(3464)T-12#,string(t_sQCrossCyPosting.OriginatorCompany_ID))) + chr(10) +
trim(substitute(#T-13'Current entity: &1.':255(1297)T-13#,string(viCompanyId))).
oiReturnStatus = -1.
<M-2 run SetMessage
(input vcMsgCrossCy (icMessage),
input '':U (icArguments),
input 'tQCrossCyPosting.Company_ID':U (icFieldName),
input string(t_sQCrossCyPosting.Company_ID) (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input t_sQCrossCyPosting.tc_Status (icRowid),
input 'QADFIN-859':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BQCrossCyPosting>
end. /* if t_sQCrossCyPosting.Company_ID = viCompanyId */
assign viMasterReferencesUsed = 0.
if t_sQCrossCyPosting.CInvoice_ID <> 0 and t_sQCrossCyPosting.CInvoice_ID <> ?
then assign viMasterReferencesUsed = viMasterReferencesUsed + 1.
if t_sQCrossCyPosting.DInvoice_ID <> 0 and t_sQCrossCyPosting.DInvoice_ID <> ?
then assign viMasterReferencesUsed = viMasterReferencesUsed + 1.
if t_sQCrossCyPosting.APMatchingGL_ID <> 0 and t_sQCrossCyPosting.APMatchingGL_ID <> ?
then assign viMasterReferencesUsed = viMasterReferencesUsed + 1.
if t_sQCrossCyPosting.ComplPostingRevPosting_ID <> 0 and t_sQCrossCyPosting.ComplPostingRevPosting_ID <> ?
then assign viMasterReferencesUsed = viMasterReferencesUsed + 1.
if viMasterReferencesUsed = 0
then do :
assign vcMsgCrossCy = trim(#T-14'You must link cross-company posting requests to a single originator.':255(3465)t-14#) + chr(10) +
trim(substitute(#T-15'Request on GL: &1.':255(3461)T-15#,string(t_sQCrossCyPosting.CrossCompanyGL_ID))) + chr(10) +
trim(substitute(#T-16'Linked to the supplier invoice &1.':255(3466)t-16#,(if t_sQCrossCyPosting.CInvoice_ID <> 0 and t_sQCrossCyPosting.CInvoice_ID <> ? then #T-17'yes':5(3467)t-17# else #T-18'no':5(3468)t-18#))) + chr(10) +
trim(substitute(#T-19'Linked to a customer invoice: &1.':255(3469)T-19#,(if t_sQCrossCyPosting.DInvoice_ID <> 0 and t_sQCrossCyPosting.DInvoice_ID <> ? then #T-20'yes':5(3467)t-20# else #T-21'no':5(3468)t-21#))) + chr(10) +
trim(substitute(#T-36'Linked to the receiver matching &1.':255(59395)t-36#,(if t_sQCrossCyPosting.APMatchingGL_ID <> 0 and t_sQCrossCyPosting.APMatchingGL_ID <> ? then #T-37'yes':5(3467)T-37# else #T-38'no':5(3468)T-38#))) + chr(10) +
trim(substitute(#T-23'Linked to Supplier Invoice Reverse: &1':255(228059461)T-23#, (if t_sQCrossCyPosting.ComplPostingRevPosting_ID <> 0 and t_sQCrossCyPosting.ComplPostingRevPosting_ID <> ? then #T-846'Yes':4(16037)T-846# else #T-54'No':4(16038)T-54#)))
oiReturnStatus = -1.
<M-3 run SetMessage
(input vcMsgCrossCy (icMessage),
input '':U (icArguments),
input 'tQCrossCyPosting.Company_ID':U (icFieldName),
input string(t_sQCrossCyPosting.Company_ID) (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input t_sQCrossCyPosting.tc_Status (icRowid),
input 'QADFIN-860':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BQCrossCyPosting>
end. /* if viMasterReferencesUsed = 0 */
if viMasterReferencesUsed > 1
then do :
assign vcMsgCrossCy = trim(substitute(#T-28'You must link cross-company posting requests to a single originator. This request is linked to &1 originators.':255(3472)t-28#,string(viMasterReferencesUsed))) + chr(10) +
trim(substitute(#T-29'Request on GL: &1.':255(3461)T-29#,string(t_sQCrossCyPosting.CrossCompanyGL_ID))) + chr(10) +
trim(substitute(#T-30'Linked to the supplier invoice &1.':255(3466)t-30#,(if t_sQCrossCyPosting.CInvoice_ID <> 0 and t_sQCrossCyPosting.CInvoice_ID <> ? then #T-31'yes':5(3467)t-31# else #T-32'no':5(3468)t-32#))) + chr(10) +
trim(substitute(#T-33'Linked to a customer invoice: &1.':255(3469)T-33#,(if t_sQCrossCyPosting.DInvoice_ID <> 0 and t_sQCrossCyPosting.DInvoice_ID <> ? then #T-34'yes':5(3467)t-34# else #T-35'no':5(3468)t-35#))) + chr(10) +
trim(substitute(#T-39'Linked to the receiver matching &1.':255(59395)t-39#,(if t_sQCrossCyPosting.APMatchingGL_ID <> 0 and t_sQCrossCyPosting.APMatchingGL_ID <> ? then #T-40'yes':5(3467)T-40# else #T-41'no':5(3468)T-41#)))
oiReturnStatus = -1.
<M-5 run SetMessage
(input vcMsgCrossCy (icMessage),
input '':U (icArguments),
input 'tQCrossCyPosting.Company_ID':U (icFieldName),
input string(t_sQCrossCyPosting.Company_ID) (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input t_sQCrossCyPosting.tc_Status (icRowid),
input 'QADFIN-861':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BQCrossCyPosting>
end. /* if viMasterReferencesUsed > 1 */
/* Check Journal Access */ /* Originator Journal */
if t_sQCrossCyPosting.OriginatorJournal_ID <> 0 and
t_sQCrossCyPosting.OriginatorJournal_ID <> ?
then do :
<Q-63 run JournalPrim (all) (Read) (Cache)
(input ?, (CompanyId)
input ?, (JournalCode)
input t_sQCrossCyPosting.OriginatorJournal_ID, (JournalID)
output dataset tqJournalPrim) in BJournal>
find first tqJournalPrim
where tqJournalPrim.tiJournal_ID = t_sQCrossCyPosting.OriginatorJournal_ID no-error.
if available tqJournalPrim
then assign vcJournalCode = tqJournalPrim.tcJournalCode.
/* Journal Code */
if vcJournalCode <> "":U and
vcJournalCode <> ?
then do :
<Q-68 run JournalPrim (all) (Read) (Cache)
(input t_sQCrossCyPosting.Company_ID, (CompanyId)
input vcJournalCode, (JournalCode)
input ?, (JournalID)
output dataset tqJournalPrim) in BJournal>
find first tqJournalPrim
where tqJournalPrim.tcJournalCode = vcJournalCode no-error.
if available tqJournalPrim
then do:
<M-126 run ValidateComponentPostJournalRole
(input tqJournalPrim.tiJournal_ID (iiJournalID),
input t_sQCrossCyPosting.Company_ID (iiCompanyID),
input vcJournalCode (icJournalCode),
output oiReturnStatus (oiReturnStatus)) in BQCrossCyPosting>
end. /* if available tqJournalPrim */
end. /* if vcJournalCode <> "":U and */
end. /* if t_sQCrossCyPosting.OriginatorJournal_ID <> 0 and */
end. /* for each t_sQCrossCyPosting where */
if oiReturnStatus < 0 then return.