project QadFinancials > class BAPMatching > method GetGLPLVarRateDiscrepancy

Description

AdditionalUpdatesAllLinesPLVarRateDiscrepancy; 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 NON-Logistic-charges and Discrepancy.


Parameters


icAPMatchingLnGLCodeinputcharacter
icAPMatchingLnDivCodeinputcharacter
icAPMatchingLnCCCodeinputcharacter
ilAPMatchingLnIsVarGLPostinginputlogical
idAPMatchingLnMatchQtyinputdecimal
idAPMatchingLnMatchUnitPriceinputdecimal
icAPMatchingLnPvodCCCodeinputcharacter
icAPMatchingLnPvodCostMtdCurinputcharacter
icAPMatchingLnPvodCostMtdGLinputcharacter
icAPMatchingLnPvodDivCodeinputcharacter
icAPMatchingLnPvodGLCodeinputcharacter
ilAPMatchingLnPvodIsLgChargeinputlogical
icAPMatchingLnPvodIteminputcharacter
icAPMatchingLnPvodItemTypeinputcharacter
icAPMatchingLnPvodLgChargeinputcharacter
icAPMatchingLnPvodPrjCodeinputcharacter
idAPMatchingLnPvodReceiptQtyinputdecimal
icAPMatchingLnPvodSiteinputcharacter
idAPMatchingLnPvodUnitPriceinputdecimal
idAPMatchingLnVarRateTCinputdecimal
icPvoDomaininputcharacter
iiPvoIdinputinteger
iiPvodLineIDinputinteger
icPvodOpAllocCodeinputcharacterinputer 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
ocCostCentreCodeoutputcharacterCostCentreCode
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BAPMatching.GetGLPLVarRate


