project QadFinancials > class BBankNumber > method ValidateComponentPostCreditor

Description

Validations for banknumbers of creditors.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBankNumber.ValidateComponentPost


program code (program5/bbanknumber.p)

assign oiReturnStatus      = -98
       viLocalReturnStatus = 0.

VALCREDITORBLOCK:
for each t_sBankNumber where
         t_sBankNumber.BankNumberParentType = {&BANKNUMBERPARENTTYPE-CREDITOR} and
         t_sBankNumber.BankNumberIsActive   = true                             and
        (t_sBankNumber.tc_Status            = "C":U or
         t_sBankNumber.tc_Status            = "N":U):
    /* ========================================= */
    /* Error when Bank is not linked to Own Bank */
    /* ========================================= */
    if (t_sBankNumber.tcOwnBankNumber = "" or
        t_sBankNumber.tcOwnBankNumber = ?)
    then do:
        assign vcMessage           = trim(#T-10'Own bank number cannot be blank or unknown.':50(57162)T-10#)
               viLocalReturnStatus = -1.
        <M-11 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'tBankNumber.tcOwnBankNumber':U (icFieldName), 
            input  t_sBankNumber.tcOwnBankNumber (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sBankNumber.tc_Rowid (icRowid), 
            input  'QadFin-9702':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BBankNumber>
    end. /* if (t_sBankNumberRefCreditor.tcOwnBankNumber = ""  or */

    /* ================================ */
    /* AR payment format is not allowed */
    /* ================================ */
    if t_sBankNumber.tcPayFormatTypeCode <> ? and 
       t_sBankNumber.tcPayFormatTypeCode <>'':U
    then do:
        if vlQueryPayFormatTypeByType = false
        then do:
            <Q-16 run PayFormatTypeByType  (Start) in BPaymentFormat >
            assign vlQueryPayFormatTypeByType = true.
        end. /* if vlQueryStartedPayFormatTypeByType = false */
        <Q-14 run PayFormatTypeByType (all) (Read) (NoCache)
           (input t_sBankNumber.tcPayFormatTypeCode, (PayFormatTypeCode)
            output dataset tqPayFormatTypeByType) in BPaymentFormat >
        find first tqPayFormatTypeByType where
                   tqPayFormatTypeByType.tcPayFormatTypeCode = t_sBankNumber.tcPayFormatTypeCode
                   no-error.
        if available tqPayFormatTypeByType and 
           tqPayFormatTypeBytype.tcPayFormatTypeModule <> {&PAYFORMATMODULE-AP}
        then do: 
            assign vcMessage           = trim(#T-12'Only AP payment format is allowed for supplier bank numbers.':150(733759699)T-12#)
                   viLocalReturnStatus = -1.
            <M-15 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tBankNumber.tcPayFormatTypeCode':U (icFieldName), 
                input  t_sBankNumber.tcPayFormatTypeCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sBankNumber.tc_Rowid (icRowid), 
                input  'QadFin-9704':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BBankNumber>
        end. /* if available tqPayFormatTypeByType and */
    end. /* if t_sBankNumber.tcPayFormatTypeCode <> ? and */

    /* ================================================= */
    /* Error when Bank is not linked to a Payment Format */
    /* ================================================= */
    if (t_sBankNumber.BankPayFormat_ID = 0 or
        t_sBankNumber.BankPayFormat_ID = ?)
    then do:
        assign vcMessage           = trim(#T-18'Payment format code cannot be blank or unknown.':50(999890805)T-18#)
               viLocalReturnStatus = -1.
        <M-20 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'tBankNumber.tcPayFormatTypeCode':U (icFieldName), 
            input  t_sBankNumber.tcPayFormatTypeCode (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sBankNumber.tc_Rowid (icRowid), 
            input  'QadFin-9706':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BBankNumber>
    end. /* if (t_sBankNumber.BankPayFormat_ID = 0 or */

    for each t_sBankNumberPayCode where
             t_sBankNumberPayCode.BankNumber_ID = t_sBankNumber.BankNumber_ID:
        if vlQueryPayFormatGroupByTypeSeq = false
        then do:
            <Q-26 run PayFormatGroupByTypeSeq  (Start) in BPaymentFormat >
            assign vlQueryPayFormatGroupByTypeSeq = true.
        end. /* if vlQueryPayFormatGroupByTypeSeq = false */
        <Q-25 run PayFormatGroupByTypeSeq (all) (Read) (NoCache)
           (input t_sBankNumberPayCode.tiPayFormatGroupSequence, (PayFormatGroupSequence)
            input true, (PayFormatGroupIsActive)
            input t_sBankNumber.tcPayFormatTypeCode, (PayFormatTypeCode)
            output dataset tqPayFormatGroupByTypeSeq) in BPaymentFormat >
        
        /* Check if mandatory fields and filled in */
        for each tqPayFormatGroupByTypeSeq:
            /* Validate Attribute Data Type */
            case tqPayFormatGroupByTypeSeq.tcPayFormatGroupDataType:
                when {&PAYFORMATGROUPDATATYPE-INTEGER} 
                then assign viPayFormatIntegerValue = int(t_sBankNumberPayCode.tcPayFormatCodeValue) no-error.
                when {&PAYFORMATGROUPDATATYPE-AMOUNT} 
                then assign vdPayFormatDecimalValue = dec(t_sBankNumberPayCode.tcPayFormatCodeValue) no-error.
                when {&PAYFORMATGROUPDATATYPE-DATE} 
                then assign vtPayFormatDateValue = date(t_sBankNumberPayCode.tcPayFormatCodeValue) no-error.
                when {&PAYFORMATGROUPDATATYPE-LOGICAL} 
                then assign vlPayFormatLogicalValue = logical(t_sBankNumberPayCode.tcPayFormatCodeValue) no-error.
                otherwise
                     assign vcPayFormatTextValue = string(t_sBankNumberPayCode.tcPayFormatCodeValue) no-error.                
            end case.
        
            /* Log Progress errors for datatype mismatches */
            if error-status:error 
            then do:
                assign viLocalReturnStatus = -1.
                do viProgressErrorCount = 1 to error-status:num-messages:
                    <M-28 run SetMessage
                       (input  error-status:get-message(viProgressErrorCount) (icMessage), 
                        input  '':U (icArguments), 
                        input  'tBankNumberPayCode.tcPayFormatCodeValue':U (icFieldName), 
                        input  t_sBankNumberPayCode.tcPayFormatCodeValue (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  t_sBankNumberPayCode.tc_Rowid (icRowid), 
                        input  'QadFin-9709':U (icFcMsgNumber), 
                        input  '':U (icFcExplanation), 
                        input  '':U (icFcIdentification), 
                        input  '':U (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BBankNumber>
                end. /* do viProgressErrorCount ... */
            end. /* if error-status:error then do */            
        end. /* for each tqPayFormatGroupByTypeSeq */
    end. /* for each t_sBankNumberPayCode */
end. /* for each t_sBankNumber where (VALCREDITORBLOCK) */

/* ============ */
/* Stop Queries */
/* ============ */
if vlQueryPayFormatTypeByType = true
then do:
    <Q-17 run PayFormatTypeByType  (Stop) in BPaymentFormat >
    assign vlQueryPayFormatTypeByType = false.
end. /* if vlQueryStartedPayFormatTypeByType = true */

if vlQueryPayFormatGroupByTypeSeq = true
then do:
    <Q-27 run PayFormatGroupByTypeSeq  (Stop) in BPaymentFormat >
    assign vlQueryPayFormatGroupByTypeSeq = false.
end. /* if vlQueryPayFormatGroupByTypeSeq = true */

assign oiReturnStatus = viLocalReturnStatus.