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/bsharedset.p)
<ANCESTOR-CODE>
if oiReturnStatus < 0
then return.
for each t_sSharedSet where
t_sSharedSet.tc_Status <> "":U:
/*initially loaded data*/
if t_sSharedSet.tc_Status = "C":U or
t_sSharedSet.tc_Status = "D":U
then do:
find first tFcRowidConvert where
tFcRowidConvert.tcFcOldRowid = t_sSharedSet.tc_Rowid no-error.
if available tFcRowidConvert
then find first t_iSharedSet where
t_iSharedSet.tc_Rowid = tFcRowidConvert.tcFcNewRowid no-error.
else find first t_iSharedSet where
t_iSharedSet.tc_Rowid = t_sSharedSet.tc_Rowid no-error.
if not available t_iSharedSet
then do:
assign vcMessage = "t_iSharedSet not available.":U + chr(10) + program-name(1)
oiReturnStatus = -1.
<M-2 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-23':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BSharedSet>
return.
end.
end.
/*Error:Cannot Modify SharedSetTypeCode if
the Shared Set is already linked to an appropriate table according to the Shared Set Type (e.g Creditor)*/
/*Error:Cannot Delete - DB constraint*/
if available t_iSharedSet and
t_iSharedSet.SharedSetTypeCode <> t_sSharedSet.SharedSetTypeCode and
t_sSharedSet.tc_Status = "C":U
then do:
assign vcMessage = "":U.
case t_iSharedSet.SharedSetTypeCode:
when {&SHAREDSETTYPECODE-COSTCENTRE}
then do:
<Q-4 run CostCentreBySharedSet (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
output dataset tqCostCentreBySharedSet) in BCostCentre >
find first tqCostCentreBySharedSet no-error.
if available tqCostCentreBySharedSet
then assign vcMessage = trim(substitute(#T-13'A cost center already exists for this shared set (for example, &1).':200(3694)t-13#,
trim(tqCostCentreBySharedSet.tcCostCentreCode))).
end.
when {&SHAREDSETTYPECODE-CREDITOR}
then do:
<Q-5 run CreditorBySharedSet (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
output dataset tqCreditorBySharedSet) in BCreditor >
find first tqCreditorBySharedSet no-error.
if available tqCreditorBySharedSet
then assign vcMessage = trim(substitute(#T-14'A supplier already exists for this shared set (for example, &1).':200(3695)T-14#,
trim(tqCreditorBySharedSet.tcCreditorCode))).
end.
when {&SHAREDSETTYPECODE-DEBTOR}
then do:
<Q-6 run DebtorBySharedSet (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
output dataset tqDebtorBySharedSet) in BDebtor >
find first tqDebtorBySharedSet no-error.
if available tqDebtorBySharedSet
then assign vcMessage = trim(substitute(#T-15'A customer already exists for this shared set (for example, &1).':200(3696)T-15#,
trim(tqDebtorBySharedSet.tcDebtorCode))).
end.
when {&SHAREDSETTYPECODE-DIVISION}
then do:
<Q-7 run DivisionBySharedSet (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
output dataset tqDivisionBySharedSet) in BDivision >
find first tqDivisionBySharedSet no-error.
if available tqDivisionBySharedSet
then assign vcMessage = trim(substitute(#T-16'A sub-account already exists for this shared set (for example, &1).':200(3697)T-16#,
trim(tqDivisionBySharedSet.tcDivisionCode))).
end.
when {&SHAREDSETTYPECODE-EXCHANGERATE}
then do:
<Q-12 run ExchangeRateByCompany (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
output dataset tqExchangeRateByCompany) in BExchangeRate >
find first tqExchangeRateByCompany no-error.
if available tqExchangeRateByCompany
then assign vcMessage = trim(substitute(#T-17'An exchange rate already exists for this shared set (for example, &1 &2 &3).':200(3698)T-17#,
trim(tqExchangeRateByCompany.tcCurrencyCode),
trim(tqExchangeRateByCompany.tcCurrencyCode2),
trim(tqExchangeRateByCompany.tcExchangeRateTypeCode))).
end.
when {&SHAREDSETTYPECODE-GL}
then do:
<Q-10 run GLBySharedSet (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
output dataset tqGLBySharedSet) in BGL >
find first tqGLBySharedSet no-error.
if available tqGLBySharedSet
then assign vcMessage = trim(substitute(#T-18'A GL account already exists for this shared set (for example, &1).':200(3699)T-18#,
trim(tqGLBySharedSet.tcGLCode))).
end.
when {&SHAREDSETTYPECODE-JOURNAL}
then do:
<Q-8 run JournalBySharedSet (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
output dataset tqJournalBySharedSet) in BJournal >
find first tqJournalBySharedSet no-error.
if available tqJournalBySharedSet
then assign vcMessage = trim(substitute(#T-20'A daybook already exists for this shared set (for example, &1).':200(3701)T-20#,
trim(tqJournalBySharedSet.tcJournalCode))).
end.
when {&SHAREDSETTYPECODE-PROJECT}
then do:
<Q-9 run ProjectBySharedSet (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
output dataset tqProjectBySharedSet) in BProject >
find first tqProjectBySharedSet no-error.
if available tqProjectBySharedSet
then assign vcMessage = trim(substitute(#T-21'A project already exists for this shared set (for example, &1).':200(3702)T-21#,
trim(tqProjectBySharedSet.tcProjectCode))).
end.
otherwise assign vcMessage = trim(substitute(#T-22'Shared Set of type &1 was not recognized.':200(3703)t-22#, trim(t_iSharedSet.SharedSetTypeCode))) + chr(10) +
trim(#T-23'Ask your system administrator or software provider to load the latest version of this program.':200(3389)t-23#).
end case.
if vcMessage <> "":U
then do:
assign vcMessage = right-trim (vcMessage, ",":U)
vcMessage = trim(substitute(#T-24'You cannot change the type of shared set '&1' from '&2' to '&3'.':200(3704)t-24#,
trim(t_sSharedSet.SharedSetCode), trim(t_iSharedSet.SharedSetTypeCode), trim(t_sSharedSet.SharedSetTypeCode))) + chr(10) +
trim(vcMessage) + chr(10) +
program-name(1)
oiReturnStatus = if oiReturnStatus < 0
then oiReturnStatus
else -1.
<M-3 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tSharedSet.SharedSetTypeCode':U (icFieldName),
input t_sSharedSet.SharedSetTypeCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sSharedSet.tc_Rowid (icRowid),
input 'QADFIN-24':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BSharedSet>
end.
end.
end.