X hits on this document

392 views

0 shares

0 downloads

0 comments

84 / 120

interfaces. Since our focus is more on reuse and reengineering of legacy code at a basic

level, it's not necessary to encumber ourselves with a very large program in order to learn

strategies for reuse and reengineering. Therefore, for purposes of demonstration, an

example COBOL program SMPLCALC.cbl, which implements a simple calculator for

integer-only arithmetic, was written to simulate a potentially useful component found in

the business logic layer of a legacy business application. The source code for

SMPLCALC.cbl is given Table 9.1; the program has single entry point that operates on

the I/O data structure SMPCALC-INTERFACE.

15:

02 SI-OPERAND-1 PIC S9(9) COMP-5.

16:

02 SI-OPERAND-2 PIC S9(9) COMP-5.

17:

02 SI-OPERATION PIC X.

03: 04: 05: 06: 07: 08: 09: 10: 11: 12:

****************************************************************** IDENTIFICATION DIVISION. PROGRAM-ID. 'SMPLCALC'. DATA DIVISION. WORKING-STORAGE SECTION. 77 MSG-NUMERIC-OVERFLOW PIC X(25) VALUE 'Numeric overflow occurred'. 77 MSG-SUCCESSFUL PIC X(22) VALUE 'Completed successfully'. LINKAGE SECTION.

13: 14:

* Input/Output data structure 01 SMPLCALC-INTERFACE.

Table 9.1. Sample business logic component to reuse and reengineer.

01: ******************************************************************

02: ** Simple COBOL program that performs integer arithmetic

**

18:

88 DO-ADD VALUE '+'.

19:

88 DO-SUB VALUE '-'.

20:

88 DO-MUL VALUE '*'.

27:

INITIALIZE SI-RESULT SI-RESULT-MESSAGE

28:

EVALUATE TRUE

21: 22:

23: 24: 25:

02 SI-RESULT PIC S9(18) COMP-3. 02 SI-RESULT-MESSAGE PIC X(128).

PROCEDURE DIVISION USING BY REFERENCE SMPLCALC-INTERFACE. MAINLINE SECTION.

26:

  • *

    Perform requested arithmetic

29:

WHEN DO-ADD

76

Document info
Document views392
Page views393
Page last viewedSun Dec 11 00:34:25 UTC 2016
Pages120
Paragraphs2913
Words25794

Comments