report procedure
Parameters
Internal usage
unused
program code (program4/bcdocumentreport.p)
empty temp-table tqCDocumentReportCheque.
<M-12 run GetReportLabels (input 'CDocumentReportCheque':U (icReportName),
input icLanguageCode (icLanguageCode),
input tFilter (tFilter),
output tqHeader (tqHeader),
output tqFilter (tqFilter),
output tqText (tqText),
output viFcReturnSuper (oiReturnStatus)) in BCDocumentReport>
if viFcReturnSuper < 0 or
oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
find first tFilter where tFilter.tcBusinessFieldName = "BankPayFormatID":U no-error.
if available tFilter
then do:
viIndex = INDEX(tFilter.tcParameterValue, " ", 1) no-error.
viIndex = viIndex - 1.
vcBankNumber = SUBSTRING(tFilter.tcParameterValue, 1, viIndex, "CHARACTER").
viIndex = viIndex + 2.
tFilter.tcParameterValue = SUBSTRING(tFilter.tcParameterValue, viIndex, -1, "CHARACTER") no-error.
viIndex = INDEX(tFilter.tcParameterValue, "#", 1) no-error.
viIndex = viIndex - 1.
vcPayFormatTypeCode = TRIM(SUBSTRING(tFilter.tcParameterValue, 1, viIndex, "CHARACTER")) no-error.
<Q-21 run BankNumberByPayFormatTypeCode (all) (Read) (NoCache)
(input vcPayFormatTypeCode, (PaymentFormatTypeCode)
input vcBankNumber, (BankNumber)
input viCompanyId, (CompanyId)
output dataset tqBankNumberByPayFormatTypeCode) in BBankNumber >
find first tqBankNumberByPayFormatTypeCode no-error.
if available tqBankNumberByPayFormatTypeCode
then assign tFilter.tcParameterValue = STRING(tqBankNumberByPayFormatTypeCode.tiBankPayFormat_ID).
else assign tFilter.tcParameterValue = "0".
end.
/* Check if necessary to update Next Pre-printed Number field of BankPayFormat */
/* When Print type is "Final Print" and Start From Number is blank, do update, else do not update */
assign vlUpdateNextPPNumber = false.
find first tFilter where tFilter.tcBusinessFieldName = "PrintType":U no-error.
if available tFilter
then do:
if tFilter.tcParameterValue = {&PRINTTYPE-FINAL}
then do:
assign vlUpdateNextPPNumber = true.
find first tFilter where tFilter.tcBusinessFieldName = "StartFromCDocumentPrePrintedNumber":U no-error.
if available tFilter
then do:
if tFilter.tcParameterValue <> ? and tFilter.tcParameterValue <> "":U
then assign vlUpdateNextPPNumber = false.
end. /* if available tFilter */
end. /* if tFilter.tcParameterValue = {&PRINTTYPE-FINAL} */
find first tFilter where tFilter.tcBusinessFieldName = "BankPayFormatID":U no-error.
if available tFilter then
assign viBankPayFormatID = integer(tFilter.tcParameterValue).
end. /* if available tFilter */
find first tFilter where tFilter.tcBusinessFieldName = "Sortby":U no-error.
if available tFilter
then do:
if tFilter.tcParameterValue = {&CDOCUMENT-SORTBY-CREDITORCODE}
then assign vlSortByCreditorCode = true.
else assign vlSortByCreditorCode = false.
end.
<M-13 run CDocumentReportAll (input {&DOCUMENTTYPECREDITOR-CHEQUE} (icCDocumentType),
output viFcReturnSuper (oiReturnStatus)) in BCDocumentReport>
if viFcReturnSuper < 0 or
oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
assign viMaxPrePrintedNumber = -1.
for each tCDocumentReportAll:
create tqCDocumentReportCheque.
buffer-copy tCDocumentReportAll to tqCDocumentReportCheque.
if tCDocumentReportAll.tiCDocRepPrePrintedNum <> ?
then assign viMaxPrePrintedNumber = maximum(tCDocumentReportAll.tiCDocRepPrePrintedNum,
viMaxPrePrintedNumber).
if vlSortByCreditorCode = true
then assign tqCDocumentReportCheque.tcSortByField = tqCDocumentReportCheque.tcCDocRepCredCode.
else assign tqCDocumentReportCheque.tcSortByField = tqCDocumentReportCheque.tcCDocRepCredName1.
if tqCDocumentReportCheque.tiPaySelLine_ID = ?
then assign tqCDocumentReportCheque.tiPaySelLine_ID = 0.
if tqCDocumentReportCheque.tcCDocRepCInvoiceType = {&INVOICETYPE-PREPAYMENT} and
tqCDocumentReportCheque.tiPaySelLine_ID <> 0
then do:
<Q-83 run PaySelLineByIDAllInfo (all) (Read) (NoCache)
(input tqCDocumentReportCheque.tiPaySelLine_ID, (PaySelLine_ID)
output dataset tqPaySelLineByIDAllInfo) in BPaymentSelection>
find first tqPaySelLineByIDAllInfo where tqPaySelLineByIDAllInfo.tiPaySelLine_ID = tqCDocumentReportCheque.tiPaySelLine_ID no-error.
if available tqPaySelLineByIDAllInfo
then do:
if (tqPaySelLineByIDAllInfo.tcPaySelLineObjectType = {&INVOICETYPE-INVOICE} and tqCDocumentReportCheque.tdCDocRepInvOrigDebitTC <> 0) or
(tqPaySelLineByIDAllInfo.tcPaySelLineObjectType = {&PAYMENTSELECTIONTYPE-PREPAYMENTINV} and tqCDocumentReportCheque.tdCDocRepInvOrigCreditTC <> 0)
then
assign tqCDocumentReportCheque.tdCDocRepCInvoiceXRefAmountTC = tqCDocumentReportCheque.tdCDocRepCInvoiceXRefAmountTC
tqCDocumentReportCheque.tdCDocRepCInvoiceXRefDiscAmTC = tqCDocumentReportCheque.tdCDocRepCInvoiceXRefDiscAmTC.
else if tqPaySelLineByIDAllInfo.tcPaySelLineObjectType = {&PAYMENTSELECTIONTYPE-PREPAYMENTINV} and tqCDocumentReportCheque.tdCDocRepInvOrigDebitTC <> 0
then
assign tqCDocumentReportCheque.tdCDocRepCInvoiceXRefAmountTC = - abs(tqCDocumentReportCheque.tdCDocRepCInvoiceXRefAmountTC)
tqCDocumentReportCheque.tdCDocRepCInvoiceXRefDiscAmTC = - abs(tqCDocumentReportCheque.tdCDocRepCInvoiceXRefDiscAmTC).
end.
end.
else do:
if (tqCDocumentReportCheque.tcCDocRepCInvoiceType = {&INVOICETYPE-PREPAYMENT} and tqCDocumentReportCheque.tdCDocRepCInvoiceXRefPaidAmtTC <> 0 and tqCDocumentReportCheque.tdCDocRepInvOrigDebitTC <> 0) or
(tqCDocumentReportCheque.tcCDocRepCInvoiceType = {&INVOICETYPE-ADJUSTMENT} and tqCDocumentReportCheque.tdCDocRepInvOrigDebitTC <> 0) or
tqCDocumentReportCheque.tcCDocRepCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then
assign tqCDocumentReportCheque.tdCDocRepCInvoiceXRefAmountTC = - abs(tqCDocumentReportCheque.tdCDocRepCInvoiceXRefAmountTC)
tqCDocumentReportCheque.tdCDocRepCInvoiceXRefDiscAmTC = - abs(tqCDocumentReportCheque.tdCDocRepCInvoiceXRefDiscAmTC).
else
assign tqCDocumentReportCheque.tdCDocRepCInvoiceXRefAmountTC = tqCDocumentReportCheque.tdCDocRepCInvoiceXRefAmountTC
tqCDocumentReportCheque.tdCDocRepCInvoiceXRefDiscAmTC = tqCDocumentReportCheque.tdCDocRepCInvoiceXRefDiscAmTC.
end.
end. /* for each tCDocumentReportAll: */
if vlUpdateNextPPNumber = true and viMaxPrePrintedNumber <> -1
then do:
if viBBankPayFormat5ID = 0 or viBBankPayFormat5ID = ?
then do:
<I-15 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "false"
&CLASS = "BBankPayFormat"}>
end. /* if viBankPayFormatID = 0 or viBankPayFormatID = ? */
else do:
<I-16 {bFcOpenInstance
&CLASS = "BBankPayFormat"}>
end. /* if viBankPayFormatID <> 0 and viBankPayFormatID <> ? */
<M-49 run SetPublicData
(input 'vcActivityCode' (icDataList),
input 'donotvalidate' (icValueList),
output viFcReturnSuper (oiReturnStatus)) in BBankPayFormat>
if viFcReturnSuper < 0 or
oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
<M-14 run UpdateBankPayFormatNbr
(input viBankPayFormatID (iiBankPayFormatID),
input viMaxPrePrintedNumber + 1 (iiNewPrePrintedNumber),
output viFcReturnSuper (oiReturnStatus)) in BBankPayFormat>
<I-17 {bFcCloseInstance
&CLASS = "BBankPayFormat"}>
if viFcReturnSuper < 0 or
oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then do:
<I-19 {bFcStopInstance
&CLASS = "BBankPayFormat"}>
return.
end. /* if oiReturnStatus < 0 */
end. /* if vlUpdateNextPPNumber = true */