Download presentation
Presentation is loading. Please wait.
Published byLydia Bishop Modified over 9 years ago
2
Lesson 5
3
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.
4
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
5
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'. PRINT-RECORD-OUT 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-.
6
Data Division fields must be initialized. –VALUE –PROCEDURE DIVISION. Move Input fields to output fields in the DETAIL-LINE record before printing.
7
FD EMPLOYEE-FILE DATA RECORD IS EMPLOYEE-RECORD. 01 EMPLOYEE-RECORDPIC X(60).... WORKING-STORAGE SECTION. 01 FILLERPIC X(14) VALUE ‘WS BEGINS HERE’. 01 WS-EMPLOYEE-RECORD. 05 EMP-NAMEPIC 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. Figure 9.3The READ INTO statement
8
The WRITE FROM statement (a) Two instruction process FD PRINT-FILE DATA RECORD IS PRINT-LINE. 01 PRINT-LINEPIC X(80). PROCEDURE DIVISION.. MOVE HEADING-LINE TO PRINT-LINE. WRITE PRINT-LINE AFTER ADVANCING PAGE. FD PRINT-FILE DATA RECORD IS PRINT-LINE. 01 PRINT-LINEPIC 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
9
STUDENT NAMECREDITSTUITION UNION FEE ACT FEESCHOLARSHIP TOTAL BILL SMITH JB 15003000 025 075 00000003100 JAMES HR 15003000 000 075 00000003075 BAKER SR 09001800 000 050 00500001350 PART-TIMER JR 03000600 025 025 00000000650 JONES PL 15003000 025 075 00000003100 HEAVYWORKER HM 18003600 000 075 00000003675 LEE BL 18003600 000 075 00000003675 CLARK JC 06001200 000 025 00000001225 GROSSMAN SE 07000600 000 025 00000001450 FRANKEL LF 10002000 000 050 00000002050 BENWAY CT 03000600 000 025 00250000375 KERBEL NB 04000800 000 025 00000000825 -------- ------- ------- -------- --------- 024500 0075 0625 000750024550 (a) Without Editing Figure 7.1 Comparison of Outputs (a)
10
STUDENT NAMECREDITSTUITION UNION FEE ACT FEESCHOLARSHIP 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)
11
Table 7.1 Editing Characters CHARACTERMEANINGCHARACTERMEANING.Actual decimal pointBBlank ZZero suppression/Slash $Dollar signCRCredit character,CommaDBDebit character *Check protection+Plus sign 0Zero-Minus sign
12
Table 7.2 Review of Editing Characters SOURCE FIELDRECEIVING FIELD PICTUREVALUEPICTUREVALUE 9(4)0678 9(4)0678 9(4)0678 9(4)V99123456 9(4)V99123456 9(4)V99123456 9(4)0008 9(4)V912345 9(4)V912345 9(5)00045 9(9)123456789 9(4)1234 9(6)080594 9(6)080594 z(4) 678 $9(4)$0678 $Z(4)$ 678 9(4).991234.56 $9(4).99$1234.56 $9,999.99$1,234.56 $$,$$9 $8 9(4)1234 9(4).991234.50 $****9$***45 999B99B9999123 45 6789 $$,$$9.00$1,234.00 99/99/9908/05/94 Z9/99/99 8/05/94 a. b. c. d. e. f. g. h. i. j. k. l. m. n.
13
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
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.