private void saveCategoryEmployee(long masterId, PayrollCategory[] categories) throws Exception {

    String sql =
        "INSERT INTO "
            + IDBConstants.TABLE_PAYROLL_CATEGORY_EMPLOYEE_HISTORY
            + "("
            + IDBConstants.ATTR_HISTORY_MASTER
            + ","
            + IDBConstants.ATTR_CATEGORY
            + ","
            + IDBConstants.ATTR_EMPLOYEE
            + ")"
            + " values (?, ?, ?)";

    for (int i = 0; i < categories.length; i++) {
      PayrollCategory payrollCategory = categories[i];

      IHRMSQL iSql = new HRMSQLSAP();
      Employee[] employees =
          iSql.getPayrollCategoryEmployee(payrollCategory.getIndex(), connection);

      for (int j = 0; j < employees.length; j++) {
        Employee emp = employees[j];

        PreparedStatement stm = connection.prepareStatement(sql);

        stm.setLong(1, masterId);
        stm.setLong(2, payrollCategory.getNewIndex());
        stm.setLong(3, emp.getIndex());

        stm.executeUpdate();
      }
    }
  }
  private void saveCategoryComponent(long masterId, PayrollCategory[] categories) throws Exception {
    String sql =
        "INSERT INTO "
            + IDBConstants.TABLE_PAYROLL_CATEGORY_COMPONENT_HISTORY
            + "("
            + IDBConstants.ATTR_HISTORY_MASTER
            + ","
            + IDBConstants.ATTR_CATEGORY
            + ","
            + IDBConstants.ATTR_COMPONENT
            + ","
            + IDBConstants.ATTR_FORMULA
            + ","
            + IDBConstants.ATTR_FORMULA_MONTH
            + ","
            + IDBConstants.ATTR_ROUND_VALUE
            + ","
            + IDBConstants.ATTR_PRECISION
            + ")"
            + " values (?, ?, ?, ?, ?, ?, ?)";

    for (int i = 0; i < categories.length; i++) {
      PayrollCategory payrollCategory = categories[i];

      HRMBusinessLogic logic = new HRMBusinessLogic(connection);

      PayrollCategoryComponent[] components =
          logic.getAllPayrollCategoryComponent(
              sessionId,
              IDBConstants.MODUL_MASTER_DATA,
              payrollCategory.getIndex(),
              IDBConstants.TABLE_PAYROLL_CATEGORY_COMPONENT);
      for (int j = 0; j < components.length; j++) {
        PayrollCategoryComponent comp = components[j];

        PreparedStatement stm = connection.prepareStatement(sql);

        stm.setLong(1, masterId);
        stm.setLong(2, payrollCategory.getNewIndex());
        stm.setLong(3, comp.getPayrollComponent().getIndex());
        stm.setString(4, comp.getFormulaEntity().getFormulaCode());
        stm.setInt(5, (int) comp.getEveryWhichMonth());
        stm.setInt(6, (int) comp.getFormulaEntity().getNumberRounding().getRoundingMode());
        stm.setInt(7, comp.getFormulaEntity().getNumberRounding().getPrecision());

        stm.executeUpdate();
      }
    }
  }