# MATHAPP Tutorial & Reference

This appendix provides you with a tutorial that uses MATHAPP to form a simplified funds transfer process. MATHAPP is a simple mathematics application package that is written as ATMI services and doesn't require that an external database be installed. This appendix also provides you with a MATHAPP reference.

## Creating a Simplified Funds Transfer Process Flow: a Tutorial

The following is an example of how a process flow is created. It follows from the example presented in Chapter 1, "Big Picture Overview," and is carried through the remainder of this user's guide. This example is simplified to allow the use of MATHSERV, a simple math application that is provided with the eLink Business Process Option software. A working process flow can be created according to these instructions using only the installed software.

### Logging On

In this series of steps, you log on to the Process Design Assistant.

1. Start the eLink Process Design Assistant. For instructions, see Starting the Process Design Assistant in Chapter 3, "Specifying Business Service Contracts."

The BEA eLink Business Process Option opening window appears.

> Figure B-1 Process Design Assistant Opening Window

2. Log on to the Process Design Assistant. For instructions, see Logging On to the Process Design Assistant in Chapter 3, "Specifying Business Service Contracts." Remember to set your logon option defaults according to these instructions before logging on for the first time.

   The Process Design Assistant Business Interface Window appears.

   > Figure B-2 Business Interface Window

### Loading an Interface & Adding an Operation

In this series of steps, you set up the interface to the applications connected to eLink. The interface consists of a number of contracts. Contracts are agreements on inputs and expected outputs to and from eLink and the applications connected to eLink. They are also referred to as operations. You also add an operation that will become the template for your process flow.

1. Import mathserv.fml (using the Import button). This file contains the FML field definitions needed for MATHSERV. You must import an FML file for particular FML field definitions, but you should do so only once to avoid overwriting subsequent changes to the operation parameters (elements). For instructions, see Importing FML Files in Chapter 3, "Specifying Business Service Contracts."

If mathserv.fml does not appear on the list of Importable Files in the Import FML window, see the README file for configuration and installation of the MATHSERV application. This README file can be found on your server in $TUXDIR/apps/mathapp.

> Figure B-3 Import FML Window

The imported FML fields will appear as elements in the repository tree after refreshing the screen. These elements are now available for use in creating operations and interfaces. Operations & interfaces can be created interactively. However in this tutorial, we will load the interface used by this tutorial.

2. Load SIMPLOPS.IFCE, the SimpleOps interface, using the Load button. You will find SIMPLOPS.IFCE in the Sample directory which is in the directory where you installed the Process Design Assistant client. For instructions, see Loading Externally Described Interfaces in Chapter 3, "Specifying Business Service Contracts." For an explanation of SIMPLOPS.IFCE, how it works, and its implications on the rest of the eLink architecture, see Appendix A, "Interface File (*.IFCE) Reference."

   The Interface Load Results dialog box appears and lists the actions taken to load the SIMPLOPS Interface.

   Note: Because loading an interface may reset certain operational parameters, it should only be done once for a particular interface.

   As an alternative, you could interactively create an interface with the SUBTRACT_INTEGER and ADD_INTEGER operations in it. For instructions in interactively creating an interface, see the Usage section of Chapter 3, "Specifying Business Service Contracts."

3. Wait until load is completed, then click OK.

   The SIMPLOPS interface will appear in the Contract Repository tree after refreshing it (File...Refresh).

4. Add an operation according to the instructions in Adding Operations in Chapter 3, "Specifying Business Service Contracts." Call it SimpleTeller. Be sure to enter an ATMI name of SimpleTeller. Include the INTEGER_OPERAND and INTEGER_RESULTS elements in it. Modify the SimpleTeller parameter INTEGER_RESULT by changing its Passing Mode to "out." For instructions in modifying elements, see Modifying Parameters in Chapter 3, "Specifying Business Service Contracts."

5. Make sure that the Occurrence attribute of INTEGER_OPERAND is set to "3" and the Occurrence attribute of INTEGER_RESULTS is set to "2." If these attributes are not set to these values, change them as needed. You cannot change the Occurrence attribute by modifying it as a parameter. You must go to the list of elements and modify them as elements. For instructions in modifying these elements, see Modifying Elements in Chapter 3, "Specifying Business Service Contracts."

