12 13 14 15 Move CURSOR to a line, use ERASE EOF to Delete it -or- PF20 to Insert After it Semicolon (;) is the TAB Character Asterisk (*) in col. 1 = suppress upcase Press PF24 for Instructions ``` Figure 37 — Second Page of Custom Code for %SELECT ## Recompile and Test Do this:** Press PF15 to exit MAGEC. Resubmit MMPCREAT. Check the listing. **Do this:** If you are using a mainframe, use the appropriate New Copy command. **Do this:** Use the TS01 TransID to get back into MAGEC. ## Define New Function to Security In order to execute the new VACTOT function, it must first be defined to the MAGEC security system. We will not describe the tasks of the Security Officer in this chapter since your company may wish to restrict access (cont.) to the Security System's functions. To avoid delays, we have taken the liberty of predefining VACTOT to the system. (cont.) Therefore, it is not necessary for you to ask the Security Officer to do it. Defining a new function can be done online (cont.) in less than one minute and it takes effect immediately. Refer to the MAGEC "Security" chapter for more (cont.) information. The Security Officer uses the command: FCDADD VACTOT     to define your new function code. **Do this:** Have your Security Officer define the new function to the Security System (if it is not already defined). You may do it yourself if you are authorized. Refer to the notes below. **Note:** You can look at the function code definition for VACTOT by doing the FCDSEE VACTOT     command, if the definition already exists. **Note:** If you add a new function code definition, you must do the **LOAD command to tell MAGEC to reload its in-memory images of security parameters before you can test that new function. **Note:** The easiest way to add the VACTOT function code definition to the repository is to duplicate the VACLOC function code definition. To do this you would: 1). type the command FCDSEE VACLOC, and press ENTER 2). alter the command to FCDDUP VACTOT, and press ENTER ## Test New Function **Do this:** Enter the command: VACTOT . . . press ENTER. Your new function will read all the employees' VAC data and tally the grand totals and display them to you. You have now completed Sample Project 3. You should now have a good working understanding of how to use the MAGEC (cont.) Customization screens and Insertion Points. Of course, there are an infinite number of other types of customization (cont.) which you can do. These projects have set you off to a good start with MAGEC. You will find that you can use MAGEC for 100% of your (cont.) Online Applications development since you can do anything with MAGEC that you could do with Cobol or "C" or Assembler (cont.) language (it is permissable in MAGEC to CALL other-language subroutines). You may wish to re-read this chapter, paying closer attention to the explanations on each page, in order to reinforce (cont.) your understanding. The Appendices in the back of this chapter and in the back of the chapter titled "Application (cont.) Developer", will be continually helpful to you as reference material. ``` VACTOT 000000000 END OF LIST - PF5=Restart/PF7=Backward ** TOTALS - ALL EMPLOYEES VACATION DAYS ======= 1,234.56 SICK DAYS =========== 126.70 COMP DAYS =========== 55.00 TOTAL DAYS ========== 1,416.26 ++++ 23 Records Scanned, 00 Displayed so far - page 1 ++++ Key 1 = Employee# (9-digits) Press PF13 for Hardcopy You may position the CURSOR to an item and Press ENTER to "SEE" it (Browsing Forward) or Press PF4 to "CHG" it ``` Figure 38 — VACTOT Display # Test Project 4 ## Chaining Screens Warning!** This project calls for some research and some thinking on your part. It is intended to get you started using the (cont.) manuals, especially the Appendices at the end of each tutorial section, to help solve real-world problems. It also (cont.) teaches you how to test for PF keys and how to chain from screen to screen programmatically. This time we will let you figure out how to do a small project on your own. The solution is in this book, immediately (cont.) following this project description. We recommend that you try to solve the problem first, then look at the (cont.) solution. There are a set of standard functions for accessing the Security Information File (SIF), just like the ones you have (cont.) just created for the VAC file. We would like to have the ability to transfer to the SIFSEE screen from any VAC (cont.) maintenance screen (VACSEE, VACCHG, etc.) for the same employee. In other words: if you were looking at the VACSEE (cont.) screen for employee 12 you should be able to press a PF key to immediately see the SIFSEE screen for employee (cont.) 12 without having to type in any command. For the sake of this project let's use PF6 to do that. The opposite page contains some helpful hints which should make the project easier for you. You might wish to keep in mind that the generated MMP now supports ten functions, they are categorized into two (cont.) classes: *maintenance functions* and *browse functions*. In this project we are interested in providing the ability to (cont.) transfer from any of the maintenance functions (VACADD, VACCHG, VACDEL, VACSEE, VACNXT, VACDUP) to the SIFSEE function. (cont.) We are not trying to transfer from any of the browse screens (though that is no more difficult to (cont.) do). **Do this:** Read these instructions and the hints on the facing page. Browse through the Appendices for more help. ## Helpful Hints The appendices of this book will help you to know how to transfer to another function or screen. They will also help (cont.) you to know how to sense which PF key was pressed. They will also help you to find the customization insertion point (cont.) appropriate to accomplish what you want to do. You will want to insert customization to sense the PF key from the maintenance screen. The insertion point names are generally mnemonic so that you can more easily remember them. When you are adding customization to an insertion point for which there is default logic, you will usually be presented (cont.) with a proforma (on the screen) which resembles the default logic. It is usually easiest to then just press ENTER, (cont.) adding the code from the screen to the dictionary as custom code, then to edit the new custom code. You can insert (cont.) additional coding plus retain the default coding in that manner. The solution is just below here. ## Solution to Test Project 4 To accomplish the objective of Test Project 4, from the prior page, you should have added the following statement into the %PFKEYM insertion point for application 600:  IF (TWA-MSK-PF6-HIT) ** MOVE QUOTE TO TWA-MSK-AID MOVE FTH-FUNCT TO TWA-NONTP-REQUEST MOVE 'SIFSEE' TO SFUNCT GO TO AA900-GOBACK.   The sequence of the MOVE's is not important. The MOVE QUOTE TO TWA-MSK-AID is optional, but it is a good idea. You should have added this code by doing: ALGADD 600/PFKEYM proforma is displayed press ENTER to add code from screen as new custom code data is added, screen returns in "edit mode" position cursor above first line of code, press PF20 screen "opens up" for lines to be inserted type in the code shown above, press ENTER new lines inserted, screen displays them submit MMPCREAT (in batch) NEW COPY as appropriate to your environment Note:** The proforma for the %PFKEYM insertion point includes the logic to test for all the standard MAGEC/SAA PF keys. (cont.) It also includes the logic to test for the situation in which an operator is doing an inquiry function and attempts to (cont.) modify the displayed data. The default logic issues a message asking: Did you Intend to Change Data? The operator may (cont.) then alter the Function Code to xxxCHG and press ENTER to complete the update. A popular alternative is to have the (cont.) program bypass the question and automatically alter the function code to xxxCHG and to process the update immediately. (cont.) Neither method bypasses any security since MAGEC will verify that this operator is allowed to do the CHG function (cont.) before actually accepting it. The proforma for %PFKEYM shows the default logic commented out and the alternative logic (cont.) added below it. If you want to retain the default method of asking the operator ratner than automatically processing (cont.) the update, you must remove the asterisks from column 7 of the default code shown and remove the alternate logic below (cont.) it. Otherwise, the program will do the automatic switch to the xxCHG function. # Project 5 ## Using Lookup Tables **Note:** By this time we assume that you have learned something from the earlier tutorials. This project gives you (cont.) less "hand-holding" and leaves you to your own devices. It does give you liberal hints and suggestions to help you (cont.) along, though. MAGEC includes some very useful and powerful features associated with editing a screen field against a table of valid (cont.) values. One obvious example of how these features can be used is in the validation of a State (or Province) code as (cont.) part of an address. **Do this:** This project will also require you to think about what you have learned so far. Please read the instructions below . The Vacation file (Data Class VAC) actually contains more data than we have been using thus far in our tutorial (cont.) projects. There is an Element named VAC02 which contains the City, State, and Zip (as in a U.S. street address) for (cont.) each employee on the file. It is possible that for some of the employees there is not actually valid data in these (cont.) fields, but merely the default value of spaces. That will become apparent to you when you try to access that (cont.) data. The very first screen you filled in when you initially began to develop the Vacation application was the Screen Header (cont.) Definition. Refer to Figure 01 in the "Application Developer" tutorial. That screen (the SHDxxx screen) includes a (cont.) parameter for the Verify Option. We initially set that option to NO. The verify option tells MAGEC whether to generate (cont.) special code into your MMP which will protect against bad data which is read from your files and databases. As you (cont.) know, Cobol programs ordinarily will abend if they try to access non-numeric data in a numeric field. Since we are now (cont.) going to access Element VAC02, which we have said may contain non-numeric Zip codes (spaces), we should turn on the (cont.) verify option in order to protect ourselves. We must also add Element VAC02 to the list of Elements to be accessed from the VAC Data Class. **Do this:** Use the SHDCHG function to alter the Verify Option from NO to VERIFY, and to add VAC02 as Element 2 under the Element Names parameters. Be sure you receive the message in SCOMPL, top right of the screen, which says: Data UPDATED on Database, otherwise, you probably entered something incorrectly. **Do this:** Look at the screen shown in Figure 39. Our objective is to modify the Vacation screen to look approximately like this. The new fields are highlighted by the shadow box. There are seven new fields. Three of them are Prompts (constants). (cont.) Three of them are variables. and one of them is a "W-field" used to display the state name associated with the (cont.) two-character state abbreviation code. ``` VACSEE 01 ** Date: 08/15/1993 VACATION/SICK/COMP DAYS Time: 01:15:03 Emp# 000-00-0001 First Name Harry Last Name Houdini Hire Date 12/31/87 Earned Vacation 14.50 Vacation Taken 2.25 Due 12.25 Sick Days Earned 124.50 Sick Days Taken 3.00 Due 121.50 Comp Days Earned 2.00 Comp Days Taken .00 Due 2.00 Comments (3 lines) Heavily into Escape literature. Likes to be submerged while handcuffed and strait-jacketed in a coffin-like vault Total Days Due 135.75 City Waxahachie State TX Zip 75102 Texas Press PF4 for browse (LOC) screen Press PF13 for Hardcopy Press PF16 to Copy field to buffer Press PF17 to Paste data from buffer Press PF2 for field-level HELP ``` Figure 39 — Address Data on Inquiry Screen ## Manual Screen Painting For this project we will have you use the manual screen painting facility, MSKDEF, which you have used before (refer to (cont.) Figure 12 in this "Customization" tutorial) to add the new fields to the screen. That will help familiarize you with (cont.) more of the specification parameters for screen fields. You can draw the "constants by typing the literal values, i.e. "City", directly onto the screen exactly where you want (cont.) them. Don't forget to use the less than symbol () to define the size of each field. You can draw the "variables using either all X's or all 9's to indicate alpha-numeric or numeric fields. Only the Zip (cont.) Code field is numeric, the others are alpha-numeric. The city name is 15 characters long, the state code is 2 (cont.) characters long, and the zip code is 5 digits long. The "W-field" in which the state name is to be displayed should be (cont.) approximately 20 characters long. Its size is not very critical since MAGEC will automatically truncate or pad the (cont.) state name to make it fit into whatever size field you give it. Do this:** Use the MSKDEF function to draw the seven new screen fields onto Mask 600. Once you have drawn the new fields onto the screen you must modify the specifications for all but the three constant (cont.) fields. To do this you use the PF18 key, as before. Each of the specification parameters will be shown with its default (cont.) value, you overtype the default to alter it to the value you desire. The desired values are: Scrn Fld NM Source/Target Lgth Type -- R/O TBL# city SCITY VAC02-CITY 15 X "Required state SSTATE VAC02-STATE 02 T "Required 003 zip code SZIP VAC02-ZIP 05 N "Required W-field SSTNAM 20 W "Optional In addition, you must specify the W-Fld parameter for SSTATE as being "SSTNAM". This tells MAGEC that SSTNAM is the (cont.) W-field for SSTATE. MAGEC will automatically place the description (in this case, the state name) into the W-field (cont.) based upon the code (in this case, state abbreviation) entered into the T-field (in this case, (cont.) SSTATE). Next: https://magec.com/DOC/markdown/cstm10.md.txt