public static List <Employee> getAllEmployees(RfcDestination destination) { List <Employee> ret = new List <Employee>(); RfcRepository repo = destination.Repository; IRfcFunction employeeList = repo.CreateFunction("BAPI_EMPLOYEE_GETLIST"); employeeList.SetValue("ORG_SEARK", "*"); employeeList.SetValue("JOB_SEARK", "*"); employeeList.SetValue("SUR_NAME_SEARK", "*"); employeeList.SetValue("LST_NAME_SEARK", "*"); employeeList.Invoke(destination); IRfcTable employees = employeeList.GetTable("EMPLOYEE_LIST"); for (int cuIndex = 0; cuIndex < employees.RowCount; cuIndex++) { employees.CurrentIndex = cuIndex; Employee emp = new Employee(); emp.PeronalNr = employees.GetString("PERNR"); emp.Name = employees.GetString("ENAME"); emp.OrgID = employees.GetString("ORG_ID"); emp.Organisation = employees.GetString("ORG_TEXT"); emp.JobID = employees.GetString("JOB_ID"); emp.Job = employees.GetString("JOB_TEXT"); emp.empDetail = EmployeeDetail.getEmployeeDetail(destination, emp.PeronalNr); emp.empAddr = EmployeeAddress.getEmployeeAddress(destination, emp.PeronalNr); ret.Add(emp); } return(ret); }
public static EmployeeDetail getEmployeeDetail(RfcDestination destination, string employeeNum) { EmployeeDetail ret = new EmployeeDetail(); RfcRepository repo = destination.Repository; IRfcFunction employeeList = repo.CreateFunction("BAPI_PERSDATA_GETDETAILEDLIST"); employeeList.SetValue("EMPLOYEENUMBER", employeeNum); employeeList.Invoke(destination); IRfcTable employeedetails = employeeList.GetTable("PERSONALDATA"); for (int cuIndex = 0; cuIndex < employeedetails.RowCount; cuIndex++) { ret.FirstName = employeedetails.GetString("FIRSTNAME"); ret.LastName = employeedetails.GetString("LASTNAME"); ret.Nationality = employeedetails.GetString("NAMEOFNATIONALITY"); ret.Language = employeedetails.GetString("NAMEOFLANGUAGE"); } return(ret); }