### Exporting & Testing Operations

The interface and operation that you're creating, exporting, and testing will become the palette and template for your process flow. The process flow directs and drives your entire eLink system.

1. Export the operations within the SIMPLOPS interface if they are not already exported. See the Export Instructions in Chapter 3, "Specifying Business Service Contracts," for instructions.

2. Export the SimpleTeller operation. See the Export Instructions in Chapter 3, "Specifying Business Service Contracts," for instructions.

3. Test the SubtractInteger and AddInteger operations using the test button. For instructions, see Test Operation Instructions in Chapter 3, "Specifying Business Service Contracts."

### Generating Palette & Template

In this series of steps, you will generate the palette and template that will be used to form your process flow. You must use only the generated palette and template to form your process flow because only they have the necessary components to form a proper eLink process flow.

1. Select the newly created SIMPLOPS interface. then click on the Palette button. The Palette Generation Results dialog appears. The log file displays in the dialog indicating the actions performed to generate the Palette from the selected interface. For instructions, see Generating a Palette in Chapter 4, "Designing Business Processes."

The Palette Generation Results window appears displaying a list of generation actions.

2. Wait until the log is done displaying, then select the OK button.

3. Select operation SimpleTeller, then the Template button.

   The Template Generation Results window appears displaying a list of generation actions.

4. Wait until the log is done displaying, then select the OK button.

### Moving to the Business Process Window

The Business Process Window is the part of the eLink Business Process Option where you form your process flow. Be sure to use these instructions to move to the Business Process Window. Using these instructions ensures the correct configuration of your Business Process Window.

1. Click on the Edit Flow button to start the Business Process Window.

A login dialog appears.

2. Click on the Login button to confirm your login to the Business Process database. There is no need to change any of the entries in the login dialog.

   The Business Process Window appears.

### Setting Up Your Process Flow

The Business Process Window allows you to form process flows from generated palettes and templates.

Note: The only process flows that will work in eLink are those that are formed from generated palettes and templates.

The first step in forming your process flows is to copy the tasks, which will be the elements of your process flow, from your palettes to your templates.

1. Click on the Open Process button.

The Process Query dialog appears.

2. Select All eLink Palettes from the left window, then the Search button.

   A list of available palettes appears.

3. Select the newly created Palette: SIMPLOPS, then the OK button.

   Palette: SIMPLOPS appears in a Design Pad window.

4. Click on Open Process button.

   The Process Query dialog appears.

5. Select All eLink Templates, then the Search button.

   Available templates display in the right window.

6. Select the SimpleTeller template generated in the Process Design Assistant, then the OK button.

   The SimpleTeller template window appears in a Design Pad window. The task pane of the template should be empty the first time you use it.

7. Select the SubtractInteger icon from the Palette window, then choose Edit —> Copy.

8. Activate the SimpleTeller Template window by clicking in it, then choose Edit —> Paste from the menu bar.

   This places the SubtractInteger object on the SimpleTeller Template's design pad. As an alternative to Steps 23 and 24, you can drag the SubtractInteger icon from the palette's design pad to the template's design pad. For instructions, see Copying tasks between Design Pad windows in Chapter 4, "Designing Business Processes."

9. Repeat steps 23 and 24 twice but use the AddInteger icon instead.

   This places two AddInteger tasks on the SimpleTeller template.

### Modifying Tasks and Processes

Tasks are generated from operations. Operations become tasks during palette generation when they are given default parameter assignments. In the following steps, the tasks are improved by the addition of perform conditions, dependencies, and the modification of parameter assignments.

1. Add a dependency from the SubtractInteger task to one of the AddInteger tasks. For instructions, see Adding dependencies in Chapter 4, "Designing Business Processes."

2. Add another dependency from the SubtractInteger task to the other AddInteger task.

