Also, you must specify the number of significant digits (SIG) left of the decimal point, and the number of decimal (cont.) places (DEC), for any numeric fields. For the SZIP field there are 5 digits left, and no digits right of the decimal (cont.) point. We have arbitrarily specified that each of the variables will be a Required field. That means that MAGEC will issue an (cont.) error message to the operator if it is left blank when doing add or change operations. If a field is optional, MAGEC (cont.) will appropriately default it to either spaces or zeros on the database if it is left blank. You should us an unprotect field attribute for the city name, state code, and zip code variables; use skip-protect attributes for the other four fields. **Do this:** Do the MSKCRE function by pressing PF10 from the MSKDEF screen, then re-submit MMPCREAT to re-generate and compile the application. ## Demonstrate Table Features Once you have achieved a clean compile, which should be in the first try unless you made an error somewhere along the (cont.) line, you are ready to test. In the PC environment it is not necessary to issue any NEW COPY command, but on a (cont.) mainframe, it is. For more detail reagrding this, refer to the discussion in the "Application Developer" tutorial (cont.) regarding "New Copy of MMP" which is near Figure 15 in that section. **Do this:** Do a NEW COPY, as appropriate You should now be able to use the VACCHG function to try to update an employee's vacation data. The new city, state, (cont.) and zip fields should be on the screen. If the data is missing (i.e. blanks) you should receive error messages, such (cont.) as: Required Data Not Entered     Warning! Bad Data on File     You can type into the city, state, and zip fields to update the data on file, thereby correcting the errors noted. If you enter a valid state or province abbreviation (that is, one which is defined in Table #003), the appropriate (cont.) state name will appear on the screen in the W-field. If you enter an invalid abbreviation, you will receive an error (cont.) message, as: Invalid State/Province Code     If you point the cursor into the State Code field (SSTATE) and press PF2, the low-level Help key, you will receive (cont.) field-level help for that screen field. This is much like the field-level help for any other screen field, except that (cont.) there will be a message telling you that you can press PF8 to list the table of valid values (table #003, the State / (cont.) Province Code Table). If you press PF8 you will receive the first page of valid state codes, subsequently pressing PF8 (cont.) will page forward, PF7 pages backward. When you have a list of state codes displayed on the screen, you can position the cursor down to the line on which the (cont.) desired code appears (i.e. Texas) and press ENTER. MAGEC will then copy the code from the table into the screen field (cont.) from which you pressed PF2. The screen will return to the Vacation screen, but the selected code will be filled into it (cont.) automatically (i.e =. TX will be in the State Code field). This eliminates the need for your operators to memorize (cont.) lists of codes. When the code is copied from the table into your screen field, as described above, you will see a message displayed in (cont.) SCOMPL saying that a code was copied from the table onto your screen. This does not update the file, it merely places (cont.) the code into the screen field. You can modify it, or any other screen field's data, then press ENTER to update the (cont.) record on the database. ## Table Maintenance Table #003 is provided with MAGEC when the system is initially installed. Table #003 is used for the tutorial projects (cont.) and as a demonstration of how Lookup Tables work. It can also be used by any of your own applications to validate state (cont.) or province codes. Any MAGEC Lookup Table can be used by any number of applications. You can modify any Lookup Table using the built-in online functions provided with MAGEC. Tables are identified by a 3-digit number, 001 through 999. The numbers 200 through 255 are reserved for use by the MAGEC software. To display any given MAGEC table you can use the online command: TBLLST nnn     where nnn is the 3-digit table number. To alter any entry in a table you can use the command: TBLCHG nnn/eeeeeee     where "nnn" is the 3-digit table number and "eeeeee" is the code (up to 16 characters long). Similarly, you can add an entry to a table using the command: TBLADD nnn/eeeeee     or you can delete any entry using: TBLDEL nnn/eeeeee     If you prefer a batch hardcopy listing of any given table, or of several tables, you can use the batch utility program, (cont.) TBLLIST. Refer to the "Offline Utilities" chapter of your *Programmer's Reference Guide* for details regarding (cont.) TBLLIST. Now, let's look at the display of the State / Province Table. **Do this:** Enter the command: TBLLST 003, press ENTER. For details regarding how to define your own tables, refer to the "Database Administration" chapter of your *Programmer's Reference Guide*. For details on how to produce a Where-Used report for any table, refer to the "Offline Utilities" section of your *Programmer's Reference* manual under the topic "MAGECLBR". # Project 6 ## Generating Pop-Up Window Programs **Note:** In this project we will demonstrate another way that you could have added the capability for the operator to (cont.) update and see the city, state, and zip code information. Rather then placing it on the VACxxx screen (MSK600), as we (cont.) just did in Project 5, we could generate another program which uses a miniature screen, approximately one-fourth the (cont.) size of the large full-screen display. We could have shown the city, state, and zip code data in that smaller screen (cont.) and we could have "CALL"ed the small screen program from MMP600, effectively popping up a window. When the operator is (cont.) finished looking at or updating the data in the small window, he/she can return to the full-screen as it was left by (cont.) merely pressing PF3. A pop-up window program is very much like any other program except that it uses a smaller screen area and it does not (cont.) erase the data previously on the screen when it is invoked. The small window is superimposed on the larger screen (cont.) "behind" it. pop-up window programs can do the same kinds of functions as can full-screen programs. The standard set of (cont.) nine functions is available to select from, plus any custom functions can be added. A pop-up window program and screen are not limited to being invoked by just one particular calling program, but rather, (cont.) they can be invoked from any number of other programs. The most usual way to invoke a pop-up window program is via the (cont.) MAGEC Attach / Detach facility discussed in Appendix R of this section; however, you can invoke a pop-up window program (cont.) via the Fetch (discussed in Appendix B), or just by typing one of its Function Codes into SFUNCT on the screen, since (cont.) they are really just ordinary programs like any other. Similarly, the Attach / Detach facility is most often used to (cont.) invoke pop-up window programs, but it can also invoke full-screen programs just as well. Since you have just finished doing a project which placed the city, state, and zip code onto the full-screen display, (cont.) creating a pop-up window to display them will seem unnecessary and redundant. It is! Remember, we are doing this (cont.) project just to demonstrate how to create a pop-up window application. Developing a Pop-Up window application is really almost exactly like developing any other application. The process is (cont.) very similar to the one you used in the very first project in the "Application Developer" tutorial. The differences (cont.) are: 1. You will specify "MODELWIN" as the model to use when generating the application, rather than the default "MODELMMP". 2. You will be forced to use the manual screen painting method since automatic screen painting is not yet supported (as of release 2.6) for developing pop-up windows applications in MAGEC. 3. MAGEC will automatically prepare the screen painter with a border to mark off the pop-up window. You should draw your screen fields within that border. Other than that, there is really no difference from what you did in the first development tutorial project. To invoke the pop-up window program from MMP600, you will use the Attach facility. This is very similar to what you did (cont.) in Project 4, earlier in this section, except that in that project you used the Fetch facilty. The Fetch does not (cont.) automatically set up for a return to the calling program and screen as the Attach does. In Cobol lingo, the Fetch and (cont.) Attach are to one another as are the GO TO and PERFORM . Since we will be developing an entirely new program, we must first choose an MMP number and Mask number for it. For (cont.) this project we will choose MMP800 and Mask 800. We can use the TSKLST to help us through the process as we did (cont.) before. **Do this:** Type the command TSKLST 800, and press ENTER. The SHDADD screen should appear with 800 set into the key area of the screen (SKEY). **Do this:** Fill in the screen, specifying the following: (then press ENTER) MMP# 800 Function Code Prefix VAP Verify Opt VERIFY Use MODEL MODELWIN Primary DCL VAC ELTs VAC01 VAC02 **Note:** In this application we really want only the city, state, and zip code data (all of which are contained in (cont.) element VAC02) to be displayed on the screen; however, we are selecting Element VAC01 as well as VAC02 because the key (cont.) for the record is in Element VAC01. It is *always advisable* to read the record key with the data, even in cases where (cont.) you theoretically do not need the key. The prefix VAP stands for Vacation Popup (an arbitrary choice). Since the function codes VACxxx have already been used, we must specify some other unique function codes for this program. The MMPADD screen will appear with 800 filled into the key area (SKEY), and default values filled into the fields in (cont.) the body of the screen. These default values were copied from the prior screen (SHDADD) and will be correct almost all (cont.) of the time. There will also be a white box displayed with a message telling you that you can press PF6 to review, or (cont.) modify, the selection of functions to be included into this program. **Do this:** Press PF6. A pop-up window appears with all nine of the standard functions highlighted (selected) as a default. You can place the (cont.) cursor to the line on which any of the functions is shown and press PF4 to unselect, or ENTER to select it. We wish (cont.) only to be able to see and change data in this program. **Do this:** Unselect all functions except for SEE/NXT and CHG. Then press PF6 to apply your changes and proceed. The TSKLST display will appear showing your current status for developing MMP800. **Do this:** Cursor-Select the "Paint Screen" task, press ENTER. The MSKDEF screen (manual screen painter) appears immediately. It has a square border drawn on the screen showing the (cont.) dimensions of a one-fourth-size pop-up screen. The reason that MAGEC is able to know that this is a Pop Up screen, (cont.) rather than a full screen, is because you specified MODELWIN in the SHD (Screen Header) definition. **Note:** It is possible, and legal, for you to draw fields outside of that border, or to alter the size and shape of (cont.) the pop-up screen; however, at this stage of your training it is wisest to just "color within the lines" until you have (cont.) more experience and can deal with added complexity. Since you specified to access both Element VAC01 and VAC02 earlier, you have all of the fields within both those (cont.) Elements available to this application. All that is necessary to meet our objective is to place the city, state, and (cont.) zip code in this screen; however, you may wish to also display the Employee number so that an operator looking at this (cont.) display clearly knows to which Employee this address data belongs. **Do this:** Draw the fields on this screen to display city, state, and zip code, with the appropriate prompts and with the W-field for displaying state name. The fields will be exactly like those you drew in the previous project (Project 5), but they will be in different (cont.) locations on the screen. Refer to the previous project if you do not remember what to do. **Hint:** If you have spent a little time studying the *Programmer's Reference* manual, "Screen Painting" section, you (cont.) might have noticed that you can duplicate a field from one Mask to another. You could, for example, use the Field Dup (cont.) function (PF20) to duplicate a field from Mask 600 to Mask 800. You can specify the target Mask#, Row and Column when (cont.) you use the Field Dup key. Doing that would reduce the amount of work you have to do here since you have already drawn (cont.) fields onto Mask 600 exactly like you need them on Mask 800. One way to ascertain the desired Row and Column is to just move the cursor to where you would like a field and look at (cont.) the bottom-right-hand corner of your screen. In most environments MAGEC, or the terminal controller, will display the (cont.) Row and Column of the cursor's position there. **Do this:** Press PF10 to execute MSKCRE. MSKCRE will generate the screen Mask and the Cobol copybook for it.Next, MSKSEE will display the new screen to you. At this point you have finished generating the screen Mask and it is time to generate the MMP (program). **Do this:** Press PF15 to exit MAGEC. **Do this:** Submit the MMPCREAT batch jobstream for 800. If you have a clean compile, you are ready to test the new program. If not, correct your errors and re-submit MMPCREAT, then begin testing. **Do this:** Log back onto MAGEC using the TS01 transid, Employee# 18, password=ALEE. Since the new program is not yet being invoked by any other program, the only way for you to test it now is to type in the Function Code with an appropriate key value. **Do this:** Type in the command: VAPSEE 01, and press ENTER Your little pop-up screen should appear with the data for Employee 01 showing. If you wish, you can update the data by changing it on the screen and doing the VAPCHG function. If all this seems to work, the next task will be to add the code into MMP600 to Attach to the VAPSEE function upon sensing some PF key. For this project we will use PF10 to invoke the VAPSEE pop-up. Since the keys for the VACxxx and VAPxxx functions are identical (Employee#), it is not necessary to alter the contents (cont.) of SKEY at all in order to invoke the VAPxxx functions from the VACxxx functions; therefore, we only need to alter the (cont.) contents of SFUNCTand then to go do the Attach. The insertion point at which this should be done is, you guessed it, %PFKEYM. **Do this:** Type the command: ALGSEE 600/PFKEYM, and press ENTER. The screen will display the PFKEYM custom coding as we last left it in Project 4 earlier. The code to sense PF6 and (cont.) Fetch to SIFSEE is still there where we put it. Now we will add a test for another PF key (PF10) and an Attach to (cont.) VAPSEE if PF10 was hit. **Do this:** Place the cursor onto the ruler line, above the first line of Cobol code, and press PF20 to insert more code. The screen "opens up" allowing you to type in more code to be inserted before the first line of Cobol code which was shown on the screen. **Do this:** TYPE in the following Cobol code: ``` IF (TWA-MSK-PF10-HIT) ``` ``` MOVE 'VAPSEE' TO SFUNCT ``` ``` GO TO AA760-ATTACH. ``` **Do this:** Press ENTER. The screen will return to you with your new lines of code inserted at the top. **Do this:** Press PF15 to exit MAGEC. Next you must re-compile MMP600 to include the new custom coding. **Do this:** Submit MMPCREAT for 600. **Do this:** Log back into MAGEC, as before. Now we will test the Attach from the VACSEE screen to the VAPSEE pop-up, and then the Detach back to the VACSEE screen. **Do this:** Type in the command: VACSEE 01, and press ENTER. The familiar VACSEE screen should be displayed. **Do this:** Press PF10. The VAPSEE pop-up should appear supreimposed on the VACSEE screen. You may change the data and do the VAPCHG function here, if you wish. **Do this:** Press PF3. The VAPSEE pop-up should disappear, returning to the VACSEE screen "as it was before you pressed PF10. If you altered (cont.) the city, state, zip code data in the pop-up, the altered values will not show on the VACSEE display until you press (cont.) ENTER to refresh the screen. # Appendix A -- How to Call a SubTask ## Linking to a Subroutine MMP Since your MAGEC MMP's are Cobol programs you are able to use the standard facility of your TP Monitor to invoke (cont.) Next: https://magec.com/DOC/markdown/cstm11.md.txt