Best Practices for Internal Value Object

When deciding which fields to include in the internal value object class, consider that all data fields that the application accepts and the function uses are valid fields.

If an internal business function call passes processing fields, you must determine whether these fields should be exposed in the internal value object class. An example of this type of processing field would be a field that is used to manipulate a cache. If a business service is called from another business service and a processing field is exposed and passed in from the calling business service, will the behavior be as expected? If not, that processing field should not be exposed in the internal value object class. Fields that should not be exposed in the internal value object class can be handled by creating another value object called InternalProcessing. The InternalProcessing value object can contain all unexposed processing fields as member variables. The InternalProcessing value object should not be part of the InternalValueObject class and should not be exposed from the business service method signature. The InternalProcessing value object can be passed in the business function method calls but is not passed in or out of the business service method.

This code sample shows an InternalProcessing value object:

/**
* InternalProcessing contains processing fields used for 
* ProcessPurchaseOrderAcknowledge
* but these will not be exposed fields.
*/
public class InternalProcessing extends ValueObject {
   /**
    * Action Flag
    * EnterpriseOne Key Field: false
    * EnterpriseOne Alias: ACFL
    * EnterpriseOne field length:  1
    * EnterpriseOne User Defined Code: 08/AC
    */
   private String cProcessHeaderDetailFlag = null;
  /**
    * Job Number
    * EnterpriseOne Key Field: false
    * EnterpriseOne Alias: JOBS
    * EnterpriseOne field length:  8
    * EnterpriseOne decimal places: 0
    * EnterpriseOne Next Number: 00/4
    */
   private MathNumeric mnF4311JobNumber = null;
   /**
    * Transaction ID
    * EnterpriseOne Key Field: false
    * EnterpriseOne Alias: TCID
    * EnterpriseOne field length:  15
    * EnterpriseOne decimal places: 0
    */
   private MathNumeric mnTransactionID = null;
   /**
    * Process ID
    * EnterpriseOne Key Field: false
    * EnterpriseOne Alias: PEID
    * EnterpriseOne field length:  15
    * EnterpriseOne decimal places: 0
    */
   private MathNumeric mnProcessID = null;
   /**
    * Job Number
    * EnterpriseOne Key Field: false
    * EnterpriseOne Alias: JOBS
    * EnterpriseOne field length:  8
    * EnterpriseOne decimal places: 0
    * EnterpriseOne Next Number: 00/4
    */
   private MathNumeric mnCacheJobNumber = null;
}

This code sample shows how to pass the InternalProcessing value object to business function methods:

     public static E1MessageList processPurchaseOrderAcknowledge
(IContext context,IConnection connection, InternalProcessPurchase
OrderAcknowledge internalVO){
       //Call start internal method, passing the context (which was 
       //passed from published business service).
       startInternalMethod(context, "processPurchaseOrderAcknowledge",
 internalVO);
       //Create new message list for business service processing.
       E1MessageList messages = new E1MessageList();
       InternalProcessing internalProcessingVO = new 
InternalProcessing();
       //TODO: call method (created by the wizard), which then 
       //executes Business Function or Database operation.
       messages = callPurchaseOrderAcknowledgeNotify(context, 
connection, internalVO,internalProcessingVO);
       //TODO:  add messages returned from E1 processing to business 
       //service message list.
       //Call finish internal method passing context.
       finishInternalMethod(context, "processPurchaseOrderAcknowledge
");
       //Call finish internal method passing context.
       return messages;
   }
   /**
    * Calls the PurchaseOrderAcknowledgeNotify(B4302190) business 
    * function which has the D4302190A data structure.
    * @param context conditionally provides the connection for the 
    * business function call and logging information
    * @param connection can either be an explicit connection or null.
    * If null the default connection is used.
    * @param TODO document input parameters
    * @return A list of messages if there were application errors, 
    * warnings,or informational messages. Returns null if there were 
    * no messages.
    */
   private static E1MessageList callPurchaseOrderAcknowledgeNotify
(IContext context, IConnection connection, InternalProcessPurchase
OrderAcknowledge internal VO, InternalProcessing internalProcessingVO) {
       BSFNParameters bsfnParams = new BSFNParameters();
       // map input parameters from input value object
       bsfnParams.setValue("cProcessHeaderDetailFlag", 
internalProcessingVO.
get CProcessHeaderDetailFlag());
       bsfnParams.setValue("mnF4311JobNumber", internalProcessingVO.
getMnF4311JobNumber());
       bsfnParams.setValue("mnTransactionID", internalProcessingVO.
getMnTransactionID());
       bsfnParams.setValue("mnProcessID", internalProcessingVO.get
MnProcessID());
       bsfnParams.setValue("mnCacheJobNumber", internalProcessingVO.
getMnCacheJobNumber());
       bsfnParams.setValue("cHeaderOrderStatusCode", internalVO.get
CHeaderOrderStatusCode());
       bsfnParams.setValue("mnOrderNumber", internalVO.getMnOrder
Number());
       bsfnParams.setValue("szOrderType", internalVO.
getSzOrderType());
       bsfnParams.setValue("szOrderCompany", internalVO.getSzOrder
Company());
       ....
       //get bsfnService from context
       IBSFNService bsfnService = context.getBSFNService();
       //execute business function
       bsfnService.execute(context, connection, "PurchaseOrder
AcknowledgeNotify",bsfnParams);
       //map output parameters to output value object
       internalProcessingVO.setCProcessHeaderDetailFlag(bsfnParams.
getValue("cProcessHeaderDetailFlag").toString());
       internalProcessingVO.setMnF4311JobNumber((MathNumeric)bsfn
Params.getValue("mnF4311JobNumber"));
       internalProcessingVO.setMnTransactionID((MathNumeric)bsfn
Params.getValue("mnTransactionID"));
       internalProcessingVO.setMnProcessID((MathNumeric)bsfnParams.
getValue("mn⇒ProcessID"));
       internalProcessingVO.setMnCacheJobNumber((MathNumeric)bsfn
Params.getValue("mnCacheJobNumber"));
       internalVO.setCHeaderOrderStatusCode(bsfnParams.
getValue("cHeaderOrderStatusCode").toString());
       internalVO.setMnOrderNumber((MathNumeric)bsfnParams.getValue
("mnOrderNumber"));
        ...
       //return any errors, warnings, or informational messages to the
       //caller
       return bsfnParams.getE1MessageList();
   }