Presentation is loading. Please wait.

Presentation is loading. Please wait.

Printing on power systems Program/ Command Data Report Layout (Printer File) Job Output Queue *FILE Spooled File.

Similar presentations


Presentation on theme: "Printing on power systems Program/ Command Data Report Layout (Printer File) Job Output Queue *FILE Spooled File."— Presentation transcript:

1

2 Printing on power systems

3 Program/ Command Data Report Layout (Printer File) Job Output Queue *FILE Spooled File

4 Printing Reports with COBOL

5 A Good Report… Heading (a meaningful report name) –Date and Page Number Column Headings (to identify data) Order column from left to right to highlight significant data Edit numbers for readability Include Totals at end of report and groups of items ** To identify the ‘level’ of a total Clearly indicate the end of the report.

6 Record Formats Each Record format is defined using it’s own Group-Item in the Working Storage Section. Record format name is defined using the 01 level Fields and literals are defined using subsequent levels with Picture & Values Clauses

7 How Many Record Formats? HeadingCustomer Accounts Date: 2004-12-31Page: 999 Column Heading Date Amount Customer Heading Customer: 1015 Cindy Laurin Detail Line 2004-05-12$100.00 Detail Line 2004-06-09$200.00 Detail Line 2004-09-28$300.00 Customer Total* Totals: 1015 Cindy Laurin $600.00 Customer Heading Customer: 1016 Bruce Nugent Detail Line 2004-01-31$100.00 Customer Total * Totals: 1016 Bruce Nugent$100.00 Report Total ** Totals: All Customers $700.00 End of Report *** End of Report

8 Picture Clause Review Define Variables Define how Variables are displayed

9 Editing Functions FunctionCharacter Printing of a / as a separator/ Printing of Decimal Point in an integer. Suppress Leading Zeros in an integerZ Print a Dollar Sign in front of an integer$ Print a Comma in an integer, Printing of + or – signs+ or - Printing of ‘Debit’ or ‘Credit’ symbolsDB or CR Printing of Spaces as separatorsB Printing of Zeros as separators0 Print Leading asterix*

10 Examples Trans-Amount PIC S9(6)V999 Value 4565.78. Report-ItemEdited Results PIC $ZZZ,ZZZ.99- PIC $ZZZ,ZZZ.99CR PIC $ZZZZZZB99 PIC $ZZZZZZ.99+

11 Examples Trans-Amount PIC S9(6)V999 Value 4565.78-. Report-ItemEdited Results PIC 9(6)V999 PIC $999999V999 PIC $ZZZ,ZZZ.99 PIC $ZZZ,ZZZ.9

12 Examples Trans-Amount PIC S9(6)V999 Value 4565.78-. Report-ItemEdited Results PIC $ZZZ,ZZZ.99- PIC $ZZZ,ZZZ.99CR PIC $ZZZZZZB99 PIC $ZZZZZZ.99+

13 Printing in COBOL FILE SECTION FD Customer-Report. 01 Print-Record-Out. WORKING STORAGE. 01 Heading-1 05 PIC X(8) Value Spaces. 05 PIC X(17) Value ‘Customer Accounts’ 05 PIC X(5) Value Spaces. 05 PIC X(6) Value ‘Date: ‘ 05 WS-Date-Out format of date. 05 PIC X(1) Value Spaces. 05 PIC X(6) Value ‘Page: ‘. 05 WS-Page PIC 9(3).

14 Printing or Writing to a Spooled File And using an IMPLIED MOVE WORKING-STORAGE. 01 Detail-Line-1 PIC X(80) VALUE ‘Cindy’s Test’ 01 Detail-Line-2 PIC X(80) VALUE ‘COBOL Line of Code’ WRITE Print-Record-Out FROM Detail-Line-1 WRITE Print-Record-Out FROM Detail-Line-2

15 Printing or Writing to a Spooled File (using AFTER ADVANCING) Detail-Line-1 PIC X(80) VALUE ‘Cindy’s Test’. Detail-Line-2 PIC X(80) VALUE ‘COBOL Line of Code’. WRITE Print-Record-Out FROM Detail-Line-1 AFTER ADVANCING 1 LINE. WRITE Print-Record-Out FROM Detail-Line-2 AFTER ADVANCING 1 LINE.

