home *** CD-ROM | disk | FTP | other *** search
- REPORT r_sales(rbegin, rend, mon, msales, emp)
- {
- The r_sales report prints the value of sales for a six-month
- period, by salesperson and month, with salesperson and month
- totals and a grand total. The information is printed in
- tabular format on the screen.
- }
- DEFINE msales INTEGER,
- sfirst CHAR(1),
- slast CHAR(15),
- col, totcol ARRAY[6] OF INTEGER,
- months ARRAY[12] OF CHAR(3),
- rbegin, rend DATE,
- mon, emp, temp1 SMALLINT
-
- OUTPUT
- TOP MARGIN 0
- BOTTOM MARGIN 0
- LEFT MARGIN 0
- PAGE LENGTH 22
-
- FORMAT
-
- PAGE HEADER
- IF (PAGENO = 1) THEN
- LET months[1] = "Jan" LET months[2] = "Feb"
- LET months[3] = "Mar" LET months[4] = "Apr"
- LET months[5] = "May" LET months[6] = "Jun"
- LET months[7] = "Jul" LET months[8] = "Aug"
- LET months[9] = "Sep" LET months[10] = "Oct"
- LET months[11] = "Nov" LET months[12] = "Dec"
- FOR temp1 = 1 TO 6
- LET totcol[temp1] = 0
- END FOR
- END IF
-
- CLEAR SCREEN
- PRINT COLUMN 35, "S A L E S"
- PRINT COLUMN 20, "for the period ",
- rbegin USING "MMM. DD, YYYY", " - ", rend USING "MMM. DD, YYYY"
- PRINT COLUMN 33, "by salesperson"
- SKIP 1 LINE
- LET temp1 = MONTH(rbegin)
- PRINT "Salesperson", COLUMN 22, months[temp1];
- LET temp1 = temp1 + 1
- IF temp1 > 12 THEN LET temp1 = temp1 - 12 END IF
- PRINT COLUMN 30, months[temp1];
- LET temp1 = temp1 + 1
- IF temp1 > 12 THEN LET temp1 = temp1 - 12 END IF
- PRINT COLUMN 38, months[temp1];
- LET temp1 = temp1 + 1
- IF temp1 > 12 THEN LET temp1 = temp1 - 12 END IF
- PRINT COLUMN 46, months[temp1];
- LET temp1 = temp1 + 1
- IF temp1 > 12 THEN LET temp1 = temp1 - 12 END IF
- PRINT COLUMN 54, months[temp1];
- LET temp1 = temp1 + 1
- IF (temp1 > 12) THEN LET temp1 = temp1 - 12 END IF
- PRINT COLUMN 62, months[temp1], COLUMN 74, "Total"
- SKIP 1 LINE
-
- ON EVERY ROW
- IF (MONTH(rbegin) > mon) THEN
- LET mon = mon + 12
- END IF
- LET mon = mon - MONTH(rbegin) + 1
- LET col[mon] = msales
-
- BEFORE GROUP OF emp
- FOR temp1 = 1 TO 6
- LET col[temp1] = 0
- END FOR
-
- AFTER GROUP OF emp
- SELECT fname[1],
- lname
- INTO sfirst,
- slast
- FROM sperson
- WHERE empnum = emp
-
- PRINT sfirst, 1 SPACE, slast,
- COLUMN 18, col[1] USING "###,##&",
- COLUMN 26, col[2] USING "###,##&",
- COLUMN 34, col[3] USING "###,##&",
- COLUMN 42, col[4] USING "###,##&",
- COLUMN 50, col[5] USING "###,##&",
- COLUMN 58, col[6] USING "###,##&",
- COLUMN 70, col[1] + col[2] + col[3] + col[4] + col[5] + col[6]
- USING "#,###,##&"
- FOR temp1 = 1 TO 6
- LET totcol[temp1] = totcol[temp1] + col[temp1]
- END FOR
-
- PAGE TRAILER
- CALL wwait()
-
- ON LAST ROW
- SKIP 1 LINE
- PRINT "Total",
- COLUMN 18, totcol[1] USING "###,##&",
- COLUMN 26, totcol[2] USING "###,##&",
- COLUMN 34, totcol[3] USING "###,##&",
- COLUMN 42, totcol[4] USING "###,##&",
- COLUMN 50, totcol[5] USING "###,##&",
- COLUMN 58, totcol[6] USING "###,##&",
- COLUMN 70, totcol[1] + totcol[2] + totcol[3]
- + totcol[4] + totcol[5] + totcol[6]
- USING "#,###,##&"
- END REPORT
-