incubus - an obsession in computing
  • rss
  • Home
  • Linux Apps
    • C&G 4250 Linux Extension
  • C&G 4240
    • Overview
    • Validate Program
    • Sort Program
    • Update / Merge Program
    • Report Program
    • Downloads
  • C&G 4250
    • Overview
    • Data Entry Program
    • Validate Program
    • Sort Program
    • Customer Update / Merge Program
    • Customer Report Program
    • Stock Update / Merge Program
    • Stock Report Program
    • Downloads
  • About
  • Contact

Customer Report Program

Program Overview:

The contents of the newly created customer master file produced by the Update Program (494792P3.exe) are now to be printed under suitable headings. A carried forward total is to be printed toward the bottom of every page where a total is to be carried forward (with the exception of the final page printed). A brought forward total is also to be printed toward the top of each page where there is a total to carry forward (with the exception of the first page printed).

The binary file which contains the newly created customer records must be named 494792NF.DAT, and must be located in the same directory from where the report program is located and executed from. This is unless the user changes this default file name by entering additional program parameters at the command line. Below describes how the default file names may be overridden: -

494792P4.exe <new customer master file> <printer>

The defaults file names are as follows: -

New Customer master file – 494792NF.DAT
Printer – PRN

If the user wishes to override one of these files they must also enter the file names of all the files preceding it. For example to override the printer to a text file named test.txt, they must enter the following command: -

494792P3.exe 494792NF.DAT test.txt

However if the user only wishes to change the name of the customer master file, they may enter the following command: -

494792P2.exe NEWCUSTMAST.DAT

The overriding of the default file names is mainly for test purposes or where there is a need to do so. Such a need may arise when there is a need to produce a report for an old customer mater file, where maybe the old report had been accidentally destroyed. The everyday users of this program need not even have to be aware of this overriding feature.

Report:

When the program is first started it checks to see if there was a command-line argument given. If there was then the argument is taken to be the name of the NEW customer master file, and an attempt at opening this file is made. If the attempt fails then the program reverts to using the default file name (494792NF.DAT). An attempt at opening the default named file is now made, if this also fails an error message informing the user that the file could not be opened is displayed and the program exits returning the user back to the operating system.

If there was another command-line argument given this is taken to be the name of the printer file (where the output from this program is printed to). An attempt at opening this file is made. If the attempt fails then the program reverts to using the default file name (PRN). An attempt at opening the default named file is now made, if this also fails an error message informing the user that the file could not be opened is displayed and the program exits returning the user back to the operating system.

If no command-line arguments were given then all default file names are used.

Once the required files have been opened, the printer is reset to its default settings, and then placed in landscape mode. A page header is now printed at the top of the first page. This page header contains the following information: -

Page title – Zenith Paints Transaction Credit Limit Report.
Current system date, in the format DD/MM/YYYY.
Current page number, Page #.
Column headings for the following: -
” Customer Code
” Customer Name
” Customer Address
” Balance
” Credit Limit
” Last Movement date

A message is now displayed to the user informing them that the Customer Master file is about to be printed (the names of the two files are also displayed so that the user knows where the input is coming from and the output is going to).

The main processing loop is now entered; a customer record is read from the master file. If a record was read successfully a counter which keeps a count of the total number of records processed is incremented. The current customers balance is added to a variable which is used to store the total balance of all customers.

A check is now made to ensure the customers balance does not exceed their credit limit. If the customer has exceeded their credit limit then a variable which keeps count of the number of customers that have exceeded their credit limit is incremented. The amount by which the customer has exceeded their credit limit is added to a variable which is used to store the total excess credit limits of all customers. Also the customers details are printed with their balance highlighted by the printing of two stars each side of the balance (indicating that the balance is too high). If the customer was not over their credit limit then their details are printed without the need for any highlighting of fields.

A new line is now printed, by calling the prtNewline() function so as to keep track of the number of lines printed per page. When a new page is printed a brought forward balance is printed towards the top of the page (just under the page headings). At the bottom of every page (with the exception of the last page)
a carried forward balance is printed. The main processing loop continues until there are no more records to read from the customer master file.

