BCS MVS COBOL Prepare Current Date

There comes the time when it is beneficial to format the current date and time. The following COBOL sub routine does exactly that.

000100 IDENTIFICATION DIVISION.                                         00010000
000200 PROGRAM-ID.    ABS00010.                                         00020000
000300 AUTHOR.        ARCH BROOKS.                                      00030000
000400 INSTALLATION   BROOKS COMPUTING SYSTEMS, LLC.                    00040000
000500 DATE-WRITTEN.  09/25/2014.                                       00050000
000600 DATE-COMPILED. 09/25/2014.                                       00060000
000700 ENVIRONMENT DIVISION.                                            00070000
000800 CONFIGURATION SECTION.                                           00080000
000900 SOURCE-COMPUTER. IBM-Z-OS.                                       00090000
001000 OBJECT-COMPUTER. IBM-Z-OS.                                       00100000
001100 INPUT-OUTPUT SECTION.                                            00110000
001200 FILE-CONTROL.                                                    00120000
001300 DATA DIVISION.                                                   00130000
001400 FILE SECTION.                                                    00140000
001500 WORKING-STORAGE SECTION.                                         00150000
001600 01  WS-CURRENT-DATE.                                             00160002
001700     05  CC PIC XX.                                               00170001
001800     05  YY PIC XX.                                               00180001
001900     05  MM PIC XX.                                               00190001
002000     05  DD PIC XX.                                               00200001
002100     05  HH PIC XX.                                               00210001
002200     05  MN PIC XX.                                               00220006
002300     05  SS PIC XX.                                               00230001
002400     05  SSHH PIC XX.                                             00240001
002500     05  GMTO PIC X(5).                                           00250001
003210 LINKAGE SECTION.                                                 00321003
003300 01  FMT-DATE PIC X(10).                                          00330002
003310 01  SHORT-DATE REDEFINES FMT-DATE.                               00331003
003320     05  MM PIC XX.                                               00332003
003330     05  P1 PIC X.                                                00333005
003340     05  DD PIC XX.                                               00334003
003350     05  P2 PIC X.                                                00335005
003360     05  CC PIC XX.                                               00336003
003370     05  YY PIC XX.                                               00337003
003400 PROCEDURE DIVISION USING FMT-DATE.                               00340001
003500     MOVE FUNCTION CURRENT-DATE TO WS-CURRENT-DATE.               00350002
003510     MOVE '/' TO P1.                                              00351005
003520     MOVE '/' TO P2.                                              00352005
003600     MOVE CORR WS-CURRENT-DATE TO SHORT-DATE.                     00360002
003700     CALL 'ABS00007'.                                             00370000

Notice the usage of move corr (esponding) statement.  This one statement properly populates the formatted output area.  As long as the data names correspond this statement works flawlessly.

Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.

Leave a Reply