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

Getting data into work area from function module export parameter

Former Member
0 Likes
3,074

Hi there,

I am working on the SAPUI5 to create an app to display employee lookup. Now what i want to get manager name of the employee by submitting employee ID method. There is function module available in my system to get manager info by entering EMPLOYEE ID. The FM is working good, now further i want to use this FM into the Application Class method to display manager name on the screen,

The FM is Z_ORGCHART_ANG, with importing parameter as EMPLOYEE ID and the EXPORTING parameter is defined as table,

Now in the method i have declared the variables as,

DATA:

         it_emp        TYPE STANDARD TABLE OF ztab_orgchart_ang,

         wa_emp     LIKE LINE OF it_emp,

   CALL METHOD get_employee_number( ).

   CALL FUNCTION 'Z_ORGCHART_ANG'

     EXPORTING

       i_pernr         = gv_pernr

     IMPORTING

       e_tab_employees = it_emp.


   READ TABLE it_emp INTO wa_emp INDEX 1.

   CHECK sy-subrc EQ 0.


Now when i try to select particular field from wa_emp suppose wa_emp-managerid, then the status message is getting displayed as WA_EMP is table without header line thus not having component as MANAGERID. I think the problem arising is due to EXPORT parameter in method it should be DECLARED as TABLE. Is there any solution available for this problem please share it with me? Or is there any other method to get MANAGER data using employee ID.



Thanks


Avadhut

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,045

Double-click on  "ztab_orgchart_ang" in your source, is it a structure or an internal table definition. In the second case, suggested by the FM signture which uses it as an export parameter and not an obsolete table parameter, replace

it_emp        TYPE STANDARD TABLE OF ztab_orgchart_ang,

with

it_emp        TYPE ztab_orgchart_ang,


Regards,

Raymond


9 REPLIES 9
Read only

former_member182888
Participant
0 Likes
2,045

Peace be upon you,

you should define your work area as

         wa_emp     type it_emp,


hope you find this helpful

Read only

0 Likes
2,045

Hi Marwan Al-Tawansy,

I have tried out with it but didn't work out. The export parameter is defined with internal table type now i didn't understand how to retrieve data from it.

Thanks,

Avadhut

Read only

former_member206650
Active Participant
0 Likes
2,045

Hi Avadhut,

try using the statement

READ TABLE it_emp INDEX <> INTO wa_emp.

better use the KEY if you know the exact record to be fetched by using the known field.

hope it works...

Read only

0 Likes
2,044

Hi Vishnu,

Thanks for the reply it is working but when i try to access any field from wa_emp suppose "wa_emp-managerid" getting status message as

We cannot define table with header line in class.

Thanks,

Avadhut

Read only

Former Member
0 Likes
2,044

Hi,

use your original wa_emp declaration and replace line

READ TABLE it_emp INTO wa_emp INDEX 1.

with

READ TABLE it_emp INDEX 1 INTO wa_emp.

Regards,

Klaus

Read only

0 Likes
2,044

Hi Klaus,

Done but getting same error.

Thanks,

Avadhut

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,047

Double-click on  "ztab_orgchart_ang" in your source, is it a structure or an internal table definition. In the second case, suggested by the FM signture which uses it as an export parameter and not an obsolete table parameter, replace

it_emp        TYPE STANDARD TABLE OF ztab_orgchart_ang,

with

it_emp        TYPE ztab_orgchart_ang,


Regards,

Raymond


Read only

0 Likes
2,044

Hi Raymond,

It is Table Type defined in SE11. I have tried out using

it_emp TYPE ztab_orgchart_ang.

but when i create a work are for it and try to access the field from work area like wa_emp-managerid then getting error message.

Thanks,

Avadhut

Read only

0 Likes
2,044

Now double click on the Line Type associated to the internal table, which kind of ddic object do you identify ?


DATA: it_emp TYPE ztab_orgchart_ang,

     wa_emp LIKE LINE OF it_emp. " or use line type,

If this is a structure, that should perform well, else you may have to read thru another internal table or even a deep structure.

Regards,

Raymond