Professional Documents
Culture Documents
begin-heading 9
#include 'arhdg01.sqc'
print $DateHeading (3,) center
print $xvaging_id (3,1,9)
print $xvagingid (3,+1,15)
print $xvcf_parms (4,1,21)
print $xvcfparms (4,+1,100)
print $xvagedisplayoption (5,1,#xfwagedisplayoption)
print $AgeDisplayName (0,+1,19)
LET $BUSINESS_UNIT = RTRIM($BUSINESS_UNIT,' ')
print $xv_bus_unit (6,1,14)
if $BUSINESS_UNIT <> ''
print $BUSINESS_UNIT (0,+1,10)
else
print $xv_all_vals (0,+1,10)
END-IF
!***********************************************************************
! Procedure: CREATE-ARRAYS
! Description: Establish arrays used to store aging categories and
! report sub-totals.
!***********************************************************************
begin-procedure CREATE-ARRAYS
create-array name=categories size=20
field=category:char
field=descrshort:char
field=start-day:number
field=end-day:number
create-array name=ITEM-TOTALS size=12
field=amt:number
create-array name=customer-total size=12
field=amt:number
create-array name=CF-TOTAL size=12
field=amt:number
create-array name=CF-TOTAL2 size=12
field=amt:number
end-procedure
!***********************************************************************
! Procedure: INIT-REPORT
! Description: Prompt for run-time parameters and populate aging
! categories array with aging 'buckets'
!***********************************************************************
begin-procedure INIT-REPORT
DO INIT-DATETIME
do Init-Number
do GET-CURRENT-DATETIME
do INITIALIZE-CF-ARRAY
do DEFINE-PRCS-VARS
do GET-RUN-CONTROL-PARMS
do INITIALIZE-VARIABLES
do SELECT-PARAMETERS
do AGE-DISPLAY-OPTION
do GET-XLAT-FIELDS
do SET-HDR-OPTIONS
do BUILD-CF-ARRAY
do BUILD-WHERE-CLAUSE
do CREATE-ARRAYS
do LOAD-CATEGORIES
do GET-SUBTOTALS
do GET-CF-PARAMETERS
do BuildCF-WHERE-CLAUSE
end-procedure
!***********************************************************************
! Procedure: READ-AGING-TABLE
! Description: This procedure reads the aging table for the aging setid
! and aging id entered.
!***********************************************************************
begin-procedure READ-AGING-TABLE
begin-select
A.EFFDT
A.BASIS_DT
A.DISPUTE_AGING
A.DISPUTE_CATEGORY
A.DISPUTE_PRTY
A.DEDUCTION_AGING
A.DEDUCTION_CTGY
A.DEDUCTION_PRTY
A.COLLECTION_AGING
A.COLLECTION_CTGY
A.COLLECTION_PRTY
move &a.effdt to $aging-effdt
move &a.basis_dt to $basis-dt
move &a.dispute_aging to $dispute-aging
move &a.dispute_category to $dispute-category
move &a.dispute_prty to #dispute-priority
move &a.deduction_aging to $deduction-aging
move &a.deduction_ctgy to $deduction-category
move &a.deduction_prty to #deduction-priority
move &a.collection_aging to $collection-aging
move &a.collection_ctgy to $collection-category
move &a.collection_prty to #collection-priority
FROM PS_AGING_TBL A
WHERE A.EFF_STATUS = 'A'
AND A.AGING_ID = $agingid
AND A.SETID = $setid
AND A.EFFDT = (SELECT MAX(B.EFFDT) FROM PS_AGING_TBL B
WHERE B.AGING_ID = $agingid
AND B.SETID = $setid
AND B.EFFDT <= $asofdate)
end-select
end-procedure
!***********************************************************************
! Function: AGE-DISPLAY-OPTION
! Description: This procedure stores additional where clause criteria
! to a string, so it may be used in the main select.
!***********************************************************************
begin-procedure AGE-DISPLAY-OPTION
if $agedisplayoption = 'A'
move '' to $agedisplaystring
end-if
if $agedisplayoption = 'D'
move 'AND A.DISPUTE_STATUS <> '' ''' to $agedisplaystring
end-if
if $agedisplayoption = 'E'
move 'AND A.DEDUCTION_STATUS <> '' ''' to $agedisplaystring
end-if
if $agedisplayoption = 'C'
move 'AND A.COLLECTION_STATUS <> '' ''' to $agedisplaystring
end-if
move 'AGE_DISPLAY_OPTION' to $FieldName
move $agedisplayoption to $FieldValue
do Read-Translate-Table
move $XLATLongName to $AgeDisplayName
end-procedure
!-----------------------------------------------------------------------!
! Procedure: BuildCF-WHERE-CLAUSE !
! Descr: This procedure stores SQL is used to dynamically build the !
! where clause !
!-----------------------------------------------------------------------!
begin-procedure BuildCF-WHERE-CLAUSE
let $ANDCFS = ''
BEGIN-SELECT
JLNCF.FIELDNAME
let $Chartfield = RTRIM(&JLNCF.FIELDNAME,' ')
let $ANDCFS = $ANDCFS || ' AND I.' || $Chartfield ||'=B.'||$Chartfield
FROM PS_FS_RPTCF JLNCF
WHERE JLNCF.OPRID = $prcs_oprid
AND JLNCF.RUN_CNTL_ID = $prcs_run_cntl_id
AND JLNCF.PNLGRPNAME='RUN_AR30006'
AND JLNCF.CF_SELECT_OPT = 'Y'
END-SELECT
#debugx show '$ANDCFS = |' $ANDCFS '|'
end-procedure
!***********************************************************************
! Procedure: MAIN-PROCESS
! Description: This is the main report procedure. It is executed once.
! The 'post' date on the item (PS_ITEM) is compared with
! 'as of' date. If the 'as of' date is on or before the
! 'post' date, the item balance is determined by looking
! at the item activity (PS_ITEM_ACTIVITY).
!***********************************************************************
begin-procedure MAIN-PROCESS
begin-select
[$CF_SUBTOTAL2] &CF_SUBTOTAL2=CHAR () on-break print=ne
ver level=1 AFTER=CF-TOTAL2
[$CF_SUBTOTAL] &CF_SUBTOTAL=CHAR () on-break print=ne
ver level=2 AFTER=CF-TOTAL
A.CUST_ID () on-break print=ne
ver level=3 AFTER=CUSTOMER-TOTAL
A.ITEM () on-break print=ne
ver level=4 AFTER=ITEM-TOTAL SAVE=$OLD-ITEM
A.ITEM_LINE () on-break print=ne
ver level=5 AFTER=ITEM-LINE-TOTAL
A.ITEM_SEQ_NUM
A.BAL_AMT_BASE
B.MONETARY_AMOUNT
A.BAL_CURRENCY
A.POST_DT
A.DUE_DT
A.ACCOUNTING_DT
A.ASOF_DT
A.DISPUTE_STATUS
A.DEDUCTION_STATUS
A.COLLECTION_STATUS
A.DUE_DAYS
A.ENTRY_TYPE
A.ENTRY_REASON
A.PYMNT_TERMS_CD
A.DOCUMENT
C.NAME1
B.ACCOUNT
B.ALTACCT
B.OPERATING_UNIT
B.FUND_CODE
B.DEPTID
B.PROGRAM_CODE
B.CLASS_FLD
B.BUDGET_REF
B.PROJECT_ID
B.CURRENCY_CD
B.PRODUCT
B.DST_SEQ_NUM
move &A.CUST_ID to $custid
move &A.item to $item
move &A.BAL_CURRENCY to $report-currency
move &A.item_line to #item-line
move &A.ITEM_SEQ_NUM to #item_seq_num
move &A.bal_amt_base to #bal-amt-base
move &B.MONETARY_AMOUNT to #monetary_amt
move &A.post_dt to $post-dt
move &A.due_dt to $due-dt
move &A.accounting_dt to $accounting-dt
move &A.asof_dt to $item-asof-dt
move &A.dispute_status to $dispute-status
move &A.due_days to #grace-days
move &A.entry_type to $entrytype
move &A.entry_reason to $entryreason
move &A.PYMNT_TERMS_CD to $pymnt-terms
move &A.document to $document
move &C.name1 to $cust-name
move &B.ACCOUNT to $account
move &B.ALTACCT to $altacct
move &B.OPERATING_UNIT to $operating_unit
move &B.FUND_CODE to $fund_code
move &B.DEPTID to $deptid
move &B.PROGRAM_CODE to $program_code
move &B.CLASS_FLD to $class_fld
move &B.BUDGET_REF to $budget_ref
move &B.PROJECT_ID to $project_id
move &B.CURRENCY_CD to $currency_cd
move &B.PRODUCT to $product
move &B.DST_SEQ_NUM to #DST_SEQ_NUM
IF #item_seq_num > 1 or
#item_seq_num = 1 and #DST_SEQ_NUM > 1
do CALC-REMAIN-BALANCE
end-if
do DIFF-DATE($asofdate,$post-dt,#diff-years,#diff-months,#diff-days)
if #diff-days < 0
do SELECT-ITEM-ACTIVITY
end-if
IF $CUSTOMER-TOTAL-PRINTED = 'Y'
print $xvcust_id (+2,19,11)
print $CUSTID (0,+2,15)
print $xvcust_name (0,+10,30)
print $cust-name (0,+2,30)
let $CUSTOMER-TOTAL-PRINTED = 'N'
END-IF
!***********************************************************************
! Procedure: SELECT-ITEM-ACTIVITY
! Description: This procedure is called in the event that the posted
! date on the item is later than the run-time as-of date
! (so that the item balance reported accurately reflects
! the item activity at the time of the as of date).
!***********************************************************************
begin-procedure SELECT-ITEM-ACTIVITY
MOVE 0 TO #bal-amt-base
begin-select
C.ENTRY_AMT_BASE
C.ACCOUNTING_DT
C.POST_DT
move &C.ENTRY_AMT_BASE to #activity-amt-base
move &C.ACCOUNTING_DT to $activity-acctg-dt
move &C.POST_DT to $ACTIVITY-POST-DT
! if the ACCTG date on the item activity is on or before the as of date
! we include it in the item balance. If you want to use the POSTED date
! of the activity instead, comment out the first line below and uncomment
! the second line.
do DIFF-DATE($asofdate,$activity-acctg-dt,#diff-years,#diff-months,#diff-day
s)
! do DIFF-DATE($asofdate,$activity-post-dt,#diff-years,#diff-months,#diff-days
)
if #diff-days >= 0
add #activity-amt-base to #bal-amt-base
end-if
FROM PS_ITEM_ACTIVITY C
WHERE C.ITEM = $item
AND C.ITEM_LINE = #item-line
!AND c.ITEM_SEQ_NUM = #item_seq_num
AND C.CUST_ID = $CUSTID
AND C.BUSINESS_UNIT = $BUSINESS_UNIT
end-select
end-procedure
!************************************************************************
! Function: CATEGORIZE-AMT
! Description: This function establishes which method should be used to
! to categorize the item balance into an aging bucket.
! If the item is not in dispute,a deduction, or a collection,
! the item balance is aged normally (by date) unless there
! is an entry type override. If the item is in dispute,a
! deduction, or a collection, it is aged according the
! corresponding aging parameter defined on the aging id.
!************************************************************************
begin-procedure CATEGORIZE-AMT
move '' to $aging-status
if not isblank($dispute-status)
and ((#dispute-priority < #deduction-priority) or isblank($deduction-st
atus)or isnull($deduction-status))
and ((#dispute-priority < #collection-priority) or isblank($collection-
status) or isnull($collection-status))
let $aging-status = 'D'
let $aging-option = $dispute-aging
end-if
if not isblank($deduction-status)
and ((#deduction-priority < #dispute-priority) or isblank($dispute-stat
us) or isnull($dispute-status))
and ((#deduction-priority < #collection-priority) or isblank($collectio
n-status) or isnull($collection-status))
let $aging-status = 'E'
let $aging-option = $deduction-aging
end-if
if not isblank($collection-status)
and ((#collection-priority < #deduction-priority) or isblank($deduction
-status)or isnull($deduction-status))
and ((#collection-priority < #dispute-priority) or isblank($dispute-sta
tus) or isnull($dispute-status))
let $aging-status = 'C'
let $aging-option = $collection-aging
end-if
end-procedure
!***********************************************************************
! Procedure: GET-ENTRYTYPE-BUCKET
! Description: This Procedure is called to establish whether the entry
! type for item has aging exceptions set up to place the
! item in a specific aging bucket.
!***********************************************************************
begin-procedure GET-ENTRYTYPE-BUCKET
move 0 to #i
move 8 to #bucket-num !ITEM 6
move 'N' to $entrytype-aging
move ' ' to $entrytype-category
begin-select
D.AGING_CATEGORY
let $entrytype-category = RTRIM(&d.aging_category, ' ')
FROM PS_ENTRY_TYPE_TBL D
WHERE D.ENTRY_TYPE = $entrytype
AND D.SETID = $setid
ORDER BY D.AGING_CATEGORY
end-select
if $entrytype-category = ''
move ' ' to $entrytype-category
end-if
if $entrytype-category <> ' '
move 'Y' to $entrytype-aging
while #i < 8 !ITEM 6
get $category from categories(#i)
if $category = $entrytype-category
move #i to #bucket-num
move 8 to #i !ITEM 6
end-if
add 1 to #i
end-while
end-if
end-procedure
!***********************************************************************
! Procedure: GET-BASISDATE-BUCKET
! Description: This Procedure is called in the event that an item is
! neither categorized by 'dispute category' nor by entry
! type category. The aging category into which the item
! is placed is determined by comparing the days overdue
! with the start and end dates for the aging categories.
!***********************************************************************
begin-procedure GET-BASISDATE-BUCKET
move 1 to #i
move 8 to #bucket-num !ITEM 6
evaluate $basis-dt
when = 'A'
do DIFF-DATE($asofdate,$item-asof-dt,#diff-years,#diff-months,#diff-days)
when = 'I'
do DIFF-DATE($asofdate,$accounting-dt,#diff-years,#diff-months,#diff-days
)
when-other
do DIFF-DATE($asofdate,$due-dt,#diff-years,#diff-months,#diff-days)
end-evaluate
let #days-overdue=#diff-days - #grace-days
end-procedure
!***********************************************************************
! Procedure: GET-DISPUTE-BUCKET
! Description: This Procedure is called if the item is in dispute and
! disputed items are flagged to be placed in a specific
! category (defined when setting up the aging id).
!***********************************************************************
begin-procedure GET-DISPUTE-BUCKET
move 8 to #bucket-num !ITEM 6
move 0 to #i
move 'N' to $dispute-aged
while #i < 8 !ITEM 6
get $category from categories(#i)
if $category = $dispute-category
move #i to #bucket-num
move 8 to #i !ITEM 6
move 'Y' to $dispute-aged
end-if
add 1 to #i
end-while
end-procedure
!***********************************************************************
! Procedure: EVALUATE-DISPUTE-STATUS
! Description: This Procedure is called if the the dispute method on the
! aging id is 'D' (vary by dispute code).
!***********************************************************************
begin-procedure EVALUATE-DISPUTE-STATUS
begin-select
F.SETID
move &f.setid to $dispute-setid
FROM PS_SET_CNTRL_REC F
WHERE F.SETCNTRLVALUE = $BUSINESS_UNIT
AND F.RECNAME = 'DISPUTE_TBL'
end-select
begin-select
G.DISPUTE_AGE_TYPE
move &g.dispute_age_type to $dispute-age-type
FROM PS_DISPUTE_TBL G
WHERE G.DISPUTE_STATUS = $DISPUTE-STATUS
AND G.SETID = $dispute-setid
AND G.EFFDT = (SELECT MAX(H.EFFDT) FROM PS_DISPUTE_TBL H
WHERE H.DISPUTE_STATUS = $DISPUTE-STATUS
AND H.SETID = $dispute-setid
AND H.EFFDT <= $asofdate)
end-select
evaluate $dispute-age-type
when = 'A'
do STD-CATEGORY
when = 'C'
do GET-DISPUTE-BUCKET
when = 'X'
let $exclude = 'Y'
when-other
do STD-CATEGORY
end-evaluate
end-procedure
!***********************************************************************
! Function: GET-DEDUCTION-BUCKET
! Description: This function is called if the item is a deduction and
! deduction items are flagged to be placed in a specific
! category (defined when setting up the aging id).
!***********************************************************************
begin-procedure GET-DEDUCTION-BUCKET
move 8 to #bucket-num !ITEM 6
move 0 to #i
move 'N' to $deduction-aged
while #i < 8 !ITEM 6
get $category from categories(#i)
if $category = $deduction-category
move #i to #bucket-num
move 8 to #i !ITEM 6
move 'Y' to $deduction-aged
end-if
add 1 to #i
end-while
end-procedure
!***********************************************************************
! Function: EVALUATE-DEDUCTION-STATUS
! Description: This function is called if the the deduction method on the
! aging id is 'D' (vary by deduction code).
!***********************************************************************
begin-procedure EVALUATE-DEDUCTION-STATUS
begin-select
X.SETID
move &X.setid to $deduction-setid
FROM PS_SET_CNTRL_REC X
WHERE X.SETCNTRLVALUE = $business-unit
AND X.RECNAME = 'DEDUCTION_TBL'
end-select
move ' ' to $deduction-age-type
begin-select
G.DEDUCTION_AGE_TYPE
move &g.deduction_age_type to $deduction-age-type
FROM PS_DEDUCTION_TBL G
WHERE G.DEDUCTION_STATUS = $DEDUCTION-STATUS
AND G.SETID = $deduction-setid
AND G.EFFDT = (SELECT MAX(H.EFFDT) FROM PS_DEDUCTION_TBL H
WHERE H.DEDUCTION_STATUS = $DEDUCTION-STATUS
AND H.SETID = $deduction-setid
AND H.EFFDT <= $asofdate)
end-select
evaluate $deduction-age-type
when = 'A'
do STD-CATEGORY
when = 'C'
do GET-DEDUCTION-BUCKET
when = 'X'
let $exclude = 'Y'
when-other
do STD-CATEGORY
end-evaluate
end-procedure
!***********************************************************************
! Function: GET-COLLECTION-BUCKET
! Description: This function is called if the item is a collection and
! collection items are flagged to be placed in a specific
! category (defined when setting up the aging id).
!***********************************************************************
begin-procedure GET-COLLECTION-BUCKET
move 8 to #bucket-num !ITEM 6
move 0 to #i
move 'N' to $collection-aged
while #i < 8 !ITEM 6
get $category from categories(#i)
if $category = $collection-category
move #i to #bucket-num
move 8 to #i !ITEM 6
move 'Y' to $collection-aged
end-if
add 1 to #i
end-while
end-procedure
!***********************************************************************
! Function: EVALUATE-COLLECTION-STATUS
! Description: This function is called if the the collection method on the
! aging id is 'D' (vary by collection code).
!***********************************************************************
begin-procedure EVALUATE-COLLECTION-STATUS
begin-select
Y.SETID
move &y.setid to $collection-setid
FROM PS_SET_CNTRL_REC Y
WHERE Y.SETCNTRLVALUE = $business-unit
AND Y.RECNAME = 'COLLECTION_TBL'
end-select
move ' ' to $collection-age-type
begin-select
G.COLLECT_AGE_TYPE
move &g.collect_age_type to $collection-age-type
FROM PS_COLLECTION_TBL G
WHERE G.COLLECTION_STATUS = $COLLECTION-STATUS
AND G.SETID = $collection-setid
AND G.EFFDT = (SELECT MAX(H.EFFDT) FROM PS_COLLECTION_TBL H
WHERE H.COLLECTION_STATUS = $COLLECTION-STATUS
AND H.SETID = $collection-setid
AND H.EFFDT <= $asofdate)
end-select
evaluate $collection-age-type
when = 'A'
do STD-CATEGORY
when = 'C'
do GET-COLLECTION-BUCKET
when = 'X'
let $exclude = 'Y'
when-other
do STD-CATEGORY
end-evaluate
end-procedure
!***********************************************************************
! Procedure: LOAD-CATEGORIES
! Description: This Procedure is called to retrieve the aging categories
! from the PS_AGING_TBL table. The category data is used
! to determine which aging category an item is placed in,
! depending on the start and end dates for each category.
!***********************************************************************
begin-procedure LOAD-CATEGORIES
move 1 to #i
begin-select
AGING_CATEGORY
DESCRSHORT
START_DAY
END_DAY
IF #i<8
PUT &aging_category &descrshort &start_day &end_day INTO CATEGORIES(#I) CA
TEGORY DESCRSHORT START-DAY END-DAY
ELSE
PUT &aging_category 'Others' &start_day &end_day INTO CATEGORIES(#I) CATEG
ORY DESCRSHORT START-DAY END-DAY
END-IF
add 1 to #i
FROM PS_AGING_CATEG_TBL
WHERE AGING_ID = $agingid
AND SETID = $setid
AND EFFDT = $aging-effdt
ORDER BY START_DAY
end-select
! let $category-headings = $category-headings || $xvother !ITEM
end-procedure
!***********************************************************************
! Procedure: ITEM-TOTAL
! Description: This Procedure prints out the item,item-line totals, adds the
! item totals to the customer totals
!***********************************************************************
begin-procedure ITEM-TOTAL
IF $ITEM <> $OLD-ITEM
do DIFF-DATE($asofdate,$post-dt,#diff-years,#diff-months,#diff-days)
if #diff-days < 0
do SELECT-ITEM-ACTIVITY
end-if
if $FIRSTITEM_ITEMLINE = 'Y'
print $Chartfieldname2 (+1,1,16)
print $CF_DETAILVALUE2 (0,+2,8)
print $Chartfieldname (+1,10,10)
print $CF_DETAILVALUE (0,+1,15)
print $xvcust_id (+1,19,11)
print $CUSTID (0,+2,15)
print $xvcust_name (0,+10,30)
print $cust-name (0,+2,30)
IF $SUMM_DETAIL_OPTN = 'D'
print $Item (+2,1,13)
END-IF
else
IF $SUMM_DETAIL_OPTN = 'D'
print $Item (+2,1,13)
END-IF
end-if
IF $SUMM_DETAIL_OPTN = 'D'
print #item-line (0,15,4) edit 999
print $item-asof-dt-p (0,20,10)
print $entrytype (0,31,5)
print $entryreason (0,37,5)
print $pymnt-terms (0,45,5)
! print $document (0,51,10)
END-IF
DO PROCESS-AMOUNTS
LET $ITEM-TOTAL-PRINTED = 'Y'
LET $FIRSTITEM_ITEMLINE = 'N'
!Set item values back to zero
move 1 to #i
WHILE #i < 12
put 0 into item-totals(#i) amt
add 1 to #i
END-WHILE
END-IF
end-procedure
!***********************************************************************
! Procedure: ITEM-LINE-TOTAL
! Description: This Procedure prints out the item,item-line totals, adds the
! item totals to the customer totals
!***********************************************************************
begin-procedure ITEM-LINE-TOTAL
do DIFF-DATE($asofdate,$post-dt,#diff-years,#diff-months,#diff-days)
if #diff-days < 0
do SELECT-ITEM-ACTIVITY
end-if
if $FIRSTITEM_ITEMLINE = 'Y'
print $Chartfieldname2 (+1,1,16)
print $CF_DETAILVALUE2 (0,+2,8)
print $Chartfieldname (+1,10,10)
print $CF_DETAILVALUE (0,+1,15)
print $xvcust_id (+1,19,11)
print $CUSTID (0,+2,15)
print $xvcust_name (0,+10,30)
print $cust-name (0,+2,30)
IF $SUMM_DETAIL_OPTN = 'D'
print $Item (+2,1,13)
END-IF
else
IF $SUMM_DETAIL_OPTN = 'D'
print $Item (+2,1,13)
END-IF
end-if
IF $SUMM_DETAIL_OPTN = 'D'
print #item-line (0,15,4) edit 999
print $item-asof-dt-p (0,20,10)
print $entrytype (0,31,5)
print $entryreason (0,37,5)
print $pymnt-terms (0,45,5)
! print $document (0,51,10)
END-IF
LET $CF_DETAILVALUE2_OLD = $CF_DETAILVALUE2
DO PROCESS-AMOUNTS
LET $ITEM-TOTAL-PRINTED = 'Y'
LET $FIRSTITEM_ITEMLINE = 'N'
!Set item values back to zero
move 1 to #i
WHILE #i < 12
put 0 into item-totals(#i) amt
add 1 to #i
END-WHILE
end-procedure
!***********************************************************************
! Procedure: CUSTOMER-TOTAL
! Description: This Procedure prints out the customer totals, adds the
! customer totals to the CF-TOTAL and REPORT-TOTALS
!***********************************************************************
begin-procedure CUSTOMER-TOTAL
print $xvtotal (+2,16,5)
print $cust-name (0,+3,30)
!Get Total Item Amount Column
move 10 to #BUCKET-NUM !ITEM 8
get #AMT from customer-total(#BUCKET-NUM)
ARRAY-ADD #AMT to cf-total(#BUCKET-NUM)
do Format_Currency_Amt(#AMT,$report-currency,$AsOfToday,'B99,999,999.99',$amt
,'I')
! print $amt (0,52,15) !ITEM (0,63,15)
move 11 to #BUCKET-NUM !ITEM 9
get #AMT from customer-total(#BUCKET-NUM)
ARRAY-ADD #AMT to cf-total(#BUCKET-NUM)
do Format_Currency_Amt(#AMT,$report-currency,$AsOfToday,'B99,999,999.99',$amt
,'I')
!CSV Request-begin
move 1 to #i
move 1 to #col
while #i < 5 !ITEM 1 until item 6
print ' ' (0,#col,1) !Blank column
add 1 to #i
add 1 to #col
end-while
!CSV Request-end
print $amt (0,52,15) !ITEM (0,82,15)
move 1 to #i
while #i < 9 !ITEM 7
get #AMT from customer-total(#i)
!CSV Request-begin
!If #AMT <> 0
!CSV Request-end
LET #BUCKET-NUM = #I
ARRAY-ADD #AMT to cf-total(#BUCKET-NUM)
ARRAY-ADD #AMT to REPORT-TOTALS(#BUCKET-NUM)
DO GET-PRINT-POSITION
do Format_Currency_Amt(#AMT,$report-currency,$AsOfToday,'B99,999,9
99.99',$amt,'I')
print $amt (0,#COL,15)
!CSV Request-begin
!end-if
!end-Request-end
add 1 to #i
end-while
!Set customer values back to zero
move 1 to #i
WHILE #i < 12
put 0 into customer-total(#i) amt
add 1 to #i
END-WHILE
Let $CUSTOMER-TOTAL-PRINTED = 'Y'
end-procedure
!***********************************************************************
! Procedure: CF-TOTAL
! Description: This Procedure prints out the Chartfield Subtotal Value and adds
the
! Chartfield Subtotal Value to the 2nd Chartfield Totals.
!***********************************************************************
begin-procedure CF-TOTAL
if $PrintCFSubtotal = 'Y'
print $xv_totals (+2,1,10)
print $Chartfieldname (0,+1,10)
print $CF_DETAILVALUE (0,+1,15)
end-if
!Get Total Item Amount Column
move 10 to #BUCKET-NUM !ITEM 8
get #AMT from cf-total(#BUCKET-NUM)
ARRAY-ADD #AMT to CF-TOTAL2(#BUCKET-NUM)
if $PrintCFSubtotal = 'Y'
do Format_Currency_Amt(#AMT,$report-currency,$AsOfToday,'B99,999,999.99',$
amt,'I')
! print $amt (0,52,15) !ITEM (0,63,15)
end-if
move 11 to #BUCKET-NUM !ITEM 9
get #AMT from cf-total(#BUCKET-NUM)
ARRAY-ADD #AMT to CF-TOTAL2(#BUCKET-NUM)
if $PrintCFSubtotal = 'Y'
do Format_Currency_Amt(#AMT,$report-currency,$AsOfToday,'B99,999,999.99',$
amt,'I')
print $amt (0,52,15) !ITEM (0,82,15)
end-if
!CSV Request-begin
move 1 to #i
move 1 to #col
while #i < 5 !ITEM 1 until item 6
print ' ' (0,#col,1) !Blank column
add 1 to #i
add 1 to #col
end-while
!CSV Request-end
move 1 to #i
while #i < 9 !ITEM 7
get #AMT from cf-total(#i)
if #AMT <> 0
LET #BUCKET-NUM = #I
ARRAY-ADD #AMT to CF-TOTAL2(#BUCKET-NUM)
if $PrintCFSubtotal = 'Y'
do GET-PRINT-POSITION
do Format_Currency_Amt(#AMT,$report-currency,$AsOfToday,
'B99,999,999.99',$amt,'I')
print $amt (0,#COL,15)
end-if
end-if
add 1 to #i
end-while
print ' ' (+1,1,1) !Blank Line
LET $CF-TOTAL-PRINTED = 'Y'
!***********************************************************************
! Procedure: CF-TOTAL2
! Description: This Procedure prints out the report totals for the second
! Chartfield
!***********************************************************************
begin-procedure CF-TOTAL2
if $PrintCFSubtotal2= 'Y'
print $xv_totals (+2,1,10)
print $Chartfieldname2 (0,+1,16)
print $CF_DETAILVALUE2 (0,+1,8)
move 1 to #i
WHILE #i < 9 !ITEM 7
GET #age-amt from ITEM-TOTALS(#I)
!CSV Request-begin
!If #age-amt <> 0
!CSV Request-end
LET #BUCKET-NUM = #I
DO GET-PRINT-POSITION
move #age-amt to #AMT
ARRAY-ADD #AMT to CUSTOMER-TOTAL(#BUCKET-NUM)
IF $SUMM_DETAIL_OPTN = 'D'
do Format_Currency_Amt(#AMT,$report-currency,$AsOfToday,'B99,999,99
9.99',$amt,'I')
print $amt (0,#COL,15)
end-if
!CSV Request-begin
!end-if
!CSV Request-end
add 1 to #i
END-WHILE
WHEN = 'C' !Age by CF Selected
Move #bal-amt-base to #AMT
move 10 to #BUCKET-NUM !ITEM 8
ARRAY-ADD #AMT to CUSTOMER-TOTAL(#BUCKET-NUM) !ITEM 10 reserved for Total I
tem Amount
IF $SUMM_DETAIL_OPTN = 'D'
do Format_Currency_Amt(#AMT,$report-currency,$AsOfToday,'B99,999,999.99',$a
mt,'I')
! print $amt (0,52,15) !ITEM (0,63,15) !Total Item Amount Column
end-if
move 1 to #i
WHILE #i < 9 !ITEM 7
GET #age-amt from ITEM-TOTALS(#i)
If #age-amt <> 0
LET #BUCKET-NUM = #i
DO GET-PRINT-POSITION
move #age-amt to #AMT
ARRAY-ADD #AMT to CUSTOMER-TOTAL(#BUCKET-NUM)
add #AMT to #totalselected
IF $SUMM_DETAIL_OPTN = 'D'
do Format_Currency_Amt(#AMT,$report-currency,$As
OfToday,'B99,999,999.99',$amt,'I')
print $amt (0,#COL,15)
end-if
end-if
add 1 to #i
END-WHILE
move 11 to #bucket-num !ITEM 11 reserved for Total Selected Amount
ARRAY-ADD #totalselected to CUSTOMER-TOTAL(#BUCKET-NUM)
IF $SUMM_DETAIL_OPTN = 'D'
do Format_Currency_Amt(#totalselected,$report-currency,$AsOfToday,'B99,9
99,999.99',$amt,'I')
print $amt (0,52,15) !ITEM (0,82,15) !Total Item Select Amount Column
end-if
move 0 to #totalselected
END-EVALUATE
end-procedure
!----------------------------------------------------------------------!
! Procedure: PRINT-REPORT-TOTALS !
! Descr: Print overall report totals, summing all customers. !
! Added for JFMIP. !
!----------------------------------------------------------------------!
begin-procedure PRINT-REPORT-TOTALS
move 1 to #i
do GET-PRINT-POSITION
move #COL to #REPORT-TOTALS-BEGINCOL
print $xv_reporttotals (+2,1,50)
!CSV Request-begin
move 1 to #i
while #i < 9 !ITEM 6
get $descrshort from categories(#i) descrshort
let $category-headings = $descrshort
print $category-headings (0,#REPORT-TOTALS-BEGINCOL,13)
let #REPORT-TOTALS-BEGINCOL = #REPORT-TOTALS-BEGINCOL + 14
add 1 to #i
end-while
!print $category-headings (0,#REPORT-TOTALS-BEGINCOL,115)
!CSV Request-end
print ' ' (+1,1,1) !Move to next line
move 1 to #i
while #i < 9
do GET-PRINT-POSITION
print '-------------' (0,#COL,13)
add 1 to #i
end-while
print ' ' (+1,1,1) !Move to next line
move 1 to #i
while #i < 9
do GET-PRINT-POSITION
get #AMT from REPORT-TOTALS(#i)
do Format_Currency_Amt(#AMT,$report-currency,$AsOfToday,'B99,999,999.99',$am
t,'I')
print $amt (0,#COL,14)
add 1 to #i
end-while
!CSV Request-begin
!print '=' (+1,#REPORT-TOTALS-BEGINCOL,110) fill
!CSV Request-end
end-procedure
!----------------------------------------------------------------------!
! Procedure: GET-SUBTOTALS !
! Descr: Gather Subtotals on runcontrol !
!----------------------------------------------------------------------!
begin-procedure GET-SUBTOTALS
if #CFCount > 0
let #CFidx = 0
let #subtotalcnt = 0 !Up to 2 fields can be subtotaled on the runcon
trol page
while #CFidx < #CFCount
get $SubTotal from CFsInfo(#CFidx) SubTotal
get $CFName from CFsInfo(#CFidx) CField
EVALUATE #CFidx
WHEN = 0
let $CF_Subtotal = 'B.'||$CFName
let $Chartfieldname = $CFName
if $SubTotal = 'Y'
let $PrintCFSubtotal = 'Y'
end-if
WHEN = 1
let $CF_SUBTOTAL2 = 'B.'||$CFName
let $Chartfieldname2 = $CFName
if $SubTotal = 'Y'
let $PrintCFSubtotal2 = 'Y'
end-if
end-evaluate
add 1 to #CFidx
end-while
end-if
end-procedure !GET-SUBTOTALS
!----------------------------------------------------------------------!
! Procedure: GET-CF-PARAMETERS !
! Descr: Gathers Chartfield From/To Ranges entered on runcntl page!
!----------------------------------------------------------------------!
begin-procedure GET-CF-PARAMETERS
if #CFCount > 0
let #CFidx = 0
while #CFidx < #CFCount
get $CFIELD from CFsInfo(#CFidx) CFIELD
get $CFValue from CFsInfo(#CFidx) CFVALUE
get $CFVALUETO from CFsInfo(#CFidx) CFVALUETO
Let $CFIELD = RTRIM($CFIELD,' ')
Let $CFvalue = RTRIM($CFvalue,' ')
Let $CFVALUETO = RTRIM($CFVALUETO,' ')
if $CFvalue <> ''
IF $CFVALUE = $CFVALUETO !Single Value
LET $CFPARMS = $CFPARMS||' AND B.'||$CFIELD||' = '||$QUOTE||$CFV
alue||$QUOTE
Let $xvcfparms = $xvcfparms||$CFIELD||' = '||$CFVALUE||','
else !range
LET $CFPARMS = $CFPARMS||' AND B.'||$CFIELD||' BETWEEN '||$QUOTE
||$CFValue||$QUOTE||' AND '||$QUOTE||$CFVALUETO||$QUOTE
Let $xvcfparms = ' '||$xvcfparms||' '||$CFIELD||' = '||$CFVALUE|
|'-'||$CFVALUETO||','
end-if
end-if
add 1 to #CFidx
end-while
else
end-if
let $xvcfparms = rtrim($xvcfparms,',')
end-procedure
!----------------------------------------------------------------------!
! Procedure: BUILD-WHERE-CLAUSE !
! Descr: Build Where Clause for use in program !
!----------------------------------------------------------------------!
begin-procedure BUILD-WHERE-CLAUSE
LET $BUSINESS_UNIT = RTRIM($BUSINESS_UNIT,' ')
LET $CUST_ID = RTRIM($CUST_ID,' ')
IF $BUSINESS_UNIT <> ''
LET $WHERE_BU_CUST = 'AND A.BUSINESS_UNIT ='||$quote||$BUSINESS_UNIT||$quote
END-IF
IF $CUST_ID <> ''
LET $WHERE_BU_CUST = $WHERE_BU_CUST || 'AND A.CUST_ID = '||$quote||$CUST_ID||$qu
ote
END-IF
end-procedure
!----------------------------------------------------------------------!
! Procedure: GET-PRINT-POSITION !
! Descr: !
!----------------------------------------------------------------------!
begin-procedure GET-PRINT-POSITION
Evaluate #i
WHEN = 1
LET #COL = 65 !ITEM 98
WHEN = 2
LET #COL = 79 !ITEM 114
WHEN = 3
LET #COL = 93 !ITEM 130
WHEN = 4
LET #COL = 107 !ITEM 146
WHEN = 5
LET #COL = 121 !ITEM 162
WHEN = 6
LET #COL = 135 !ITEM 162
WHEN = 7
LET #COL = 149 !ITEM
WHEN = 8
LET #COL = 163 !ITEM
END-EVALUATE
end-procedure
!***********************************************************************
! Procedure: INITIALIZE-VARIABLES
! Description: This procedure initializes variables used in the program
!***********************************************************************
begin-procedure INITIALIZE-VARIABLES
let $quote = chr(39)
move 'AR30006' to $ReportID
let $panel_group_name = 'RUN_AR30006'
move '' to $category-headings
move 1 to #i
move '' to $CF_DETAILVALUE2
let $CF-TOTAL-PRINTED = 'N'
let $CF-TOTAL2-PRINTED = 'N'
let $FIRSTITEM_ITEMLINE = 'Y'
let $ITEM-TOTAL-PRINTED = 'N'
let $xvcfparms = ' '
let $CF_Subtotal = $quote||'X'||$quote
let $CF_SUBTOTAL2 = $quote||'X'||$quote
let $PrintCFSubtotal = 'N'
let $PrintCFSubtotal2= 'N'
let $Chartfieldname = ' '
move 0 to #totalselected
do Init_Report_Translation('AR30006', $prcs_language_cd)
end-procedure
!***********************************************************************
! Procedure: PRINT-UNDERLINE
! Description: This Procedure prints underline under totals
!***********************************************************************
begin-procedure PRINT-UNDERLINE
print ' ' (+1,1,100) fill
print '-' (0,65,112) fill
print '' (+1,0)
end-procedure
!***********************************************************************
! Procedure: DEFAULT-LEDGER-GROUP
! Description: This Procedure prints underline under totals
!***********************************************************************
begin-procedure DEFAULT-LEDGER-GROUP
begin-select
B.LEDGER
move &B.LEDGER to $LEDGER
FROM PS_BU_LED_GRP_TBL A , PS_LED_GRP_LED_TBL B
WHERE A.BUSINESS_UNIT = $BUSINESS_UNIT
AND A.LEDGER_GROUP = B. LEDGER_GROUP
AND B.SETID= (
SELECT SETID
FROM PS_SET_CNTRL_REC
WHERE SETCNTRLVALUE = A.BUSINESS_UNIT
AND RECNAME = 'LED_GRP_TBL')
AND A.DEFAULT_LEDGER_GRP = 'Y'
AND B.PRIMARY_LEDGER = 'Y'
end-select
end-procedure
!***********************************************************************
! Procedure: END-PROCESS
! Desc: Update the process scheduler run control
!***********************************************************************
begin-procedure END-PROCESS
If $prcs_process_instance <> ''
do UPDATE-PRCS-RUN-STATUS
do Commit-Transaction
end-if
end-procedure
!----------------------------------------------------------------------!
! Procedure: get-xlat-fields !
! Desc: Retrieves Translation Values from the STRINGS_TBL !
!----------------------------------------------------------------------!
Begin-Procedure get-xlat-fields
do Get_Field_Information('AR30006','TOTAL',$xvtotal,#xfwtotal)
do Get_Field_Information('AR30006','ENTRY',$xventry,#xfwtotal)
do Get_Field_Information('AR30006','TYPE',$xvtype,#xfwtype)
do Get_Field_Information('AR30006','REASON',$xvreason,#xfwreason)
do Get_Field_Information('AR30006','AGING_ID',$xvaging_id,#xfwaging_id)
do Get_Field_Information('AR30006','AMOUNT', $xvamount, #xfwamount)
do Get_Field_Information('AR30006','AR30006', $xvar30006, #xfwar30006)
do Get_Field_Information('AR30006','ALL_VALS', $xv_all_vals,#xfw_all_vals)
do Get_Field_Information('AR30006','BUS_UNIT', $xv_bus_unit,#xfw_bus_unit)
do Get_Field_Information('AR30006','ASOF_DT', $xvas_of_dt, #xfwas_of_dt)
do Get_Field_Information('AR30006','DOCUMENT',$xvdocument,#xfwdocument)
do Get_Field_Information('AR30006','CUST_ID',$xvcust_id,#xfwcust_id)
do Get_Field_Information('AR30006','CUST_NAME',$xvcust_name,#xfwcust_name)
do Get_Field_Information('AR30006','ITEM',$xvitem,#xfwitem)
do Get_Field_Information('AR30006','SELECTED',$xvselected,#xfwselected)
do Get_Field_Information('AR30006','ITEM_LINE',$xvitemline,#xfwitemline)
do Get_Field_Information('AR30006','OTHER',$xvother,#xfwother)
do Get_Field_Information('AR30006','TERMS',$xvterms,#xfwterms)
do Get_Field_Information('AR30006','DISPLAY_OPN',$xvdisplay,#xfwdisplay)
do Get_Field_Information('AR30006','AGE_DISPLAY_OPTION',$xvagedisplayoption,#
xfwagedisplayoption)
do Get_Field_Information('AR30006','CHARTFIELD_SELECT',$xvcfselected,#xfwcfse
lected)
do Get_Field_Information('AR30006','ITEM_BALANCE',$xvitembal,#xfwitembal)
do Get_Field_Information('AR30006','CF_PARMS',$xvcf_parms,#xfwcf_parms)
do Get_Field_Information('AR30006','TOTALS',$xv_totals,#xfwtotals)
do Get_Field_Information('AR30006','REPORTTOTALS',$xv_reporttotals,#xfwreport
totals)
End-Procedure !get-xlat-fields
!----------------------------------------------------------------------!
! Procedure: Set-hdr-options !
! Desc: Set printing options for header !
!----------------------------------------------------------------------!
Begin-Procedure Set-hdr-options
evaluate $DISPLAY_OPN
when = 'C'
let $xvdisplayopn = $xvcfselected
when = 'I'
let $xvdisplayopn = $xvitembal
end-evaluate
end-procedure
!----------------------------------------------------------------------!
! Called SQC Procedures !
!----------------------------------------------------------------------!
#include 'reset.sqc' ! Reset printer procedure
#include 'curdttim.sqc' ! Get-Current-DateTime procedure
#include 'datetime.sqc' ! Routines for date and time formatting
#include 'prcsapi.sqc' ! Update Process Request API
#include 'prcsdef.sqc' ! Update Process Request Variable Declare
#include 'gar30006.sqc' ! Get Variables entered through Process Scheduler
#include 'tranctrl.sqc' ! Commit transactions
#include 'readxlat.sqc' ! Routing for Getting Translate Value