Chapter 7 – Editing and Coding Standards Numeric field types –Numeric –Numeric-edited Use...

14
Chapter 7 – Editing and Coding Standards • Numeric field types – Numeric – Numeric-edited • Use these only for the fields you define for printing purposes

Transcript of Chapter 7 – Editing and Coding Standards Numeric field types –Numeric –Numeric-edited Use...

Page 1: Chapter 7 – Editing and Coding Standards Numeric field types –Numeric –Numeric-edited Use these only for the fields you define for printing purposes.

Chapter 7 – Editing and Coding Standards

• Numeric field types– Numeric– Numeric-edited

• Use these only for the fields you define for printing purposes

Page 2: Chapter 7 – Editing and Coding Standards Numeric field types –Numeric –Numeric-edited Use these only for the fields you define for printing purposes.

STUDENT NAME CREDITS TUITION UNION FEE ACT FEE SCHOLARSHIP TOTAL BILL

SMITH JB 15 003000 025 075 00000 003100 JAMES HR 15 003000 000 075 00000 003075 BAKER SR 09 001800 000 050 00500 001350 PART-TIMER JR 03 000600 025 025 00000 000650 JONES PL 15 003000 025 075 00000 003100 HEAVYWORKER HM 18 003600 000 075 00000 003675 LEE BL 18 003600 000 075 00000 003675 CLARK JC 06 001200 000 025 00000 001225 GROSSMAN SE 07 000600 000 025 00000 001450 FRANKEL LF 10 002000 000 050 00000 002050 BENWAY CT 03 000600 000 025 00250 000375 KERBEL NB 04 000800 000 025 00000 000825

-------- ------- ------- -------- ---------024500 0075 0625 000750 024550

(a) Without Editing

Figure 7.1 Comparison of Outputs (a)

Page 3: Chapter 7 – Editing and Coding Standards Numeric field types –Numeric –Numeric-edited Use these only for the fields you define for printing purposes.

STUDENT NAME CREDITS TUITION UNION FEE ACT FEE SCHOLARSHIP TOTAL BILL

SMITH JB 15 $3,000 $25 $75 $3,100 JAMES HR 15 $3,000 $75 $3,075 BAKER SR 9 $1,800 $50 $500 $1,350 PART-TIMER JR 3 600 $25 $25 $650 JONES PL 15 $3,000 $25 $75 $3,100 HEAVYWORKER HM 18 $3,600 $75 $3,675 LEE BL 18 $3,600 $75 $3,675 CLARK JC 6 $1,200 $25 $1,225 GROSSMAN SE 7 600 $25 $1,450 FRANKEL LF 10 $2,000 $50 $2,050 BENWAY CT 3 600 $25 $250 $375 KERBEL NB 4 800 $25 $825 LUCKY ONE FR 9 $1,800 $50 $2,000 $150CR

-------- ------- ------- -------- ---------$26,400 $75 $675 $2,750 $24,400

(b) With Editing

Figure 7.1 Comparison of Outputs (b)

Page 4: Chapter 7 – Editing and Coding Standards Numeric field types –Numeric –Numeric-edited Use these only for the fields you define for printing purposes.

• Editing characters

– Decimal point• Actual decimal point• Implied decimal point• 05 Field-A PIC 9v99.• 05 Field-A-Edited PIC 9.99.

– Zero suppression• Gets rid of the left side zeros• 05 FIELD-B PIC 9(5).• 05 FIELD-B-EDITED PIC ZZZZ9.

– Dollar sign• Fixed

– 05 FIELD-D PIC 9(4).– 05 FIELD-D-EDITED PIC $ZZZ9.

• Floating– 05 FIELD-D-EDITED PIC $$$$9.

– Receiving field must be one character bigger than the sending field

Page 5: Chapter 7 – Editing and Coding Standards Numeric field types –Numeric –Numeric-edited Use these only for the fields you define for printing purposes.

– Comma• 05 FIELD-E PIC 9(4).• 05 FIELD-E-EDITED PIC $$,$$9.• In this example 2 extra spaces needed

– Check protection• Used when printing a check to avoid blank spaces

between a fixed dollar sign and first digit.• 05 FIELD-G-EDITED PIC $**,**9.

– Insertion characters• /, BLANK (B), 0• Printed exactly where they appear in the PIC statement• 05 FIELD-H PIC 9(6).• 05 FIELD-H-EDITED PIC 99/99/99.

Page 6: Chapter 7 – Editing and Coding Standards Numeric field types –Numeric –Numeric-edited Use these only for the fields you define for printing purposes.

• Signed numbers

– Require a ‘S’ in the PIC clause – signed field• FIELD-A PIC S99 VALUE - 20

– Default is positive if no ‘S’ even if the result of a calculation is negative.

– CR and DB symbols• Credit and debit• Treats them identically• Only shows CR or DB if value is negative

