© Al Lee & Associates, Inc., 2001–2026 all rights reserved
Exit This Topic
the code below was ai-generated to add a validation to a
MAGEC-generated MMP to validate that a hypothetical employee was
at least 18 years old when hired. This was the result of an inter-
active training session for aiMAGEC.
*================================================================*
* %VARSTOR INSERTION POINT - LINKAGE SECTION *
* AI CONSUMPTION NOTES: *
* - -MAGECINC DATRQ-C starts with 04-level. *
* - Do NOT use VALUE clauses here except for 88-level *
* (reentrancy rule). *
* - Fields are auto-initialized to LOW-VALUES on entry. *
*================================================================*
04 TEMP-DATE PIC X(8).
* MAGDATE Request Area - Official copybook
* ignore include if copybook already included elsewhere
-IFUNIQUE
-MAGECINC DATRQ-C
*================================================================*
* %EDIT, %EDIT2 INSERTION POINTs - Screen Field Validation *
* AI CONSUMPTION NOTES: *
* - Always test (NOT ERROR-FOUND) first for cross-field rules. *
* to be sure both fields are good *
* - Use screen fields (e.g.SDATEB, SDATEH) in %EDIT, not DB *
* source/target fields (not yet Filled) *
* - Move E to error flag fields (SDATEBE, SDATEHE) so that *
* MAGEC will automatically highlight them appropriately *
* depending on hardware, user options, etc. *
* - fill in ERROR-NUMBER PERFORM'ing CA100-... *
* - No GO TO outside PERFORM'd routine - *
* - to exit routine, GO TO or fall through to EXIT paragraph *
* - Use parentheses for clarity on all "IF" conditions *
* (especially when NOT logic involved) *
* - MAGDATE: Always MOVE SPACES first, use DATRQ-C fields *
* - Always test return code on return from any subroutine *
*================================================================*
IF ((NOT ERROR-FOUND)
AND (SDATEB NOT = SPACES)
AND (SDATEH NOT = SPACES))
MOVE SPACES TO MAGEC-DATE-REQUEST-AREA
MOVE SDATEB TO MAGEC-DATE-FROM
MOVE "CCYYMMDD" TO MAGEC-DATE-FORMAT
MOVE 6574 TO MAGEC-PLUS-MINUS-DAYS *> 18 years precision (18*365.25)
MOVE "CCYYMMDD" TO MAGEC-DATE-THRU-FORMAT
CALL "MAGDATE" USING MAGEC-DATE-REQUEST-AREA
IF (MAGDATE-OK)
MOVE MAGEC-DATE-THRU TO TEMP-DATE
IF (SDATEH < TEMP-DATE)
MOVE "9XX" TO ERROR-NUMBER
MOVE E TO SDATEBE
MOVE E TO SDATEHE
* --- FATAL ERROR example (blocks update) ---
PERFORM CA100-LOAD-ERR-CODE-TBL THRU CA199-EXIT.
* --- WARNING example (update still proceeds) ---
PERFORM CA400-LOAD-WARNING-TO-TBL THRU CA499-EXIT.
END-IF
ELSE
MOVE "9YY" TO ERROR-NUMBER
MOVE E TO SDATEBE
MOVE E TO SDATEHE
PERFORM CA100-LOAD-ERR-CODE-TBL THRU CA199-EXIT
END-IF
END-IF