Examples of applyUpdates using a transaction action

The example shows how a PaymentUpdateBean can be used to apply a single update to a transaction in the FTM database that changes the transaction amount to $100, expressed in pennies as 10000. It uses Java™ classes in appbr.jar to send the request and retrieve a transactional response. There is a timeout of 5 seconds (5000 milliseconds) that is used when waiting for the response. Only the first few lines show how to build the transaction update bean itself. The rest of the lines show how to send the message and receive the response.
// build the transaction update bean
PaymentId paymentId = ???; // supply your target payment ID here
PresentmentId presentmentId = ???; // supply your batch (ICL) ID here
PaymentUpdateBean update = new PaymentUpdateBean ( paymentId );
update.setAmount ( 10000 );

// create the service request message instance...
AppBridgeServiceRequest abreq = new ApplicationBridgeServiceRequest ( );
abreq.setSourceId ( "MY APPLY UPDATES EXAMPLE" );
abreq.setDestinationId ( "TRANSACTION SERVER" );
abreq.setResponseRequired ( true );
abreq.setPayloadBean ( update );
abreq.setUnitOfWork ( presentmentId.getIdentifier ( ) );
abreq.setMsgType ( "applyUpdates" );

// send the message...
TransportControl xctl = new TransportControl ( getConfig ( ) );
xctl.setTransactional ( true );
xctl.initMessage ( abreq );
String msgid = xctl.sendMessage ( );
if (msgid == null) 
   System.err.println ( "Message ID not generated" );
else
{
   // commit the JMS send and garner the response...
   xctl.commit ( );
   TextMessage resp = (TextMessage) xctl.readSync ( msgid, 5000 );
   if (resp == null) 
      System.err.println ( "Failure reading response" );
   else
   {
      AppBridgeServiceResponse abresp = (AppBridgeServiceResponse)
      TransportControl.toABMessageObject ( resp, xctl );
      if (abresp.getErrorCode() == 0)
         System.out.println ( "Response received - successful" );
      else 
         System.err.println ( "Error receiving response, RC =" +
                             abresp.getErrorCode() + ", MSG =\'" +
                             abresp.getErrorMessage() + "\'" );
   }
}
The following example shows how to build the transaction update bean. It shows how to apply a single update that modifies the amount, changes the routing transit field, sets the pocket, and resets the suspect flag.
// build the transaction update bean
PaymentUpdateBean update = new PaymentUpdateBean ( 102938 );
update.setAmount ( 55555 );
update.setTransitRouting ( "1111-1111" );
update.setPocket ( (short) 14 );
update.setSuspectFlag ( false );
The following example illustrates using the modify transactions bean to apply updates to multiple transactions.
// build the modify transactions bean instance...
ModifyPaymentsBean modpay = new ModifyPaymentsBean ( );

// build the first transaction update bean
PaymentUpdateBean update = new PaymentUpdateBean ( 111111 );
update.setAmount ( 12345 );
modpay.addAction ( update );

// build the second transaction update bean
PaymentUpdateBean update = new PaymentUpdateBean ( 222222 );
update.setPocket ( (short) 21 );
modpay.addAction ( update );

// build the third transaction update bean
PaymentUpdateBean update = new PaymentUpdateBean ( 333333 );
update.setSuspectFlag ( false );
update.setSuspectReviewId ( "JANE DOE" );
modpay.addAction ( update );

// apply the action to the message payload
abreq.setPayloadBean ( modpay );

The payload can reference a ModifyPaymentsBean instance rather than the PaymentUpdateBean instances shown in other examples. The payload can contain any implementation of the PaymentAction interface.

The following example sets a user data field named MEMO. A column in the payment user table called MEMO must exist for this to work. In the example, the MEMO column is defined as a VARCHAR(32) value. A string value is used for setting the column.
// build the transaction update bean
PaymentUpdateBean update = new PaymentUpdateBean ( 123456 );
update.setUserData ( "MEMO", "Subscription renewal" );

Do not try to use the setUserData method to update columns in the payment or item tables. It can only be used in payment user tables.

The following example shows how to move a transaction in the balancing order. This example moves the transaction with an ID of 777777 between the transactions at balance orders 490 and 491. The application sets and maintains the appropriate balancing of numeric values for all transactions in the FTM database.
// build the transaction update bean
PaymentUpdateBean update = new PaymentUpdateBean ( 777777 );
update.setBalanceOrder ( 490.5 );