project QadFinancials > class BAPMatching > method AdditionalUpdatesAllTaxGetPPV

Description

AdditionalUpdatesAllTaxNewGetPPV: submethod of AdditionalUpdatesAllTaxNew that assigns the PPV-account (and division and CC) in the calc-fields of APMatchingLn


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BAPMatching.AdditionalUpdatesAllTaxNewTwo
method BAPMatching.AdditionalUpdatesAllTaxOldOne


program code (program6/bapmatching.p)

/* ================================================================================ */
/* AdditionalUpdatesAllTaxNewGetPPV: submethod of AdditionalUpdatesAllTaxNew that   */
/* assigns the PPV-account (and division and CC) in the calc-fields of APMatchingLn */
/* ================================================================================ */

/* ================== */
/* Exception handling */
/* Start Block        */
/* ================== */
assign oiReturnStatus      = -98
       viLocalReturnStatus = 0.
PPVHANDLINGBLOCK : DO :

    /* ======================================================================== */
    /* First check whether everything is available what is supposed to be avail */
    /* ======================================================================== */
    if not available tAPMatching        or  
       not available tAPMatchingLn      or
       not available tqPendingVoucherForMatchingAcc
    then do :
        assign viLocalReturnStatus  = -3
               vcMsgAPMatching      = trim(substitute(#T-16'Internal error: information that should have been available is not available.':254(999890202)T-16#)) + chr(10) + 
                                      trim(substitute(#T-17'Available matching header: &1.':234(49819)T-17#,available (tAPMatching)))  + chr(10) + 
                                      trim(substitute(#T-14'Available matching details: &1.':234(49820)T-14#,available (tAPMatchingLn))) + chr(10) + 
                                      trim(substitute(#T-20'Available accounting query: &1.':255(68803)T-20#,available (tqPendingVoucherForMatchingAcc))).
        <M-12 run SetMessage (input  vcMsgAPMatching (icMessage), 
                     input  '':U (icArguments), 
                     input  '':U (icFieldName), 
                     input  '':U (icFieldValue), 
                     input  'E':U (icType), 
                     input  3 (iiSeverity), 
                     input  '':U (icRowid), 
                     input  'QadFin-7833':U (icFcMsgNumber), 
                     input  '':U (icFcExplanation), 
                     input  '':U (icFcIdentification), 
                     input  '':U (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
        Leave PPVHANDLINGBLOCK.
    end. /* if not avail */

    /* Check if Logistics charges */
    if tAPMatchingLn.APMatchingLnPvodIsLgCharge        = true                           and
       tqPendingVoucherForMatchingAcc.tcpvo_order_type = {&PENDINGVOUCHER-ORDERTYPE-PO}
    then do:
        <M-75 run AdditionalUpdatesAllTaxGetLogChargePPV  (output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
        if viFcReturnSuper <> 0
        then assign viLocalReturnStatus = viFcReturnSuper.

        Leave PPVHANDLINGBLOCK.
    end.

    /* Check if item is an Inventory-item; this mean Normal and Sub-contract-items */
    if tqPendingVoucherForMatchingAcc.tcprh_type = "":U or
       tqPendingVoucherForMatchingAcc.tcprh_type = "S":U
    then do :
        /* =========================================================================================================================== */
        /* Case 1: Get info from AccDeftMstr (acdf_acct): Domain + Module(PO) + Type (PO_PPV_ACCT) + ProductLine + Site + SupplierType */
        /* Case 2: Get info from AccDeftMstr (acdf_acct): Domain + Module(PO) + Type (PO_PPV_ACCT) + ProductLine + Site                */
        /* Case 3: Get info from the product-line (pl_ppv_acct): Domain + ProductLine                                                  */
        /* Case 4: Get info from the GL-control-file (gl_ppv_acct): Domain                                                             */
        /* =========================================================================================================================== */
        /* Get info from AccDeftMstr (acdf_acct): Domain + Module(PO) + Type (PO_PPV_ACCT) + ProductLine + Site + SupplierType */
        <Q-18 run AccountDefaultMasterByPrimKey (all) (Read) (Cache)
            (input tqPendingVoucherForMatchingAcc.tcpvo_domain, (DomainCode)
            input 'PO':U, (Module)
            input 'PO_PPV_ACCT':U, (Type)
            input tqPendingVoucherForMatchingAcc.tcpt_prod_line, (Key1)
            input tqPendingVoucherForMatchingAcc.tcprh_site, (Key2)
            input tqPendingVoucherForMatchingAcc.tcvd_type, (Key3)
            input '':U, (Key4)
            input '':U, (Key5)
            input '':U, (Key6)
            output dataset tqAccountDefaultMasterByPrimKey) in BMfgAccountDefaultMaster >
        find first tqAccountDefaultMasterByPrimKey where 
                   tqAccountDefaultMasterByPrimKey.tcacdf_domain = tqPendingVoucherForMatchingAcc.tcpvo_domain   and 
                   tqAccountDefaultMasterByPrimKey.tcacdf_key1   = tqPendingVoucherForMatchingAcc.tcpt_prod_line and 
                   tqAccountDefaultMasterByPrimKey.tcacdf_key2   = tqPendingVoucherForMatchingAcc.tcprh_site     and 
                   tqAccountDefaultMasterByPrimKey.tcacdf_key3   = tqPendingVoucherForMatchingAcc.tcvd_type      and 
                   tqAccountDefaultMasterByPrimKey.tcacdf_key4   = "":U                                          and 
                   tqAccountDefaultMasterByPrimKey.tcacdf_key5   = "":U                                          and
                   tqAccountDefaultMasterByPrimKey.tcacdf_key6   = "":U
                   no-lock no-error.
        if available tqAccountDefaultMasterByPrimKey and tqAccountDefaultMasterByPrimKey.tcacdf_acct <> "":U
        then 
            /* === Case 1: Get info from AccDeftMstr (acdf_acct): Domain + Module(PO) + Type (PO_PPV_ACCT) + ProductLine + Site + SupplierType */
            assign tAPMatchingLn.tcAPMatchingLnPVVGLCode  = tqAccountDefaultMasterByPrimKey.tcacdf_acct
                   tAPMatchingLn.tcAPMatchingLnPVVDivCode = tqAccountDefaultMasterByPrimKey.tcacdf_sub
                   tAPMatchingLn.tcAPMatchingLnPVVCCCode  = tqAccountDefaultMasterByPrimKey.tcacdf_cc.
        else do :
            /* Get info from AccDeftMstr (acdf_acct): Domain + Module(PO) + Type (PO_PPV_ACCT) + ProductLine + Site */
            <Q-19 run AccountDefaultMasterByPrimKey (all) (Read) (Cache)
               (input tqPendingVoucherForMatchingAcc.tcpvo_domain, (DomainCode)
                input 'PO':U, (Module)
                input 'PO_PPV_ACCT':U, (Type)
                input tqPendingVoucherForMatchingAcc.tcpt_prod_line, (Key1)
                input tqPendingVoucherForMatchingAcc.tcprh_site, (Key2)
                input '':U, (Key3)
                input '':U, (Key4)
                input '':U, (Key5)
                input '':U, (Key6)
                output dataset tqAccountDefaultMasterByPrimKey) in BMfgAccountDefaultMaster >
            find first tqAccountDefaultMasterByPrimKey where 
                       tqAccountDefaultMasterByPrimKey.tcacdf_domain = tqPendingVoucherForMatchingAcc.tcpvo_domain   and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key1   = tqPendingVoucherForMatchingAcc.tcpt_prod_line and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key2   = tqPendingVoucherForMatchingAcc.tcprh_site     and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key3   = "":U                                          and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key4   = "":U                                          and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key5   = "":U                                          and
                       tqAccountDefaultMasterByPrimKey.tcacdf_key6   = "":U
                       no-lock no-error.
            if available tqAccountDefaultMasterByPrimKey and tqAccountDefaultMasterByPrimKey.tcacdf_acct <> "":U
            then 
                /* === Case 2: Get info from AccDeftMstr (acdf_acct): Domain + Module(PO) + Type (PO_PPV_ACCT) + ProductLine + Site */
                assign tAPMatchingLn.tcAPMatchingLnPVVGLCode  = tqAccountDefaultMasterByPrimKey.tcacdf_acct
                       tAPMatchingLn.tcAPMatchingLnPVVDivCode = tqAccountDefaultMasterByPrimKey.tcacdf_sub
                       tAPMatchingLn.tcAPMatchingLnPVVCCCode  = tqAccountDefaultMasterByPrimKey.tcacdf_cc.
            else do :
                /* Get info from the product-line (pl_ppv_acct): Domain + ProductLine */
                <Q-24 run ProductLineForMatchingAcc (all) (Read) (Cache)
                   (input tqPendingVoucherForMatchingAcc.tcpvo_domain, (DomainCode)
                    input tqPendingVoucherForMatchingAcc.tcpt_prod_line, (ProductLineCode)
                    output dataset tqProductLineForMatchingAcc) in BMfgProductLine >
                find first tqProductLineForMatchingAcc where 
                           tqProductLineForMatchingAcc.tcpl_domain    = tqPendingVoucherForMatchingAcc.tcpvo_domain and 
                           tqProductLineForMatchingAcc.tcpl_prod_line = tqPendingVoucherForMatchingAcc.tcpt_prod_line
                           no-lock no-error.
                if available tqProductLineForMatchingAcc and tqProductLineForMatchingAcc.tcpl_apvr_acct <> "":U
                then
                    /* === Case 3: Get info from the product-line (pl_ppv_acct): Domain + ProductLine */
                    assign tAPMatchingLn.tcAPMatchingLnPVVGLCode  = tqProductLineForMatchingAcc.tcpl_ppv_acct
                           tAPMatchingLn.tcAPMatchingLnPVVDivCode = tqProductLineForMatchingAcc.tcpl_ppv_sub
                           tAPMatchingLn.tcAPMatchingLnPVVCCCode  = tqProductLineForMatchingAcc.tcpl_ppv_cc.
                else do :
                    /* Get info from the GL-control-file (gl_ppv_acct): Domain */
                    <Q-25 run SystemAccountControlForAll (all) (Read) (Cache)
                       (input tqPendingVoucherForMatchingAcc.tcpvo_domain, (DomainCode)
                        output dataset tqSystemAccountControlForAll) in BMfgSystemAccountControl >
                    find first tqSystemAccountControlForAll where 
                               tqSystemAccountControlForAll.tcgl_domain = tqPendingVoucherForMatchingAcc.tcpvo_domain
                               no-lock no-error.
                    if not available tqSystemAccountControlForAll
                    then do :
                        assign vcMsgAPMatching      = trim(substitute(#T-26'Unable to find System/Account Control for domain &1 while retrieving the Purchase-price-variances':255(733753805)T-26#,tqPendingVoucherForMatchingAcc.tcpvo_domain))
                               viLocalReturnStatus  = -1.
                        <M-28 run SetMessage
                           (input  vcMsgAPMatching (icMessage), 
                            input  '':U (icArguments), 
                            input  '':U (icFieldName), 
                            input  '':U (icFieldValue), 
                            input  'E':U (icType), 
                            input  3 (iiSeverity), 
                            input  '':U (icRowid), 
                            input  'QadFin-7834':U (icFcMsgNumber), 
                            input  '':U (icFcExplanation), 
                            input  '':U (icFcIdentification), 
                            input  '':U (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
                        Leave PPVHANDLINGBLOCK.
                    end. /* if not available tqSystemAccountControlForAll */
                    /* === Case 4: Get info from the GL-control-file (gl_ppv_acct): Domain */
                    assign tAPMatchingLn.tcAPMatchingLnPVVGLCode  = tqSystemAccountControlForAll.tcgl_ppv_acct
                           tAPMatchingLn.tcAPMatchingLnPVVDivCode = tqSystemAccountControlForAll.tcgl_ppv_sub
                           tAPMatchingLn.tcAPMatchingLnPVVCCCode  = tqSystemAccountControlForAll.tcgl_ppv_cc.
                end. /* if available tqProductLineForMatchingAcc and tqProductLineForMatchingAcc.tcpl_apvr_acct <> "":U */
            end. /* Not if available tqAccountDefaultMasterByPrimKey and tqAccountDefaultMasterByPrimKey.tcacdf_acct <> "":U */
        end. /* Not if available tqAccountDefaultMasterByPrimKey and tqAccountDefaultMasterByPrimKey.tcacdf_acct <> "":U */
    end. /* if tqPendingVoucherForMatchingAcc.tcprh_type = "":U or */
    else do:
        /* For Non-Inventory Items */
        /* === Case 7 : Get info from the APMatchingLine/Pvod*/
        assign tAPMatchingLn.tcAPMatchingLnPVVGLCode  = tAPMatchingLn.tcGLCode
               tAPMatchingLn.tcAPMatchingLnPVVDivCode = tAPMatchingLn.tcDivisionCode 
               tAPMatchingLn.tcAPMatchingLnPVVCCCode  = tAPMatchingLn.tcCostCentreCode.
    end.  /* if not tqPendingVoucherForMatchingAcc.tcprh_type = "":U */
END. /* PPVHANDLINGBLOCK */

/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = viLocalReturnStatus.