report procedure
Parameters
Internal usage
unused
program code (program7/bapmatchingreport.p)
empty temp-table tqMatchingVarianceForLC.
<M-2 run GetReportLabels
(input 'MatchingVarianceForLC':U (icReportName),
input icLanguageCode (icLanguageCode),
input tFilter (tFilter),
output tqHeader (tqHeader),
output tqFilter (tqFilter),
output tqText (tqText),
output viFcReturnSuper (oiReturnStatus)) in BAPMatchingReport>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus >= 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
<M-3 run SetDataItemsBasedOnFilterTT
(output viFcReturnSuper (oiReturnStatus)) in BAPMatchingReport>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus >= 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
assign vlIsLgCharge = true.
assign vlIsAvailable = true.
if vlIncludeInventory = ? then assign vlIncludeInventory = false.
if vlIsBlankSupplierFilter = ? then assign vlIsBlankSupplierFilter = false.
if vlShowPostingDetailsFilter = ? then assign vlShowPostingDetailsFilter = false.
if vlShowPostingDetailsFilter then
do:
<Q-4 run SelectGL (all) (Read) (NoCache)
(input ?, (CompanyId)
output dataset tqSelectGL) in BGL >
<Q-5 run SelectDivision (all) (Read) (NoCache)
(input ?, (CompanyId)
output dataset tqSelectDivision) in BDivision >
<Q-6 run SelectCostCentre (all) (Read) (NoCache)
(input ?, (CompanyId)
output dataset tqSelectCostCentre) in BCostCentre >
<Q-7 run SelectProject (all) (Read) (NoCache)
(input ?, (CompanyId)
output dataset tqSelectProject) in BProject >
<Q-8 run SelectCurrency (all) (Read) (NoCache) (output dataset tqSelectCurrency) in BCurrency >
end. /*if vlShowPostingDetailsFilter then*/
if vtFromPODateFilter <> ? or vtToPODateFilter <> ? then
do:
if vcOrderTypeFilter = ? or can-do({&APMATCHINGLNPVODORDERTYPE-PURCHASE},vcOrderTypeFilter) then
do:
<Q-17 run PurchaseOrderByOrderDate (all) (Read) (NoCache)
(input vtFromPODateFilter, (FromOrderDate)
input vtToPODateFilter, (ToOrderDate)
output dataset tqPurchaseOrderByOrderDate) in BMfgPO >
end.
if vcOrderTypeFilter = ? or can-do({&APMATCHINGLNPVODORDERTYPE-SALES},vcOrderTypeFilter) then
do:
<Q-18 run SalesOrderByOrderDate (all) (Read) (NoCache)
(input vtFromPODateFilter, (FromOrderDate)
input vtToPODateFilter, (ToOrderDate)
output dataset tqSalesOrderByOrderDate) in BMfgSalesOrder >
end.
if vcOrderTypeFilter = ? or can-do({&APMATCHINGLNPVODORDERTYPE-DISTRIB},vcOrderTypeFilter) then
do:
<Q-19 run DistSiteOrderByOrderDate (all) (Read) (NoCache)
(input vtFromPODateFilter, (FromOrderDate)
input vtToPODateFilter, (ToOrderDate)
output dataset tqDistSiteOrderByOrderDate) in BAPMatchingReport >
end.
end. /*if vtFromPODateFilter <> ? or vtToPODateFilter <> ? then*/
<Q-9 run CInvoiceForMatchingVariance (all) (Read) (NoCache)
(input vcCreditorCodeFromFilter, (FromCreditorCode)
input vcCreditorCodeToFilter, (ToCreditorCode)
input vcCompanyFilter, (CompanyCode)
input vcFromLgChargeFilter, (FromLogisticCharge)
input ?, (CompanyId)
input vcFromPurchaseOrderFilter, (FromPurchaseOrder)
input vcToPurchaseOrderFilter, (ToPurchaseOrder)
input vcFromItemFilter, (FromItem)
input vcToItemFilter, (ToItem)
input vtFromInvoiceDateFilter, (FromInvoiceDate)
input vtToInvoiceDateFilter, (ToInvoiceDate)
input vcSiteFilter, (ReceiptSite)
input vcCurrFilter, (CurrencyCode)
input vcToLgChargeFilter, (ToLogisticCharge)
input vlIsLgCharge, (IsLgCharge)
input vtFromInvoicePostDateFilter, (FromInvoicePostingDt)
input vtToInvoicePostDateFilter, (ToInvoicePostingDt)
input ?, (OrderType)
input ?, (DomainId)
output dataset tqCInvoiceForMatchingVariance) in BAPMatchingReport>
for each tqCInvoiceForMatchingVariance where
(if vlIncludeInventory then
true else
tqCInvoiceForMatchingVariance.tcAPMatchingLnPvodItemType <> {&APMATCHINGLNPVODITEMTYPE-NORMAL}) and
(if vdShowVarOverPerFilter <> 0 and vdShowVarOverPerFilter <> ? then
(((tqCInvoiceForMatchingVariance.tdAPMatchingLnVarRateLC + tqCInvoiceForMatchingVariance.tdAPMatchingLnVarUsageLC) * 100 /
tqCInvoiceForMatchingVariance.tdAPMatchingLnReceiptAmtLC) > vdShowVarOverPerFilter)
else true) and
(if vdShowVarOverAmtFilter <> 0 and vdShowVarOverAmtFilter <> ? then
((tqCInvoiceForMatchingVariance.tdAPMatchingLnVarRateLC + tqCInvoiceForMatchingVariance.tdAPMatchingLnVarUsageLC) > vdShowVarOverAmtFilter)
else true):
create tGetMatchingVariance.
buffer-copy tqCInvoiceForMatchingVariance to tGetMatchingVariance.
end. /*for each tqCInvoiceForMatchingVariance where*/
<Q-20 run PendingVoucherForOrderType (Start) in BAPMatchingReport >
<Q-11 run PostingLineByPostingLnId (Start) in BPosting >
for each tGetMatchingVariance break by tGetMatchingVariance.tiCInvoice_ID:
<Q-16 run PendingVoucherForOrderType (all) (Read) (NoCache)
(input tGetMatchingVariance.tcPvoDomain, (PvoDomain)
input tGetMatchingVariance.tiPvoID, (PvoId)
input tGetMatchingVariance.tiPvodLineID, (PvoLineId)
input vcBuyerFilter, (Buyer)
input vcFromInternalRefFilter, (FromInternalRef)
input vcToInternalRefFilter, (ToInternalRef)
output dataset tqPendingVoucherForOrderType) in BAPMatchingReport >
find first tqPendingVoucherForOrderType no-error.
if available tqPendingVoucherForOrderType then
do:
if vlIsBlankSupplierFilter and
(tqPendingVoucherForOrderType.tcpvo_supplier <> "":U or
tqPendingVoucherForOrderType.tcpvo_supplier <> ?) then
next.
if vtFromPODateFilter <> ? or vtToPODateFilter <> ? then
do:
assign vlIsAvailable = false.
if tqPendingVoucherForOrderType.tcpvo_order_type = "01":U and
(vcOrderTypeFilter = ? or can-do({&APMATCHINGLNPVODORDERTYPE-PURCHASE},vcOrderTypeFilter)) then
do:
for first tqPurchaseOrderByOrderDate where
tqPurchaseOrderByOrderDate.tcpo_domain = tqPendingVoucherForOrderType.tcpvo_domain and
tqPurchaseOrderByOrderDate.tcpo_nbr = tqPendingVoucherForOrderType.tcpvo_order:
assign vlIsAvailable = true.
end. /*for first tqPurchaseOrderByOrderDate where */
end. /*if tqPendingVoucherForOrderType.tcpvo_order_type = "01":U and */
if tqPendingVoucherForOrderType.tcpvo_order_type = "02":U and
(vcOrderTypeFilter = ? or can-do({&APMATCHINGLNPVODORDERTYPE-SALES},vcOrderTypeFilter)) then
do:
for first tqSalesOrderByOrderDate where
tqSalesOrderByOrderDate.tcso_domain = tqPendingVoucherForOrderType.tcpvo_domain and
tqSalesOrderByOrderDate.tcso_nbr = tqPendingVoucherForOrderType.tcpvo_order:
assign vlIsAvailable = true.
end. /*for first tqSalesOrderByOrderDate where*/
end. /*tqPendingVoucherForOrderType.tcpvo_order_type = "02":U and */
if tqPendingVoucherForOrderType.tcpvo_order_type = "03":U and
(vcOrderTypeFilter = ? or can-do({&APMATCHINGLNPVODORDERTYPE-DISTRIB},vcOrderTypeFilter)) then
do:
for first tqDistSiteOrderByOrderDate where
tqDistSiteOrderByOrderDate.tcdss_domain = tqPendingVoucherForOrderType.tcpvo_domain and
tqDistSiteOrderByOrderDate.tcdss_nbr = tqPendingVoucherForOrderType.tcpvo_order:
assign vlIsAvailable = true.
end. /*for first tqDistSiteOrderByOrderDate where */
end. /*if tqPendingVoucherForOrderType.tcpvo_order_type = "03":U and */
if vlIsAvailable = false then next.
end. /*if vtFromPODateFilter <> ? or vtToPODateFilter <> ? then*/
for first tqPendingVoucherForOrderType:
case tqPendingVoucherForOrderType.tcpvo_order_type:
when "01":U then
assign vcOrderType = {&APMATCHINGLNPVODORDERTYPE-PURCHASE-TR} .
when "02":U then
assign vcOrderType = {&APMATCHINGLNPVODORDERTYPE-SALES-TR}.
when "03":U then
assign vcOrderType = {&APMATCHINGLNPVODORDERTYPE-DISTRIB-TR}.
end case. /* case tGetMatchingVariance.tcAPMatchingLnPvodItemType*/
create tqMatchingVarianceForLC.
assign
tqMatchingVarianceForLC.tcCInvoiceCreditorCode = tGetMatchingVariance.tcCreditorCode
tqMatchingVarianceForLC.tcCinvoiceJournal = tGetMatchingVariance.tcCinvoiceJournal
tqMatchingVarianceForLC.tiCinvoiceVoucher = tGetMatchingVariance.tiCInvoiceVoucher
tqMatchingVarianceForLC.tiCInvoicePeriod = tGetMatchingVariance.tiPeriodYear
tqMatchingVarianceForLC.tcCinvoiceReference = tGetMatchingVariance.tcCInvoiceReference
tqMatchingVarianceForLC.tcCInvoiceCompanyCode = tGetMatchingVariance.tcCompanyCode
tqMatchingVarianceForLC.tcCInvoiceCurrency = tGetMatchingVariance.tcCurrencyCode
tqMatchingVarianceForLC.ttCInvoicePostingDate = tGetMatchingVariance.ttCInvoicePostingDate
tqMatchingVarianceForLC.tcPurchaseOrderNbr = tGetMatchingVariance.tcAPMatchingLnPvodOrder
tqMatchingVarianceForLC.tiPurchaseOrderLnNbr = tGetMatchingVariance.tiAPMatchingLnPvodOrderLnNbr
tqMatchingVarianceForLC.tcInternalReference = tqPendingVoucherForOrderType.tcpvo_internal_ref
tqMatchingVarianceForLC.tcCreditorCode = tqPendingVoucherForOrderType.tcpvo_supplier
tqMatchingVarianceForLC.tcOrderType = vcOrderType
tqMatchingVarianceForLC.tcLogisticChargeCode = tGetMatchingVariance.tcAPMatchingLnPvodLgCharge
tqMatchingVarianceForLC.tcReceiptSite = tqPendingVoucherForOrderType.tcpvo_shipto
tqMatchingVarianceForLC.tcIssueSite = tqPendingVoucherForOrderType.tcpvo_shipfrom
tqMatchingVarianceForLC.tdInvoiceUnitPrice = tGetMatchingVariance.tdAPMatchingLnMatchUnitPrice
tqMatchingVarianceForLC.tdAccuredAmt = tqPendingVoucherForOrderType.tdpvod_accrued_amt
tqMatchingVarianceForLC.tdVarRate = tGetMatchingVariance.tdAPMatchingLnVarRateTC
tqMatchingVarianceForLC.tdVarRatePerc = (tGetMatchingVariance.tdAPMatchingLnVarRateLC / tGetMatchingVariance.tdAPMatchingLnReceiptAmtLC * 100)
tqMatchingVarianceForLC.tdVarExchRateLC = tGetMatchingVariance.tdAPMatchingLnVarExchRateLC
tqMatchingVarianceForLC.tcSortBy = vcSortingFilter
tqMatchingVarianceForLC.tiPostingType = 0.
if vlShowPostingDetailsFilter then
do:
do viCount = 1 to 4:
case viCount:
when 1 then assign viPostingLine_ID = tGetMatchingVariance.tiPvoPostingLine_ID.
when 2 then assign viPostingLine_ID = tGetMatchingVariance.tiVarExchRatePostingLine_ID.
when 3 then assign viPostingLine_ID = tGetMatchingVariance.tiVarRatePostingLine_ID.
when 4 then assign viPostingLine_ID = tGetMatchingVariance.tiVarUsagePostingLine_ID.
end case.
if viPostingLine_ID <> ? and viPostingLine_ID <> 0 then
do:
<Q-13 run PostingLineByPostingLnId (all) (Read) (NoCache)
(input ?, (CompanyId)
input viPostingLine_ID, (PostingLine_ID)
output dataset tqPostingLineByPostingLnId) in BPosting >
find first tqPostingLineByPostingLnId no-error.
if available tqPostingLineByPostingLnId then
do:
create tqMatchingVarianceForLC.
buffer-copy tqPostingLineByPostingLnId to tqMatchingVarianceForLC.
assign tqMatchingVarianceForLC.tiPostingType = 1.
end. /*if available tqPostingLineByPostingLnId then*/
end. /*if viPostingLine_ID <> ? and viPostingLine_ID <> 0 then*/
end. /*repeat viCount = 1 to 4:*/
end. /*if vlShowPostingDetailsFilter then*/
end. /*for first tqPendingVoucherForOrderType*/
end. /*if available tqPendingVoucherForOrderType then*/
end. /*for each tGetMatchingVariance:*/
<Q-14 run PostingLineByPostingLnId (Stop) in BPosting >
<Q-21 run PendingVoucherForOrderType (Stop) in BAPMatchingReport >
for each tqMatchingVarianceForLC where
tqMatchingVarianceForLC.tiPostingType = 1 and
tqMatchingVarianceForLC.tiGL_ID <> 0 and
tqMatchingVarianceForLC.tiGL_ID <> ?
break by
tqMatchingVarianceForLC.tiGL_ID:
if first-of(tqMatchingVarianceForLC.tiGL_ID) then
do:
assign vcGLCode = ?.
for first tqSelectGL where tqSelectGL.tiGL_ID = tqMatchingVarianceForLC.tiGL_ID:
assign vcGLCode = tqSelectGL.tcGLCode.
end.
end. /*if first-of(tqMatchingVarianceForLC.tiGL_ID) then*/
assign tqMatchingVarianceForLC.tcGLCode = vcGLCode.
end.
for each tqMatchingVarianceForLC where
tqMatchingVarianceForLC.tiPostingType = 1 and
tqMatchingVarianceForLC.tiDivision_ID <> 0 and
tqMatchingVarianceForLC.tiDivision_ID <> ?
break by
tqMatchingVarianceForLC.tiDivision_ID:
if first-of(tqMatchingVarianceForLC.tiDivision_ID) then
do:
assign vcDivisionCode = ?.
for first tqSelectDivision where tqSelectDivision.tiDivision_ID = tqMatchingVarianceForLC.tiDivision_ID:
assign vcDivisionCode = tqSelectDivision.tcDivisionCode.
end.
end. /*if first-of(tqMatchingVarianceForLC.tiGL_ID) then*/
assign tqMatchingVarianceForLC.tcDivisionCode = vcDivisionCode.
end.
for each tqMatchingVarianceForLC where
tqMatchingVarianceForLC.tiPostingType = 1 and
tqMatchingVarianceForLC.tiCostCentre_ID <> 0 and
tqMatchingVarianceForLC.tiCostCentre_ID <> ?
break by
tqMatchingVarianceForLC.tiCostCentre_ID:
if first-of(tqMatchingVarianceForLC.tiCostCentre_ID) then
do:
assign vcCostCentreCode = ?.
for first tqSelectCostCentre where tqSelectCostCentre.tiCostCentre_ID = tqMatchingVarianceForLC.tiCostCentre_ID:
assign vcCostCentreCode = tqSelectCostCentre.tcCostCentreCode.
end.
end. /*if first-of(tqMatchingVarianceForLC.tiGL_ID) then*/
assign tqMatchingVarianceForLC.tcCostCentreCode = vcCostCentreCode.
end.
for each tqMatchingVarianceForLC where
tqMatchingVarianceForLC.tiPostingType = 1 and
tqMatchingVarianceForLC.tiProject_ID <> 0 and
tqMatchingVarianceForLC.tiProject_ID <> ?
break by
tqMatchingVarianceForLC.tiProject_ID:
if first-of(tqMatchingVarianceForLC.tiProject_ID) then
do:
assign vcProjectCode = ?.
for first tqSelectProject where tqSelectProject.tiProject_ID = tqMatchingVarianceForLC.tiProject_ID:
assign vcProjectCode = tqSelectProject.tcProjectCode.
end.
end. /*if first-of(tqMatchingVarianceForLC.tiGL_ID) then*/
assign tqMatchingVarianceForLC.tcProjectCode = vcProjectCode.
end.
for each tqMatchingVarianceForLC where
tqMatchingVarianceForLC.tiPostingType = 1 and
tqMatchingVarianceForLC.tiCurrency_ID <> 0 and
tqMatchingVarianceForLC.tiCurrency_ID <> ?
break by
tqMatchingVarianceForLC.tiCurrency_ID:
if first-of(tqMatchingVarianceForLC.tiCurrency_ID) then
do:
assign vcCurrencyCode = ?.
for first tqSelectCurrency where tqSelectCurrency.tiCurrency_ID = tqMatchingVarianceForLC.tiCurrency_ID:
assign vcCurrencyCode = tqSelectCurrency.tcCurrencyCode.
end.
end. /*if first-of(tqMatchingVarianceForLC.tiGL_ID) then*/
assign tqMatchingVarianceForLC.tcPLCurrencyCode = vcCurrencyCode.
end.