private static BSSVDBWhereClauseBuilder buildF560205WhereClause(
      IContext context, BE_HumanTaskQuery internalVO) {
    // specify condition records must meet to be selected
    boolean processFlag = false;
    ArrayList whereFields = new ArrayList();
    // BSSVDBWhereField[] whereFields = new BSSVDBWhereField[5];
    // Include workflow type
    String workflowType = internalVO.getF560205_Z56WFTP();
    String workflowLevel = internalVO.getF560205_SLCUSTFN();
    if (workflowType != null && workflowLevel != null) {
      whereFields.add(
          new BSSVDBWhereField(
              null, new BSSVDBField("F560205.Z56WFTP"), IDBService.EQUALS, workflowType));
      whereFields.add(
          new BSSVDBWhereField(
              IDBService.AND,
              new BSSVDBField("F560205.SLCUSTFN"),
              IDBService.EQUALS,
              workflowLevel));
      processFlag = true;
    } else return null;

    // include workflow branch if present
    String workflowBranch = internalVO.getF560205_MCU();
    if (workflowBranch != null) {
      whereFields.add(
          new BSSVDBWhereField(
              IDBService.AND, new BSSVDBField("F560205.MCU"), IDBService.EQUALS, workflowBranch));
      processFlag = true;
    }

    // include alternate key 1 if present
    String altKey1 = internalVO.getF560205_ALKY();
    if (altKey1 != null) {
      whereFields.add(
          new BSSVDBWhereField(
              IDBService.AND, new BSSVDBField("F560205.ALKY"), IDBService.EQUALS, altKey1));
      processFlag = true;
    }
    // include alternate key 2 if present
    String altKey2 = internalVO.getF560205_ALKY1();
    if (altKey2 != null) {
      whereFields.add(
          new BSSVDBWhereField(
              IDBService.AND, new BSSVDBField("F560205.ALKY1"), IDBService.EQUALS, altKey2));
      processFlag = true;
    }
    // include alternate key 3 if present
    String altKey3 = internalVO.getF560205_Z56ALKY3();
    if (altKey3 != null) {
      whereFields.add(
          new BSSVDBWhereField(
              IDBService.AND, new BSSVDBField("F560205.Z56ALKY3"), IDBService.EQUALS, altKey3));
      processFlag = true;
    }
    // include alternate key 4 if present
    String altKey4 = internalVO.getF560205_Z56ALKY4();
    if (altKey4 != null) {
      whereFields.add(
          new BSSVDBWhereField(
              IDBService.AND, new BSSVDBField("F560205.Z56ALKY4"), IDBService.EQUALS, altKey4));
      processFlag = true;
    }
    // include alternate key 5 if present
    String altKey5 = internalVO.getF560205_Z56ALKY5();
    if (altKey5 != null) {
      whereFields.add(
          new BSSVDBWhereField(
              IDBService.AND, new BSSVDBField("F560205.Z56ALKY5"), IDBService.EQUALS, altKey5));
      processFlag = true;
    }
    // include alternate key 6 if present
    String altKey6 = internalVO.getF560205_Z56ALKY6();
    if (altKey6 != null) {
      whereFields.add(
          new BSSVDBWhereField(
              IDBService.AND, new BSSVDBField("F560205.Z56ALKY6"), IDBService.EQUALS, altKey6));
      processFlag = true;
    }
    // include alternate key 7 if present
    String altKey7 = internalVO.getF560205_Z56ALKY7();
    if (altKey7 != null) {
      whereFields.add(
          new BSSVDBWhereField(
              IDBService.AND, new BSSVDBField("F560205.Z56ALKY7"), IDBService.EQUALS, altKey7));
      processFlag = true;
    }
    // include alternate key 8 if present
    String altKey8 = internalVO.getF560205_Z56ALKY8();
    if (altKey8 != null) {
      whereFields.add(
          new BSSVDBWhereField(
              IDBService.AND, new BSSVDBField("F560205.Z56ALKY8"), IDBService.EQUALS, altKey8));
      processFlag = true;
    }
    // build the where clause
    int size = whereFields.size();
    BSSVDBWhereField[] whereArray = new BSSVDBWhereField[size];
    for (int x = 0; x < size; x++) {
      whereArray[x] = (BSSVDBWhereField) whereFields.get(x);
    }

    BSSVDBWhereClauseBuilder whereClause = null;
    if (processFlag == true) {
      whereClause = new BSSVDBWhereClauseBuilder(context, whereArray);
    }
    return whereClause;
  }
  /**
   * Selects records from the F560205 table.
   *
   * <p>Following SQL statement can be produced by this generated code
   *
   * <blockquote>
   *
   * <pre><code>
   * SELECT F560205.Z56WFTP, F560205.MCU, F560205.ALKY, F560205.ALKY1, F560205.SLCUSTFN, F560205.CUID, F560205.GROUP, F560205.FTH1, F560205.FTH2, F560205.FMTST, F560205.CFGGC, F560205.FMTET, F560205.RVID
   * FROM F560205
   * WHERE F560205.Z56WFTP=? AND F560205.MCU=? AND F560205.ALKY=? AND F560205.ALKY1=? AND F560205.SLCUSTFN=?
   * </code></pre>
   *
   * </blockquote>
   *
   * @param context conditionally provides the connection for the database operation and logging
   *     information
   * @param connection can either be an explicit connection or null. If null the default connection
   *     is used.
   * @param internalVO TODO document input parameters
   * @return an E1Message containing the text of any database exceptions that may have occurred
   */
  private static E1MessageList selectFromF560205(
      IContext context, IConnection connection, BE_HumanTaskQuery internalVO) {
    // create return object
    E1MessageList returnMessages = new E1MessageList();

    // specify columns to select
    BSSVDBField[] selectFields = {
      new BSSVDBField("F560205.Z56WFTP"), // String - WorkflowType
      new BSSVDBField("F560205.Z56WTDS"), // String - WorkflowTypeDescription
      new BSSVDBField("F560205.MCU"), // String - CostCenter
      new BSSVDBField("F560205.ALKY"), // String - AlternateAddressKey
      new BSSVDBField("F560205.ALKY1"), // String - AlternateAddressKey1
      new BSSVDBField("F560205.Z56ALKY3"), // String - AlternateAddressKey3
      new BSSVDBField("F560205.Z56ALKY4"), // String - AlternateAddressKey4
      new BSSVDBField("F560205.Z56ALKY5"), // String - AlternateAddressKey5
      new BSSVDBField("F560205.Z56ALKY6"), // String - AlternateAddressKey6
      new BSSVDBField("F560205.Z56ALKY7"), // String - AlternateAddressKey7
      new BSSVDBField("F560205.Z56ALKY8"), // String - AlternateAddressKey8
      new BSSVDBField("F560205.SLCUSTFN"), // String - ServiceLevelCustomFunction
      new BSSVDBField("F560205.GROUP"), // String - GROUP
      new BSSVDBField("F560205.CUID"), // String - CurrentUserID
      new BSSVDBField("F560205.SUBGRP"), // String - SubscriberGroup
      new BSSVDBField("F560205.FTH1"), // Numeric - ForeignThreshold1
      new BSSVDBField("F560205.FTH2"), // Numeric - ForeignThreshold2
      new BSSVDBField("F560205.FMTST"), // String - StartTime9
      new BSSVDBField("F560205.CFGGC"), // String - ConfigurationGroupCode
      new BSSVDBField("F560205.GRPNAME"), // String - GroupName
      new BSSVDBField("F560205.FMTET"), // String - EndTime9
      new BSSVDBField("F560205.RVID"), // String - ReviewerID
      new BSSVDBField("F560205.WGNA"), // String - WorkGroupName
      new BSSVDBField("F560205.URCD"), // String - UserReservedCode
      new BSSVDBField("F560205.URDT"), // Date - UserReservedDate
      new BSSVDBField("F560205.URAT"), // Numeric - UserReservedAmount
      new BSSVDBField("F560205.URAB"), // Numeric - UserReservedNumber
      new BSSVDBField("F560205.URRF"), // String - UserReservedReference
    };

    // specify sort order
    BSSVDBSortField[] sortOrder = null;
    BSSVDBWhereClauseBuilder whereClause = null;
    BSSVDBResultSet resultSet = null;
    BSSVDBFieldMap[] fieldMap = null;
    boolean selectDistinct = false;
    boolean recordFound = false;

    try {
      // get dbService from context
      IDBService dbService = context.getDBService();

      // adjust select criteria as necessary
      String workflowLevel = internalVO.getF560205_SLCUSTFN();
      // if(workflowLevel.compareToIgnoreCase("LEVEL1") == 0)
      if (0 == 0) {

        //    int retryCount = 7; //Number of times to retry
        int retryCount = 10; // Number of times to retry
        while (!recordFound && retryCount > 0) {
          // Remove fields from select criteria when necessary
          switch (retryCount) {
            case 9:
              internalVO.setF560205_Z56ALKY8(null);
              break;
            case 8:
              internalVO.setF560205_Z56ALKY7(null);
              break;
            case 7:
              internalVO.setF560205_Z56ALKY6(null);
              break;
            case 6:
              internalVO.setF560205_Z56ALKY5(null);
              break;
            case 5:
              internalVO.setF560205_Z56ALKY4(null);
              break;
            case 4:
              internalVO.setF560205_Z56ALKY3(null);
              break;
            case 3:
              internalVO.setF560205_ALKY1(null);
              break;
            case 2:
              internalVO.setF560205_ALKY(null);
              break;
            case 1:
              internalVO.setF560205_MCU(null);
              break;
          }
          ;
          retryCount--;
          // Build the where clasue
          whereClause = buildF560205WhereClause(context, internalVO);
          // execute select operation
          resultSet =
              dbService.select(
                  context,
                  connection,
                  "F560205",
                  IDBService.DB_TABLE,
                  selectDistinct,
                  IDBService.DB_FETCH_ALL,
                  selectFields,
                  sortOrder,
                  whereClause);
          if (resultSet != null) {
            fieldMap = resultSet.getFieldMap();
            if (fieldMap != null && fieldMap.length > 0) recordFound = true;
          }
        }
      } else {
        whereClause = buildF560205WhereClause(context, internalVO);
        resultSet =
            dbService.select(
                context,
                connection,
                "F560205",
                IDBService.DB_TABLE,
                selectDistinct,
                IDBService.DB_FETCH_ALL,
                selectFields,
                sortOrder,
                whereClause);
        if (resultSet != null) {
          fieldMap = resultSet.getFieldMap();
          if (fieldMap != null && fieldMap.length > 0) recordFound = true;
        }
      }
    } catch (DBServiceException e) {
      internalVO.setCErrorFlag("1");
      internalVO.setSzErrorDescription("Problems performing F560205 SELECT");
      returnMessages.addMessage(new E1Message(context, "005FIS", e.getMessage()));
    }

    if (recordFound == true) {
      // process the results of the select
      ArrayList queryResults = new ArrayList();
      for (int i = 0; i < fieldMap.length; i++) {
        BSSVDBFieldMap map = fieldMap[i];
        BE_HumanTaskResult result = new BE_HumanTaskResult();

        result.setF560205_Z56WFTP((String) map.getValue("F560205.Z56WFTP"));
        result.setF560205_Z56WTDS((String) map.getValue("F560205.Z56WTDS"));
        result.setF560205_MCU((String) map.getValue("F560205.MCU"));
        result.setF560205_ALKY((String) map.getValue("F560205.ALKY"));
        result.setF560205_ALKY1((String) map.getValue("F560205.ALKY1"));
        result.setF560205_Z56ALKY3((String) map.getValue("F560205.Z56ALKY3"));
        result.setF560205_Z56ALKY4((String) map.getValue("F560205.Z56ALKY4"));
        result.setF560205_Z56ALKY5((String) map.getValue("F560205.Z56ALKY5"));
        result.setF560205_Z56ALKY6((String) map.getValue("F560205.Z56ALKY6"));
        result.setF560205_Z56ALKY7((String) map.getValue("F560205.Z56ALKY7"));
        result.setF560205_Z56ALKY8((String) map.getValue("F560205.Z56ALKY8"));
        result.setF560205_SLCUSTFN((String) map.getValue("F560205.SLCUSTFN"));
        result.setF560205_GROUP((String) map.getValue("F560205.GROUP"));
        result.setF560205_CUID((String) map.getValue("F560205.CUID"));
        result.setF560205_SUBGRP((String) map.getValue("F560205.SUBGRP"));
        result.setF560205_FTH1((MathNumeric) map.getValue("F560205.FTH1"));
        result.setF560205_FTH2((MathNumeric) map.getValue("F560205.FTH2"));
        result.setF560205_FMTST((String) map.getValue("F560205.FMTST"));
        result.setF560205_CFGGC((String) map.getValue("F560205.CFGGC"));
        result.setF560205_FMTET((String) map.getValue("F560205.FMTET"));
        result.setF560205_RVID((String) map.getValue("F560205.RVID"));
        result.setF560205_WGNA((String) map.getValue("F560205.WGNA"));
        result.setF560205_URCD((String) map.getValue("F560205.URCD"));
        result.setF560205_URDT((Date) map.getValue("F560205.URDT"));
        result.setF560205_URAT((MathNumeric) map.getValue("F560205.URAT"));
        result.setF560205_URAB((MathNumeric) map.getValue("F560205.URAB"));
        result.setF560205_URRF((String) map.getValue("F560205.URRF"));

        queryResults.add(result);
      }

      if (resultSet.hasMoreRows()) {
        returnMessages.addMessage(new E1Message(context, "028FIS", ""));
      }

      // map results to internal vo
      internalVO.setQueryResults(queryResults);
    } else {
      internalVO.setCErrorFlag("1");
      internalVO.setSzErrorDescription("No F560205 records found");
    }

    return returnMessages;
  }