Skip to Content
0
Former Member
Apr 30, 2014 at 01:19 PM

function module call inside loop on internal table

831 Views

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.