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

  1. DATABASE leads
  2. GLOBALS "globals.4gl"
  3.  
  4. MAIN
  5. {
  6. The s_medium program computes the value of each sale for each
  7. salesperson in a specified period and feeds them to the
  8. r_medium report.  The r_medium report prints the total value
  9. of the sales for each employee as well as the grand total
  10. for the period.  The output is sent to medium.out.
  11. }
  12. DEFINE   pr_ssum           RECORD
  13.             tot            MONEY,
  14.             emp            SMALLINT,
  15.             sdate          DATE,
  16.             edate          DATE
  17.          END RECORD
  18.  
  19. DECLARE c_sales CURSOR FOR
  20. SELECT      sale.quantity * product.price * (1 - sale.discount/100),
  21.             contact.empnum
  22.    INTO     pr_ssum.tot,
  23.             pr_ssum.emp
  24.    FROM     sale,
  25.             product,
  26.             contact
  27.    WHERE    sale.cnum = contact.cnum
  28.             AND sale.pcode = product.pcode
  29.             AND contact.cdate BETWEEN pr_ssum.sdate AND pr_ssum.edate
  30.    ORDER BY contact.empnum
  31.  
  32. PROMPT "Start Date (mm/dd/yy): " FOR pr_ssum.sdate
  33. PROMPT "End Date (mm/dd/yy): " FOR pr_ssum.edate
  34. START REPORT r_medium
  35. FOREACH c_sales
  36.    OUTPUT TO REPORT r_medium(pr_ssum.*)
  37. END FOREACH
  38. FINISH REPORT r_medium
  39. END MAIN
  40.  
  41. REPORT r_medium(rr)
  42. DEFINE   rr                RECORD
  43.             tot            MONEY,
  44.             emp            SMALLINT,
  45.             sdate          DATE,
  46.             edate          DATE
  47.          END RECORD
  48.  
  49. OUTPUT
  50.    REPORT TO "medium.out"
  51.  
  52. FORMAT
  53. PAGE HEADER
  54.    PRINT "Sales Summary by Salesperson"
  55.    PRINT "For the Period ", rr.sdate, " through ", rr.edate
  56.    SKIP 2 LINES
  57.    PRINT "Employee", COLUMN 20, "Total"
  58.    PRINT "Number", COLUMN 20, "Sales"
  59.    SKIP 1 LINE
  60.  
  61. AFTER GROUP OF rr.emp
  62.    PRINT rr.emp, COLUMN 15, GROUP SUM(rr.tot) USING "###,##&.&&"
  63.  
  64. ON LAST ROW
  65.    SKIP 1 LINE
  66.    PRINT "Total", COLUMN 13, SUM(rr.tot) USING "#,###,##&.&&"
  67. END REPORT
  68.