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 call inside loop on internal table

Former Member
0 Likes
1,637

Hello Experts,

  I am trying to determine the equipment that resides in all the work centers for a particular organization.  I have successfully worked it out to find the list of work centers managed by a parent organization.  BUT, when I try to loop on that resulting list to find out the work centers under each of the child work centers, I am getting stuck. 

The function '/ISDFPS/GENTAB_GET_RELATIONS' works fine by itself but inside this loop something is not working for me.  Only one child object for each organization (I_CRHD-HROID) is populating the internal table, instead of the full list.  

The internal table I_ZCRHD_FORCE-ZOBJID is only getting populated with one result per object in I-CRHD instead of all of the results for each object.  Therefore when I try to find out the work centers in the second loop, I don't have all of the organizations I need.

Any advice would be greatly appreciated!

LOOP AT I_CRHD.

   CALL FUNCTION '/ISDFPS/GENTAB_GET_RELATIONS'

     EXPORTING

    " PLVAR                 = '01'

       OTYPE                 = 'O'

       OBJID                 = I_CRHD-HROID

       RSIGN                 = 'B'

       RELAT                 = '002'

       SCLAS                 = 'O'

      BEGDA                 = '19000101'

      ENDDA                 = '99991231'

      SVECT                 = '1234'

      OPEXFLAG              = 'X'

      REFRESH               = 'X'

     TABLES

       DISP_TAB              = I_DISP_TAB_2

       RELAT_TAB             = I_RELAT_TAB_2

    EXCEPTIONS

      NO_ACTIVE_PLVAR       = 1

      OTHERS                = 2.

IF SY-SUBRC <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

   ENDIF.

"""tring to keep a list of each work center that exists under each organization in the I_CRHD internal table

I_ZCRHD_FORCE-ZOBJID = I_DISP_TAB_2-OBJID.

APPEND I_ZCRHD_FORCE.


ENDLOOP.

LOOP AT I_ZCRHD_FORCE.

     CALL FUNCTION '/ISDFPS/FORCE_MNWKCTR'

       EXPORTING

         IV_OBJID       = I_ZCRHD_FORCE-Zobjid

*   IV_PLVAR       =

      IMPORTING

        ES_CRHD        = I_CRHD_2

ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
806

Hi,

it looks you are not loop thru table( I_DISP_TAB_2) output from Function,

Loop  at this table & place this 2 statments in that loop.

I_ZCRHD_FORCE-ZOBJID = I_DISP_TAB_2-OBJID.

APPEND I_ZCRHD_FORCE.

This should fix your problem

Raj Patel

4 REPLIES 4
Read only

Former Member
0 Likes
807

Hi,

it looks you are not loop thru table( I_DISP_TAB_2) output from Function,

Loop  at this table & place this 2 statments in that loop.

I_ZCRHD_FORCE-ZOBJID = I_DISP_TAB_2-OBJID.

APPEND I_ZCRHD_FORCE.

This should fix your problem

Raj Patel

Read only

0 Likes
806

Thank you that worked for me.

Read only

Former Member
0 Likes
806

Hi,

I_DISP_TAB_2 is a table in your example. When you want to use the table entries then you must loop through that table. But you are simply trying to assign the value of WA I_DISP_TAB_2.


If it is a table with header line then I_DISP_TAB_2 means just workarea. But I_DISP_TAB_2[] means the contents in that table. So Please check if you are getting all the entries in the table I_DISP_TAB_2[] in debugging. If you are getting then you just need to loop through that table to append it to different table.


Regards,

Aswath.

Read only

0 Likes
806

Looks like you are also correct.  Thank you for your help as well sir.