1 / 12

Lesson 5

Lesson 5. 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

dale-benson
Download Presentation

Lesson 5

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. Lesson 5

  2. 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.

  3. Report CPCH04A BEST DEAL STORES 09/18/00 EMPLOYEE HOURS WORKED REPORT PAGE 1 EMPLOYEE HOURS HOURLY NUMBER EMPLOYEE NAME WORKED RATE SALES 123 45 6789 SMITH 2.0 280.00 $80,000.00 000 01 2345 MARY 12.0 8.00 $8,000.00 123 23 4345 LARRY 1.0 10.00 $18,000.00

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

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

  6. 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.

  7. 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 The WRITE FROM statement

  8. 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)

  9. 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)

  10. 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

  11. a.b.c.d.e.f.g.h.i.j.k.l.m.n. 9(4) 06789(4) 06789(4) 06789(4)V99 1234569(4)V99 1234569(4)V99 1234569(4) 00089(4)V9 123459(4)V9 123459(5) 000459(9) 1234567899(4) 12349(6) 0805949(6) 080594 z(4) 678$9(4) $0678$Z(4) $ 6789(4).99 1234.56$9(4).99 $1234.56$9,999.99 $1,234.56$$,$$9 $89(4) 12349(4).99 1234.50$****9 $***45999B99B9999 123 45 6789$$,$$9.00 $1,234.0099/99/99 08/05/94Z9/99/99 8/05/94 Table 7.2 Review of Editing Characters SOURCE FIELD RECEIVING FIELD PICTURE VALUE PICTURE VALUE

  12. 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 Coding Standards • Procedure Division • Develop functional paragraphs • Sequence paragraph names • Avoid Commas • Use scope terminators • Indent • Both Divisions • Space attractively • Avoid constants • Don’t overcomment

More Related