Identifying formatters

As with the data elements, you may need to create new formatters. In this step, you look at the process flows and the data elements, and determine whether any new formatters are required for sending data to the backend system. Also in this step, you create a set of record formatters for exchanging information between the client and the server.

For the Java(TM) Client Sample Application, in addition to the new data element you defined above, you will also need to define a new format or decorator to send data to the backend system. When it is creating the send format for an operation that sends a string (HostBuff) to the backend system buffer (the buffer from which the backend system will read), the format must append the field value to the field identifier to create the output string that is placed in the backend system buffer. Since no existing format does this, you can do the following:

You can use only the first option when all the data fields that belong to the data entities to be formatted are of the same type. For instance, if all the data fields that had to be formatted into the backend system buffer were strings, you could build a new class derived from StringFormat, and override the format method to add the field identifier before the field value.

This approach is not appropriate for the Java Client Sample Application, because all the data entities to be sent to the backend system, including those of the HostField type, have elements of different types. For example, the Date data field contains a Date object. You will need to create both a new data format (to format the strings) and a new decorator (to format the other types). The Java Client Sample Application uses the following format and decorator when formatting the data to be sent to the backend system:

These two new classes extend the toolkit, and you will see how to implement them later, in Customizing the toolkit.

Next, you must create the list of record formatters required for exchanging information between the client and the server. As mentioned in the step where you identified process flows, each client operation must define a format to transfer data to the server operation, and each server operation must define a format to transfer data back to the client operation. These formatters use Req and Rep to designate whether the format for the client/server operation is a request or a reply.

The following records formatters are used in the Java Client Sample Application (the names used in the implementation are shown in parentheses):

On the server side, you must define, for each operation, the specific record formatters for accessing the backend system.

The following are used in the Java Client Sample Application (they are identified by adding Send (send) or Rec (receive) to the backend system communication formatters):

You must also define a format for writing to the Electronic Journal before sending a transaction to the backend system, and another for writing to the Electronic Journal after receiving a reply from the backend system. The Java Client Sample Application uses the following Hashtable formatters that come with the toolkit:

For all formatters, you must create a detailed definition of the complete record that refers to each data element and its specific field format, delimiters, and decorators. The following is an example:

Customer Search Send (customerSearchSendFmt)
    <fmtDef id="customerSearchSendFmt">
        <record>
            <constant value="Tx01"/>
            <fHostString dataName="CustomerId"> <delim
delimChar="#"/>
        </record>
    </fmtDef>

This is how the definition of the Send format for the Customer Search operation looks in the generated XML file.

The following table shows the complete list of data fields and formatters required for the Java Client Sample Application:

Table 1. Required data fields and formatters
Data fields Data type in the client Data type in the server Format C/S req/rep Format host send/rec Format journal
Date DataField HostField fDate fDate+fHostDecor
AccountNumber DataField HostField fString fHostString
AccountBalance DataField DataField fString fString
MaxAmount DataField DataField fFloat fFloat
CustomerId DataField HostField fString fHostString
CustomerName DataField DataField fString fString
TrxId Constant Constant Constant Constant
Amount DataField HostField fFloat fFloat+fHostDecor
BranchId DataField HostField fString B
AccountList iColl iColl iColl iColl
Account kColl kColl kColl kColl
AccountNumber DataField DataField fString fString
Type DataField DataField fString fString
Name DataField DataField fString fString
Balance DataField DataField fString fString
accountStatement Details iColl iColl iColl iColl
OpnDate DataField DataField fString fString
OpnDescription DataField DataField fString fString
OpnAmount DataField DataField fString fString
OpnBalance DataField DataField fString fString
TID DataField DataField fString fObject
UserId DataField DataField fString fObject
TrxReplyCode DataField DataField fString fString fObject
TrxErrorMessage DataField DataField fString fString fObject
HostBuff DataField DataField fString fObject