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/bpaymentformat.p)
define buffer b_sPayFormatGroup for t_sPayFormatGroup.
<ANCESTOR-CODE>
assign vcListPair = {&PAYMENTFORMATS}
vcListCode = ?
vcListTr = ?.
do viIndex = 2 to num-entries(vcListPair, chr(2)) by 2:
assign vcListCode = if vcListCode = ?
then entry(viIndex, vcListPair, chr(2))
else vcListCode + chr(2) + entry(viIndex, vcListPair,chr(2))
vcListTr = if vcListTr = ?
then entry(viIndex - 1, vcListPair,chr(2))
else vcListTr + chr(2) + entry(viIndex - 1, vcListPair,chr(2)).
end.
/*Validations on PayFormatGroup table*/
assign vcPayFormatTypeCode = "":U
vcPayFormatTypeCode2 = "":U
viPayFormatGroupSequence = 0.
for each t_sPayFormatGroup
by t_sPayFormatGroup.PayFormatTypeCode
by t_sPayFormatGroup.PayFormatGroupSequence:
/*find a translation for each PayFormatCode -
sort by PayFormatTypeCode NEEDED*/
if vcPayFormatTypeCode <> t_sPayFormatGroup.PayFormatTypeCode
then do:
/*initiate TR value with CODE value*/
assign vcPayFormatTypeCode = t_sPayFormatGroup.PayFormatTypeCode
vcPayFormatTypeCodeTr = vcPayFormatTypeCode
viIndex = lookup(t_sPayFormatGroup.PayFormatTypeCode, vcListCode, chr(2)) no-error.
if viIndex > 0
then assign vcPayFormatTypeCodeTr = entry(viIndex, vcListTr, chr(2)) no-error.
end.
/*error: has to be a positive value*/
if not (t_sPayFormatGroup.PayFormatGroupSequence > 0)
then do:
assign vcMessage = trim(substitute(#T-3'The group code (&1) entered for payment format '&2' is not defined in the system.':200(2952)T-3#,
string(t_sPayFormatGroup.PayFormatGroupSequence),
trim(vcPayFormatTypeCodeTr))) +
trim(#T-4'The group code must be a positive value.':200(46870)T-4#)
oiReturnStatus = -1.
<M-2 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPayFormatGroup.PayFormatGroupSequence':U (icFieldName),
input t_sPayFormatGroup.PayFormatGroupSequence (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPayFormatGroup.tc_Rowid (icRowid),
input 'QADFIN-622':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
end.
/*error: only one active Group is allowed for each sequence
check only once for a certain Pay Format Code and Sequence
sort by PayFormatTypeCode and Sequence NEEDED*/
if vcPayFormatTypeCode2 <> t_sPayFormatGroup.PayFormatTypeCode or
viPayFormatGroupSequence <> t_sPayFormatGroup.PayFormatGroupSequence
then do:
assign vcPayFormatTypeCode2 = t_sPayFormatGroup.PayFormatTypeCode
viPayFormatGroupSequence = t_sPayFormatGroup.PayFormatGroupSequence.
if t_sPayFormatGroup.PayFormatGroupIsActive and
can-find(first b_sPayFormatGroup where
b_sPayFormatGroup.PayFormatGroup_ID <> t_sPayFormatGroup.PayFormatGroup_ID and
b_sPayFormatGroup.PayFormatTypeCode = t_sPayFormatGroup.PayFormatTypeCode and
b_sPayFormatGroup.PayFormatGroupSequence = t_sPayFormatGroup.PayFormatGroupSequence and
b_sPayFormatGroup.PayFormatGroupIsActive = true)
then do:
assign vcMessage = trim(substitute(#T-5'More than one active group is defined for this payment format (&1) and group code (&2).':200(2954)T-5#,
trim(vcPayFormatTypeCodeTr),
string(t_sPayFormatGroup.PayFormatGroupSequence))) +
trim(#T-6'You can only specify one active group for each payment format and group code.':200(2955)T-6#)
oiReturnStatus = -1.
<M-1 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tPayFormatGroup.PayFormatGroupSequence':U (icFieldName),
input t_sPayFormatGroup.PayFormatGroupSequence (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sPayFormatGroup.tc_Rowid (icRowid),
input 'QADFIN-621':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
end.
end.
/* Only one default attribute is allowed per pay group */
if can-find(first t_sPayFormatCode where
t_sPayFormatCode.tc_Status <> 'D':U and
t_sPayFormatCode.PayFormatGroup_ID = t_sPayFormatGroup.PayFormatGroup_ID and
t_sPayFormatCode.PayFormatCodeIsDefault = true)
then do:
find t_sPayFormatCode where
t_sPayFormatCode.tc_Status <> 'D':U and
t_sPayFormatCode.PayFormatGroup_ID = t_sPayFormatGroup.PayFormatGroup_ID and
t_sPayFormatCode.PayFormatCodeIsDefault = true no-error.
if not available t_sPayFormatCode
then do:
assign vcMessage = trim(substitute(#T-18'More than one default attribute is defined for payment group code (&1) of payment format (&2)':225(64776)T-18#,
string(t_sPayFormatGroup.PayFormatGroupSequence),
trim(vcPayFormatTypeCodeTr)))
oiReturnStatus = -1.
<M-19 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-6790':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
end.
end.
end.
/*Check the consistency between Module and payment instrument.*/
for each t_sPayFormatType:
if t_sPayFormatType.PayFormatTypeModule = {&PAYFORMATMODULE-AR} then do:
if t_sPayFormatType.PayFormatTypePayInstrument = {&PAYMENTMEANS-TRANSFER} or
t_sPayFormatType.PayFormatTypePayInstrument = {&PAYMENTMEANS-ELECTRONIC}
then do:
<M-17 run SetMessage
(input #T-17'AR payments cannot use this payment instrument.':200(49259)T-17# (icMessage),
input '' (icArguments),
input 'tPayFormatType.PayFormatTypePayInstrument':U (icFieldName),
input t_sPayFormatType.PayFormatTypePayInstrument (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'QadFin-5396':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
oiReturnStatus = -1.
end.
end.
if t_sPayFormatType.PayFormatTypeModule = {&PAYFORMATMODULE-AP} and
(t_sPayFormatType.PayFormatTypePayInstrument = {&PAYMENTMEANS-DIRECTDEBIT} or
t_sPayFormatType.PayFormatTypePayInstrument = {&PAYMENTMEANS-CREDITCARD})
then do:
<M-8 run SetMessage
(input trim(#T-9'AP payments cannot use this payment instrument.':200(65486)T-9#) (icMessage),
input '' (icArguments),
input 'tPayFormatType.PayFormatTypePayInstrument':U (icFieldName),
input t_sPayFormatType.PayFormatTypePayInstrument (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'QadFin-5128':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
oiReturnStatus = -1.
end.
if t_sPayFormatType.PayFormatTypeLinesPerPage > 30
then do:
<M-20 run SetMessage
(input trim(#T-21'Invoices per check cannot be greater than 30.':200(999890090)T-21#) (icMessage),
input '' (icArguments),
input 'tPayFormatType.PayFormatTypeLinesPerPage':U (icFieldName),
input t_sPayFormatType.PayFormatTypeLinesPerPage (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'QadFin-8603':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
oiReturnStatus = -1.
end.
end.
/* When an attribute's input option is selectable, make sure it has selectable values. */
for each t_sPayFormatGroup where t_sPayFormatGroup.PayFormatGroupInputOption = {&PAYFORMATGROUPINPUTOPTION-SELECTABLE}:
find first t_sPayFormatCode where t_sPayFormatCode.PayFormatGroup_ID = t_sPayFormatGroup.PayFormatGroup_ID
and t_sPayFormatCode.tc_Status <> 'D':U no-error.
if not available(t_sPayFormatCode) then do:
<M-10 run SetMessage
(input trim(#T-11'Attribute with selectable input option should have at least one selectable attribute value':200(47366)T-11#) (icMessage),
input '' (icArguments),
input 'tPayFormatGroup.PayFormatGroupInputOption':U (icFieldName),
input t_sPayFormatGroup.PayFormatGroupInputOption (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'QadFin-5129':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
oiReturnStatus = -1.
end.
end.
/* When an attribute's input option is editable, make sure there is no selectable value. */
for each t_sPayFormatGroup where t_sPayFormatGroup.PayFormatGroupInputOption = {&PAYFORMATGROUPINPUTOPTION-EDITABLE}:
find first t_sPayFormatCode where t_sPayFormatCode.PayFormatGroup_ID = t_sPayFormatGroup.PayFormatGroup_ID
and t_sPayFormatCode.tc_Status <> 'D':U no-error.
if available(t_sPayFormatCode) then do:
<M-13 run SetMessage
(input trim(#T-15'Attribute with editable input option should not have any selectable attribute values.':200(49230)T-15#) (icMessage),
input '' (icArguments),
input 'tPayFormatGroup.PayFormatGroupInputOption':U (icFieldName),
input t_sPayFormatGroup.PayFormatGroupInputOption (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'QadFin-5141':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
oiReturnStatus = -1.
end.
end.
/* Check that attribute values are valid */
for each t_sPayFormatGroup where t_sPayFormatGroup.PayFormatGroupInputOption = {&PAYFORMATGROUPINPUTOPTION-SELECTABLE} or
t_sPayFormatGroup.PayFormatGroupInputOption = {&PAYFORMATGROUPINPUTOPTION-BOTH}:
for each t_sPayFormatCode where t_sPayFormatCode.PayFormatGroup_ID = t_sPayFormatGroup.PayFormatGroup_ID
and t_sPayFormatCode.tc_Status <> 'D':U:
<M-12 run ApiTypeChecking
(input t_sPayFormatGroup.PayFormatGroupCode (icFieldName),
input t_sPayFormatCode.PayFormatCode (icFieldValue),
input t_sPayFormatGroup.PayFormatGroupDataType (icFieldType),
output viFcReturnSuper (oiReturnStatus)) in BPaymentFormat>
if viFcReturnSuper <> 0 then do:
if viFcReturnSuper < 0 then do:
oiReturnStatus = viFcReturnSuper.
end.
else do:
if oiReturnStatus = 0 then do:
oiReturnStatus = viFcReturnSuper.
end.
end.
end.
end.
end.