Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Function Module Export parameter

Former Member
0 Likes
2,164

Hi Experts,

I am currently working on the UI5 mobile application development. I have developed the application for Employee Lookup, now what i want to do is to get manager name by providing employee number to it. I have created a Function Module to achieve this by modifying existing one in system. Now what happens this FM takes EMPLOYEE NUMBER as import parameter and RETURNS all the data regarding the EMPLOYEE in Export parameter table, this export parameter table is getting populated with single line entry only. And MANAGER for this first entry appears for all employees, The code is as below,

METHOD get_data_manager.

   DATA: it_employee   TYPE STANDARD TABLE OF bapiemp_ls,

         it_pernr      TYPE STANDARD TABLE OF hrobject,

         it_uri        TYPE STANDARD TABLE OF toauri,

         it_org        TYPE STANDARD TABLE OF bapip0001b,

         it_object     TYPE STANDARD TABLE OF objec,

         wa_object     LIKE LINE OF it_object,

         wa_org        LIKE LINE OF it_org,

         wa_pernr      LIKE LINE OF it_pernr,

         wa_employee   LIKE LINE OF it_employee,

         it_emp        TYPE ztab_orgchart_ang,

         wa_emp        TYPE zstr_orgchart_ang,

         wa_uri        LIKE LINE OF it_uri.

* Get my Employee number

   CALL METHOD get_employee_number( ).

   CALL FUNCTION 'Z_ORGCHART_ANG'

     EXPORTING

       i_pernr         = gv_pernr

     IMPORTING

       e_tab_employees = it_emp.

*--------------------------------------------------------------------*

* BUILD DATA & IMAGE

*--------------------------------------------------------------------*

   LOOP AT it_emp INTO wa_emp.

     MOVE wa_emp-managerid   TO wa_employee_list-pernr.

     MOVE wa_emp-managername TO wa_employee_list-ename.

     MOVE wa_emp-title       TO wa_employee_list-job_text.

     MOVE wa_emp-city        TO wa_employee_list-org_text.

*   Get Employee Image

     CALL METHOD get_data_image( ).

*   Get Employee Communication

     CALL METHOD get_data_comm( ).

*   Get Employee Address

     CALL METHOD get_data_address( ).

     APPEND wa_employee_list TO it_employee_mang.

     CLEAR  wa_employee_list.

   ENDLOOP.

* Sorting

   SORT it_employee_mang BY ename.

ENDMETHOD.



The method "get_employee_number( )" returns all the employee numbers as gv_pernr. Do I need to call the FM "Z_ORGCHART_ANG" in loop s that it can return entries for all employees. If you have any idea regarding this issue please share it with me.



Thanks,

Avadhut

5 REPLIES 5
Read only

Former Member
0 Likes
1,385

Hi,

Is gv_pernr holds single value?

Read only

0 Likes
1,385

Hi Ashok,

The coding for gv_pernr is like this,

select single pernr

          from pa0105

          into gv_pernr

          where usrty eq '0001'

            and usrid eq sy-uname

            and endda ge sy-datum

            and begda le sy-datum.

Thanks,

Avadhut

Read only

0 Likes
1,385

Hi..

Here we are fetching the value using system username SY-UNAME. So it is possible to retrieve the manager for the particular user who is running the report.

Regards

Rajkumar Narasimman

Read only

0 Likes
1,385

Hi,

The method "get_employee_number( )" returns all the employee numbers as gv_pernr. Do I need to call the FM "Z_ORGCHART_ANG" in loop s that it can return entries for all employees. If you have any idea regarding this issue please share it with me.


Based on above comments gv_pernr brings all the employee details.So you can loop the code like below.


Loop.

* Get my Employee number

   CALL METHOD get_employee_number( ).

   CALL FUNCTION 'Z_ORGCHART_ANG'

     EXPORTING

       i_pernr         = gv_pernr

     IMPORTING

       e_tab_employees = it_emp.

append lines of it_emp to it_emp1.

endloop.


Hopes it helps you.


Thanks,

Ashok.

Read only

rajkumarnarasimman
Active Contributor
0 Likes
1,385

Hi Avadhut,

Yes, if you need to retrieve all the managers of the employee, it is required to call the FM Z_ORGCHART_ANG inside the LOOP.


LOOP AT IT_PA0001 INTO WA_PA0001.

  CALL FUNCTION 'Z_ORGCHART_ANG'

     EXPORTING

       i_pernr         = WA_PA0001-PERNR

     IMPORTING

       e_tab_employees = it_emp.


"If required, Append the internal table values to final table

APPEND LINES OF IT_EMP INTO IT_FINAL.


ENDLOOP.


Regards


Rajkumar Narasimman