Скачать презентацию Lesson 5 Packed-Decimal or Computational-3 COMP-3 Скачать презентацию Lesson 5 Packed-Decimal or Computational-3 COMP-3

9d6a1fa3d2b62f78267957039c34c6fc.ppt

  • Количество слайдов: 14

Lesson 5 Lesson 5

Packed-Decimal or Computational-3 (COMP-3) • • MOVE 8649008 TO WS-AMOUNT 86 49 00 8 Packed-Decimal or Computational-3 (COMP-3) • • MOVE 8649008 TO WS-AMOUNT 86 49 00 8 ====> 4 bytes instead of 7. Significant storage saving. On the AS/400 numeric zoned decimal field is – converted to packed decimal format – Arithmetic is performed – converted back to zoned decimal format.

Report CPCH 04 A 09/18/00 EMPLOYEE NUMBER 123 45 6789 000 01 2345 123 Report CPCH 04 A 09/18/00 EMPLOYEE NUMBER 123 45 6789 000 01 2345 123 23 4345 BEST DEAL STORES EMPLOYEE HOURS WORKED REPORT HOURS HOURLY EMPLOYEE NAME WORKED RATE SMITH 2. 0 280. 00 MARY 12. 0 8. 00 LARRY 1. 0 10. 00 PAGE 1 SALES $80, 000. 00 $8, 000. 00 $18, 000. 00

 • • • 01 HEADING-1. 05 05 PIC PIC X(5) VALUE SPACES. X(7) • • • 01 HEADING-1. 05 05 PIC PIC X(5) VALUE SPACES. X(7) VALUE 'CPCH 04 A'. X(18) VALUE SPACES. X(16) VALUE 'BEST DEAL STORES'. 01 DETAIL-LINE. 05 05 EMPLOYEE-NUMBER-OUT 05 05 LAST-NAME-OUT 05 05 HOURS-WORKED-OUT 05 05 HOURLY-RATE-OUT 05 05 SALES-OUT PIC PIC PIC X(8) VALUE SPACES. 999 B 9999. X(5) VALUE SPACES. X(15). X(5) VALUE SPACES. Z(2). 9. X(5) VALUE SPACES. Z(3). 99. X(5) VALUE SPACES. $$$, $$9. 99 -. PRINT-RECORD-OUT

 • Data Division fields must be initialized. – VALUE – PROCEDURE DIVISION. • • Data Division fields must be initialized. – VALUE – PROCEDURE DIVISION. • Move Input fields to output fields in the DETAIL-LINE record before printing.

Figure 9. 3 The READ INTO statement FD EMPLOYEE-FILE DATA RECORD IS EMPLOYEE-RECORD. 01 Figure 9. 3 The READ INTO statement FD EMPLOYEE-FILE DATA RECORD IS EMPLOYEE-RECORD. 01 EMPLOYEE-RECORD PIC X(60). . WORKING-STORAGE SECTION. 01 FILLER PIC X(14) VALUE ‘WS BEGINS HERE’. 01 WS-EMPLOYEE-RECORD. 05 EMP-NAME PIC X(25). . PROCEDURE DIVISION. . READ EMPLOYEE-FILE INTO WS-EMPLOYEE-RECORD AT END MOVE ‘NO’ TO DATA-REMAINS-SWITCH NOT AT END PERFORM PROCESS-THIS-RECORD END-READ.

The WRITE FROM statement FD PRINT-FILE DATA RECORD IS PRINT-LINE. 01 PRINT-LINE PIC X(80). The WRITE FROM statement FD PRINT-FILE DATA RECORD IS PRINT-LINE. 01 PRINT-LINE PIC X(80). PROCEDURE DIVISION. . . MOVE HEADING-LINE TO PRINT-LINE. WRITE PRINT-LINE AFTER ADVANCING PAGE. (a) Two instruction process FD PRINT-FILE DATA RECORD IS PRINT-LINE. 01 PRINT-LINE PIC X(80). . . 01 HEADING-LINE. 03 PIC X(17) VALUE SPACES. 03 PIC X(25) VALUE ‘ INVENTORY REPORT PREPARED BY GARPL’. PROCEDURE DIVISION. . . WRITE PRINT-LINE FROM HEADING-LINE AFTER ADVANCING PAGE. (b) One instruction process