– Plus and minus signs

• BLANK WHEN ZERO clause– Use after a PIC clause

• 05 UNION-FEE PIC $$$9.99 BLANK WHEN ZERO.

Page 7: Chapter 7 – Editing and Coding Standards Numeric field types –Numeric –Numeric-edited Use these only for the fields you define for printing purposes.

Table 7.1 Editing Characters

CHARACTER MEANING CHARACTER MEANING

. Actual decimal point B Blank

Z Zero suppression / Slash

$ Dollar sign CR Credit character

, Comma DB Debit character

* Check protection + Plus sign

0 Zero - Minus sign

Page 8: Chapter 7 – Editing and Coding Standards Numeric field types –Numeric –Numeric-edited Use these only for the fields you define for printing purposes.

Table 7.3 CR and DB Editing Characters

SOURCE FIELD RECEIVING FIELD

PICTURE VALUE PICTURE VALUE

S9(5) 98765S9(5) -98765S9(5) 98765S9(5) -98765

$$$,999CR $98,765$$$,999CR $98,765CR$$$,999DB $98,765$$$,999DB $98,765DB

a.b.c.d.

Page 9: Chapter 7 – Editing and Coding Standards Numeric field types –Numeric –Numeric-edited Use these only for the fields you define for printing purposes.

Table 7.4 Floating Plus and Minus Sign

SOURCE FIELD RECEIVING FIELD

PICTURE VALUE PICTURE VALUE

S9(4) 1234S9(4) 0123S9(4) -1234S9(4) 1234 S9(4) 0123S9(4) -1234S9(4) 1234 S9(4) -1234

++,+++ +1,234++,+++ +123++,+++ -1,234--,--- 1,234--,--- 123--,--- -1,234ZZ,ZZ9+ 1,234+ZZ,ZZ9- 1,234-

a.b.c.d.e.f.g.h.

Page 10: Chapter 7 – Editing and Coding Standards Numeric field types –Numeric –Numeric-edited Use these only for the fields you define for printing purposes.

• Coding standards– If someone else must edit your program– Data division

• Meaningful data names– X or IN-EMPLOYEE-NAME

• Consistent data name prefixes– Within the same record (01) or File Descriptor (FD)– IN-… WS-…

• Column alignment of picture clauses– This helps check that the PIC clause is correct

• Standard format for picture clause– PIC, PICTURE, PIC IS use only one

• Consistent indentation of level numbers• Avoidance of 77-level entries

Page 11: Chapter 7 – Editing and Coding Standards Numeric field types –Numeric –Numeric-edited Use these only for the fields you define for printing purposes.

• Procedure division– Development of functional paragraphs

• Useful names, READ-FILE, WRITE-HEADING

– Sequencing of paragraph names• 100-WRITE-HEADER, 200-READ-FILE• Used to locate paragraph header quickly

– Avoidance of commas– Use scope terminators

• Ex, END-IF, END-READ

– Consistent indentation• Readability

– Use of Spaces– Avoidance of literals or constants in the procedure

division– Don’t over comment

• Use care when commenting

Page 12: Chapter 7 – Editing and Coding Standards Numeric field types –Numeric –Numeric-edited Use these only for the fields you define for printing purposes.

• Make the PIC clause: Page 191– 1.a Floating $, omission of cents, printing of

commas, max value of $9,999,999

– c. fixed dollar sign, zero suppression of insignificant leading zeros, no commas, max value of $99,999.99

– d. floating $, use of commas, max value of $9,999.00 and trailing CR if negative.

Page 13: Chapter 7 – Editing and Coding Standards Numeric field types –Numeric –Numeric-edited Use these only for the fields you define for printing purposes.

1. 9(6) 123456 9(6)

2. 9(6) 123456 9(8)

3. 9(6) 123456 9(6).99

4. 9(4)V99 123456 9(6)

5. 9(4)V99 123456 9(4)

6. 9(4)V99 123456 $$$$$9.99

7. 9(4)V99 123456 $$$,$$9.99

8. 9(6) 123456 $$$$,$$9.99

9. 9(6) 123456 Z(8)

10. 9(4)V99 123456 $ZZZ,ZZZ.99

Page 14: Chapter 7 – Editing and Coding Standards Numeric field types –Numeric –Numeric-edited Use these only for the fields you define for printing purposes.

1. S9(4)V99 45600 $$$$$.99CR2. S9(4)V99 45600 $$,$$$.99DB3. S9(4) 4567 $$,$$$.004. S9(6) 122577 99B99B995. S9(6) 123456 ++++,+++6. S9(6) -123456 ++++,+++7. S9(6) 123456 ----,---8. S9(6) -123456 ----,---9. 9(4)V99 567890 $$$$,$$$.9910. 9(4)V99 567890 $ZZZ,ZZZ.9911. 9(4)V99 567890 $***,***.99