Internal Value Object for Update
The internal value object for an update database operation contains a component that represents the where clause for the records to be updated and a component that represents the fields to be updated. The variable names updateWhereFields and updateFields for these components are important because the generated code assumes that the proper naming convention is used. The generated code should require minimal changes, if any.
This code sample shows the structure for the internal value object:
public class InternalUpdateAddressBookStaging extends ValueObject {
/**
* Internal VO representing the where clause for updating the
* F0101Z2 table.
*/
private InternalUpdateAddressBookStagingWhereFields
updateWhereFields = new InternalUpdateAddressBookStagingWhereFields();
/**
* Internal VO representing the fields to be updated in the F0101Z2
* table.
*/
private InternalUpdateAddressBookStagingFields updateFields = new
InternalUpdateAddressBookStagingFields();
/**
* Number of rows updated as returned by the database call.
*/
private long numberRowsUpdated = 0;
This code sample shows the generated code for the update database operation, with the updates that you are required to make in bold type:
private static E1MessageList UpdateF0101Z2(IContext context,
IConnection connection, InternalUpdateAddressBookStaging internalVO) {
//create return object
E1MessageList returnMessages = new E1MessageList();
//specify columns to update
BSSVDBField[] updateFields =
{new BSSVDBField("F0101Z2.ALPH"), // String - NameAlpha
new BSSVDBField("F0101Z2.DC"), // String - DescripCompressed
new BSSVDBField("F0101Z2.MCU") // String - CostCenter
};
//specify update values
Object[] updateValues =
{internalVO.getUpdateFields().getF0101Z2_ALPH(),
internalVO.getUpdateFields().getF0101Z2_DC(),
internalVO.getUpdateFields().getF0101Z2_MCU()
};
//specify condition records must meet to be updated
BSDBWhereField[] whereFields =
{new BSDBWhereField(null, new BSSVDBField("F0101Z2.EDUS"),
IDBService.EQUALS, internalVO.getUpdateWhereFields().getF0101Z2_EDUS()),
new BSDBWhereField(IDBService.AND, new BSSVDBField("F0101Z2.
EDBT"),
IDBService.EQUALS, internalVO.getUpdateWhereFields().getF0101Z2_EDBT()),
new BSDBWhereField(IDBService.AND, new BSSVDBField("F0101Z2.
EDTN"),
IDBService.EQUALS, internalVO.getUpdateWhereFields().getF0101Z2_EDTN()),
new BSDBWhereField(IDBService.AND, new BSSVDBField("F0101Z2.
EDLN"),
IDBService.EQUALS, internalVO.getUpdateWhereFields().
getF0101Z2_EDLN())};
BSSVDBWhereClauseBuilder whereClause =
new BSSVDBWhereClauseBuilder(context, whereFields);
try {
//get dbService from context
IDBService dbService = context.getDBService();
//execute db update operation
long numRecordsUpdated =
dbService.BSSVDBUpdate(context, connection, "F0101Z2",
IDBService.DB_TABLE, updateFields, updateValues, whereClause);
internalVO.setNumberRowsUpdated(numRecordsUpdated);
} catch (DBServiceException e) {
// take some action in response to the database exception
returnMessages.addMessage(new E1Message(context, "005FIS",
TABLE_NAME + E1Message.sLineSeparator+e.getMessage())); }
return returnMessages;
}
This class diagram shows the business service objects for UpdateAddressBookStaging: