if it is a numeric field, code:
MOVE '99/999-9999' (or any valid numeric pattern)
    TO PATTERN-MASK.
MOVE SPACES TO DE-EDITED-DATA.
MOVE data-field TO DE-EDITED-VALUE.
PERFORM CB200-INSERT-PATTERN THRU CB299-EXIT.
MOVE SCREEN-FIELD TO target-display-field.
##
Editing Field Using Pattern
To validate (edit) the format of an input data field using the Pattern editing, code (usually in %EDIT):
MOVE data-field TO SCREEN-FIELD.
MOVE 'XX-99-XXX-AA' (or any valid pattern)
    TO PATTERN-MASK.
PERFORM CB500-EDIT-PATTERN THRU CB599-EXIT.
IF PATTERN-ERROR EQUAL E
    MOVE E TO data-fieldE
    PERFORM CA100-LOAD-ERR-CODE-TBL THRU CA199-EXIT
ELSE
    MOVE SCREEN-FIELD TO data-field.
##
De-Patternizing a Field
To remove the pattern insertion characters from a patternized field, code (usually in %CALC):
MOVE 'XX99-A99/X' (or any valid pattern)
    TO PATTERN-MASK.
MOVE field-with-pattern TO SCREEN-FIELD.
PERFORM CB600-STRIP-PATTERN THRU CB699-EXIT.
MOVE DE-EDITED-DATA TO data-field.
          - or --