16 Printing or Writing to a Spooled File (using BEFORE ADVANCING) Detail-Line-1 PIC X(80) VALUE ‘Cindy’s Test’. Detail-Line-2 PIC X(80) VALUE ‘COBOL Line of Code’. WRITE Print-Record-Out FROM Detail-Line-1 BEFORE ADVANCING 1 LINE. WRITE Print-Record-Out FROM Detail-Line-2 BEFORE ADVANCING 1 LINE.

17 Printing or Writing to a Spooled File (using AFTER ADVANCING) Detail-Line-1 PIC X(80) VALUE ‘Cindy’s Test’. Detail-Line-2 PIC X(80) VALUE ‘COBOL Line of Code’. WRITE Print-Record-Out FROM Detail-Line-1. WRITE Print-Record-Out FROM Detail-Line-2 AFTER ADVANCING PAGE.

18 Printing or Writing to a Spooled File With MIXED advancing! Detail-Line-1 PIC X(80) VALUE ‘Cindy’s Test’. Detail-Line-2 PIC X(80) VALUE ‘COBOL Line of Code’. WRITE Print-Record-Out FROM Detail-Line-1 AFTER ADVANCING 1 LINE. WRITE Print-Record-Out FROM Detail-Line-2 BEFORE ADVANCING 1 LINE.

19 Control Breaks A.K.A Level Breaks

20 Report Types Transaction Reports Summary or Group Reports Exception Reports

21 Summary or Group Reports Most efficiently handled using: – Logical Files to sort the data in Summary or Group order –Control Breaks methodology to process the data.

22 Control Break Occurs when there is a change in key fields when reading sequentially through a file

23 Customer Accounts Date: 05/04/00Page: 999 Date Amount Customer: 1015 Cindy Laurin-Moogk 05/01/00$100.00 05/02/00$200.00 05/03/00$300.00 * Totals: 1015 Cindy Laurin-Moogk$600.00 Customer: 1016 Bruce Nugent 05/01/00$100.00 * Totals: 1016 Bruce Nugent$100.00 ** Totals: All Customers $700.00 *** End of Report Where’s the Control Break?

24 What do you do at a Control Break? Print the totals for the save or previous key Initialize the accumulators used for the group or level Print headings for the new or file key

25 Single Control Break (using ifs) Read the First Record (check for EOF) If not EOF Write the heading for file-key Move file-key to save-key Do While not End of File If save-key  file-key Calculate & Write totals for save-key Initialize Accumulators Move file-key to save-key Write headings for file-key Process Record Read the next Record (check for EOF) ENDDO Calculate & Write totals for save-key

26 Single Control Break (Using Nested Loops) Read the First Record (check for EOF) Do While not End of File Write the heading for file-key Move file-key to save-key Do While file-key = save-key and not EOF Process Record Read the next record (check for EOF) ENDDO Calculate & Write totals for save-key Initialize Accumulators ENDDO

27 Multiple Control Breaks (Using Ifs) Read the First Record (check for EOF) If not EOF Write the headings for file-key Move file-key to save-key Do While not End of File If save-Primary-key  file-Primary-key Calculate & Write totals for save-Secondary-key Calculate & Write totals for save-Primary-key Initialize Primary & Secondary Accumulators Move file-key to save-key Write headings for Primary & Secondary file-keys If save-Secondary-key  file-Secondary-key Calculate & Write totals for save-Secondary-key Initialize Secondary Accumulators Move file-Secondary-key to save-Secondary-key Write headings for file-Secondary-key Process Record Read the next Record (check for EOF) ENDDO Calculate & Write totals for save-Secondary-key Calculate & Write totals for save-Primary-key

28 Multiple Control Breaks (Using Nested Loops) Read the First Record (check for EOF) Do While not End of File Write the headings for file-Primary-key Move file-Primary-key to save-Primary-key Do While not EOF and file-Primary-key = save-Primary-key Write headings for file-Secondary-key Move file-Secondary-key to save-Secondary-key Do While not EOF and file-Secondary-key = save-Secondary-key and file-Primary-key = save-Primary-key Process Record Read the next record (check for EOF) ENDDO Calculate & Write totals for save-Secondary-key Initialize Secondary Accumulators ENDDO Calculate & Write totals for save-Primary-key Initialize Primary Accumulators ENDDO

29 28 Sequential Access Reads one record at a time Reads records in arrival / sorted sequence.