On exiting the main processing loop a check is made to ensure that at least one customer was on the master customer file. If there were no records stored on the file then a [FAIL] message is displayed to inform the user that the report program has failed. If one or more records were processed then a [PASS] message is displayed to inform the user all went well. The following totals are now printed:-

” Total number of customers processed = #
” Total number of customers over their credit limit = #
” Total excess credit = £.
” Final grand total balance = £.

The printer is now reset back to its default state and all previously opened files are closed before the program exits and returns back to the operating system.

Design decisions:

There were no major design decisions as this was a quite straight forward program to design. It opens the new customer master file and the printer, then simply reads each record from the master file and prints these details to the printer. The printout is in landscape and condensed mode so that all the customers’ details are printed on a single line under appropriate headings.

To start with the file names were hard coded within the program; if any of them were not found then the program would exit. This was changed quite late in the program development, as it would be more practical to allow the user to override the name of any file at the command line (as a command line argument). This way the file names are not hard coded into the program, which makes the program much more flexible. If however a file name is not provided on the command line or there was an error trying to open the given file name then the default file names are used.

Limitations:

There are no real limitations to this program, as all it’s purpose in life is to produce a formatted report. The only real limitation is that the customer master file must be renamed to CUSTMAST.DAT before the transaction processing system is used again. This is because the update file will not update the correct customer master file unless this file is renamed but will overwrite the previously created new customer master file. It would be a rather minor code change to this program, or the update program to rename the old master file and the new master file (creating a backup of the old master file for future reference).

Another slight limitation is that the customer master file must be stored in binary format and must be formatted in the correct way. With the master file being in binary format there would be more effort needed if this program were to be ported to another operating system with a different word size as there would be if it were stored in text format. But it would be much easier for a human to use a text editor and change the values held within the master file if it were stored in text format.

All of the programs are limited to using a Hewlett Packard printer as all printouts use Hewlett Packard specific escape codes to format the output. If the printer is changed for a different make then this program will need modification and recompilation. The modifications are all contained within the printer.h header file and so should not cause any problems if this task is required.

Comments rss
Comments rss
Trackback
Trackback

Leave a Reply

Click here to cancel reply.

You must be logged in to post a comment.

Search @incubus

Recent Posts

  • Compressed Hard Disk Image
  • It’s been along time …
  • T209 ECA Result
  • Old Linux Discs…
  • Panasonic CF-U1 / 2D Barcode Imager
  • Useful Gentoo Aliases
  • Hosting Provider Changed.
  • Linux – Merge AVI Files
  • Coders at Work
  • Remove OGA Office Not Genuine Notifications (KB949810)

Links

  • Demonoid
  • Engadget
  • Gentoo Linux
  • Gentoo Planet
  • Gentoo Universe
  • GNOME
  • GNOME Planet
  • ISO Hunt
  • OS News
  • Piratebay

Navigation

  • Register
  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

Archives

  • May 2010 (1)
  • February 2010 (1)
  • December 2009 (3)
  • November 2009 (2)
  • September 2009 (4)
  • August 2009 (1)
  • July 2009 (1)
  • May 2009 (2)
  • April 2009 (1)
  • February 2009 (2)
  • January 2009 (1)
  • December 2008 (1)
  • November 2008 (1)
  • October 2008 (3)
  • September 2008 (7)
  • August 2008 (16)

Categories

  • 4240 (1)
  • 4250 (1)
  • Code (8)
  • Linux (29)
  • ODB2 (2)
  • Open University (6)
  • Tips & Tricks (13)
  • Uncategorized (5)

Stats

Visits Today: 7
rss Comments rss design by jide powered by Wordpress get firefox
© Copyright 1999-2010 @incubus. All Rights Reserved. All trademarks acknowledged.
incubus.co.uk || incubus.mobi || rankinstine.co.uk