MOVE DE-EDITED-VALUE TO data-field.
DE-EDITED-VALUE is used for numeric data items, DE-EDITED-DATA is used for non-numeric items.
#
Appendix N -- Altering the Key Delimiter
##
Delimiter Character
The default logic generated by MAGEC for online MMP's stipulates that the key component fields (if there is more than (cont.)
one component field) are separated by a slash (/). This should be a good standard in most cases, however, sometimes it (cont.)
is desireable to use another character. One example of such a case is when the key data is a code which might contain a (cont.)
slash as a valid data character (such as a part number).
To alter the delimiter character used, you must enter a single line of Cobol customization coding into the %PREINIT insertion point. That line of code should say:
MOVE '-' TO D-LIMITER.
Where '-' is any valid character which you desire to be used as the new delimiter in place of the default slash.
#
Appendix O -- Converting Dates
##
Date Conversion Subroutine
The MAGDATE subroutine is provided with MAGEC in order to facilitate the conversions, comparisons, and validations of (cont.)
dates. It accepts Gregorian, Julian, and alpha-numeric date formats as input and validates and converts to any/all (cont.)
formats automatically.
To use MAGDATE your program must include the MAGDATE request area. It may be included into both online and batch (cont.)
programs in the Working Storage area (insertion point %LITERAL). Your program must fill in the appropriate fields (cont.)
within the request area and then:
CALL 'MAGDATE' USING MAGEC-DATE-REQUEST-AREA.
You should always test the return code** to verify whether MAGDATE has encountered an error in your request or has successfully completed the request. To test for successful completion , code:
IF (MAGDATE-OK) ...
There are condition names (88-level names) for a variety of possible error codes. You might wish to test for which type (cont.)
of error was found in the case that MAGDATE-OK is not true. The various return code values will be discussed later in (cont.)
this appendix.
##
Request Area
The MAGDATE request area is defined in Cobol in a library include member (copybook). To include it into your Working Storage, code:
-MAGECINC DATRQ-C
The following format is an abbreviated version of the DATRQ-C copybook. *The actual copybook includes several (cont.)
breakdowns of the various fields and lists of condition names (88-levels) for values.* These may be useful to you in (cont.)
some cases, so you may wish to review the actual copybook to familiarize yourself with them. It is not necessary to do (cont.)
so in order to use the basic functions of MAGDATE, however. The copybook is coded beginiing with a Cobol 04-level item. (cont.)
That facilitates including it into %VARSTOR or %DATADEF, if you find a need to do so. If you are including it into (cont.)
%LITERAL you might wish to precede the -MAGECINC statement with an 01-level item (i.e. "01 (cont.)
MAGDATE-AREA.").
  04 MAGEC-DATE-REQUEST-AREA.
**    05 MAGEC-DATE-REQ-RESERVED      PIC X(04).
    05 MAGEC-BIN-THRU REDEFINES MAGEC-DATE-REQ-RESERVED PIC S9(8) COMP.
    05 MAGEC-DATE-FROM      PIC X(12).
    05 FILLER  REDEFINES MAGEC-DATE-FROM.
        07 MAGEC-DATE-FROM-N                PIC 9(8).
    05 MAGEC-DATE-FORMAT      PIC X(12).
    05  MAGEC-DATE-THRU      PIC   X(12).
    05 MAGEC-DATE-THRU-FORMAT      PIC X(12).
    05 MAGEC-PLUS-MINUS-DAYS      PIC S9(5).
    05 MAGEC-LEAP-YEAR-CODE      PIC X.
    05 MAGEC-DATE-RETURN-CODE      PIC X(02).
      88 MAGDATE-OK      VALUE SPACES.
    05 MAGEC-RETURNED-DATE-INFO.
      07 MAGEC-DAY-OF-WK-CODE       PIC X(01).
      07 MAGEC-DAY-OF-WK-NAME       PIC X(10).
      07 MAGEC-MONTH-NAME       PIC X(10).
      07 MAGEC-END-PERIOD-FLAG       PIC X(01).
      07 MAGEC-GREG-DATES.
        09 MAGEC-GREG-MDCY       PIC 9(8).
        09 MAGEC-GREG-DMCY       PIC 9(8).
        09 MAGEC-GREG-CYMD       PIC 9(8).
        09 FILLER REDEFINES MAGEC-GREG-CYMD.
          11 FILLER       PIC X(2).
          11 MAGEC-GREG-YMD     PIC 9(6).
        09 MAGEC-GREG-MDY     PIC 9(6).
        09 MAGEC-GREG-DMY     PIC 9(6).
      07 MAGEC-JUL-DATE.
        09 MAGEC-JUL-DATE-CCYY     PIC 9(7).
        09 FILLER REDEFINES MAGEC-JUL-DATE-CCYY.
          11 MAGEC-JUL-DATE-CC     PIC 9(2).
          11 MAGEC-JUL-DATE-YYDDD    PIC 9(5).
      07 MAGEC-PERIOD-DATES-GREG.
        09 MAGEC-BEG-END-MONTH.
          11 MAGEC-BEG-MO-GREG     PIC 9(8).
          11 MAGEC-END-MO-GREG    PIC 9(8).
          11 MAGEC-BEG-MO-DAYOFWK     PIC X.
          11 MAGEC-END-MO-DAYOFWK     PIC X.
       09 MAGEC-BEG-END-QTR.
          11 MAGEC-BEG-QTR-GREG     PIC 9(8).
          11 MAGEC-END-QTR-GREG     PIC 9(8).
          11 MAGEC-BEG-QTR-DAYOFWK     PIC X.
          11 MAGEC-END-QTR-DAYOFWK    PIC X.
        09 MAGEC-BEG-END-SEMI.
          11 MAGEC-BEG-SEMI-GREG    PIC 9(8).
          11 MAGEC-END-SEMI-GREG     PIC 9(8).
          11 MAGEC-BEG-SEMI-DAYOFWK     PIC X.
          11 MAGEC-END-SEMI-DAYOFWK     PIC X.
       09 MAGEC-BEG-END-YR.
          11 MAGEC-BEG-YR-GREG     PIC 9(8).
          11 MAGEC-END-YR-GREG     PIC 9(8).
          11 MAGEC-BEG-YR-DAYOFWK     PIC X.
          11 MAGEC-END-YR-DAYOFWK     PIC X.
Your program must be linked to include the MAGDATE subroutine in order for you to call it. (cont.)
This is done in the link step of your compile jobstream. MAGDATE is found on the standard MAGEC library (loadlibrary, (cont.)
relocatable library, VSE/SP sublibrary, or in the \MAGMF directory).
##
Validating a Date
The most basic function of the MAGDATE subroutine is date validation. You can pass it a date and a format specification (cont.)
(telling it what format the date is in). It will return with a return code of spaces (MAGDATE-OK) or another value (cont.)
indicating the type of error found in the date. You can also convert a date to another format, compare two dates to (cont.)
determine how many days apart they are, or project the date any number of days before or after a given (cont.)
date.
To do this you should understand the possible values of both the return code (MAGEC-DATE-RETURN-CODE), and of the (cont.)
format specification (MAGEC-DATE-FORMAT). Let us first examine the return codes**. The copybook includes (cont.)
condition-names (88-levels) under MAGEC-DATE-RETURN-CODE, as described below.
The copybook includes condition names to define the possible return code values. They are:
value
             
condition-name
             
meaning
blank
             
MAGDATE-OK
             
successful completion of the requested action, the given date is a valid date in the format specified.
01
             
INVALID-MAGEC-DATE-FORMAT
             
the format specification is not valid
02
             
NON-NUMERIC-JULIAN-DATE
             
input format was julian and the date given was not numeric
03
             
NON-NUMERIC-MO-DAY-OR-YR
             
input format was gregorian and one of the components was not numeric
04
             
INVALID-MONTH
             
month of input date was not 01 through 12 - or JAN thru DEC
05
             
INVALID-DAY-OF-MONTH
             
the day number is not valid within the month (consider leap years for Feb.)
06
             
INVALID-JULIAN-DAY
             
input format was julian and the day number is invalid in the year given
07
             
INVALID-THRU-DATE-FORMAT
             
date comparison or projection was requested and the thru-date format is not valid
08
             
NON-NUMERIC-JULIAN-THRU
             
date comparison of julian dates was requested and the thru-date is not valid
09
             
NON-NUMERIC-MDY-THRU
             
date comparison in gregorian was requested and the thru-date is not valid
10
             
INVALID-MONTH-THRU
             
date comparison was requested and the month of the thru-date is invalid
11
             
INVALID-DAY-OF-MONTH-THRU
             
date comparison was requested and the day of the thru-month is invalid

next: cstm19.md.txt