Skip to Content
avatar image
Former Member

Getting data into work area from function module export parameter

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.jpg (30.2 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Jan 13, 2015 at 12:17 PM

    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


    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • Jan 13, 2015 at 11:30 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 13, 2015 at 11:04 AM

    Peace be upon you,

    you should define your work area as

             wa_emp     type it_emp,


    hope you find this helpful 😊

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • avatar image
    Former Member
    Jan 13, 2015 at 11:25 AM

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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

      1.jpg (39.1 kB)