3. Modify the root level INTEGER_OPERAND attribute value. Its attribute value should be specified as follows (For more information on modifying attribute values, see Instructions for Setting an Attribute Value or Modifying an Existing Value in Chapter 4, "Designing Business Processes."):

   $JOB.BAL_ACT_1=INTEGER_OPERAND[0];
   $JOB.TR_AMOUNT=INTEGER_OPERAND[1];
   $JOB.BAL_ACT_2=INTEGER_OPERAND[2]

   > Figure B-4 Modifying Root Level INTEGER_OPERAND

4. Modify the root level INTEGER_RESULT attribute value. Its attribute value should be specified as follows:

   INTEGER_RESULT[0]=$JOB.BAL_ACT_1;
   INTEGER_RESULT[1]=$JOB.BAL_ACT_2

   > Figure B-5 Modifying Root Level INTEGER_RESULT

5. Modify the SubtractInteger INTEGER_OPERAND attribute value as follows:

   INTEGER_OPERAND[0]=$JOB.BAL_ACT_1;
   INTEGER_OPERAND[1]=$JOB.TR_AMOUNT

6. Modify the SubtractInteger INTEGER_RESULT attribute value as follows:

   $JOB.BAL_ACT_1=INTEGER_RESULT[0]

7. Modify the first occurance of the AddInteger INTEGER_OPERAND attribute value as follows:

   INTEGER_OPERAND[0]=$JOB.BAL_ACT_2;
   INTEGER_OPERAND[1]=$JOB.TR_AMOUNT

8. Modify the first occurance of the AddInteger INTEGER_RESULT attribute value as follows:

   $JOB.BAL_ACT_2=INTEGER_RESULT[0]

9. Modify the second occurance of the AddInteger INTEGER_OPERAND attribute value as follows:

   INTEGER_OPERAND[0]=$JOB.BAL_ACT_1;
   INTEGER_OPERAND[1]=$JOB.TR_AMOUNT

10. Modify the second occurance of the AddInteger INTEGER_RESULT attribute value as follows:

    $JOB.BAL_ACT_1=INTEGER_RESULT[0]

11. Add a new attribute BAL_ACT_1 with data type Integer to the process level of the SimpleTeller process. For instructions, see Instructions for Adding an Attribute to be Used in a Perform Condition in Chapter 4, "Designing Business Processes."

12. Add a perform condition to the first occurance of your AddInteger task, so the integers are added only if the result of SubtractInteger is greater than or equal to zero. The effect of this perform condition is that the transfer amount will only be added to the second account balance if the first account is not overdrawn by the SubtractInteger task. For instructions on adding a PerformCondition, see Adding PerformConditions to tasks in Chapter 5, "Making eLink Processes Work." Here is the syntax of the Perform Condition to be added:

    $JOB.BAL_ACT_1>=0

13. Add a perform condition to the other AddInteger tasks, so the integers are added only if the result of SubtractInteger is less than zero. The effect of this perform condition is that the transfer amount will be added back into the first account balance (hence, reversing the withdrawal) if the first account is overdrawn by the SubtractInteger (withdrawal) task. For instructions on adding a PerformCondition, see Adding PerformConditions to tasks in Chapter 5, "Making eLink Processes Work." Here is the syntax of the Perform Condition to be added:

    $JOB.BAL_ACT_1<0

### Adding Your New Process to the Configuration

This series of steps adds your new process to your eLink Business Process Option configuration, so it can be run by the process runner or starter processes. To do this you must edit your eLink_BPO.cfg by adding the process name, which is also called a service name, to a SERVICE_LIST setting.

1. Logon to your Business Process Option server as the Business Process Option administrator. Your server was installed so that "icadmin" is both your user name and password. Your password has probably been changed since installation, so check with your System Administrator to determine the administrator user name and password.

2. Change directories to the directory where the eLink Business Process Option is installed. The default path for this directory is

   /work1/ic/appdir

