| ```
**
DBDITO Command:
```**
The **FILE **portion of the command is where you specify the Data Class.
In the **KEY** portion you specify the name of the key.
In the **ELEMENTS** area you list the Elements you wish to read.
Commands which begin with "LOC" (such as LOCKY) only return the key value which was found. For more information on the (cont.)
DB commands, you can refer to Appendix B of this chapter, and the "Database Administration" chapter.
**
NOTE:
**
The data is displayed in character/hex (over/under) format. If you were using DBDITO to update the data, you could (cont.)
enter in either character or hexadecimal, or in a combination of the two. To enter data in hexadecimal, you must type a (cont.)
dot (.) in the character position and the desired hex code in the two rows below the dot. If the character row (top (cont.)
row) contains any character other than a dot, DBDITO will accept it as the desired character and will compute its (cont.)
hexadecimal value and display it below. If the character row contains a dot, DBDITO will compute the character value (cont.)
for the hexadecimal code and will display it in the character row above the hex code. If the character is not (cont.)
displayable on a 3270, DBDITO will display a dot in that position. Spaces are displayed as dots, (cont.)
also.
Type a dot in the character position if you want MAGEC to accept your input in hexadecimal below for that character. If (cont.)
the character position is any character other than a dot, MAGEC will accept the character, ignoring the hexadecimal (cont.)
value below it.
| ```
**
 DBDITO ___________________________ M A G E C DATABASE UTILITY
CMD LOCKY FILE VAD KEY VADK1 RTN CDE DBID ___
ELEMENTS VAD01_____________________________________________
START RECORD DISPLAY AT 0001
......................................................................
0000000000000000004444444444444444444444444444444444444444444444444444
0000000000000000000000000000000000000000000000000000000000000000000000
......................................................................
4444444444444444444444444444444444444444444444444444444444444444444444
0000000000000000000000000000000000000000000000000000000000000000000000
......................................................................
4444444444444444444444444444444444444444444444444444444444444444444444
0000000000000000000000000000000000000000000000000000000000000000000000
......................................................................
4444444444444444444444444444444444444444444444444444444444444444444444
0000000000000000000000000000000000000000000000000000000000000000000000
Press PF1 for Instructions
```**
**
NOTE:
**
The DBDITO display shows character values on the first line and hex values velow in orver-under format. The hex values (cont.)
are shown in EBCDIC or ASCII, based upon which environment you are running in. This example shows the EBCDIC display (cont.)
(HEX '40' for spaces).
FIgure 18 -- DBDITO Screen
If there are no records on the file you will receive a message saying NO RECORD FOUND on the bottom of the screen. This (cont.)
is a normal circumstance if you access the file immediately following its initializtion (using MAGINIT). In mainframe (cont.)
environments the MAGINIT program can be modified to either leave one record (the initialization record) on the file, or (cont.)
to delete it. It is often convenient in a CICS environement to leave the initialization record on the file -- it can be (cont.)
deleted using any CICS program or using DBDITO.
The screen will be displayed showing the found key value from the file in the data area. It is shown in character/hex, (cont.)
over/under format. The figure shown below shows how the display might look. It shows the hexadecimal values in EBCDIC, (cont.)
as they might appear on a mainframe. On a PC you would see a similar screen with ASCII. DBDITO displays the character (cont.)
value on the top line of each row of data, unless the character is non-displayable. Then it displays a dot (.) in that (cont.)
position.
If you wanted to update the data you could key in the changes in character format on the top line, or in hex in the (cont.)
lines below. If you wish to update by keying in hex you must be sure that the character (top) line contains a dot in (cont.)
the positions where you want your hex entry to be taken. This allows you to key both character and hex into one (cont.)
screenful of data, saving keystrokes and translation difficulties. On the bottom of the screen DBDITO displays the (cont.)
access method and error messages (translation of the return code) if appropriate.
The DB command to update a record is "UPDAT". A list of the DB commands may be found in Appendix B of this tutorial. (cont.)
For additional detailed information on the DB commands (also referred to as MAGECIO commands) please refer to the (cont.)
"Database Administration" chapter .
| ```
**     DO THIS:
See below.
   
```**
| ```
**
 DBDITO ___________________________ M A G E C DATABASE UTILITY
CMD LOCKY FILE VAD KEY VADK1 RTN CDE DBID ___
ELEMENTS VAD01
START RECORD DISPLAY AT 0001
XXXXXXXXXXXXXXXXXX....................................................
EEEEEEEEEEEEEEEEEE4444444444444444444444444444444444444444444444444444
77777777777777777700000000000000000000000000000000000000000000000000000
......................................................................
4444444444444444444444444444444444444444444444444444444444444444444444
0000000000000000000000000000000000000000000000000000000000000000000000
......................................................................
4444444444444444444444444444444444444444444444444444444444444444444444
0000000000000000000000000000000000000000000000000000000000000000000000
......................................................................
4444444444444444444444444444444444444444444444444444444444444444444444
0000000000000000000000000000000000000000000000000000000000000000000000
PF23:+280, PF22:-280, PF8:REDNX, PF7:REDPR
Access Method is MAGEC/DB
```**
**
NOTE:
**
This display presumes that your file was intialized with one record having a key of 'XXXXXXXXXXXXXXXXXX'. That may, or (cont.)
may not, be true for your installation since different options are available for initializing files.
Figure 19 -- DBDITO Screen
#
Business Rules
##
Cross-Field / Cross-File Edits
MAGEC provides the means for you to define extended, complex editing of data which can involve multiple data items and (cont.)
even cross-file validations. This editing can be defined by the person defining the data to the dictionary and will (cont.)
then be automatically inserted into any applications generated which update the data. These edits are called "Business (cont.)
Rules".
Business Rules are routines coded in Cobol which may be as large as 15,000 lines of Procedure Division code plus 15,000 (cont.)
lines of Data Division code. They are associated with an Element. Whenever that Element is added or updated the (cont.)
Business Rule logic is invoked. While the primary purpose for coding Business Rules is to validate data before it is (cont.)
placed onto the files, there is actually no limitation to what you can do in this logic. It is perfectly legal to do (cont.)
I/O, even other updates or adds, in the Business Rule logic. Some examples of what you might do in the Business Rule (cont.)
logic are:
1)
 
