Java Reference
In-Depth Information
So far, little of this makes much sense. Why not just have CALLER call MYSUB
directly? One answer might be that you need to enhance MYSUB without affecting
other programs that already call MYSUB. In this case, NEWSUB could perform
some additional new logic and call MYSUB for the old logic.
Suppose you want NEWSUB to always translate the stored text field to all up-
percase. Programs that needed this feature plus the standard features of MYSUB
could call NEWSUB. NEWSUB would now look like this:
NEWSUB COBOL
IDENTIFICATION DIVISION.
PROGRAM-ID. NEWSUB.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 TEMP-TEXT-STRING
PIC X(20).
LINKAGE SECTION.
01 PASSED-MYSUB-CONTROL.
03 MYSUB-ACTION-SWITCH PIC X.
88 MYSUB-ACTION-EVALUATE VALUE "E".
88 MYSUB-ACTION-SET-AND-EVALUATE VALUE "S".
03 MSG-TEXT PIC X(20).
03 MSG-SIZE PIC 9(8).
01 PASSED-TEXT-STRING PIC X(20).
PROCEDURE DIVISION USING PASSED-MYSUB-CONTROL,
PASSED-TEXT-STRING.
START-PROGRAM SECTION.
START-PROGRAM-S.
*
Check the passed parameters to see if you should just call MYSUB.
IF MYSUB-ACTION-EVALUATE OF PASSED-MYSUB-CONTROL OR
MYSUB-ACTION-SET-AND-EVALUATE OF PASSED-MYSUB-CONTROL
MOVE PASSED-TEXT-STRING TO TEMP-TEXT-STRING
CALL "MYSUB" USING PASSED-MYSUB-CONTROL,
TEMP-TEXT-STRING
*
Convert the stored text after calling MYSUB.
INSPECT MSG-TEXT CONVERTING
"abcdefghijklmnopqrstuvwxyz" TO
"ABCDEFGHIJKLMNOPQRSTUVWXYZ".
EXIT PROGRAM.
Search WWH ::




Custom Search