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 Parameter's - Getting data

Former Member
0 Likes
761

Hello experts,

I am working on UI5 mobile application development, i have developed the app for Employee Lookup. Now i want to display Manager name by passing personal number of employee. I have use the FM which is defined in our system. I have rectified all other issues from the code, But still there is one issue still exists its regarding Manager name. It’s like getting same manager name for all employees, I guess it is causing due to the export parameter in FM used, this export parameter is getting populated with single entry at a time like below,

Due to this the manager name for the First employee is appearing for all other employees, to avoid this I have changed the code as

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_empl.

Afterwards LOOPing through it_empl and trying to display individual manager details. But it is not working out correctly. I have also tried out with using LOOP for above code but it’s also not working out correctly. Getting same issue like same manager name for all employees.  The code for the method used is like 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,

         it_empl       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.

   APPEND LINES OF it_emp TO it_empl.

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

* BUILD DATA & IMAGE

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

   LOOP AT it_empl 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.


So I am trying to rectify this issue, if you have any idea to rectify this issue please share it with me.


Thanks,

Avadhut

2 REPLIES 2
Read only

Former Member
0 Likes
720

Hi Avadhut,

First, when you debugging, you can see different manager id exist in it_empl?

I`d like write like this:

LOOP AT it_empl 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.

     APPEND wa_employee_list TO it_employee_mang.

     CLEAR  wa_employee_list.

ENDLOOP.

DELETE ADJUST DUPULICATE FROM it_employee_mang COMPARING PERNR ENAME.


LOOP AT it_employee_mang INTO wa_employee_list.

    lv_index = sy-tabix.

*   Get Employee Image

     CALL METHOD get_data_image( ).

*   Get Employee Communication

     CALL METHOD get_data_comm( ).

*   Get Employee Address

     CALL METHOD get_data_address( ).

    MODIFY it_employee_mang  FROM wa_employee_list. INDEX lv_index.


ENDLOOP.


regards,

Archer

Read only

0 Likes
719

Hi Dengyong Zhang,

Thanks for the reply. I have tried out using above code but still its not working out correctly. FYI for FM 'Z_ORGCHART_ANG' when we submit PERNR then it  retrieves all the data for that employee number including manager name and manager id as below,

In the next code due to this, the manager name for First employee appear for all. Thus to rectify this issue i have used logic as,

APPEND LINES OF it_emp TO it_empl.

And afterwards looping it_empl, but its not working out correctly. Still displaying  same managername for all employees. If you have any idea regarding this please share it with me.

Thanks,

Avadhut