I'm using DFSORT's ICETOOL DISPLAY operator to generate a list of accounts. I'm using a 'BREAK' on the branches to separate the accounts by sortcode and then sum the balance for the account. Everything works fine, but I get an additional entry(account) after summing the balance using BTOTAL. I've added my code below and the result so you better understand my question.
code
//SUR0007 JOB (5678),'ACCOUNTS'
//RUNIT EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//TOOLIN DD *
DISPLAY FROM(INPUT2) LIST(REPORT) -
TITLE('LIST OF BANK ACCOUNTS BY BRANCH') -
HEADER('ACCOUNT') ON(2,8,BI,E'99999999') -
HEADER('BALANCE') ON(3,6,BI,E'99999999') -
HEADER('OWNER') ON(13,30,CH) -
BTITLE('SORTCODE:') BREAK(1,4,BI,E'999999') -
BTOTAL('BRANCH TOTAL:') -
TOTAL('GRAND TOTAL:')
/*
//INPUT2 DD DSN=USER.CICS.Z022.BANK.ACCOUNTS,DISP=SHR
//REPORT DD SYSOUT=*
result
SORTCODE:000012
ACCOUNT BALANCE
-------- --------
91317760 97999587
BRANCH TOTAL :
91317760 97999587
Expected result
SORTCODE:000012
ACCOUNT BALANCE
-------- --------
91317760 97999587
BRANCH TOTAL : 97999587
DFSORT's ICETOOL DISPLAY operator has many options, which means there is extensive documentation for it.
You should consult the DFSORT Getting Started manual for introductory-level use, and DFSORT Application Programming Guide for more high-level use.
Within BCOUNT, all numeric fields will appear with totals. Your account is numeric (binary), but if you can't make it non-numeric you can use NOST
(you can pretend that means NO Sub-Totals) as part of the formatting for any field that you do not want to be summed automatically.
To get your BTOTAL text to appear on the same line as the totals, use STATLEFT
in the report description.
Here's an example of the use of both from the Application Programming Guide:
DISPLAY FROM(ACCTS) LIST(FANCY) -
TITLE('Accounts Report for First Quarter') -
DATE(MD4/) BLANK -
HEADER('Amount') ON(12,6,ZD,C1,N08) -
HEADER(Id') ON(NUM,N02) -
HEADER('Acct#') ON(31,3,PD,NOST,LZ) -
HEADER('Date') ON(1,4,ZD,E'99/99',NOST) -
INDENT(2) BETWEEN(5) -
STATLEFT -
TOTAL('Total for Q1') -
AVERAGE('Average for Q1')
There is coding for a plain version of the same report:
DISPLAY FROM(ACCTS) LIST(PLAIN) -
TITLE('Accounts Report for First Quarter') -
DATE(MD4/) BLANK -
HEADER('Amount') ON(12,6,ZD) -
HEADER(Id') ON(NUM) -
HEADER('Acct#') ON(31,3,PD) -
HEADER('Date') ON(1,4,ZD) -
TOTAL('Total for Q1') -
AVERAGE('Average for Q1')
The output, with explanation from the example, is:
This example shows some options you can use to improve the appearance of a DISPLAY report. The first DISPLAY operator produces a "plain" report, and the second DISPLAY operator uses the options shown in bold to produce a "fancy" report.
The PLAIN output starts on a new page and looks as follows:
Accounts Report for First Quarter 05/04/2001
Amount Id Acct# Date
--------------- --------------- ------------------- --------------------
93271 1 15932 106
137622 2 187 128
83147 3 15932 212
183261 4 2158 217
76389 5 187 305
920013 6 15932 319
Total for Q1
1493703 50328 1287
Average for Q1
248950 8388 214
The FANCY output starts on a new page and looks as follows:
Accounts Report for First Quarter 05/04/2001
Amount Id Acct# Date
-------- --- ------ -----
932.71 1 15932 01/06
1,376.22 2 00187 01/28
831.47 3 15932 02/12
1,832.61 4 02158 02/17
763.89 5 00187 03/05
9,200.13 6 15932 03/19
Total for Q1 14,937.03
Average for Q1 2,489.50
Here is an explanation of the extra options used for the "fancy" report:
First ON field: In the PLAIN report, BLANK causes ICETOOL to print
the 6-byte ZD values as unedited digits with leading zeros suppressed. But for this example, we know the digits really represent dollars and cents. So in the FANCY report, we use the C1 formatting item (one of thirty-three available masks) to print the values with a comma (,) as the thousands separator and a period (.) as the decimal point.
In the PLAIN report, TOTAL causes ICETOOL to allow 15 digits for the
values because it does not know how many digits are needed. But for this example, we know the total amount will not exceed 8 digits. So in the FANCY report, we use the N08 formatting item to set the number of digits to 8. This decreases the column width for the field.
Second ON field: In the PLAIN report, NUM causes ICETOOL to allow 15
digits for the record number because it does not know how many digits are needed. But for this example, we know the number of records will not exceed 99. So in the FANCY report, we use the N02 formatting item to set the number of digits to 2. This decreases the column width for the record number.
Third ON field: In the PLAIN report, TOTAL and AVERAGE cause ICETOOL to
print the total and average for this 3-byte PD field. But for this example, we know we do not want statistics for the field because it is an account number. So in the FANCY report, we use the NOST formatting item to suppress the statistics for this field.
In the PLAIN report, the default mask of A0 causes ICETOOL to suppress
leading zeros for this 3-byte PD field. But for this example, we know that we want to show leading zeros for the field because it is an account number. So in the FANCY report, we use the LZ formatting item to print leading zeros for this field.
Fourth ON field: In the PLAIN report, BLANK causes ICETOOL to print the
4-byte ZD values as unedited digits with leading zeros suppressed. But for this example, we know the digits represent a date (month and day). So in the FANCY report, we use the E'99/99' formatting item to print the values with leading zeros and a slash (⁄) between the month and day.
In the PLAIN report, TOTAL and AVERAGE cause ICETOOL to print the total
and average for this 4-byte ZD field. But for this example, we know we do not want the total or average for this field because it is a date. So in the FANCY report, we use the NOST formatting item to suppress the statistics for this field.
Note: In some applications, we might want the minimum and maximum for a
date displayed with E'pattern', so we would not specify NOST for the date field.
INDENT: In the PLAIN report, ICETOOL starts the report in column 2
(after the control character), by default. But for this example, we want to indent the report a bit. So in the FANCY report, we use the INDENT(2) operand to indent the report by 2 blanks so it starts in column 4.
BETWEEN: In the PLAIN report, ICETOOL uses 3 blanks between the columns
of data, by default. But for this example, we want more space between the columns. So in the FANCY report, we use the BETWEEN(5) operand to insert 5 blanks between the columns.
STATLEFT: In the PLAIN report, ICETOOL prints the strings for TOTAL
and AVERAGE under the first column of data, by default, and uses two lines for each statistic to avoid having the string overlay the value. But for this example, we would like to have the TOTAL and AVERAGE strings stand out in the report and also have each string on the same line as its value. So in the FANCY report, we use the STATLEFT operand to print the TOTAL and AVERAGE strings to the left of the first column of data.
Here's the link, which also includes a "plain" version of the report to contrast with the fancy one: http://www-01.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.icea100/ice2ca_Example_1110.htm
I located the link by search-engineing for icetool display statleft nost
.