This is a collection of code patterns for some of the common Mainframe MVS programming tasks which tend to repeat from time to time. When not singled out and classified these patterns get easily lost in the bulk of an application-specific code, and constant rewriting (and debugging) them from scratch is a senseless waste of time.
Normally there are several ways to code the same logic,v and some ways are better than the other in terms or size, effectiveness, readability and ease of modification. These criteria are rather fuzzy (except for the "size"), and are affected by personal preferences. Yet, there seems to exist a certain common sense consensus of what is "good" – like mnemonic names and labels, use of indentation, commenting, etc.
My brother Victor and I have been collecting such "good" code patterns for several decades and it seems it's about time to select the most usable of them from all of our scattered notes and programs into one document which will be hyperlinked for the ease of use, and will be accessible from anywhere and by anybody who might have interest in it. However, this selection is not compiled for the Web only – rather it's our working reference, which we try to maintain as accurate and current as possible As such it inevitably will always lack an overall integrity and completeness, yet it is still a rather useful tool that often saves time.
Most of the tasks originated from a real-life experience of a professional mainframe programmer. Most of the solutions were coded and debugged in the process of practical programming of various applications. Every pattern was checked to the best of our competence, and as a rule was tested by many years of repeated usage. This is not to suggest that it is in any way guaranteed to be error-free – you will be using any code you pick from this selection entirely at your own risk, and will be completely responsible yourself for any problems that might arise from this usage. So when trying a code, please exercise the common sense precautions, and test it most thoroughly yourself before applying it to anything serious.
This legal mantra been chanted, I want to mention that all error reports and any comments about this code pattern selection are most welcome, and I'll try to do my best to fix any known problem as quick as I'll be able to do this.
*----------------------------------------------------------------- DATA DIVISION. *----------------------------------------------------------------- . . . . . LINKAGE SECTION. 01 PARM-String. 02 PARM-Length PIC 9(003) BINARY. 02 PARM-Data PIC X(100). . . . . . *----------------------------------------------------------------- PROCEDURE DIVISION USING PARM-String. *----------------------------------------------------------------- . . . . . IF (PARM-Length > 0) <parse PARM-Data parameters> END-IF. <process control parameters>
*----------------------------------------------------------------- DATA DIVISION. *----------------------------------------------------------------- . . . . . WORKING-STORAGE SECTION. . . . . . * -- Pivot Year Assumed by the Organizational Standard. 77 Pivot-Year PIC 9(02) VALUE 50. * -- Source Dates to Be Compared. 77 Source-First-Date PIC 9(5). 77 Source-Second-Date PIC 9(5). * -- Working Variables for Y2K-Compliant Date Comparison. 01 Y2K-First-Date. 02 First-Date-CC PIC 9(2). 02 First-Date-YYDDD. 03 First-Date-YY PIC 9(2). 03 First-Date-DDD PIC 9(3). 01 Y2K-Second-Date. 02 Second-Date-CC PIC 9(2). 02 Second-Date-YYDDD. 03 Second-Date-YY PIC 9(2). 03 Second-Date-DDD PIC 9(3). . . . . . *----------------------------------------------------------------- PROCEDURE DIVISION. *----------------------------------------------------------------- . . . . . * -- Append Appropriate Century to the Source Dates. MOVE FUNCTION CURRENT-DATE(1:2) TO First-Date-CC Second-Date-CC. MOVE Source-First-Date TO First-Date-YYDDD. IF (First-Date-YY > Pivot-Year) SUBTRACT 1 FROM First-Date-CC END-IF. MOVE Source-Second-Date TO Second-Date-YYDDD. IF (Second-Date-YY > Pivot-Year) SUBTRACT 1 FROM Second-Date-CC END-IF. * -- IF (Source-First-Date > Source-Second-Date) IF ( Y2K-First-Date > Y2K-Second-Date) . . . . . ELSE . . . . . END-IF.
//STEP1 EXEC PGM=IEFBR14,PARM=(19980316, // 19980322) //STEP2 EXEC PGM=IEFBR14,PARM=('START=03/18/98', // 'STOP=03/22/98')
----+----1----+----2----+----3----+----4----+----5----+----6----+----7- //STEP3 EXEC PGM=IEFBR14,PARM='LONG PARAMETER FIELD WITHOUT COMMA DEL // IMITERS - CONTINUED IN COLUMN 16 OF THE NEXT LINE'