1 / 20

Control Break Processing

Control Break Processing. ITE 370. Control Break Processing. Classic File Processing Technique Used in Main Frame Systems Used in Report Utilities Crystal Reports Designed to work on the file Regardless of Length Even if Length Changes Don’t hard code to file

Download Presentation

Control Break Processing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Control Break Processing ITE 370

  2. Control Break Processing • Classic File Processing Technique • Used in Main Frame Systems • Used in Report Utilities • Crystal Reports • Designed to work on the file • Regardless of Length • Even if Length Changes • Don’t hard code to file • You know the design & makeup of file, but not content

  3. Control Break Algorithm - Generic • ControlVar ‘* control variable which holds value of current group being processed • GrandTotal ‘* accumulator for whole file • GroupTotal ‘* accumulator for current group,(current value of ControlVar), displaying a sub-total • File ‘* file ordered by control variable, i.e. grouping variable  • Row ‘* contains information from a row of File • .Info ‘* information on row to display • .SumField ‘* numeric data to sum for a group • .ControlField ‘* stores value for control variable, i.e. the grouping variable • BEGIN • File.Open • Row  File.Read ‘* read first row of data from File • ControlVar  Row.ControlField • Display Heading with ControlVar • GroupTotal  0 • GrandTotal  0 • While Not File.EOF • If Row.ControlField <> ControlVar Then • Display Sub-totals with GroupTotal • GrandTotal  GrandTotal + GroupTotal • ControlVar  Row.ControlField • Display Heading with ControlVar • GroupTotal  0 • End If • Display Row.Info, Row.SumField • GroupTotal  GroupTotal + Row.SumField • Row  File.Read ‘* read next row of data from file • End While • ‘* display sub-totals for last group • Display GroupTotal • GrandTotal  GrandTotal + GroupTotal • Display GrandTotal • File.Close • END

  4. Example • Print a report to include the names of baseball players and the number of home runs for each player, each team & total homeruns (grouped by team / nickname) • Requires: • Sequential File Processing (Data Reader) • Header • Detail Lines • Total Lines

  5. Input File – Baseball (sorted by Control Variable - Nickname)

  6. Baseball Example • Begin • Players.Open  Open Data File • Players.Read  Get player data from row.Read gives value to Row.Info • Team  Player.Nickname, Assign Nickname to Control Var (Team) • Display Heading (Team)  Output Team • TeamHR  Initialize Group Total to 0 • TotalHR  Initialize Grand Total to 0 • While Not Players.EOF  While there are players, process the detail rows of report If Player.Nickname <> Team Then  Check to see if the is the End of the Section • Display TeamHR  Subtotals • TotalHR = TotalHR + TeamHR  Increment Grand Totals • Team  Player.Nickname, New Team Name • Display Heading  Team • TeamHR = 0  Re-Initialize the Group Total for new Team • End IF Display (Players.Last, Player.HR)  Output Players Name, Number of HR • TeamHR = TeamHR + PlayerHR  Increment Group Total • Player  Player.Read, Read next row • End While • Display TeamHT  Display Team Subtotal • TotalHR = TotalHR + TeamHR  Increment Grand Total • Display TotalHR  Display Grand Total • Players.Close  Close Data File • End

  7. Variables • Control Variable – Holds the Value of the current control variable • Team Nickname • Counters and Accumulators • Group Totals • Team Homeruns • Grand Totals • Total Homeruns • Row Information • Player.Last • Sum Field – Player.HomeRuns • Control Field – Player.Nickname

  8. Walk Through Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Row.Info (Player.Last) .Sum Field (Player.HR) .Control Field (Player.Nickname) Output

  9. Walk Through Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Angels 0 41 0 Row.Info (Player.Last) .Sum Field (Player.HR) .Control Field (Player.Nickname) Smokey 41 Angels Output Angels: Smokey 41

  10. Walk Through Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Angels 0 41 69 0 Row.Info (Player.Last) .Sum Field (Player.HR) .Control Field (Player.Nickname) Jones 28 Angels Output Angels: Smokey 41 Jones 28

  11. Walk Through Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Angels 0 41 69 0 Row.Info (Player.Last) .Sum Field (Player.HR) .Control Field (Player.Nickname) Chapman 14 Orioles Output Angels: Smokey 41 Jones 28 69

  12. Walk Through Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Orioles 0 14 0 69 Row.Info (Player.Last) .Sum Field (Player.HR) .Control Field (Player.Nickname) Chapman 14 Orioles Output Angels: Smokey 41 Jones 28 69 Orioles: Chapman 14

  13. Walk Through Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Orioles 0 14 0 69 .Control Field (Player.Nickname) Row.Info (Player.Last) .Sum Field (Player.HR) Chapman 14 Orioles Output Angels: Smokey 41 Jones 28 69 Orioles: Chapman 14

  14. Walk Through Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Red Sox 0 25 0 69 83 .Control Field (Player.Nickname) Row.Info (Player.Last) .Sum Field (Player.HR) Smith 25 Red Sox Output Angels: Smokey 41 Jones 28 69 Orioles: Chapman 14 14 Red Sox

  15. Walk Through Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Red Sox 0 25 0 69 83 .Control Field (Player.Nickname) Row.Info (Player.Last) .Sum Field (Player.HR) Smith 25 Red Sox Output Angels: Red Sox Smokey 41 Smith 25 Jones 28 69 Orioles: Chapman 14 14

  16. Walk Through Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Red Sox 0 25 54 0 69 83 .Control Field (Player.Nickname) Row.Info (Player.Last) .Sum Field (Player.HR) Brewer 29 Red Sox Output Angels: Red Sox Smokey 41 Smith 25 Jones 28 Brewer 29 69 Orioles: Chapman 14 14

  17. Walk Through Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Red Sox 0 25 54 0 69 83 .Control Field (Player.Nickname) Row.Info (Player.Last) .Sum Field (Player.HR) Miller 15 White Sox Output Angels: Red Sox Smokey 41 Smith 25 Jones 28 Brewer 29 69 54 Orioles: Chapman 14 14

  18. Walk Through Control Var (Team) Group Total (Team HR) Grand Total (Total HR) Control Var (Team) Group Total (Team HR) Grand Total (Total HR) White Sox 0 15 0 69 83 137 .Control Field (Player.Nickname) Row.Info (Player.Last) .Sum Field (Player.HR) Miller 15 White Sox Output Angels Red Sox Smokey 41 Smith 25 Jones 28 Brewer 29 69 54 Orioles White Sox Chapman 14 Miller 15 14

  19. Final Output Angels Smokey 41 Jones 28 Team HR 69 Orioles Chapman 14 Team HR 14 Red Sox Smith 25 Brewer 29 Team HR 54 White Sox Miller 15 Kennedy 35 Parker 40 Jackson 29 Team HR 119 Total HR 256

  20. Control Break Processing • Program 1 • You must determine when the section breaks need to occur • Requirements: • Connection Object • Command Object (SQL Command) • Data Reader Object • Read / Compare Items in Data Reader Object

More Related