report procedure
Parameters
icLanguageCode | input | character | |
tFilter | input | temp-table | |
dcrPaylist | output | dataset | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program7/bpaymentselectionreport.p)
empty temp-table tqPaylist.
empty temp-table tCreditorTotals.
empty temp-table tDebtorTotals.
empty temp-table tqHeaderAttr.
empty temp-table tqDetailAttr.
<M-1 run GetReportLabels (input 'PayList':U (icReportName),
input icLanguageCode (icLanguageCode),
input tFilter (tFilter),
output tqHeader (tqHeader),
output tqFilter (tqFilter),
output tqText (tqText),
output oiReturnStatus (oiReturnStatus)) in BPaymentSelectionReport>
if oiReturnStatus <> 0
then return.
/*assign tFilter*/
<M-2 run SetDataItemsBasedOnFilterTT (output viFcReturnSuper (oiReturnStatus)) in BPaymentSelectionReport>
/* =============== */
/* Validate Filter */
/* =============== */
if (vtPSFromExecutionDateFilter = ? or
vtPSTillExecutionDateFilter = ?) and
(vcPSFromPayselCodeFilter = ? or
vcPSToPayselCodeFilter = ?) and
vcEqualityPaySelCode = ? and
vtEqualityExecutionDate = ?
then do:
<M-8 run SetMessage
(input #T-1'You must enter either the execution date or the payment selection code.':100(15825)T-1# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-3814':U (icFcMsgNumber),
input #T-2'You must complete all mandatory filter fields.':100(15826)T-2# (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output oiReturnStatus (oiReturnStatus)) in BPaymentSelectionReport>
assign oiReturnStatus = -1.
return.
end.
/* ============= */
/* Precache data */
/* ============= */
<Q-9 run AddressTypePrim (all) (Read) (NoCache)
(input ?, (AddressTypeId)
input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressTypeCode)
output dataset tqAddressTypePrim) in BAddressType >
find first tqAddressTypePrim no-error.
if available tqAddressTypePrim
then assign viAddressType_ID = tqAddressTypePrim.tiAddressType_ID.
else assign viAddressType_ID = -1.
/* ================= */
/* Run Main Querries */
/* ================= */
/* if vcPSDebtorCodesFilter = ? or
vcPSCreditorCodesFilter <> ?
then do: */
<Q-14 run CountryByCode (all) (Read) (NoCache)
(input 'BE':U, (CountryCode)
output dataset tqCountryByCode) in BCountry >
find first tqCountryByCode where
tqCountryByCode.tcCountryCode = "BE":U
no-error.
assign viCountryID = if available tqCountryByCode
then tqCountryByCode.tiCountry_ID
else ?.
/* zhc defect 10132-3690 */
<Q-10 run BasePayListCreditor (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input viAddressType_ID, (AddressType_ID)
input vcPSCreditorCodesFilter, (CreditorCodes)
input vtPSFromExecutionDateFilter, (FromExecDate)
input vtPSTillExecutionDateFilter, (TillExecDate)
input vcPSFromPayselCodeFilter, (FromPaySel)
input vcPSToPayselCodeFilter, (ToPaySel)
input vcPSStatusFilter, (Staus)
input vcEqualityPaySelCode, (PaySel)
input vtEqualityExecutionDate, (ExecDate)
input vcPSCreditorNameFilter, (BusinessRelationName)
input vcPSFromCreditorNameFilter, (FromBusinessRelationName)
input vcPSToCreditorNameFilter, (ToBusinessRelationName)
output dataset tqBasePayListCreditor) in BPaymentSelectionReport >
/* Retrieve creditor data and detail attributes */
for each tqBasePayListCreditor break by tqBasePayListCreditor.tcPaySelCode
by tqBasePayListCreditor.tiCInvoice_ID:
create tqPaylist.
buffer-copy tqBasePayListCreditor to tqPaylist.
assign tqPaylist.tiInvoice_ID = tqBasePayListCreditor.tiCInvoice_ID.
if tqBasePayListCreditor.tcPaySelStatus = {&PAYMENTSELECTIONSTATUS-CLOSED}
then assign tqPaylist.tcPaySelStatus = {&PAYMENTSELECTIONSTATUS-CLOSED-TR}.
else
if tqBasePayListCreditor.tcPaySelStatus = {&PAYMENTSELECTIONSTATUS-INITIAL}
then assign tqPaylist.tcPaySelStatus = {&PAYMENTSELECTIONSTATUS-INITIAL-TR}.
else
if tqBasePayListCreditor.tcPaySelStatus = {&PAYMENTSELECTIONSTATUS-REGISTERED}
then assign tqPaylist.tcPaySelStatus = {&PAYMENTSELECTIONSTATUS-REGISTERED-TR}.
else
if tqBasePayListCreditor.tcPaySelStatus = {&PAYMENTSELECTIONSTATUS-TRANSFERRED}
then assign tqPaylist.tcPaySelStatus = {&PAYMENTSELECTIONSTATUS-TRANSFERRED-TR}.
else assign tqPaylist.tcPaySelStatus = '???':U.
if first-of(tqBasePayListCreditor.tiCInvoice_ID) then do:
/* Retrieve detail attributes for this CInvoiceBank */
<Q-25 run CInvoiceBankAttributes (all) (Read) (NoCache)
(input tqBasePayListCreditor.tiCInvoice_ID, (CInvoiceID)
input tqBasePayListCreditor.tiBankNumber_ID, (BankNumberID)
output dataset tqCInvoiceBankAttributes) in BPaymentSelectionReport >
for each tqCInvoiceBankAttributes:
create tqDetailAttr.
assign tqDetailAttr.tiPaySelLine_ID = tqBasePayListCreditor.tiPaySelLine_ID
tqDetailAttr.tcDetailAttrName = tqCInvoiceBankAttributes.tcPayFormatGroupCode.
if (tqCInvoiceBankAttributes.tiPayFormatCode_ID <> ? and tqCInvoiceBankAttributes.tiPayFormatCode_ID <> 0) then do:
assign tqDetailAttr.tcDetailAttrValue = tqCInvoiceBankAttributes.tcPayFormatCode.
end.
else do:
assign tqDetailAttr.tcDetailAttrValue = tqCInvoiceBankAttributes.tcCInvoiceBankPayCodeValue.
end. /* if (tqCInvoiceBankAttributes.tiPayFormatCode_ID <> ? */
end. /* for each tqCInvoiceBankAttributes */
end. /* if first-of(tqBasePayListCreditor.tiCInvoice_ID) */
end. /* for each tqBasePayListCreditor */
/* zhc defect 10132-3690 */
<Q-11 run BasePayListPrepay (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input viAddressType_ID, (AddressType_ID)
input vcPSCreditorCodesFilter, (CreditorCodes)
input vtPSFromExecutionDateFilter, (FromExecDate)
input vtPSTillExecutionDateFilter, (TillExecDate)
input vcPSFromPayselCodeFilter, (FromPaySel)
input vcPSToPayselCodeFilter, (ToPaySel)
input vcPSStatusFilter, (Staus)
input vcEqualityPaySelCode, (PaySel)
input vtEqualityExecutionDate, (ExecDate)
input viCountryID, (CountryID)
input vcPSCreditorNameFilter, (BusinessRelationName)
input vcPSFromCreditorNameFilter, (FromBusinessRelationName)
input vcPSToCreditorNameFilter, (ToBusinessRelationName)
output dataset tqBasePayListPrepay) in BPaymentSelectionReport >
for each tqBasePayListPrepay:
create tqPaylist.
buffer-copy tqBasePayListPrepay to tqPaylist.
end.
/* end. */
<Q-13 run AddressByCompanyID (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input viAddressType_ID, (AddressType_ID)
output dataset tqAddressByCompanyID) in BPaymentSelectionReport >
find first tqAddressByCompanyID no-error.
if available tqAddressByCompanyID
then do:
for each tqPaylist:
assign tqPaylist.tcCompanyAddressCity = tqAddressByCompanyID.tcAddressCity
tqPaylist.tcCompanyAddressStreet1 = tqAddressByCompanyID.tcAddressStreet1
tqPaylist.tcCompanyAddressStreet2 = tqAddressByCompanyID.tcAddressStreet2
tqPaylist.tcCompanyAddressZip = tqAddressByCompanyID.tcAddressZip
tqPaylist.tiCompanyAddressFormat = tqAddressByCompanyID.tiAddressFormat
tqPaylist.tcCompanyCountryCode = tqAddressByCompanyID.tcCountryCode
tqPaylist.tcCompanyCountryDescription = tqAddressByCompanyID.tcCountryDescription
tqPaylist.tcCompanyBusinessRelationName1 = tqAddressByCompanyID.tcBusinessRelationName1
tqPaylist.tcCompanyBusRelationCode = tqAddressByCompanyID.tcBusinessRelationCode.
end.
end.
assign vdTotal = 0.00
vdTotalDisc = 0.00
vcCurrencyCode = "":U.
for each tqPaylist where
tqPaylist.tcCreditorCode <> ? and
tqPaylist.tcCreditorCode <> ""
break by tqPaylist.tcPaySelCode
by tqPaylist.tcCreditorCode
by tqPaylist.tcInvoiceReference:
assign vdTotal = vdTotal + tqPaylist.tdPaySelLineAmountTC
vdTotalDisc = vdTotalDisc + tqPaylist.tdPaySelLineDiscountTC
vcCurrencyCode = (if vcCurrencyCode = "":U or
vcCurrencyCode = tqPaylist.tcCurrencyCode
then tqPaylist.tcCurrencyCode
else ?).
if last-of(tqPaylist.tcCreditorCode)
then do:
create tCreditorTotals.
assign tCreditorTotals.tcCode = tqPaylist.tcCreditorCode
tCreditorTotals.tcPayRef = tqPaylist.tcPaySelCode
tCreditorTotals.tcCurrencyCode = vcCurrencyCode.
if vcCurrencyCode <> ?
then assign tCreditorTotals.tdTotal = vdTotal
tCreditorTotals.tdTotalDisc = vdTotalDisc.
else assign tCreditorTotals.tdTotal = ?
tCreditorTotals.tdTotalDisc = ?.
Assign vdTotal = 0.00
vdTotalDisc = 0.00
vcCurrencyCode = "":U.
end.
end.
for each tCreditorTotals:
for each tqPaylist where
tqPaylist.tcCreditorCode = tCreditorTotals.tcCode and
tqPaylist.tcPaySelCode = tCreditorTotals.tcPayRef:
assign tqPaylist.tdSupplierTotal = tCreditorTotals.tdtotal
tqPaylist.tdSupplierTotalDisc = tCreditorTotals.tdTotalDisc.
end.
end.
/* Get Header Attributes */
for each tqPaylist where tqPaylist.tiPaySel_ID <> 0 and tqPaylist.tiPaySel_ID <> ? break by tqPaylist.tiPaySel_ID:
if first-of(tqPaylist.tiPaySel_ID) then do:
<Q-15 run PaySelPayCodeByPaySelID (all) (Read) (NoCache)
(input tqPaylist.tiPaySel_ID, (PaySelID)
input ?, (PayFormatGroupCode)
output dataset tqPaySelPayCodeByPaySelID) in BPaymentSelection>
for each tqPaySelPayCodeByPaySelID where
tqPaySelPayCodeByPaySelID.tcPayFormatGroupCode <> "" and
tqPaySelPayCodeByPaySelID.tcPayFormatGroupCode <> ?:
create tqHeaderAttr.
assign tqHeaderAttr.tiPaySel_ID = tqPayList.tiPaySel_ID
tqHeaderAttr.tcHeaderAttrName = tqPaySelPayCodeByPaySelID.tcPayFormatGroupCode.
if tqPaySelPayCodeByPaySelID.tiPayFormatCode_ID <> ? and
tqPaySelPayCodeByPaySelID.tiPayFormatCode_ID <> 0
then do:
<Q-24 run PayFormatCodeByID (all) (Read) (NoCache)
(input tqPaySelPayCodeByPaySelID.tiPayFormatCode_ID, (PayFormatCodeID)
output dataset tqPayFormatCodeByID) in BPaymentFormat >
find first tqPayFormatCodeByID no-lock no-error.
if available tqPayFormatCodeByID
then tqHeaderAttr.tcHeaderAttrValue = tqPayFormatCodeByID.tcPayFormatCode.
end.
else tqHeaderAttr.tcHeaderAttrValue = tqPaySelPayCodeByPaySelID.tcPaySelPayCodeValue.
end.
end.
end.
if not can-find(first tqDetailAttr) then do:
for first tqPayList:
create tqDetailAttr.
assign tqDetailAttr.tiPaySelLine_ID = tqPayList.tiPaySelLine_ID
tqDetailAttr.tcDetailAttrName = "":U
tqDetailAttr.tcDetailAttrValue = "":U.
end.
end.
/* Add Sort By information, and the default value is sort by Supplier Code */
for each tqPaylist:
assign tqPaylist.tcSortBySupBR = if (vcSortBySupBR = "":U or vcSortBySupBR = ?)
then "BUSINESSRELATIONNAME"
else vcSortBySupBR.
end.