* * * NO STANDARD DEFAULT CODE FOR THIS INSERTION POINT * * * DEFAULT ALGORITHM %SUBRTNL ENDS HERE * * * * DEFAULT ALGORITHM %SUBRTNM STARTS HERE * * * NO STANDARD DEFAULT CODE FOR THIS INSERTION POINT * * * DEFAULT ALGORITHM %SUBRTNM ENDS HERE ``` Above are two insertion points which are provided so that you can insert as much Customization logic as you like to be (cont.) performed from anywhere else in the MMP. Here you might insert a routine to do a special edit on, let us say, dates. (cont.) You might have several date fields on the screen and wish to edit each of them using this subroutine. The code you (cont.) place here may be PERFORMed as many times as you wish from the edit routine (%EDIT) or anywhere else that is needed. (cont.) The insertion point named %SUBRTNL is obsolete and supported for compatibility with older versions of MAGEC. You should (cont.) use %SUBRTNM. ``` * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ZZ999 THIS MUST BE THE LAST PARAGRAPH * * IN THIS PROGRAM. IT WILL STOP RUNAWAY LOGIC (FALL-THRU) * * IN THE USER-CODED ROUTINES AND ISSUE AN ERROR MESSAGE. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ZZ999-STOP-RUNAWAY. MOVE FALL-THRU-ERROR TO TWA-ERR-CODES. MOVE F TO FATAL-ERR. GO TO AA900-GOBACK. ``` This routine is generated at the physical end of the program. It catches "runaway" logic which might attempt to "fall (cont.) thru" the end of the program. Falling thru the end will always give bad results. In some environments it will execute (cont.) the default GOBACK or STOP RUN which the Cobol compiler puts there - that will usually terminate the whole TP Monitor. (cont.) This "safety net" catches the error before the damage is done. One way you might create such an error would be to PERFORM a subroutine THRU the EXIT and, within the subroutine, GO around the EXIT. With very little effort you can discover other ways. ## Appendix A -- Maintenance Mode Setting The logic in the generated MMP which sets the MMP-NEW-TRANSACTION switch is depicted in the following flowchart.This (cont.) switch has significant impact on the operation of the program. It indicates either that the program is in (cont.) NEW-TRANSACTION-MODE or in CONTINUATION-MODE. ## Appendix B -- Browse Mode Setting The setting of the MMP-NEW-TRANSACTION switch in the Browse mainline logic determines whether the program initiates a (cont.) new browse starting with the key value given in SKEY, or continues paging forward or backward from a browse initiated (cont.) in a prior transaction. ## Appendix C --Automatic Editing The editing and formatting of screen fields based upon their Edit types is mostly done in MAGEC's Control Program's (cont.) "automatic edit" routine, prior to its passing control to the MMP. The exception to that is the pattern edits (Edit (cont.) types "P" and "#"), which are handled within the MMP in the BB500-SCREEN-EDIT paragraph. The Control Program must make a determination as to whether or not to execute the automatic edit routine based upon the (cont.) function code and whether this will be a new transaction or a contunuation. Refer to "Appendix A" and "Appendix B" for (cont.) a discussion of NEW-TRANSACTION-MODE and CONTINUATION-MODE. Obviously, it would not be necessary to edit and validate screen data for a transaction which is merely an inquiry and (cont.) will not be updating the files or database. The Control Program looks at the SFUNCT and TWA-LAST-FUNCT fields, and the (cont.) SKEY and TWA-LAST-KEY fields before passing control to your MMP. If it determines that it is appropriate to edit the (cont.) screen data, it executes the automatic edit routines which do several things: edit (validate) the contents of each screen field based on the Edit type and associated parameters for each translate lowercase alphabetics to uppercase for type "U" and "T" fields set the error flag (SfieldE field) to space or "E" to indicate whether each field passed or failed the edits fill in the numeric (Sfield-N) value field associated with each screen field having a numeric Edit type normalize the contents of each numeric or date type field into the standard display format for its respective Edit type fill in the DAY-OF-WEEK and JULIAN-DATE fields for all fields having a date Edit type set the appropriate error number(s) into the TWA-ERR fields (occurs 6 times to allow for 6 error messages to be displayed at a time) set the master error flag (FATAL-ERR) to "F" (ERROR-FOUND), or to space fill in the values of all Edit type "W" fields associated with table edited (type "T") fields using the descriptions from the table entry on the TBL file It should also be noted that the contents of the type "W" fields will again be filled in after the MMP exits, just (cont.) before the screen is sent to the operator. This is done so that the MMP can alter the contents of the type "T" field (cont.) and the description will change accordingly. Note:** Since the determination of whether or not to execute the automatic editing routine is done prior to entering (cont.) your MMP and is based on the function code (SFUNCT), changing the function code within your MMP's processing will not (cont.) affect it. Thus, if your MMP was entered with a function code which did not indicate the need for automatic editing, (cont.) but your program logic has altered it to another function code which does require editing, the editing will not have (cont.) been done. This means that the numeric values (Sfield-N) will not have been filled in--likewise for all of the other (cont.) processes described above. If you wish to alter the function code and have the editing done, you should do a FTH-FUNCT (cont.) using the new function code so as to give the Control Program a chance to see the new function code and act upon it. (cont.) Refer to "Appendix B" of the Customization section in your MAGEC Tutorials book. Remember too, the contents of (cont.) TWA-LAST-FUNCT, SKEY, and TWA-LAST-KEY will affect the determination. Normally only the ADD, CHG, and DUP functions require automatic editing. If you wish to indicate that editing is (cont.) required for any other function you can do so on the FCD file definition for that function code. Refer to "Figure 3" in (cont.) the *Security* section of this Programmer's Reference book. Function codes ending in "ADD", "CHG", or "DUP" are considered to require automatic editing in their continuation modes (cont.) regardless what is specified on the FCD definition for them. Any other function codes receive the editing only if you (cont.) have specified "Y" for THIS FUNCTION WILL INVOKE AUTO EDITING (Y OR N): on their respective FCD (cont.) definitions. For purposes of determining whether or not to execute automatic editing for each transaction, the Control Program (cont.) treats any function code having a "Y" specified (as described above) as if it were a "CHG" function. Refer to the prior (cont.) appendices in this section for discussion of the determination logic. Within your MMP updates to the files or database should only occur in CONTINUATION-MODE since no automatic editing will (cont.) have been done for the NEW-TRANSACTION-MODE transaction. Normally NEW-TRANSACTION-MODE involves only the display of a (cont.) screen containing data to be updated (or empty fields in which to type new data to be added). If you chose to add (cont.) customization which does updates to files in NEW-TRANSACTION-MODE you will be responsible for all data validation. (cont.) *Data integrity should always be the paramount consideration!* If you wish to ignore some, or all, of the errors found by the automatic editing routine, you can. The automatic (cont.) editing routine indicates in which fieds it found errors by setting the SfieldE field (in the Mask copybook) to "E", (cont.) and by setting the master error flag and adding the appropriate error number to the list of TWA-ERR fields. You can, if (cont.) you wish, interrogate any or all of these fields to determine if a certain error was found and then unset that error by (cont.) removing (blanking) the error number from the list, resetting the SfieldE field to space, and/or resetting the master (cont.) error flag to space. It would be best to do this early in the program logic, as in %PREINIT, if possible since having (cont.) an error flagged might alter the path of the logic later on. An obvious illustration of this phenomenon is that any (cont.) coding in the %EDIT2 insertion point will be entirely bypassed if the ERROR-FOUND condition is true. Also, the (cont.) ERROR-FOUND condition triggers the Control Program to look up the error numbers indicated in the TWA-ERR's and display (cont.) the associated error messages in SERRMSG before the screen is sent. Of course, the MMP will also bypass the file (cont.) updates if ERROR-FOUND is true.