program code (program6/bapmatching.p)

    /* ==================================================================================== */
    /* Find out the correct Discrepancy GL, Division and CostCentre that are used for       */
    /* posting line created for the rate variance                                           */
    /*                                                                                      */
    /* Case 1: Get account from the product-line(global-domain, prod-line, site and loc     */
    /*         (only for positive receipts)                                                 */
    /* Case 2: Get accounts from the product-line-det (global-domain, prod-line and site)   */
    /* Case 3: Get accounts from the product-line (global-domain, prod-line)                */
    /* Case 4: Really fallback mechanism - get value from domain account control setting    */
    /* ==================================================================================== */
    FINDACCOUNTBLOCK: DO :
    
        assign vcGLCode         = "":U
               vcDivisionCode   = "":U
               vcCostCentreCode = "":U.

        /* === Case: 1 ===                                                                  */
        /* Find Product Line Discrepency Account Details in the pld_det - Inventory Account */
        if idAPMatchingLnPvodReceiptQty >= 0
        then do:
            <Q-7 run ProductLineDetForMatchingAcc (all) (Read) (NoCache)
               (input icPvoDomain, (DomainCode)
                input icpt_prod_line, (ProductLineCode)
                input icpt_site, (Site)
                input icpod_loc, (Location)
                output dataset tqProductLineDetForMatchingAcc) in BMfgProductLine>
           
            find first tqProductLineDetForMatchingAcc where 
                       tqProductLineDetForMatchingAcc.tcpld_domain   = icPvoDomain    and
                       tqProductLineDetForMatchingAcc.tcpld_prodline = icpt_prod_line and  
                       tqProductLineDetForMatchingAcc.tcpld_site     = icpt_site      and 
                       tqProductLineDetForMatchingAcc.tcpld_loc      = icpod_loc
                       no-error.
    
            if available tqProductLineDetForMatchingAcc and 
               tqProductLineDetForMatchingAcc.tcpld_dscracct <> "":U
            then do:
                assign vcGLCode         = tqProductLineDetForMatchingAcc.tcpld_dscracct
                       vcDivisionCode   = tqProductLineDetForMatchingAcc.tcpld_dscr_sub
                       vcCostCentreCode = tqProductLineDetForMatchingAcc.tcpld_dscr_cc.
                leave FINDACCOUNTBLOCK.
            end.
        end. /* if idAPMatchingLnPvodReceiptQty >= 0 */


        /* === Case: 2 ===                                                                        */
        /* Get accounts from the product-line-details (global-domain, prod-line and site=ship-to) */
        <Q-53 run ProductLineDetForMatchingAcc (all) (Read) (Cache)
           (input icPvoDomain, (DomainCode)
            input icpt_prod_line, (ProductLineCode)
            input icpvo_shipto, (Site)
            input '':U, (Location)
            output dataset tqProductLineDetForMatchingAcc) in BMfgProductLine >
			
        find first tqProductLineDetForMatchingAcc where 
                   tqProductLineDetForMatchingAcc.tcpld_domain   = icPvoDomain     and 
                   tqProductLineDetForMatchingAcc.tcpld_prodline = icpt_prod_line   and 
                   tqProductLineDetForMatchingAcc.tcpld_site     = icpvo_shipto     and
                   tqProductLineDetForMatchingAcc.tcpld_loc      = "":U
                   no-lock no-error.
        if available tqProductLineDetForMatchingAcc and 
           tqProductLineDetForMatchingAcc.tcpld_dscracct <> "":U
        then do:
            assign vcGLCode         = tqProductLineDetForMatchingAcc.tcpld_dscracct
                   vcDivisionCode   = tqProductLineDetForMatchingAcc.tcpld_dscr_sub
                   vcCostCentreCode = tqProductLineDetForMatchingAcc.tcpld_dscr_cc.
            leave FINDACCOUNTBLOCK.
        end. 
        

        /* === Case: 3 ===                                                                      */
        /* Get accounts from the product-line (global-domain, prod-line)                        */
        <Q-50 run ProductLineForMatchingAcc (all) (Read) (Cache)
           (input icPvoDomain, (DomainCode)
            input icpt_prod_line, (ProductLineCode)
            output dataset tqProductLineForMatchingAcc) in BMfgProductLine >
        find first tqProductLineForMatchingAcc where 
                   tqProductLineForMatchingAcc.tcpl_domain    = icPvoDomain and 
                   tqProductLineForMatchingAcc.tcpl_prod_line = icpt_prod_line
                   no-lock no-error.
        if available tqProductLineForMatchingAcc and 
           tqProductLineForMatchingAcc.tcpl_dscr_acct <> "":U
        then do:
            assign vcGLCode         = tqProductLineForMatchingAcc.tcpl_dscr_acct
                   vcDivisionCode   = tqProductLineForMatchingAcc.tcpl_dscr_sub
                   vcCostCentreCode = tqProductLineForMatchingAcc.tcpl_dscr_cc.
            leave FINDACCOUNTBLOCK.
        end.
            
            
            
        /* === Case: 4 ====                                                                    */
        /* Fall-back mechanism - look at system control account setting                        */
        <Q-74 run SystemAccountControlForAll (all) (Read) (Cache)
           (input icPvoDomain, (DomainCode)
            output dataset tqSystemAccountControlForAll) in BMfgSystemAccountControl>
        find first tqSystemAccountControlForAll where 
                   tqSystemAccountControlForAll.tcgl_domain = icPvoDomain
                   no-error.
                   
        if available tqSystemAccountControlForAll and
           tqSystemAccountControlForAll.tcgl_dscr_acct <> "":U 
        then do:
            assign vcGLCode         = tqSystemAccountControlForAll.tcgl_dscr_acct
                   vcDivisionCode   = tqSystemAccountControlForAll.tcgl_dscr_sub
                   vcCostCentreCode = tqSystemAccountControlForAll.tcgl_dscr_cc.
            leave FINDACCOUNTBLOCK.
        end.

    END. /* FINDACCOUNTBLOCK */
    
    /* ========================================= */
    /* Check wether we have a G/L account by now */
    /* ========================================= */
    if (vcGLCode = "":U or 
        vcGLCode = ?)  and
       (icOpAllocCode = "":U or
        icOpAllocCode = ?)
    then do:
        assign oiReturnStatus  = -3
               vcMsgAPMatching = trim(substitute(#T-52'The system cannot find the required accounting information in the pending invoice details to create the posting line on the rate variances for discrepancy (Domain:&1, Pinv: &2, Pinv det: &3).':255(55541)t-52#,icPvoDomain, iiPvoID, iiPvodLineID)).
        <M-51 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-5532':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
        return.
    end. /* if vcGLCode = "":U or */
    
    /* ======================== */
    /* Assign output parameters */
    /* ======================== */
    assign ocGLCode         = vcGLCode
           ocDivisionCode   = vcDivisionCode
           ocCostCentreCode = vcCostCentreCode.