home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 6 / 06.iso / a / a610 / 6.ddi / DEMO / FGL / R_SALES.4GL < prev    next >
Encoding:
Text File  |  1989-12-08  |  3.4 KB  |  111 lines

  1. REPORT r_sales(rbegin, rend, mon, msales, emp)
  2. {
  3. The r_sales report prints the value of sales for a six-month
  4. period, by salesperson and month, with salesperson and month
  5. totals and a grand total.  The information is printed in 
  6. tabular format on the screen.
  7. }
  8. DEFINE   msales               INTEGER,
  9.          sfirst               CHAR(1),
  10.          slast                CHAR(15),
  11.          col, totcol          ARRAY[6] OF INTEGER,
  12.          months               ARRAY[12] OF CHAR(3),
  13.          rbegin, rend         DATE,
  14.          mon, emp, temp1      SMALLINT
  15.  
  16. OUTPUT
  17.    TOP MARGIN 0
  18.    BOTTOM MARGIN 0
  19.    LEFT MARGIN 0
  20.    PAGE LENGTH 22
  21.  
  22. FORMAT
  23.  
  24. PAGE HEADER
  25.    IF (PAGENO = 1) THEN
  26.       LET months[1] = "Jan"   LET months[2] = "Feb"
  27.       LET months[3] = "Mar"   LET months[4] = "Apr"
  28.       LET months[5] = "May"   LET months[6] = "Jun"
  29.       LET months[7] = "Jul"   LET months[8] = "Aug"
  30.       LET months[9] = "Sep"   LET months[10] = "Oct"
  31.       LET months[11] = "Nov"  LET months[12] = "Dec"
  32.       FOR temp1 = 1 TO 6
  33.          LET totcol[temp1] = 0
  34.       END FOR
  35.    END IF
  36.  
  37.    CLEAR SCREEN
  38.    PRINT COLUMN 35, "S A L E S"
  39.    PRINT COLUMN 20, "for the period ",
  40.       rbegin USING "MMM. DD, YYYY", " - ", rend USING "MMM. DD, YYYY"
  41.    PRINT COLUMN 33, "by salesperson"
  42.    SKIP 1 LINE
  43.    LET temp1 = MONTH(rbegin)
  44.    PRINT "Salesperson", COLUMN 22, months[temp1];
  45.    LET temp1 = temp1 + 1
  46.    IF temp1 > 12 THEN LET temp1 = temp1 - 12 END IF
  47.    PRINT COLUMN 30, months[temp1];
  48.    LET temp1 = temp1 + 1
  49.    IF temp1 > 12 THEN LET temp1 = temp1 - 12 END IF
  50.    PRINT COLUMN 38, months[temp1];
  51.    LET temp1 = temp1 + 1
  52.    IF temp1 > 12 THEN LET temp1 = temp1 - 12 END IF
  53.    PRINT COLUMN 46, months[temp1];
  54.    LET temp1 = temp1 + 1
  55.    IF temp1 > 12 THEN LET temp1 = temp1 - 12 END IF
  56.    PRINT COLUMN 54, months[temp1];
  57.    LET temp1 = temp1 + 1
  58.    IF (temp1 > 12) THEN LET temp1 = temp1 - 12 END IF
  59.    PRINT COLUMN 62, months[temp1], COLUMN 74, "Total"
  60.    SKIP 1 LINE
  61.  
  62. ON EVERY ROW
  63.    IF (MONTH(rbegin) > mon) THEN
  64.       LET mon = mon + 12
  65.    END IF
  66.    LET mon = mon - MONTH(rbegin) + 1
  67.    LET col[mon] = msales
  68.  
  69. BEFORE GROUP OF emp
  70.    FOR temp1 = 1 TO 6
  71.       LET col[temp1] = 0
  72.    END FOR
  73.  
  74. AFTER GROUP OF emp
  75.    SELECT      fname[1],
  76.                lname
  77.       INTO     sfirst,
  78.                slast
  79.       FROM     sperson
  80.       WHERE    empnum = emp
  81.  
  82.    PRINT sfirst, 1 SPACE, slast,
  83.       COLUMN 18, col[1] USING "###,##&",
  84.       COLUMN 26, col[2] USING "###,##&",
  85.       COLUMN 34, col[3] USING "###,##&",
  86.       COLUMN 42, col[4] USING "###,##&",
  87.       COLUMN 50, col[5] USING "###,##&",
  88.       COLUMN 58, col[6] USING "###,##&",
  89.       COLUMN 70, col[1] + col[2] + col[3] + col[4] + col[5] + col[6]
  90.                         USING "#,###,##&"
  91.       FOR temp1 = 1 TO 6
  92.          LET totcol[temp1] = totcol[temp1] + col[temp1]
  93.       END FOR
  94.  
  95. PAGE TRAILER
  96.    CALL wwait()
  97.  
  98. ON LAST ROW
  99.    SKIP 1 LINE
  100.    PRINT "Total",
  101.       COLUMN 18, totcol[1] USING "###,##&",
  102.       COLUMN 26, totcol[2] USING "###,##&",
  103.       COLUMN 34, totcol[3] USING "###,##&",
  104.       COLUMN 42, totcol[4] USING "###,##&",
  105.       COLUMN 50, totcol[5] USING "###,##&",
  106.       COLUMN 58, totcol[6] USING "###,##&",
  107.       COLUMN 70, totcol[1] + totcol[2] + totcol[3]
  108.                + totcol[4] + totcol[5] + totcol[6]
  109.                            USING "#,###,##&"
  110. END REPORT
  111.