MOVE VARSTG-MSG TO SCOMPL GO TO AA800-SEND-SCREEN. IF (ADD-FUNCTION) IF (NOT-FOUND) NEXT SENTENCE ELSE IF (DUP-ERROR) MOVE DELETE-PENDING-MSG TO SCOMPL GO TO AA800-SEND-SCREEN ELSE MOVE DUPLICATE-MSG TO SCOMPL MOVE FOUR TO TWA-MSK-CUR-AD-OT PERFORM BB200-FILL-SCREEN THRU BB299-EXIT GO TO AA800-SEND-SCREEN ELSE IF (NOT-FOUND) PERFORM BB100-BLANK-SCREEN THRU BB199-EXIT MOVE E TO SCOMPLE MOVE SKEY-POSN TO TWA-MSK-CUR-AD-OT IF (NXT-FUNCTION) MOVE EOF-MSG TO SCOMPL GO TO AA800-SEND-SCREEN ELSE MOVE NOT-FOUND-MSG TO SCOMPL GO TO AA800-SEND-SCREEN. MOVE SKEY TO TWA-LAST-KEY. MOVE TWA-DB-REQUEST TO TWA-DB-REQ-SAV. ```** The AAM400 routine does the MAGECIO calls to read the file. Notice the insertion points %REDKY, %RDUKY, and %REDNX (cont.) which all have Default code which calls MAGECIO. You might provide your own Customization code to replace the Defaults (cont.) to allow you to access types of files not supported by MAGECIO or to add a little of your own logic before or after (cont.) calling MAGECIO. Notice that the %REDKY Default logic saves the Audit Stamp and the RDUKY Default logic checks to see if it has been (cont.) altered by another task since it was read in %REDKY. If you are familiar with the philosophy of Pseudo Conversational (cont.) programming then you will see that this solves the classic problem in which one terminal's update could overlay the (cont.) record just updated by another terminal, undoing its changes. The %RDUKY logic is executed only for CHG Functions and (cont.) DEL Functions in Continuation Mode. AAM440 checks for bad MAGECIO return codes or for database data overlaying the (cont.) areas beyond TWA-DB-DATA. For bad return codes an error message is placed in SCOMPL and we exit to send the (cont.) screen. | ``` ** **************************************************************** * AAM500 * * IF THIS IS A NEW TRANSACTION THIS ROUTINE BUILDS A * * SCREEN FILLED WITH BLANKS OR DATA DEPENDING UPON * * THE FUNCTION. IT THEN BYPASSES FURTHER PROCESSING * * AND SENDS THE SCREEN. * **************************************************************** AAM500-BUILD-NEW-SCREEN. IF (NEW-TRANSACTION-MODE) IF (ADD-FUNCTION) PERFORM BB100-BLANK-SCREEN THRU BB199-EXIT GO TO AA800-SEND-SCREEN ELSE PERFORM BB200-FILL-SCREEN THRU BB299-EXIT IF (NXT-FUNCTION) MOVE NXT-OR-PREV-MSG TO SCOMPL PERFORM CA800-BUILD-SKEY THRU CA899-EXIT GO TO AA800-SEND-SCREEN ELSE IF (DEL-FUNCTION) MOVE ENTER-TO-DEL-MSG TO SCOMPL GO TO AA800-SEND-SCREEN ELSE GO TO AA800-SEND-SCREEN. ```** If we are in New Transaction Mode then we do not want to continue on down to the updating routines. We perform either (cont.) the BB100 routine (to fill the screen with Underscores), or the BB200 routine to move the record data to the screen and (cont.) then we exit to send the screen. The CA800 routine transforms the record's Master Key into proper screen key format (cont.) (SKEY) with slashes ( / ) separating component fields, etc. | ``` ** **************************************************************** * AAM600 * * THIS ROUTINE EDITS THE SCREEN AND, IF ERRORS WERE FOUND, * * BYPASSES UPDATING THE DATABASE. * **************************************************************** AAM600-EDIT-SCREEN. IF (DEL-FUNCTION) PERFORM BB400-EDIT-FOR-DELETE THRU BB499-EXIT ELSE PERFORM BB500-SCREEN-EDIT THRU BB599-EXIT. ```** The AAM600 routine performs the appropriate screen edit routine for ADD, CHG, or DEL Functions in Continuation Mode. (cont.) Remember, nothing else would get this far in the logic after AAM500 above. If errors are found in either of the edits, (cont.) or if they were found in the Automatic Editing then the FATAL-ERR flag will be set to F. This condition (ERROR-FOUND) (cont.) will prevent any database updating below. | ``` ** **************************************************************** * AAM700 * * THIS ROUTINE UPDATES, DELETES, OR ADDS TO THE DATABASE * * AFTER UPDATING THE DATA DEFINITION AREA FROM THE SCREEN * * DATA IF THE FUNCTION IS ADD OR CHANGE. * **************************************************************** AAM700-UPDATE. MOVE TWA-DB-REQ-SAV TO TWA-DB-REQUEST. IF (ERROR-FOUND) IF (RDU-CMD) GO TO AAM740-RELEASE-EXCL-CONTROL ELSE GO TO AA800-SEND-SCREEN. IF (ADD-FUNCTION) PERFORM BB600-BUILD-REC THRU BB699-EXIT MOVE TWA-DB-REQ-SAV TO TWA-DB-REQUEST MOVE THIS-PGMS-ELEMENTS TO TWA-ELT-LIST IF (ERROR-FOUND) GO TO AA800-SEND-SCREEN ELSE GO TO AAM710-ADD-TO-DATABASE. IF (CHG-FUNCTION) PERFORM BB600-BUILD-REC THRU BB699-EXIT MOVE TWA-DB-REQ-SAV TO TWA-DB-REQUEST MOVE THIS-PGMS-ELEMENTS TO TWA-ELT-LIST IF (ERROR-FOUND) GO TO AAM740-RELEASE-EXCL-CONTROL ELSE GO TO AAM720-UPDATE-DATABASE. IF (DEL-FUNCTION) GO TO AAM730-DELETE-FROM-DATABASE. MOVE PGM-ERR-MSG TO SCOMPL. GO TO AA800-SEND-SCREEN. AAM710-ADD-TO-DATABASE. * * * DEFAULT ALGORITHM %ADDIT STARTS HERE MOVE THIS-PGMS-ELEMENTS TO TWA-ELT-LIST. MOVE ADDIT TO TWA-DB-CMD. CALL 'MAGECSET' USING TWA-DB-AREA-A VAC01-ELEMENT PERFORM AA840-CALL-MAGEC-IO THRU AA899-EXIT. * * * DEFAULT ALGORITHM %ADDIT ENDS HERE GO TO AAM750-TEST-RETURN-CODE. AAM720-UPDATE-DATABASE. * * * DEFAULT ALGORITHM %UPDAT STARTS HERE MOVE UPDAT TO TWA-DB-CMD. MOVE THIS-PGMS-ELEMENTS TO TWA-ELT-LIST. CALL 'MAGECSET' USING TWA-DB-AREA-A VAC01-ELEMENT PERFORM AA840-CALL-MAGEC-IO THRU AA899-EXIT. * * * DEFAULT ALGORITHM %UPDAT ENDS HERE MOVE AUDIT-STAMP TO SAVE-AUDIT-STAMP. GO TO AAM750-TEST-RETURN-CODE. AAM730-DELETE-FROM-DATABASE. * * * DEFAULT ALGORITHM %DELET STARTS HERE MOVE THIS-PGMS-ELEMENTS TO TWA-ELT-LIST. MOVE DELET TO TWA-DB-CMD. CALL 'MAGECSET' USING TWA-DB-AREA-A VAC01-ELEMENT PERFORM AA840-CALL-MAGEC-IO THRU AA899-EXIT. * * * DEFAULT ALGORITHM %DELET ENDS HERE GO TO AAM750-TEST-RETURN-CODE. AAM740-RELEASE-EXCL-CONTROL. * * * DEFAULT ALGORITHM %RELES STARTS HERE MOVE RELES TO TWA-DB-CMD. MOVE THIS-PGMS-ELEMENTS TO TWA-ELT-LIST. CALL 'MAGECSET' USING TWA-DB-AREA-A VAC01-ELEMENT PERFORM AA840-CALL-MAGEC-IO THRU AA899-EXIT. * * * DEFAULT ALGORITHM %RELES ENDS HERE GO TO AAM750-TEST-RETURN-CODE. ```** The AAM700 routines do the file updating calls to MAGECIO. Notice the insertion points %ADDIT, %UPDAT, %DELET, and (cont.) %RELES which are shown with their Default logic. You could provide Customization logic here to be done in addition to (cont.) or instead of the Default logic. The BB600 routine is performed to move the screen fields to the record fields. Within the BB600 routine is the Business (cont.) Rule processing for the Element, VAC01. If it sets the ERROR-FOUND condition, the update or add will not be done - an (cont.) error message will be issued instead. | ``` ** **************************************************************** * AAM750 * * THIS ROUTINE TESTS THE RETURN CODE AND MOVES AN * * APPROPRIATE MESSAGE INTO THE MASK'S SCOMPL AREA. * **************************************************************** SKIP2 AAM750-TEST-RETURN-CODE. IF (DUP-ERROR) MOVE DELETE-PENDING-MSG TO SCOMPL GO TO AA800-SEND-SCREEN. IF (NOT-FOUND) GO TO AAM751-UPDERR ELSE GO TO AAM752-CONT. AAM751-UPDERR. * * * DEFAULT ALGORITHM %UPDERR STARTS HERE MOVE DB-ERR-MSG TO SCOMPL. GO TO AA800-SEND-SCREEN. * * * DEFAULT ALGORITHM %UPDERR ENDS HERE AAM752-CONT. IF (ERROR-FOUND) GO TO AA800-SEND-SCREEN. MOVE SKEY-POSN TO TWA-MSK-CUR-AD-OT. IF (ADD-FUNCTION) GO TO AAM753-GOODADD ELSE GO TO AAM754-CONT. AAM753-GOODADD. * * * DEFAULT ALGORITHM %GOODADD STARTS HERE MOVE AUDIT-STAMP TO SAVE-AUDIT-STAMP. MOVE ADDED-MSG TO SCOMPL. MOVE SEE-LIT TO T-FUNCT. Next: https://magec.com/DOC/markdown/genmmp13.md.txt