Step 6. Keep Statistics and Print
FRM115 - Writing Reports
In this step, you will keep some statistics based on each department and define some report breaks.
- Define a working field for the report called TOTAL. The field should be P(14,2) with an edit code of A. Enter a label, column heading and description of Total Amount.
- Define a working field for the report called EMPCOUNT. The field should be P(3,0) with an edit code of A. Enter a label, column heading and description of Employee Count.
- Define a report break which prints the EMPCOUNT and TOTAL as a trailing break when the DEPTMENT code changes.
- Keep track of the total of the salary amounts for each department in the TOTAL field.
- Keep a count of the number of employees in each department in the EMPCOUNT field.
1. Try to make the necessary code changes based on the function description above.
2. Your code should appear as follows:
FUNCTION OPTIONS(*DIRECT)
DEFINE FIELD(#TOTAL) TYPE(*DEC) LENGTH(14) DECIMALS(2) LABEL('Total Amount')
DESC('Total Amount') COLHDG('Total Amount') EDIT_CODE(A)
DEFINE FIELD(#EMPCOUNT) TYPE(*DEC) LENGTH(3) DECIMALS(0) LABEL('Employee Count')
DESC('Employee Count') COLHDG('Employee Count') EDIT_CODE(A)
DEF_REPORT FORMSIZE(66 80)
GROUP_BY NAME(#REPDATA) FIELDS(#DEPTMENT #DEPTDESC #SECTION #EMPNO #SALARY
#STARTDTE)
DEF_HEAD NAME(#HDR01) FIELDS(#REP1PAGE #FUNCTION #STD_TITLE #DEPTMENT #DEPTDESC)
TRIGGER_BY(*OVERFLOW #DEPTMENT) DESIGN(*DOWN)
DEF_FOOT NAME(#FTR01) FIELDS(#DATE #TIME #REP1PAGE)
DEF_LINE NAME(#DET01) FIELDS(#SECTION #EMPNO #SALARY #STARTDTE)
DEF_BREAK NAME(#BRK01) FIELDS(#EMPCOUNT #TOTAL) TRIGGER_BY(#DEPTMENT)
#STD_TITLE := 'Employee Report'
SELECT FIELDS(#REPDATA) FROM_FILE(PSLMST1) WITH_KEY(#DEPTMENT #SECTION)
NBR_KEYS(*COMPUTE) GENERIC(*YES)
KEEP_TOTAL OF_FIELD(#SALARY) IN_FIELD(#TOTAL) BY_FIELD(#DEPTMENT)
KEEP_COUNT OF_FIELD(#EMPNO) IN_FIELD(#EMPCOUNT) BY_FIELD(#DEPTMENT)
FETCH FIELDS(#DEPTDESC) FROM_FILE(DEPTAB) WITH_KEY(#DEPTMENT) KEEP_LAST(1)
PRINT LINE(#DET01)
ENDSELECT
ENDPRINT
3. Save the code and then full function check or build the RDML. Make any corrections as required.
4. Exit the editor.
5. Compile the function.
6. Submit your new function using form iiiCOM19.
a. Enter a department of A and leave the section blank.
b. Check that the break totals are properly printed and check that they are correct. Each department should have its own totals and employee count.