3. Edit the file eLink_BPO.cfg by adding your new process name (in this case, it's SimpleTeller) to the SERVICE_LIST setting under either the [Server=eProcRunner] setting group (suggested) or the [Server=eProcStarter] setting group.

4. Save eLink_BPO.cfg and exit your UNIX text editor.

5. Shutdown the server upon which you are changing settings with the command

   tmshutdown -s <server name>

6. Start up the server upon which you changed settings with the command

   tmboot -s <server name>

### Testing Your Process Flow

Your process flow is tested in the same manner as testing any operation in the Business Interface Window. However, the connected applications, the eLink Platform, the Data Integration Option, and the Business Process Option can all come into play when testing a process flow.

1. Exit from the Business Process Window, then select the SimpleTeller Operation.

2. Click on the Test button.

3. Enter data in the data fields, then click OK.

### Assigning Parameters to Implement Process Flows

This section is provided to explain the mechanics of the funds transfer tutorial from the previous section in more detail as the more high-level conceptual information is presented here.

#### Root Level Input & Output

Figure B-6 shows inputs and outputs to and from the SimpleTeller process flow. This process flow implements a simple funds transfer. It is considered a simplified transfer because only whole dollar amounts may be transferred (parameters are of integer type) and because addition and subtraction tasks are used in place of actual deposit and withdrawal business services.

> Figure B-6 SimpleTeller Process Flow Inputs & Outputs

We begin by looking at the top level of the process definition. This level of the process is also known as the Root Task. The process must "know" the input and output information presented in Figure B-6 to execute the process correctly. The input information coming into the process from the caller (INTEGER_OPERAND[*]) must be assigned to job-level attributes, and the output job-level attributes must be assigned to the output going out of the process as a reply to the caller. To do this (for the purposes of the funds transfer example), the following must be assigned as the value of the root-level INTEGER_OPERAND attribute:

$JOB.BAL_ACT_1=INTEGER_OPERAND[0];
$JOB.TR_AMOUNT=INTEGER_OPERAND[1];
$JOB.BAL_ACT_2=INTEGER_OPERAND[2]

and, the following must be assigned as the value of the root-level INTEGER_RESULT attribute:

INTEGER_RESULT[0]=$JOB.BAL_ACT_1;
INTEGER_RESULT[1]=$JOB.BAL_ACT_2

Assigning these values to the root-level parameter attributes defines the inputs and outputs to and from the process at the process (root) level.

The job-level attribute names BAL_ACT_1, TR_AMOUNT, and BAL_ACT_2 were arbitrarily created and assigned and each of them can be any string of alpha-numeric (UPPERCASE) characters. It is suggested that they describe the function they are to perform. For example, BAL_ACT_1 is short for Balance of Account 1.

Figure B-7 shows the Root Task properties screen with parameter assignments made as specified above.

> Figure B-7 INTEGER_RESULT Root-Level Parameter Assignments

#### Task Level Input & Output (SubtractInteger)

Figure B-8 shows inputs and outputs to and from the SubtractInteger task. This task subtacts one integer from another. It is used to simulate a withdrawal of funds from a bank account.

> Figure B-8 SubtractInteger Task Inputs & Outputs

SubtractInteger is a sub-task of the root task, so the job-level attributes created in the Root Task can be used. These are the expressions that should be entered as the value for the SubtractInteger INTEGER_OPERAND attribute:

INTEGER_OPERAND[0]=$JOB.BAL_ACT_1;
INTEGER_OPERAND[1]=$JOB.TR_AMOUNT

and the expression entered as the value for the SubtractInteger INTEGER_RESULT attribute is:

$JOB.BAL_ACT_1=INTEGER_RESULT[0]

The actual operation performed at the application level is:

INTEGER_RESULT[0]=INTEGER_OPERAND[0]-INTEGER_OPERAND[1]

If you use substitution, the equivalent expression is:

$JOB.BAL_ACT_1=$JOB.BAL_ACT_1-$JOB.TR_AMOUNT

So, looking at this equation, you can see that a new balance is obtained for Account 1 by subtracting the transfer amount from Account 1's starting balance. This is the action that occurs in the withdrawal portion of a funds transfer. Notice that the same job-level attribute is used for the starting and ending account balance.

#### Task Level Input & Output (AddInteger)

Figure B-9 shows inputs and outputs to and from the AddInteger task. This task adds one integer to another. It is used to simulate a deposit of funds to a bank account.

> Figure B-9 AddInteger Task Inputs & Outputs

AddInteger is a sub-task of the root task, so the job-level attributes created in the Root Task can be used. These are the expressions that should be entered as the value for the AddInteger INTEGER_OPERAND attribute:

INTEGER_OPERAND[0]=$JOB.BAL_ACT_2;
INTEGER_OPERAND[1]=$JOB.TR_AMOUNT

and the expression entered as the value for the SubtractInteger INTEGER_RESULT attribute is:

$JOB.BAL_ACT_2=INTEGER_RESULT[0]

The actual operation performed at the application level is:

INTEGER_RESULT[0]=INTEGER_OPERAND[0]+INTEGER_OPERAND[1]

If you use substitution, the equivalent expression is:

$JOB.BAL_ACT_2=$JOB.BAL_ACT_2+$JOB.TR_AMOUNT

So, looking at this equation, you can see that a new balance is obtained for Account 2 by adding the transfer amount to Account 2's starting balance. This is the action that occurs in the deposit portion of a funds transfer. Notice that the same job-level attribute is used for the starting and ending account balance.

## MATHAPP Service Reference

Table B-1 lists all of the MATHAPP services and provides a desription of the required inputs and outputs. These services can be included in operations, then in interfaces in the Business Interface Window. However, you must import mathserv.fml before doing so.

Table B-1 MATHAPP Service Name Parameters: Input and Output

Service Name | Input Type | FML Field Name | Occurrence | Input/ Output
AddInteger | long | INTEGER_ OPERAND | 0 | Input
| long | INTEGER_ OPERAND | 1 | Input
| long | INTEGER_ RESULT | 0 | Output
AddFloat | float | FLOAT_ OPERAND | 0 | Input
| float | FLOAT_ OPERAND | 1 | Input
| float | FLOAT_ RESULT | 0 | Output
SubtractInteger | long | INTEGER_ OPERAND | 0 | Input
| long | INTEGER_ OPERAND | 1 | Input
| long | INTEGER_ RESULT | 0 | Output
SubtractFloat | float | FLOAT_ OPERAND | 0 | Input
| float | FLOAT_ OPERAND | 1 | Input
SubtractFloat | float | FLOAT_ RESULT | 0 | Output
MultiplyInteger | long | INTEGER_ OPERAND | 0 | Input
| long | INTEGER_ OPERAND | 1 | Input
| long | INTEGER_ RESULT | 0 | Output
MultiplyFloat | float | FLOAT_ OPERAND | 0 | Input
| float | FLOAT_ OPERAND | 1 | Input
| float | FLOAT_ RESULT | 0 | Output
DivideInteger | long | INTEGER_ OPERAND | 0 | Input
| long | INTEGER_ OPERAND | 1 | Input
| long | INTEGER_ RESULT | 0 | Output
DivideFloat | float | FLOAT_ OPERAND | 0 | Input
| float | FLOAT_ OPERAND | 1 | Input
| float | FLOAT_ RESULT | 0 | Output
SquareInteger | long | INTEGER_ OPERAND | 0 | Input
| long | INTEGER_ RESULT | 0 | Output
SquareFloat | float | FLOAT_ OPERAND | 0 | Input
| float | FLOAT_ RESULT | 0 | Output
SumInteger | long | INTEGER_ OPERAND | 0-n | Input
| long | INTEGER_ RESULT | 0 | Output
SumFloat | float | FLOAT_ OPERAND | 0-n | Input
| float | FLOAT_ RESULT | 0 | Output
SRootInteger | long | INTEGER_ OPERAND | 0 | Input
| long | INTEGER_ RESULT | 0 | Output
SRootFloat | float | FLOAT_OPERAND | 0 | Input
| float | FLOAT_ RESULT | 0 | Output
TimeInterval | char * | DATE_TIME | 0 | Input
| long | INTERVAL | 0 | Output
CurrencyFmt | float | AMOUNT | 0 | Input
CurrencyFmt | char * | FORMAT_ MASK | 0 | Input
| char * | STRING_ AMOUNT | 0 | Output
Compound | float | CAPITAL | 0 | Input
| float | INTEREST_ RATE | 0 | Input
| long | TERM_ YEARS | 0 | Input
| float | COMPOUND_AMOUNT | 0-TERM_ YEARS | Output