Verify that if Employee type is "salaried" and Location is Texas then Salary must be not less than $20,000 and not greater than $80,000.
 
2)
 
Concatenate the first three digits of Zip Code with the two-character State code and use the result as a key to access (cont.)
the Zip-State cross-reference file to ensure that this is a valid Zip Code within this State.
 
3)
 
If processing an "add" function, access the Control File to obtain the next available mod-11 Employee Number and plug it into the key for this new record to be added.
 
4)
 
Verify that if the salary of the employee being updated is greater than $60,000, then the authorization level of the (cont.)
operator making this change/add must be greater than a certain predefined authorization level.
These are a few examples of the power of Business Rules. Even the limit of 15,000 lines is not really a limit,
since you can include -MAGECINC control cards, each of which could expand to 15,000 more lines. The most common use for (cont.)
-MAGECINC's in Business Rules will be in the Data Division to include Element copybooks for I/O's done in the Procedure (cont.)
Division code for the Business Rule.
SInce this coding might very well be inserted into several applications, and since those applications might very well (cont.)
include -MAGECINC's for some of the same copybooks as are being called for in the Business Rule's Data Division coding, (cont.)
we recommend that you take advantage of the facility in MAGEC to specify that your -MAGECINC is to be expanded only if (cont.)
it is not elsewhere included in this same program. This avoids the nuisance of duplicate definitions and resulting need (cont.)
to qualify all references, and wasted space.
| ```
**     DO THIS:
Key the command: RULADD VAD01/RULWORK, press ENTER
   
```**
| ```
**
 RULADD  VAD01/RULWORK
SEARCH ARG: ..................................................................
Password: M A G E C .......  page
New Password:  ELEMENT DATA RULES  ........
  TAB Option: ON
....+..;10.;..+;..20....+...30....+...40...;+...50....+...60....+...70..
  05  RUL-xxx01-FLD1  PIC X.  01
  05  RUL-xxx01-FLD2  PIC 9.  02
  03
  04
  05
  06
  07
  08
  09
  10
  11
  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 PF4 for Menu of Named Proformas
```**
Figure 20 -- Business Rule Add Screen
The way you tell MAGEC to do that is via the -IFUNIQUE control card immediately preceeding your -MAGECINC, as shown below:
-IFUNIQUE
**-MAGECINC member/modifier
 
This will cause the member named "member/modifier" to be included into the program only if it is not already included. (cont.)
This works even if the other -MAGECINC for that member appears after this one in the physical program listing. This (cont.)
facility is not restricted only to Business Rules, it may be used anywhere in any MAGEC application; however, we (cont.)
believe that you will avoid much trouble if you establish a standard of using the -IFUNIQUE in front of every Data (cont.)
Division -MAGECINC in your Business Rules.
You are adding the Data Division code for your Business Rule. The rule we will be adding will verify that the Employee (cont.)
Number being added to the VAD Data Class is a valid number defined on the SIF Data Class. This means that the SIF Data (cont.)
Class is the "master file" and that you may not have vacation data for an employee who is not defined on the SIF (cont.)
file.
Business Rules can consist of Data Division and/or Procedure Division coding. The modifier "RULWORK" signifies that (cont.)
this code is to be inserted into the Data Division; it will be the definitions of work areas needed by the procedural (cont.)
logic (which you will be adding next). You are specifying, in this example, that you wish the SIF01-C copybook included (cont.)
unless it has been included elsewhere in the program.
To add a Business Rule for our VAD01 Element:
| ```
     DO THIS:
Key the two lines of code shown below, press ENTER.
   
```**
The code you have specified here will be inserted into the Data Division, in the TWA area of any MMP's generated to (cont.)
update Element VAD01. Since this is in the Linkage Section of your programs *you must not use the Cobol VALUE** (cont.)
clause*. You must also remember that this code will be inserted immediately behind a Cobol data item which is at level (cont.)
03; therefore, your work fields should be Cobol level 04 and below.

next: data07.md.txt