Description
AdditionalUpdatesAllLinesPLVarRateLNorma;; 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 NON-discrepancy.
Parameters
| icAPMatchingLnGLCode | input | character | |
| icAPMatchingLnDivCode | input | character | |
| icAPMatchingLnCCCode | input | character | |
| ilAPMatchingLnIsVarGLPosting | input | logical | |
| idAPMatchingLnMatchQty | input | decimal | |
| idAPMatchingLnMatchUnitPrice | input | decimal | |
| icAPMatchingLnPvodCCCode | input | character | |
| icAPMatchingLnPvodCostMtdCur | input | character | |
| icAPMatchingLnPvodCostMtdGL | input | character | |
| icAPMatchingLnPvodDivCode | input | character | |
| icAPMatchingLnPvodGLCode | input | character | |
| ilAPMatchingLnPvodIsLgCharge | input | logical | |
| icAPMatchingLnPvodItem | input | character | |
| icAPMatchingLnPvodItemType | input | character | |
| icAPMatchingLnPvodLgCharge | input | character | |
| icAPMatchingLnPvodPrjCode | input | character | |
| idAPMatchingLnPvodReceiptQty | input | decimal | |
| icAPMatchingLnPvodSite | input | character | |
| idAPMatchingLnPvodUnitPrice | input | decimal | |
| idAPMatchingLnVarRateTC | input | decimal | |
| icPvoDomain | input | character | |
| icPvodOpAllocCode | input | character | input parameter: pending voucher opeational allocation code. |
| icOpAllocCode | input | character | input parameter: operational allocation code. |
| icpod_loc | input | character | |
| iipod_op | input | integer | |
| icpod_wo_Lot | input | character | |
| icprh_site | input | character | |
| icprh_type | input | character | |
| icprh_vend | input | character | |
| icpt_prod_line | input | character | |
| icpt_site | input | character | |
| icpvo_order_type | input | character | |
| icpvo_shipfrom | input | character | |
| icpvo_shipto | input | character | |
| icpvod_channel | input | character | |
| icpvod_shipto | input | character | |
| icvd_type | input | character | |
| ocGLCode | output | character | |
| ocDivisionCode | output | character | |
| ocCostCentreCode | output | character | CostCentreCode |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bapmatching.p)
/* ======================================================================== */
/* This method takes care of the creation of a posting-line for the Rate */
/* Variance of pending-vouchers with no Logistic-charges and no discrepancy */
/* =========================================================================== */
/* Find out the correct GL, Div and CC that are used for this posting-line */
/* Case 1 : Get info from open WorkOrder */
/* Case 2 : Get info from AccDeftMstr (incl suppl-type) + type=PO_APVR_ACCT) */
/* Case 3 : Get info from AccDeftMstr (excl suppl-type) + type=PO_APVR_ACCT) */
/* Case 4 : Get info from ProdLine (pl_apvr_acct) */
/* Case 5 : Get info from GLControlFile (gl_apvr_acct) */
/* Case 6 : Get info from GLControlFile (gl_apvrx_acct) */
/* Case 7 : Get info from the APMatchingLine/Pvod */
/* Case 8 : Get info from AccDeftMstr (incl suppl-type) + type=PO_PUR_ACCT) */
/* Case 9 : Get info from AccDeftMstr (excl suppl-type) + type=PO_PUR_ACCT) */
/* Case 10: Get info from ProductLine (pl_pur_acct) */
/* Case 11: Get info from Creditor */
/* =========================================================================== */
/* Reset message-string and start a block; in case of a blocking error, we will leave the block */
assign vcMsgAPMatching = "":U.
FINDACCOUNTBLOCK: DO :
/* First check the inventroy control-file */
<Q-28 run DomainForInventoryControlFile (all) (Read) (Cache)
(input icPvoDomain, (DomainCode)
output dataset tqDomainForInventoryControlFile) in BMfgDomain >
find first tqDomainForInventoryControlFile where
tqDomainForInventoryControlFile.tcicc_domain = icPvoDomain
no-lock no-error.
if not available tqDomainForInventoryControlFile
then do :
assign vcMsgAPMatching = trim(substitute(#T-32'The inventory control account(&1) is not defined for domain '&2'.':255(49363)T-32#,"ICC_CTRL":U,icPvoDomain)) + chr(10) +
trim(substitute(#T-37'Technical details: &1.':222(55526)T-37#,"RateVar-Normal/2":U)).
Leave FINDACCOUNTBLOCK.
end. /* if not available tqDomainForInventoryControlFile */
/* Secondly check the PO-receipt history of the pendingvoucher - find was already done in the calling procedure */
If tqDomainForInventoryControlFile.tlicc_gl_tran = true
then do :
if icprh_type = "":U or
icprh_type = "S":U
then do :
/* Check if the Type=SubContract and CostOfMaterial needs to be updated and RateVar shoudl be posted to WIP */
if icprh_type = "S":U and
ilAPMatchingLnIsVarGLPosting = false and
(icAPMatchingLnPvodCostMtdGL = {&COSTMETHOD-AVERAGE} or
icAPMatchingLnPvodCostMtdCur = {&COSTMETHOD-AVERAGE} or
icAPMatchingLnPvodCostMtdCur = {&COSTMETHOD-LAST})
then do:
<Q-64 run WorkOrderRoutingByDomLotOper (all) (Read) (Cache)
(input icPvoDomain, (DomainCode)
input icpod_wo_Lot, (Lot)
input false, (AccountingClosed)
input iipod_op, (Operation)
input ?, (WorkOrderNumber)
output dataset tqWorkOrderRoutingByDomLotOper) in BMfgWorkOrder>
Find first tqWorkOrderRoutingByDomLotOper where
tqWorkOrderRoutingByDomLotOper.tcwo_domain = icPvoDomain and
tqWorkOrderRoutingByDomLotOper.tcwo_lot = icpod_wo_lot and
tqWorkOrderRoutingByDomLotOper.tiwr_op = iipod_op
no-lock no-error.
if available tqWorkOrderRoutingByDomLotOper and tqWorkOrderRoutingByDomLotOper.tcwo_acct <> "":U
then do :
/* === Case 1 : Get info from open WorkOrder */
assign vcGLCode = tqWorkOrderRoutingByDomLotOper.tcwo_acct
vcDivisionCode = tqWorkOrderRoutingByDomLotOper.tcwo_sub
vcCostCentreCode = tqWorkOrderRoutingByDomLotOper.tcwo_cc.
/* Leave the block in case we found the information here. Reason: the following code is not catched in an else-block because it has to be executed in case the information was not found here */
Leave FINDACCOUNTBLOCK.
end. /* if available WO */
end. /* if icprh_type = "S":U and */
/* Find acdf (account defaults) ; PurchaseAccountDef (incl supplier-type */
<Q-40 run AccountDefaultMasterByPrimKey (all) (Read) (Cache)
(input icPvoDomain, (DomainCode)
input 'PO':U, (Module)
input 'PO_APVR_ACCT':U, (Type)
input icpt_prod_line, (Key1)
input icprh_site, (Key2)
input icvd_type, (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_key1 = icpt_prod_line and
tqAccountDefaultMasterByPrimKey.tcacdf_key2 = icprh_site and
tqAccountDefaultMasterByPrimKey.tcacdf_key3 = icvd_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 2 : Get info from AccountDefaultMaster (incl suppl-type) + type=PO_APVR_ACCT) */
assign vcGLCode = tqAccountDefaultMasterByPrimKey.tcacdf_acct
vcDivisionCode = tqAccountDefaultMasterByPrimKey.tcacdf_sub
vcCostCentreCode = tqAccountDefaultMasterByPrimKey.tcacdf_cc.
else do :
/* Find acdf (account defaults) ; PurchaseAccountDef (incl supplier-type */
<Q-41 run AccountDefaultMasterByPrimKey (all) (Read) (Cache)
(input icPvoDomain, (DomainCode)
input 'PO':U, (Module)
input 'PO_APVR_ACCT':U, (Type)
input icpt_prod_line, (Key1)
input icprh_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 = icPvoDomain and
tqAccountDefaultMasterByPrimKey.tcacdf_key1 = icpt_prod_line and
tqAccountDefaultMasterByPrimKey.tcacdf_key2 = icprh_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 3 : Get info from AccountDefaultMaster (excl suppl-type) + type=PO_APVR_ACCT) */
assign vcGLCode = tqAccountDefaultMasterByPrimKey.tcacdf_acct
vcDivisionCode = tqAccountDefaultMasterByPrimKey.tcacdf_sub
vcCostCentreCode = tqAccountDefaultMasterByPrimKey.tcacdf_cc.
else do :
/* Find pl_rcpt in the pl_mstr - product-line */
<Q-42 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_apvr_acct <> "":U
then
/* === Case 4 : Get info from ProdLine (pl_apvr_acct) */
assign vcGLCode = tqProductLineForMatchingAcc.tcpl_apvr_acct
vcDivisionCode = tqProductLineForMatchingAcc.tcpl_apvr_sub
vcCostCentreCode = tqProductLineForMatchingAcc.tcpl_apvr_cc.
else do:
/* Find the control-file for the system-accounts */
<Q-68 run SystemAccountControlForAll (all) (Read) (Cache)
(input icPvoDomain, (DomainCode)
output dataset tqSystemAccountControlForAll) in BMfgSystemAccountControl >
find first tqSystemAccountControlForAll where
tqSystemAccountControlForAll.tcgl_domain = icPvoDomain
no-lock no-error.
if not available tqSystemAccountControlForAll
then do :
assign vcMsgAPMatching = trim(substitute(#T-44'Domain/Account Control settings are not defined for domain: &1':255(49763)T-44#,icPvoDomain)) + chr(10) +
trim(substitute(#T-45'Technical details: &1.':222(55526)T-45#,"RateVar-Normal/5":U)).
Leave FINDACCOUNTBLOCK.
end. /* if not available tqSystemAccountControlForAll */
/* === Case 5 : Get info from GLControlFile (gl_apvr_acct) */
assign vcGLCode = tqSystemAccountControlForAll.tcgl_apvr_acct
vcDivisionCode = tqSystemAccountControlForAll.tcgl_apvr_sub
vcCostCentreCode = tqSystemAccountControlForAll.tcgl_apvr_cc.
end. /* Not if available tqProductLineForMatchingAcc */
end. /* Not if available tqAccountDefaultMasterByPrimKey */
end. /* Not if available tqAccountDefaultMasterByPrimKey */
end. /* if icprh_type = "":U or */
else do :
/* Check if we want to use the Expense-account fot the variance; Find the control-file for the accounts-payable */
<Q-46 run AccountsPayableCtrlByDomain (all) (Read) (Cache)
(input icPvoDomain, (DomainCode)
output dataset tqAccountsPayableCtrlByDomain) in BMfgAccountPayableCtrl >
find first tqAccountsPayableCtrlByDomain where
tqAccountsPayableCtrlByDomain.tcapc_domain = icPvoDomain
no-lock no-error.
if not available tqAccountsPayableCtrlByDomain
then do :
assign vcMsgAPMatching = trim(substitute(#T-49'The accounts payable control account is not defined for domain: &1':255(53328)T-49#,icPvoDomain)) + chr(10) +
trim(substitute(#T-50'Technical details: case: &1.':222(49764)T-50#,"RateVar-Normal/6/1":U)).
Leave FINDACCOUNTBLOCK.
end. /* if not available tqAccountsPayableCtrlByDomain */
if tqAccountsPayableCtrlByDomain.tlapc_expvar = true /* Use Expense Account for Variances? */
then do :
/* Find the control-file for the system-accounts */
<Q-47 run SystemAccountControlForAll (all) (Read) (Cache)
(input icPvoDomain, (DomainCode)
output dataset tqSystemAccountControlForAll) in BMfgSystemAccountControl >
find first tqSystemAccountControlForAll where
tqSystemAccountControlForAll.tcgl_domain = icPvoDomain
no-lock no-error.
if not available tqSystemAccountControlForAll
then do :
assign vcMsgAPMatching = trim(substitute(#T-51'Domain/Account Control settings are not defined for domain: &1':255(49763)T-51#,icPvoDomain)) + chr(10) +
trim(substitute(#T-52'Technical details: case: &1.':222(49764)T-52#,"RateVar-Normal/6/2":U)).
Leave FINDACCOUNTBLOCK.
end. /* if not available tqSystemAccountControlForAll */
/* === Case 6 : Get info from GLControlFile (gl_apvrx_acct) */
assign vcGLCode = tqSystemAccountControlForAll.tcgl_apvrx_acct
vcDivisionCode = tqSystemAccountControlForAll.tcgl_apvrx_sub
vcCostCentreCode = tqSystemAccountControlForAll.tcgl_apvrx_cc.
end. /* if tqAccountsPayableCtrlByDomain.tlapc_expvar = true */
else
/* === Case 7 : Get info from the APMatchingLine/Pvod*/
assign vcGLCode = icAPMatchingLnGLCode
vcDivisionCode = icAPMatchingLnDivCode
vcCostCentreCode = icAPMatchingLnCCCode.
end. /* Not if icprh_type = "":U or */
end. /* If tqDomainForInventoryControlFile.tlicc_gl_tran = true */
else do :
/* Check if item is an Inventory-item; this mean Normal and Sub-contract-items */
if icprh_type = "":U or
icprh_type = "S":U
then do :
/* Find acdf (account defaults) ; PurchaseAccountDef (incl supplier-type */
<Q-57 run AccountDefaultMasterByPrimKey (all) (Read) (Cache)
(input icPvoDomain, (DomainCode)
input 'PO':U, (Module)
input 'PO_PUR_ACCT':U, (Type)
input icpt_prod_line, (Key1)
input icprh_site, (Key2)
input icvd_type, (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_key1 = icpt_prod_line and
tqAccountDefaultMasterByPrimKey.tcacdf_key2 = icprh_site and
tqAccountDefaultMasterByPrimKey.tcacdf_key3 = icvd_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 8 : Get info from AccountDefaultMaster (incl suppl-type) + type=PO_PUR_ACCT) */
assign vcGLCode = tqAccountDefaultMasterByPrimKey.tcacdf_acct
vcDivisionCode = tqAccountDefaultMasterByPrimKey.tcacdf_sub
vcCostCentreCode = tqAccountDefaultMasterByPrimKey.tcacdf_cc.
else do :
/* Find acdf (account defaults) ; PurchaseAccountDef (incl supplier-type */
<Q-69 run AccountDefaultMasterByPrimKey (all) (Read) (Cache)
(input icPvoDomain, (DomainCode)
input 'PO':U, (Module)
input 'PO_PUR_ACCT':U, (Type)
input icpt_prod_line, (Key1)
input icprh_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 = icPvoDomain and
tqAccountDefaultMasterByPrimKey.tcacdf_key1 = icpt_prod_line and
tqAccountDefaultMasterByPrimKey.tcacdf_key2 = icprh_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 9 : Get info from AccountDefaultMaster (incl suppl-type) + type=PO_PUR_ACCT) */
assign vcGLCode = tqAccountDefaultMasterByPrimKey.tcacdf_acct
vcDivisionCode = tqAccountDefaultMasterByPrimKey.tcacdf_sub
vcCostCentreCode = tqAccountDefaultMasterByPrimKey.tcacdf_cc.
else do :
/* Find pl_rcpt in the pl_mstr - product-line */
<Q-58 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
then /* === Case 10 : Get info from ProductLine (pl_pur_acct) */
assign vcGLCode = tqProductLineForMatchingAcc.tcpl_pur_acct
vcDivisionCode = tqProductLineForMatchingAcc.tcpl_pur_sub
vcCostCentreCode = tqProductLineForMatchingAcc.tcpl_pur_cc.
end. /* Not if available tqAccountDefaultMasterByPrimKey */
end. /* Not if available tqAccountDefaultMasterByPrimKey */
end. /* Item is Inventory-item */
else do :
/* Check whether the supplier is defined on the pending-voucher */
if icprh_vend = "":U or
icprh_vend = ?
then do :
assign vcMsgAPMatching = trim(substitute(#T-62'The system cannot find the default accounting information for the supplier because the supplier is not specified on the pending invoice.':255(49769)T-62#,icprh_vend)) + chr(10) +
trim(substitute(#T-63'Technical details: case: &1.':222(49764)T-63#,"RateVar-Normal/10/1":U)).
Leave FINDACCOUNTBLOCK.
end. /* if icprh_vend = "":U */
/* CA779219 - take the account of the Matching Grid */
if (icAPMatchingLnGLCode <> '' and
icAPMatchingLnGLCode <> ?) or
(icPvodOpAllocCode <> '' and
icPvodOpAllocCode <> ?)
then do :
/* === Case 11: Get info from Creditor */
assign vcGLCode = icAPMatchingLnGLCode
vcDivisionCode = icAPMatchingLnDivCode
vcCostCentreCode = "":U.
end.
/* CA779219 */
else do :
/* Get the G/L and Division of the Creditor */
<Q-59 run CreditorForGLDivProfileDetails (all) (Read) (Cache)
(input tAPMatching.Company_ID, (CompanyId)
input icprh_vend, (CreditorCode)
output dataset tqCreditorForGLDivProfileDetails) in BCreditor >
Find first tqCreditorForGLDivProfileDetails where
tqCreditorForGLDivProfileDetails.tcCreditorCode = icprh_vend
no-lock no-error.
if not available tqCreditorForGLDivProfileDetails
then do :
assign vcMsgAPMatching = trim(substitute(#T-60'The system cannot find the default accounting information of supplier &1. Check the supplier definition.':255(49770)T-60#,icprh_vend)) + chr(10) +
trim(substitute(#T-66'Technical details: case: &1.':222(49764)T-66#,"RateVar-Normal/10/2":U)).
Leave FINDACCOUNTBLOCK.
end. /* if not available tqCreditorForGLDivProfileDetails */
/* === Case 11: Get info from Creditor */
assign vcGLCode = tqCreditorForGLDivProfileDetails.tcGLCode
vcDivisionCode = tqCreditorForGLDivProfileDetails.tcDivisionCode
vcCostCentreCode = "":U.
end.
end. /* Item is no Inventory-item */
end. /* If tqDomainForInventoryControlFile.tlicc_gl_tran = false */
END. /* FINDACCOUNTBLOCK */
/* ================================== */
/* Raise error if GL is not yet known */
/* ================================== */
if vcMsgAPMatching <> "":U
then do :
assign oiReturnStatus = -3.
<M-31 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-5527':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.