Figure 7. 1 Comparison of Outputs (a) STUDENT NAME SMITH JAMES BAKER PART-TIMER JONES Figure 7. 1 Comparison of Outputs (a) STUDENT NAME SMITH JAMES BAKER PART-TIMER JONES HEAVYWORKER LEE CLARK GROSSMAN FRANKEL BENWAY KERBEL CREDITS JB HR SR JR PL HM BL JC SE LF CT NB 15 15 09 03 15 18 18 06 07 10 03 04 TUITION 003000 001800 000600 003000 003600 001200 000600 002000 000600 000800 -------024500 UNION FEE ACT FEE 025 000 000 000 000 ------0075 075 050 025 075 075 025 050 025 ------0625 (a) Without Editing SCHOLARSHIP 00000 00500 00000 00000 00250 00000 -------000750 TOTAL BILL 003100 003075 001350 000650 003100 003675 001225 001450 002050 000375 000825 ----024550

Figure 7. 1 Comparison of Outputs (b) STUDENT NAME SMITH JAMES BAKER PART-TIMER JONES Figure 7. 1 Comparison of Outputs (b) STUDENT NAME SMITH JAMES BAKER PART-TIMER JONES HEAVYWORKER LEE CLARK GROSSMAN FRANKEL BENWAY KERBEL LUCKY ONE CREDITS JB HR SR JR PL HM BL JC SE LF CT NB FR TUITION 15 15 9 3 15 18 18 6 7 10 3 4 9 $3, 000 $1, 800 600 $3, 000 $3, 600 $1, 200 600 $2, 000 600 800 $1, 800 -------$26, 400 UNION FEE ACT FEE $25 $25 ------$75 $75 $50 $25 $75 $75 $25 $50 ------$675 (b) With Editing SCHOLARSHIP $500 $250 $2, 000 -------$2, 750 TOTAL BILL $3, 100 $3, 075 $1, 350 $650 $3, 100 $3, 675 $1, 225 $1, 450 $2, 050 $375 $825 $150 CR ----$24, 400

Table 7. 1 Editing Characters CHARACTER MEANING . Actual decimal point B Blank Z Table 7. 1 Editing Characters 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

Table 7. 2 Review of Editing Characters SOURCE FIELD PICTURE a. b. c. d. Table 7. 2 Review of Editing Characters SOURCE FIELD PICTURE a. b. c. d. e. f. g. h. i. j. k. l. m. n. 9(4)V 99 9(4)V 9 9(4)V 9 9(5) 9(9) 9(4) 9(6) VALUE 0678 123456 0008 12345 00045 123456789 1234 080594 RECEIVING FIELD PICTURE VALUE z(4) $9(4) $Z(4) 9(4). 99 $9, 999. 99 $$, $$9 9(4). 99 $****9 999 B 9999 $$, $$9. 00 99/99/99 Z 9/99/99 678 $0678 $ 678 1234. 56 $1, 234. 56 $8 1234. 50 $***45 123 45 6789 $1, 234. 00 08/05/94

Coding Standards • Data Division – Choose meaningful names – Prefix all data names Coding Standards • Data Division – Choose meaningful names – Prefix all data names within the same FD or 01 with tow or three characters unique to the FD – Begin all PICTURE clauses in the same column – Choose one form of PICTURE clause – Indent successive level numbers under an 01 consistently – Avoid 77 -level entries • Procedure Division – Develop functional paragraphs – Sequence paragraph names – Avoid Commas – Use scope terminators – Indent • Both Divisions – Space attractively – Avoid constants – Don’t overcomment

Question What is green, has wheels, and grows around the house Do you give Question What is green, has wheels, and grows around the house Do you give up ? The answer is: Grass I lied about the wheels Weinberg “Understanding the Professional Programmer”

What is wrong with that question • The rules have been changed !!! • What is wrong with that question • The rules have been changed !!! • You have to play by the rules • Program specs change.