project QadFinancials > class BAPMatching > method GetGLPLVarRateLogCharge

Description

AdditionalUpdatesAllLinesPLVarRateLogCharge; submethod of AdditionalUpdatesAllLinesPLVarRate that is located in the same segment. This method takes about find thie correct accounting information to create a posting-line for the Rate-Variance (difference in price) for Logistic-charges.


Parameters


icAPMatchingLnGLCodeinputcharacter
icAPMatchingLnDivCodeinputcharacter
icAPMatchingLnCCCodeinputcharacter
ilAPMatchingLnIsVarGLPostinginputlogical
idAPMatchingLnMatchQtyinputdecimal
idAPMatchingLnMatchUnitPriceinputdecimal
icAPMatchingLnPvodCCCodeinputcharacter
icAPMatchingLnPvodCostMtdCurinputcharacter
icAPMatchingLnPvodCostMtdGLinputcharacter
icAPMatchingLnPvodDivCodeinputcharacter
icAPMatchingLnPvodGLCodeinputcharacter
ilAPMatchingLnPvodIsLgChargeinputlogical
icAPMatchingLnPvodIteminputcharacter
icAPMatchingLnPvodItemTypeinputcharacter
icAPMatchingLnPvodLgChargeinputcharacter
icAPMatchingLnPvodPrjCodeinputcharacter
idAPMatchingLnPvodReceiptQtyinputdecimal
icAPMatchingLnPvodSiteinputcharacter
idAPMatchingLnPvodUnitPriceinputdecimal
idAPMatchingLnVarRateTCinputdecimal
icPvoDomaininputcharacter
icPvodOpAllocCodeinputcharacterInput parameter: Pending voucher operational allocation code.
icOpAllocCodeinputcharacterInput parameter: Operational allocation code.
icpod_locinputcharacter
iipod_opinputinteger
icpod_wo_Lotinputcharacter
icprh_siteinputcharacter
icprh_typeinputcharacter
icprh_vendinputcharacter
icpt_prod_lineinputcharacter
icpt_siteinputcharacter
icpvo_order_typeinputcharacter
icpvo_shipfrominputcharacter
icpvo_shiptoinputcharacter
icpvod_channelinputcharacter
icpvod_shiptoinputcharacter
icvd_typeinputcharacter
ocGLCodeoutputcharacter
ocDivisionCodeoutputcharacter
ocCostCentreCodeoutputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BAPMatching.GetGLPLVarRate


