7 63 3 KEEP_COUNT Example

LANSA Technical

7.63.3 KEEP_COUNT Example

A personnel file contains details of employees with their department, section and salary. Print details of the count of departments and sections and the totals of salaries by department and section

DEF_LINE NAME(#DETAIL) FIELDS(#EMPNO #FULLNAME #DEPTMENT #SECTION #SALARY)
*
DEF_BREAK NAME(#SECSUM) FIELDS(#DEPTMENT #SECTION #DEM_SCTOT #DEM_SCSEM) TRIGGER_BY(#DEPTMENT #SECTION)
DEF_BREAK NAME(#DEPSUM) FIELDS(#DEPTMENT #DEM_DPTOT #DEM_DPSEM) TRIGGER_BY(#DEPTMENT)
*
SELECT FIELDS(#DETAIL) FROM_FILE(PERSNEL)
KEEP_COUNT OF_FIELD(#EMPNO) IN_FIELD(#DEM_DPSEM) BY_FIELD(#DEPTMENT)
KEEP_COUNT OF_FIELD(#EMPNO) IN_FIELD(#DEM_SCSEM) BY_FIELD(#DEPTMENT #SECTION)
KEEP_TOTAL OF_FIELD(#SALARY) IN_FIELD(#DEM_DPTOT) BY_FIELD(#DEPTMENT)
KEEP_TOTAL OF_FIELD(#SALARY) IN_FIELD(#DEM_SCTOT) BY_FIELD(#DEPTMENT #SECTION)
PRINT LINE(#DETAIL)
ENDSELECT
*
ENDPRINT