CA879-EXIT.
EXIT.
CA899-EXIT.
EXIT.
* * * DEFAULT ALGORITHM %SKEYBLD ENDS HERE
```**
The entire CA800 routine is a Default for the insertion point named %SKEYBLD. Its purpose is to build the key value in (cont.)
screen format from the Master key field in the record. It is performed from the NXT Functions. In most cases you would (cont.)
not want to touch this routine. In the unlikely event that you need to display the key somehow other than it would be (cont.)
built by this routine then you can override the entire CA800 routine with your own.
##
Service Routines
The CA600, CA900, CB200, CB500, CB600, CB900, DA100, DA200, DA300, FA100, FA400, and FA500 routines are not shown here (cont.)
because they are used "internally" by the SCN and FND Functions and by the Pattern Editing. You cannot alter them. The (cont.)
CC100 routine, also not shown, is used for the VERZUN function which displays statistics for your application. The (cont.)
DA400 routine (not shown) is performed to spool report lines. These routines should never be altered by (cont.)
you.
The CB900-SPOOL routine consists of the insertion point %SPOOL. The Default logic for %SPOOL includes the library (cont.)
member named SPOOLIT. You can override this default spooling routine by coding customization for %SPOOL, if you (cont.)
wish.
| ```
**
JA100-LOGICAL-JOIN.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* LOGICALLY JOIN SECONDARY DATA FILES TO THE PRIMARY FILE *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
MOVE TWA-DB-REQUEST TO TWA-DB-REQ-SAV.
* * * CUSTOM ALGORITHM %JOIN STARTS HERE
IF (NOT-FOUND) GO TO JA900-RETURN.
MOVE REDKY TO TWA-DB-CMD.
MOVE 'SIFK1' TO TWA-DB-KEY-NAME.
MOVE 'SIF01 TO TWA-ELT-LIST.
MOVE LOW-VALUES
TO SIF01-LOVALU.
MOVE VAC01-EMPNUM TO SIF01-EMPNUM.
MOVE SIF01-MASTER-KEY TO TWA-KEY-VALUE.
CALL 'MAGECSET' USING TWA-DB-AREA-A SIF01-ELEMENT.
PERFORM AA840-CALL-MAGEC-IO THRU AA899-EXIT.
IF (NOT-FOUND)
MOVE SPACES TO SIF01-ELEMENT
GO TO JA900-RETURN.
* * * CUSTOM ALGORITHM %JOIN ENDS HERE
JA900-RETURN.
MOVE TWA-DB-REQ-SAV TO TWA-DB-REQUEST.
MOVE THIS-PGMS-ELEMENTS TO TWA-ELT-LIST.
JA999-EXIT.
EXIT.
```**
This is the JA100 routine which is performed from every "read" routine immediately after reading the primary file (cont.)
record. It is where you can code the reads for as many other files as you like to construct a "logical record" for the (cont.)
MMP to process against.
The insertion point named %JOIN is an extremely important one and you will find it very useful. You can not only read (cont.)
other files but also compute values into VARIABLE-STORAGE fields which may be specified as "Source/Target" fields to be (cont.)
displayed on the screen.
Using this insertion point wisely can greatly simplify your MMP's logic and your work. The code shown in this example (cont.)
was generated in the Automatic Logical Join process during the development of this application.
The coding found in the %JOIN insertion point could be placed there in any of several ways. It could be manually coded (cont.)
by the developer as ordinary customization coding, it could be generated via the semi-automated development process (cont.)
which requires some programmer input, or it could be generated using the fully-automated development process which (cont.)
requires no programmer input. Regardless how it got there, it can be altered or added to online via the standard (cont.)
customization processes.
| ```
**
***************************************************
* MISCELLANEOUS *
* USER-CODED CUSTOM SUBROUTINES WILL BE PLACED *
* BELOW. *
* *
***************************************************
* * * DEFAULT ALGORITHM %SUBRTNL STARTS HERE
* * * 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 (cont.)
be 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 a (cont.)
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 your MMP (cont.)
and is based on the function code (SFUNCT), changing the function code within your MMP's processing will not affect it. (cont.)
Thus, if your MMP was entered with a function code which did not indicate the need for automatic editing, but your (cont.)
program logic has altered it to another function code which does require editing, the editing will not have been done. (cont.)
This means that the numeric values (Sfield-N) will not have been filled in--likewise for all of the other processes (cont.)
described above.
If you wish to alter the function code and have the editing done, you should do a FTH-FUNCT using the new function code (cont.)
so as to give the Control Program a chance to see the new function code and act upon it. Refer to "Appendix B" of the (cont.)
Customization* section in your MAGEC Tutorials book. Remember too, the contents of TWA-LAST-FUNCT, SKEY, and (cont.)
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.