program code (program6/bapmatching.p)

    /* =================================================================================================== */
    /* This method takes care of the creation of a posting-line for the RateVariance (difference in price) */
    /* of pending-vouchers with the Logistic-charges                                                       */
    /* =================================================================================================== */
    
    /* ======================================================================================== */
    /* Find out the correct GL, Division and CostCentre that are used for this posting-line     */
    /* Case 1: Get info from AccountDefaults (AccType,Charge,ProdLine,ShipTo,SupplType,Channel) */
    /* Case 2: Get info from AccountDefaults (AccType,Charge,ProdLine,ShipTo,SupplType)         */
    /* Case 3: Get info from AccountDefaults (AccType,Charge,ProdLine,ShipTo)                   */
    /* Case 4: Get info from AccountDefaults (AccType,Charge,ProdLine)                          */
    /* Case 5: Get info from AccountDefaults (AccType,Charge)                                   */
    /* Case 6: Get info from AccountDefaults (AccType,Charge,Special ProdLine)                  */
    /* Case 7: Get info from AccountDefaults (AccType)                                          */
    /* ======================================================================================== */
    /* Reset message-string and start a block; in case of a blocking error, we will leave the block */
    assign vcMsgAPMatching = "":U.
    FINDACCOUNTBLOCK: DO :
        /* Get account-type we will use to find the correct acdf record */
        case icpvo_order_type:
            when {&PENDINGVOUCHER-ORDERTYPE-PO} then assign vcAccountType = "LA_IN_VAR_ACCT":U.
            when {&PENDINGVOUCHER-ORDERTYPE-SO} then assign vcAccountType = "LA_OUT_SO_VAR_ACCT":U.
            when {&PENDINGVOUCHER-ORDERTYPE-DO} then assign vcAccountType = "LA_OUT_DO_VAR_ACCT":U.
        end case.

        if vcAccountType = "":U
        then do: 
            assign vcMsgAPMatching = trim(substitute(#T-56'Cannot find the account type based on the order type (&1).':255(55797)t-56#,icpvo_order_type)) + chr(10) + 
                                     trim(substitute(#T-57'Technical details: &1.':222(55526)T-57#,"RateVar-Logistic/11":U)).
            Leave FINDACCOUNTBLOCK.
        end. /* If vcAccountType = "":U */
        
        /* Get Customer/Supplier type */
        assign vcCustSuplType = "":U.
        case icpvo_order_type:
            when {&PENDINGVOUCHER-ORDERTYPE-PO}
            then do:
                if icpvo_shipfrom <> ? and
                   icpvo_shipfrom <> "":U
                then do:
                    <Q-59 run SupplierByDomainAddress (all) (Read) (NoCache)
                       (input icPvoDomain, (Domain)
                        input icpvo_shipfrom, (Site)
                        output dataset tqSupplierByDomainAddress) in BMfgSupplier >
                    find first tqSupplierByDomainAddress no-error.
                    if available tqSupplierByDomainAddress
                    then assign vcCustSuplType = tqSupplierByDomainAddress.tcvd_type.
                end.
            end. /* when "PO" */
            
            when {&PENDINGVOUCHER-ORDERTYPE-SO} or
            when {&PENDINGVOUCHER-ORDERTYPE-DO}
            then do:
                if icpvod_shipto <> ? and
                   icpvod_shipto <> "":U
                then do:
                    <Q-58 run CustomerByDomainAddress (all) (Read) (NoCache)
                       (input icPvoDomain, (DomainCode)
                        input icpvod_shipto, (Address)
                        output dataset tqCustomerByDomainAddress) in BMfgCustomer >
                    find first tqCustomerByDomainAddress no-error.
                    if available tqCustomerByDomainAddress
                    then assign vcCustSuplType = tqCustomerByDomainAddress.tccm_type.
                end.
            end. /* when "SO" */
        end case.

        /* Find acdf (account defaults) ; PurchaseAccountDef */
        /* === Case 1: Get info from AccountDefaults (AccType,Charge,ProdLine,ShipTo,SupplType,Channel) */
        <Q-41 run AccountDefaultMasterByPrimKey (all) (Read) (Cache)
           (input icPvoDomain, (DomainCode)
            input 'LA':U, (Module)
            input vcAccountType, (Type)
            input icAPMatchingLnPvodLgCharge, (Key1)
            input icpt_prod_line, (Key2)
            input icpvo_shipto, (Key3)
            input vcCustSuplType, (Key4)
            input icpvod_channel, (Key5)
            input '':U, (Key6)
            output dataset tqAccountDefaultMasterByPrimKey) in BMfgAccountDefaultMaster >
        find first tqAccountDefaultMasterByPrimKey where 
                   tqAccountDefaultMasterByPrimKey.tcacdf_domain = icPvoDomain    and 
                   tqAccountDefaultMasterByPrimKey.tcacdf_type   = vcAccountType                                  and 
                   tqAccountDefaultMasterByPrimKey.tcacdf_key1   = icAPMatchingLnPvodLgCharge and 
                   tqAccountDefaultMasterByPrimKey.tcacdf_key2   = icpt_prod_line  and 
                   tqAccountDefaultMasterByPrimKey.tcacdf_key3   = icpvo_shipto    and 
                   tqAccountDefaultMasterByPrimKey.tcacdf_key4   = vcCustSuplType                                 and 
                   tqAccountDefaultMasterByPrimKey.tcacdf_key5   = icpvod_channel  and 
                   tqAccountDefaultMasterByPrimKey.tcacdf_key6   = "":U
                   no-lock no-error.
        
        /* === Case 2: Get info from AccountDefaults (AccType,Charge,ProdLine,ShipTo,SupplType) */
        if not available tqAccountDefaultMasterByPrimKey or
           tqAccountDefaultMasterByPrimKey.tcacdf_acct = "":U
        then do:
            /* Find acdf (account defaults) ; PurchaseAccountDef */
            <Q-60 run AccountDefaultMasterByPrimKey (all) (Read) (Cache)
               (input icPvoDomain, (DomainCode)
                input 'LA':U, (Module)
                input vcAccountType, (Type)
                input icAPMatchingLnPvodLgCharge, (Key1)
                input icpt_prod_line, (Key2)
                input icpvo_shipto, (Key3)
                input vcCustSuplType, (Key4)
                input '':U, (Key5)
                input '':U, (Key6)
                output dataset tqAccountDefaultMasterByPrimKey) in BMfgAccountDefaultMaster >
            find first tqAccountDefaultMasterByPrimKey where 
                       tqAccountDefaultMasterByPrimKey.tcacdf_domain = icPvoDomain    and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_type   = vcAccountType                                  and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key1   = icAPMatchingLnPvodLgCharge and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key2   = icpt_prod_line  and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key3   = icpvo_shipto    and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key4   = vcCustSuplType                                 and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key5   = "":U                                           and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key6   = "":U
                       no-lock no-error.
        end.
        
        /* === Case 3: Get info from AccountDefaults (AccType,Charge,ProdLine,ShipTo) */    
        if not available tqAccountDefaultMasterByPrimKey or
           tqAccountDefaultMasterByPrimKey.tcacdf_acct = "":U
        then do:
            /* Find acdf (account defaults) ; PurchaseAccountDef */
            <Q-49 run AccountDefaultMasterByPrimKey (all) (Read) (Cache)
               (input icPvoDomain, (DomainCode)
                input 'LA':U, (Module)
                input vcAccountType, (Type)
                input icAPMatchingLnPvodLgCharge, (Key1)
                input icpt_prod_line, (Key2)
                input icpvo_shipto, (Key3)
                input '':U, (Key4)
                input '':U, (Key5)
                input '':U, (Key6)
                output dataset tqAccountDefaultMasterByPrimKey) in BMfgAccountDefaultMaster >
            find first tqAccountDefaultMasterByPrimKey where 
                       tqAccountDefaultMasterByPrimKey.tcacdf_domain = icPvoDomain    and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_type   = vcAccountType                                  and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key1   = icAPMatchingLnPvodLgCharge and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key2   = icpt_prod_line  and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key3   = icpvo_shipto    and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key4   = "":U                                           and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key5   = "":U                                           and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key6   = "":U
                       no-lock no-error.
        end.    
            
        /* === Case 4: Get info from AccountDefaults (AccType,Charge,ProdLine) */            
        if not available tqAccountDefaultMasterByPrimKey or
           tqAccountDefaultMasterByPrimKey.tcacdf_acct = "":U
        then do:
            <Q-50 run AccountDefaultMasterByPrimKey (all) (Read) (Cache)
               (input icPvoDomain, (DomainCode)
                input 'LA':U, (Module)
                input vcAccountType, (Type)
                input icAPMatchingLnPvodLgCharge, (Key1)
                input icpt_prod_line, (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 = icPvoDomain    and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_type   = vcAccountType                                  and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key1   = icAPMatchingLnPvodLgCharge and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key2   = icpt_prod_line  and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key3   = "":U                                           and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key4   = "":U                                           and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key5   = "":U                                           and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key6   = "":U
                       no-lock no-error.
        end.
                        
        /* === Case 5: Get info from AccountDefaults (AccType,Charge) */
        if not available tqAccountDefaultMasterByPrimKey or
           tqAccountDefaultMasterByPrimKey.tcacdf_acct = "":U
        then do:
            <Q-51 run AccountDefaultMasterByPrimKey (all) (Read) (Cache)
               (input icPvoDomain, (DomainCode)
                input 'LA':U, (Module)
                input vcAccountType, (Type)
                input icAPMatchingLnPvodLgCharge, (Key1)
                input '':U, (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 = icPvoDomain    and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_type   = vcAccountType                                  and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key1   = icAPMatchingLnPvodLgCharge and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key2   = "":U                                           and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key3   = "":U                                           and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key4   = "":U                                           and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key5   = "":U                                           and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key6   = "":U
                       no-lock no-error.
        end.                
            
        /* === Case 6: Get info from AccountDefaults (AccType, special product line) */    
        if not available tqAccountDefaultMasterByPrimKey or
           tqAccountDefaultMasterByPrimKey.tcacdf_acct = "":U
        then do:
            <Q-52 run AccountDefaultMasterByPrimKey (all) (Read) (Cache)
               (input icPvoDomain, (DomainCode)
                input 'LA':U, (Module)
                input vcAccountType, (Type)
                input icAPMatchingLnPvodLgCharge, (Key1)
                input '********':U, (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 = icPvoDomain    and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_type   = vcAccountType                                  and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key1   = icAPMatchingLnPvodLgCharge and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key2   = "********":U                                   and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key3   = "":U                                           and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key4   = "":U                                           and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key5   = "":U                                           and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key6   = "":U
                       no-lock no-error.
        end.
            
        /* === Case 7: Get info from AccountDefaults (AccType) */    
        if not available tqAccountDefaultMasterByPrimKey or
           tqAccountDefaultMasterByPrimKey.tcacdf_acct = "":U
        then do:    
            <Q-54 run AccountDefaultMasterByPrimKey (all) (Read) (NoCache)
               (input icPvoDomain, (DomainCode)
                input 'LA':U, (Module)
                input vcAccountType, (Type)
                input '':U, (Key1)
                input '':U, (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 = icPvoDomain    and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_type   = vcAccountType                                  and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key1   = "":U                                           and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key2   = "":U                                           and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key3   = "":U                                           and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key4   = "":U                                           and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key5   = "":U                                           and 
                       tqAccountDefaultMasterByPrimKey.tcacdf_key6   = "":U
                       no-lock no-error.
        end.
        
        /* === Assign G/L account, Division and cost centre */
        if available tqAccountDefaultMasterByPrimKey
        then assign vcGLCode         = tqAccountDefaultMasterByPrimKey.tcacdf_acct
                    vcDivisionCode   = tqAccountDefaultMasterByPrimKey.tcacdf_sub
                    vcCostCentreCode = tqAccountDefaultMasterByPrimKey.tcacdf_cc.
    END. /* FINDACCOUNTBLOCK */
    
    /* ================================== */
    /* Raise error if GL is not yet known */
    /* ================================== */
    if vcMsgAPMatching <> "":U
    then do :
        assign oiReturnStatus = -3.
        <M-23 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-5525':U (icFcMsgNumber), 
                     input  '':U (icFcExplanation), 
                     input  '':U (icFcIdentification), 
                     input  '':U (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
        Return.
    end. /* if vcMsgAPMatching <> "":U */
    
    /* ======================== */
    /* Assign output parameters */
    /* Set ReturnStatus = OK    */
    /* ======================== */
    assign ocGLCode         = vcGLCode
           ocDivisionCode   = vcDivisionCode
           ocCostCentreCode = vcCostCentreCode.
    if oiReturnStatus = -98
    then assign oiReturnStatus = 0.