/**
   * Calls the BE_ProcessWorkflowMessage(B5602000) business function which has the D5602000F
   * datastructure.
   *
   * @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 BE_ProcessWorkflowMessage(
      IContext context, IConnection connection, BE_ProcessWorkflowMessage_D5602000F internalVO) {
    BSFNParameters bsfnParams = new BSFNParameters();

    // map input parameters from input value object
    bsfnParams.setValue("mnGroupId", internalVO.getMnGroupId());
    bsfnParams.setValue("cWriteXmlToFile", internalVO.getCWriteXmlToFile());

    try {
      // get bsfnService from context
      IBSFNService bsfnService = context.getBSFNService();

      // execute business function
      bsfnService.execute(context, connection, "BE_ProcessWorkflowMessage", bsfnParams);
    } catch (BSFNServiceInvalidArgException invalidArgEx) {
      // Create error message for Invalid Argument exception and return it in ErrorList
      E1MessageList returnMessages = new E1MessageList();
      returnMessages.addMessage(new E1Message(context, "018FIS", invalidArgEx.getMessage()));
      return returnMessages;
    } catch (BSFNServiceSystemException systemEx) {
      // Create error message for System exception and return it in ErrorList
      E1MessageList returnMessages = new E1MessageList();
      returnMessages.addMessage(new E1Message(context, "019FIS", systemEx.getMessage()));
      return returnMessages;
    }

    // map output parameters to output value object
    internalVO.setMnGroupId((MathNumeric) bsfnParams.getValue("mnGroupId"));
    internalVO.setCWriteXmlToFile(bsfnParams.getValue("cWriteXmlToFile").toString());
    internalVO.setCErrorFlag(bsfnParams.getValue("cErrorFlag").toString());
    internalVO.setSzErrorDescription((String) bsfnParams.getValue("szErrorDescription"));

    // return any errors, warnings, or informational messages to the caller
    return bsfnParams.getE1MessageList();
  }
  /**
   * Calls the GetNextUniqueKeyID(X00022) business function which has the DX00022A datastructure.
   *
   * @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 callGetNextUniqueKeyID(
      IContext context, IConnection connection, InternalGetUKI_DX00022A internalVO) {
    BSFNParameters bsfnParams = new BSFNParameters();

    // map input parameters from input value object
    bsfnParams.setValue("szObjectName", internalVO.getSzObjectName());

    try {
      // get bsfnService from context
      IBSFNService bsfnService = context.getBSFNService();

      // execute business function
      bsfnService.execute(context, connection, "GetNextUniqueKeyID", bsfnParams);
    } catch (BSFNServiceInvalidArgException invalidArgEx) {
      // Create error message for Invalid Argument exception and return it in ErrorList
      E1MessageList returnMessages = new E1MessageList();
      returnMessages.addMessage(new E1Message(context, "018FIS", invalidArgEx.getMessage()));
      return returnMessages;
    } catch (BSFNServiceSystemException systemEx) {
      // Create error message for System exception and return it in ErrorList
      E1MessageList returnMessages = new E1MessageList();
      returnMessages.addMessage(new E1Message(context, "019FIS", systemEx.getMessage()));
      return returnMessages;
    }

    // map output parameters to output value object
    internalVO.setMnUniqueKeyID((MathNumeric) bsfnParams.getValue("mnUniqueKeyID"));

    // return any errors, warnings, or informational messages to the caller
    return bsfnParams.getE1MessageList();
  }
  /**
   * Calls the BE_UpdateWorkflowHeader(N5602000) business function which has the D5602000I
   * datastructure.
   *
   * @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 BE_UpdateWorkflowHeader(
      IContext context, IConnection connection, BE_UpdateWorkflowHeader_D5602000I internalVO) {
    BSFNParameters bsfnParams = new BSFNParameters();

    // map input parameters from input value object
    bsfnParams.setValue("mnTaskId", internalVO.getMnTaskId());
    bsfnParams.setValue("szCompanyKeyOrderNo", internalVO.getSzCompanyKeyOrderNo());
    bsfnParams.setValue("mnDocumentOrderInvoiceE", internalVO.getMnDocumentOrderInvoiceE());
    bsfnParams.setValue("szOrderType", internalVO.getSzOrderType());
    bsfnParams.setValue("mnLineNumber", internalVO.getMnLineNumber());
    bsfnParams.setValue("szCostCenterHeader", internalVO.getSzCostCenterHeader());
    bsfnParams.setValue("mnIdentifierShortItem", internalVO.getMnIdentifierShortItem());
    bsfnParams.setValue("szAccountId", internalVO.getSzAccountId());
    bsfnParams.setValue("mnSequenceNumber1", internalVO.getMnSequenceNumber1());
    bsfnParams.setValue("szLineType", internalVO.getSzLineType());
    bsfnParams.setValue("szGenericKey", internalVO.getSzGenericKey());
    bsfnParams.setValue("mnCompositeKeyValues", internalVO.getMnCompositeKeyValues());
    bsfnParams.setValue("mnDocVoucherInvoiceE", internalVO.getMnDocVoucherInvoiceE());
    bsfnParams.setValue("szDocumentType", internalVO.getSzDocumentType());
    bsfnParams.setValue("szCompany", internalVO.getSzCompany());
    bsfnParams.setValue("szUserId", internalVO.getSzUserId());
    bsfnParams.setValue("jdDateUpdated", internalVO.getJdDateUpdated());
    bsfnParams.setValue("mnTimeLastUpdated", internalVO.getMnTimeLastUpdated());
    bsfnParams.setValue("szWorkStationId", internalVO.getSzWorkStationId());
    bsfnParams.setValue("szProgramId", internalVO.getSzProgramId());

    try {
      // get bsfnService from context
      IBSFNService bsfnService = context.getBSFNService();

      // execute business function
      bsfnService.execute(context, connection, "BE_UpdateWorkflowHeader", bsfnParams);
    } catch (BSFNServiceInvalidArgException invalidArgEx) {
      // Create error message for Invalid Argument exception and return it in ErrorList
      E1MessageList returnMessages = new E1MessageList();
      returnMessages.addMessage(new E1Message(context, "018FIS", invalidArgEx.getMessage()));
      return returnMessages;
    } catch (BSFNServiceSystemException systemEx) {
      // Create error message for System exception and return it in ErrorList
      E1MessageList returnMessages = new E1MessageList();
      returnMessages.addMessage(new E1Message(context, "019FIS", systemEx.getMessage()));
      return returnMessages;
    }

    // map output parameters to output value object
    internalVO.setCErrorCode(bsfnParams.getValue("cErrorCode").toString());
    internalVO.setSzErrorDescription((String) bsfnParams.getValue("szErrorDescription"));

    // return any errors, warnings, or informational messages to the caller
    return bsfnParams.getE1MessageList();
  }
  private static E1MessageList BE_FormatWorkFlowMessage(
      IContext context, IConnection connection, BE_FormatWorkFlowMessage_D5602000E internalVO) {
    BSFNParameters bsfnParams = new BSFNParameters();

    // map input parameters from input value object

    bsfnParams.setValue("szMessageTemplate", internalVO.getSzMessageTemplate());
    bsfnParams.setValue("szParameter01", internalVO.getSzParameter01());
    bsfnParams.setValue("szParameter02", internalVO.getSzParameter02());
    bsfnParams.setValue("szParameter03", internalVO.getSzParameter03());
    bsfnParams.setValue("szParameter04", internalVO.getSzParameter04());
    bsfnParams.setValue("szParameter05", internalVO.getSzParameter05());
    bsfnParams.setValue("szParameter06", internalVO.getSzParameter06());
    bsfnParams.setValue("szParameter07", internalVO.getSzParameter07());
    bsfnParams.setValue("szParameter08", internalVO.getSzParameter08());
    bsfnParams.setValue("szParameter09", internalVO.getSzParameter09());
    bsfnParams.setValue("szParameter10", internalVO.getSzParameter10());
    bsfnParams.setValue("szEmailMsg", internalVO.getSzEmailMsg());
    bsfnParams.setValue("mnMessageId", internalVO.getMnMessageId());
    bsfnParams.setValue("mnMessageLineNum", internalVO.getMnMessageLineNum());
    bsfnParams.setValue("szWorkflowLineType", internalVO.getSzWorkflowLineType());
    bsfnParams.setValue("szXmlTag", internalVO.getSzXmlTag());

    try {
      // get bsfnService from context
      IBSFNService bsfnService = context.getBSFNService();

      // execute business function
      bsfnService.execute(context, connection, "BE_FormatWorkflowMessage", bsfnParams);
    } catch (BSFNServiceInvalidArgException invalidArgEx) {
      // Create error message for Invalid Argument exception and return it in ErrorList
      E1MessageList returnMessages = new E1MessageList();
      returnMessages.addMessage(new E1Message(context, "018FIS", invalidArgEx.getMessage()));
      return returnMessages;
    } catch (BSFNServiceSystemException systemEx) {
      // Create error message for System exception and return it in ErrorList
      E1MessageList returnMessages = new E1MessageList();
      returnMessages.addMessage(new E1Message(context, "019FIS", systemEx.getMessage()));
      return returnMessages;
    }

    // map output parameters to output value object
    internalVO.setCErrorCode(bsfnParams.getValue("cErrorFlag").toString());
    internalVO.setSzErrorDescription((String) bsfnParams.getValue("szErrorMessage"));
    // return any errors, warnings, or informational messages to the caller
    return bsfnParams.getE1MessageList();
  }
  /**
   * Calls the BE_AddWorkflowHeader(N5602000) business function which has the D5602000B
   * datastructure.
   *
   * @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 BE_AddWorkflowHeader(
      IContext context, IConnection connection, BE_AddWorkFlowHeader_D5602000B internalVO) {
    BSFNParameters bsfnParams = new BSFNParameters();

    // map input parameters from input value object
    bsfnParams.setValue("mnGroupId", internalVO.getMnGroupId());
    bsfnParams.setValue("mnMessageId", internalVO.getMnMessageId());
    bsfnParams.setValue("mnParentId", internalVO.getMnParentId());
    bsfnParams.setValue("szBranch", internalVO.getSzBranch());
    bsfnParams.setValue("szWorkflowType", internalVO.getSzWorkflowType());
    bsfnParams.setValue("szWorkflowOriginator", internalVO.getSzWorkflowOriginator());
    bsfnParams.setValue("szAuditProgramId", internalVO.getSzAuditProgramId());

    try {
      // get bsfnService from context
      IBSFNService bsfnService = context.getBSFNService();

      // execute business function
      bsfnService.execute(context, connection, "BE_AddWorkflowHeader", bsfnParams);
    } catch (BSFNServiceInvalidArgException invalidArgEx) {
      // Create error message for Invalid Argument exception and return it in ErrorList
      E1MessageList returnMessages = new E1MessageList();
      returnMessages.addMessage(new E1Message(context, "018FIS", invalidArgEx.getMessage()));
      return returnMessages;
    } catch (BSFNServiceSystemException systemEx) {
      // Create error message for System exception and return it in ErrorList
      E1MessageList returnMessages = new E1MessageList();
      returnMessages.addMessage(new E1Message(context, "019FIS", systemEx.getMessage()));
      return returnMessages;
    }

    // map output parameters to output value object
    internalVO.setMnGroupId((MathNumeric) bsfnParams.getValue("mnGroupId"));
    internalVO.setMnMessageId((MathNumeric) bsfnParams.getValue("mnMessageId"));
    internalVO.setMnParentId((MathNumeric) bsfnParams.getValue("mnParentId"));
    internalVO.setSzBranch((String) bsfnParams.getValue("szBranch"));
    internalVO.setSzWorkflowType((String) bsfnParams.getValue("szWorkflowType"));
    internalVO.setSzWorkflowOriginator((String) bsfnParams.getValue("szWorkflowOriginator"));
    internalVO.setCErrorFlag(bsfnParams.getValue("cErrorFlag").toString());
    internalVO.setSzErrorMessage((String) bsfnParams.getValue("szErrorMessage"));
    internalVO.setSzAuditProgramId((String) bsfnParams.getValue("szAuditProgramId"));
    internalVO.setCSuppressErrorMessage(bsfnParams.getValue("cSuppressErrorMessage").toString());

    // return any errors, warnings, or informational messages to the caller
    return bsfnParams.getE1MessageList();
  }
  /**
   * Calls the PriceCheck(N564704) business function which has the D564074A datastructure.
   *
   * @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 callPriceCheck(
      IContext context, IConnection connection, InternalPriceCheck_D564074A internalVO) {
    BSFNParameters bsfnParams = new BSFNParameters();

    // map input parameters from input value object
    bsfnParams.setValue("mnAddressNumber", internalVO.getMnAddressNumber());
    bsfnParams.setValue("mnAddressNumberShipTo", internalVO.getMnAddressNumberShipTo());
    bsfnParams.setValue("szIdentifier2ndItem", internalVO.getSzIdentifier2ndItem());
    bsfnParams.setValue("szCostCenter", internalVO.getSzCostCenter());
    bsfnParams.setValue("mnQuantityMinimum", internalVO.getMnQuantityMinimum());
    bsfnParams.setValue("szP4074Version", internalVO.getSzP4074Version());

    try {
      // get bsfnService from context
      IBSFNService bsfnService = context.getBSFNService();

      // execute business function
      bsfnService.execute(context, connection, "PriceCheck", bsfnParams);
    } catch (BSFNServiceInvalidArgException invalidArgEx) {
      // Create error message for Invalid Argument exception and return it in ErrorList
      E1MessageList returnMessages = new E1MessageList();
      returnMessages.addMessage(new E1Message(context, "018FIS", invalidArgEx.getMessage()));
      return returnMessages;
    } catch (BSFNServiceSystemException systemEx) {
      // Create error message for System exception and return it in ErrorList
      E1MessageList returnMessages = new E1MessageList();
      returnMessages.addMessage(new E1Message(context, "019FIS", systemEx.getMessage()));
      return returnMessages;
    }

    // map output parameters to output value object
    internalVO.setMnAddressNumber((MathNumeric) bsfnParams.getValue("mnAddressNumber"));
    internalVO.setMnAddressNumberShipTo((MathNumeric) bsfnParams.getValue("mnAddressNumberShipTo"));
    internalVO.setSzIdentifier2ndItem((String) bsfnParams.getValue("szIdentifier2ndItem"));
    internalVO.setSzCostCenter((String) bsfnParams.getValue("szCostCenter"));
    internalVO.setMnQuantityMinimum((MathNumeric) bsfnParams.getValue("mnQuantityMinimum"));
    internalVO.setJdPriceEffectiveDate((Date) bsfnParams.getValue("jdPriceEffectiveDate"));
    internalVO.setSzAdjustmentSchedule((String) bsfnParams.getValue("szAdjustmentSchedule"));
    internalVO.setSzUnitOfMeasurePricing((String) bsfnParams.getValue("szUnitOfMeasurePricing"));
    internalVO.setMnExchangeRate((MathNumeric) bsfnParams.getValue("mnExchangeRate"));
    internalVO.setCCurrencyMode(bsfnParams.getValue("cCurrencyMode").toString());
    internalVO.setMnAmtPricePerUnit2((MathNumeric) bsfnParams.getValue("mnAmtPricePerUnit2"));

    // return any errors, warnings, or informational messages to the caller
    return bsfnParams.getE1MessageList();
  }
  /**
   * Calls the BE_BuildParameterizedUrl(B5602000) business function which has the D5602000H
   * datastructure.
   *
   * @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 BE_BuildParameterizedUrl(
      IContext context, IConnection connection, BE_BuildParameterizedUrl_D5602000H internalVO) {
    BSFNParameters bsfnParams = new BSFNParameters();

    // map input parameters from input value object
    bsfnParams.setValue("szProgramName", internalVO.getSzProgramName());
    bsfnParams.setValue("szFormName", internalVO.getSzFormName());
    bsfnParams.setValue("szVersion", internalVO.getSzVersion());
    bsfnParams.setValue("szEncodedRedirectUrl", internalVO.getSzEncodedRedirectUrl());
    bsfnParams.setValue("szParameterIdList", internalVO.getSzParameterIdList());
    bsfnParams.setValue("szParameterValueList", internalVO.getSzParameterValueList());
    bsfnParams.setValue("szParameterizedURL", internalVO.getSzParameterizedURL());

    try {
      // get bsfnService from context
      IBSFNService bsfnService = context.getBSFNService();

      // execute business function
      bsfnService.execute(context, connection, "BE_BuildParameterizedUrl", bsfnParams);
    } catch (BSFNServiceInvalidArgException invalidArgEx) {
      // Create error message for Invalid Argument exception and return it in ErrorList
      E1MessageList returnMessages = new E1MessageList();
      returnMessages.addMessage(new E1Message(context, "018FIS", invalidArgEx.getMessage()));
      return returnMessages;
    } catch (BSFNServiceSystemException systemEx) {
      // Create error message for System exception and return it in ErrorList
      E1MessageList returnMessages = new E1MessageList();
      returnMessages.addMessage(new E1Message(context, "019FIS", systemEx.getMessage()));
      return returnMessages;
    }

    // map output parameters to output value object
    internalVO.setSzProgramName((String) bsfnParams.getValue("szProgramName"));
    internalVO.setSzFormName((String) bsfnParams.getValue("szFormName"));
    internalVO.setSzVersion((String) bsfnParams.getValue("szVersion"));
    internalVO.setSzEncodedRedirectUrl((String) bsfnParams.getValue("szEncodedRedirectUrl"));
    internalVO.setSzParameterIdList((String) bsfnParams.getValue("szParameterIdList"));
    internalVO.setSzParameterValueList((String) bsfnParams.getValue("szParameterValueList"));
    internalVO.setSzParameterizedURL((String) bsfnParams.getValue("szParameterizedURL"));
    internalVO.setCErrorFlag(bsfnParams.getValue("cErrorFlag").toString());
    internalVO.setSzErrorDescription((String) bsfnParams.getValue("szErrorDescription"));

    // return any errors, warnings, or informational messages to the caller
    return bsfnParams.getE1MessageList();
  }