SAP functions for pre-population |
||
Manually we can get this with multiple searches on table hrp1001 - for example:
data: l_pid type bapiusr01-employeeno, l_return type bapiret2, l_sobid type sobid, l_sobid_t type table of sobid, l_employee type sobid, l_employee_t type table of sobid, l_objid type hrobjid, l_plvar type plvar value '01', l_name type emnam, l_grade type persk, l_pernr type persno, l_form_data type /flm/form_data, l_form_data_t type /flm/sfs_form_data_t. * * 1 Find personel number of the manager call function 'BAPI_USR01DOHR_GETEMPLOYEE' destination 'E5F' exporting id = im_uname importing return = l_return employeenumber = l_pid. * l_objid = l_pid. * * 2 Get team for the current manager select sobid from hrp1001 into l_sobid up to 1 rows where otype = 'P' and objid = l_objid and plvar = l_plvar and rsign = 'B' and relat = '008' and istat = '1' and begda le sy-datum and endda ge sy-datum and sclas eq 'S'. endselect. check sy-subrc eq 0. move l_sobid to l_objid. select sobid from hrp1001 into l_sobid up to 1 rows where otype = 'S' and objid = l_objid and plvar = l_plvar and rsign = 'A' and relat = '012' and istat = '1' and begda le sy-datum and endda ge sy-datum and sclas eq 'O'. endselect. * check sy-subrc eq 0. move l_sobid to l_objid. select sobid from hrp1001 into table l_sobid_t where otype = 'O' and objid = l_objid and plvar = l_plvar and rsign = 'B' and relat = '003' and istat = '1' and begda le sy-datum and endda ge sy-datum and sclas eq 'S'. * check sy-subrc eq 0. * loop at l_sobid_t into l_objid. clear l_sobid. select sobid from hrp1001 into l_sobid up to 1 rows where otype = 'S' and objid = l_objid and plvar = l_plvar and rsign = 'A' and relat = '008' and istat = '1' and begda le sy-datum and endda ge sy-datum and sclas eq 'P'. endselect. append l_sobid to l_employee_t. endloop. * * 3 Get the names and grades for each team member loop at l_employee_t into l_employee. l_pernr = l_employee. * Get employee name, grade, business area, position select ename persk up to 1 rows from pa0001 into (l_name, l_grade) where pernr = l_pernr and endda ge sy-datum and begda le sy-datum. endselect. clear l_form_data. l_form_data-name = l_pernr. l_form_data-value = l_name. append l_form_data to l_form_data_t. endloop. ex_form_data[] = l_form_data_t[]. |
Powered by FogBugz