30 29 Defining Sequential organization with sequential Access SELECT Employee-File ASSIGN to DATABASE-EMPPF ORGANIZATION is SEQUENTIAL ACCESS MODE is SEQUENTIAL. If the ORGANIZATION clause is omitted then it is assumed sequential.

31 30 Sequential Read. READ file-name AT END Perform end-of-file-logic NOT AT END Perform detail-processing END-READ

32 31 Random Access Techniques

33 32 Random Access Records are processed in some other order than the one in which they were physically written to the disk or indexed. A key field is looked up in an index, the address is retrieved and the record is accessed from the physical file using the address.

34 33 Dynamic Access Defined when a file will be used both randomly and sequentially

35 34 Normalization Theory (Relational Database Design) First Normal Form: –Information entities are divided into Files or Tables on the basis of their Relationships. Second Normal Form: –All Entities must have a logical dependency on the Primary Key (or part of). Third Normal Form: –All Entities must have a functional dependency on the Primary Key in it’s entirety.

36 35 Due to Normalization Practices, we usually have more than one file in our databases. Typically reports usually consists of one or more Sequential files and one or more Random Access files.

37 36 Defining INDEXED organization with Sequential Access SELECT Employee-File ASSIGN to DATABASE-EMPPF ORGANIZATION is INDEXED ACCESS MODE is SEQUENTIAL RECORD KEY is EXTERNALLY-DESCRIBED-KEY File status is WS-STATUS. 03 WS-STATUS PIC XX.

38 37 FILE STATUS CLAUSE When this clause is used the system will provide feed back to a program in a on any I/O activity to a file. The STATUS variable can be tested for specific errors encountered. i.e. WRITE DATA-FILE INVALID KEY PERFORM CHECK-STATUS END-WRITE IF STATUS-FIELD = ‘00’ PERFORM ALL-IS-NORMAL END-IF.

39 38 Defining a Random Access File SELECT Employee-File ASSIGN to DATABASE-EMPPF ORGANIZATION is INDEXED ACCESS MODE is RANDOM RECORD KEY is EXTERNALLY-DESCRIBED-KEY (with duplicates) File status is variable-name. STRICTLY RANDOM

40 39 Defining a Dynamic Access File SELECT Employee-File ASSIGN to DATABASE-EMPPF ORGANIZATION is INDEXED ACCESS MODE is DYNAMIC RECORD KEY is EXTERNALLY-DESCRIBED-KEY (with duplicates) file status is variable-name.

41 40 Beware of File Status Code 95! Need to add ‘WITH DUPLICATES’ to your select statement or your need to take it out!

42 41 Randomly Retrieve a Record using a Random Defined File Update/Populate the Key Fields in the File. READ file-name INVALID KEY Perform invalid-logic NOT INVALID KEY Perform valid-logic END-READ.

43 42 Sequentially Read using a Random Defined Record Make sure that ACCESS is DYNAMIC!! READ file-name NEXT RECORD AT END Perform perform end-of-file-logic END-READ.

44 43 Positioning the File Pointer in an INDEXED organized file Used with ACCESS Sequential or dynamic access defined files. Initialize the record key START file-name INVALID KEY Perform Invalid-Logic NOT INVALID KEY Perform valid-logic END-START. A “start” MUST be followed by a valid read to retrieve the file data into the specific file’s area.

45 44 Other Random Access Verbs

46 45 REWRITE Updates a record in a file File must be opened as I-O instead of input Record must be read first before rewrite REWRITE record-name (FROM variable-name) INVALID KEY perform error-rtn NOT INVALID KEY perform continue-rtn END-REWRITE.

47 46 DELETE Deletes a record from a file File must be opened as I-O The record must be read first DELETE file-name RECORD INVALID KEY perform error-rtn NOT INVALID KEY perform continue-rtn END-DELETE.

48 47 WRITE Writes records to a file File must be opened as I-O or OUTPUT WRITE record-name (FROM variable) INVALID KEY perform error-rtn NOT INVALID KEY perform continue-rtn END-WRITE.

49 48 Check the source for CPCH13B to familiarize and see an example. Source to be found in BAC344LIB CPCH13C for use of DECLARATIVES Used to declare / define / catch execution time situations / conditions “GLOBAL” to a program


Download ppt "Printing on power systems Program/ Command Data Report Layout (Printer File) Job Output Queue *FILE Spooled File."

Similar presentations


Ads by Google