Application Development 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: 

Problem using Function Module

Former Member
0 Kudos

Hi,

I am using RH_STRUC_GET with evalPath O-O-S-P and get the or g structure. I then loop through the table obtained from RH_STRUC_GET and re-use RH_STRUC_GET with a evaluation path 'bossonly' to find out who the managers are. But it does not work. I get No ROOTS FOUND error.

When I try the function module RH_STRUC_GET separately with the same input fields then it works!!!

Please let me know if I am doing anything wrong. My code is shown below....

FUNCTION Z_ORGBUILDER_CONN.

*"----


""Local interface:

*" IMPORTING

*" VALUE(OTYPE) LIKE OBJEC-OTYPE

*" VALUE(OBJID) LIKE OBJEC-OBJID

*" VALUE(PATHID) LIKE GDSTR-WEGID

*" VALUE(PLVAR) LIKE OBJEC-PLVAR

*" EXPORTING

*" VALUE(RETURN) LIKE BAPIRET2 STRUCTURE BAPIRET2

*" TABLES

*" L_ZCONN_TAB TYPE ZCONN_TAB

*" RESULT_TAB STRUCTURE SWHACTOR OPTIONAL

*" RESULT_OBJEC STRUCTURE OBJEC OPTIONAL

*" RESULT_STRUC STRUCTURE STRUC OPTIONAL

*" L_ZCONN_ORG TYPE ZCONN_TAB

*" L_ZCONN_POS_HOLDER TYPE ZCONN_POS_TAB

*" L_MANAGERS STRUCTURE OBJEC

*"----


DATA: z_struc type zconn_struc.

DATA: xresult_struc like result_struc.

DATA: yresult_struc like result_struc.

DATA: z_struc1 type zconn_struc.

DATA: z_struc_pos type zconn_position.

DATA: temp_tab LIKE SWHACTOR occurs 0 with HEADER LINE.

DATA: temp like struc-objid.

CALL FUNCTION 'RH_STRUC_GET'

EXPORTING

act_otype = otype

act_objid = objid

act_plvar = plvar

act_wegid = pathid

TABLES

result_tab = result_tab

result_struc = result_struc

result_objec = result_objec

EXCEPTIONS

no_plvar_found = 1

no_entry_found = 2

OTHERS = 3.

IF sy-subrc <> 0.

RAISE no_roots_found.

ENDIF.

LOOP AT result_struc into xresult_struc.

read table result_struc into yresult_struc with key seqnr =

xresult_struc-pup.

if sy-subrc = 0.

z_struc-objectID = xresult_struc-OBJID.

z_struc-objectType = xresult_struc-otype.

z_struc-parentID = yresult_struc-objid.

z_struc-parentType = yresult_struc-otype.

endif.

Append z_struc to l_zconn_tab.

ENDLOOP.

LOOP AT l_zconn_tab.

if l_zconn_tab-objectType = 'O' or l_zconn_tab-objectType = 'S'.

z_struc1-objectID = l_zconn_tab-objectID.

z_struc1-objectType = l_zconn_tab-objectType.

z_struc1-parentID = l_zconn_tab-parentID.

z_struc1-parentType = l_zconn_tab-parentType.

Append z_struc1 to l_zconn_org.

endif.

ENDLOOP.

LOOP AT l_zconn_tab.

if l_zconn_tab-objectType = 'P'.

z_struc_pos-position = l_zconn_tab-parentID.

z_struc_pos-pos_holder = l_zconn_tab-objectID.

Append z_struc_pos to l_zconn_pos_holder.

endif.

ENDLOOP.

loop at result_struc.

if result_struc-otype = 'O'.

CALL FUNCTION 'RH_STRUC_GET'

EXPORTING

act_otype = 'O'

act_objid = result_struc-objid

act_plvar = '01'

act_wegid = 'bossonly'

TABLES

result_tab = temp_tab

EXCEPTIONS

no_plvar_found = 1

no_entry_found = 2

OTHERS = 3.

IF sy-subrc <> 0.

RAISE no_roots_found.

ENDIF.

APPEND LINES OF temp_tab to L_managers.

endif.

endloop.

ENDFUNCTION.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

So when you "test" in SE37 the function module RH_STRUC_GET works correctly? Please debug you "Z" function module and make sure that the values that are being passed to the RH_STRUC_GET are the absolute same as when passing in the "TEST" mode. You might be having a field conversion issue.

Regards,

Rich Heilman

9 REPLIES 9

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

So when you "test" in SE37 the function module RH_STRUC_GET works correctly? Please debug you "Z" function module and make sure that the values that are being passed to the RH_STRUC_GET are the absolute same as when passing in the "TEST" mode. You might be having a field conversion issue.

Regards,

Rich Heilman

0 Kudos

Hi Rich,

I debugged it and there is no problem in the passed in values. Not really sure what is going on...

Thanks!

0 Kudos

What are the values that you are passing to the function module.

Regards,

Rich Heilman

0 Kudos

act_otype = 'O'

act_objid = result_struc-objid

act_plvar = '01'

act_wegid = 'bossonly'

result_struc-objid values are 60000251

60000253

60000254

Regards,

Mark

0 Kudos

Please make sure that BOSSONLY is uppercase. Does it work now?




act_wegid = 'BOSSONLY'

Regards,

Rich Heilman

0 Kudos

Thanks Rich. This is just stupid of me. It wokrs now with BOSSONLY. Didnt realize that it was case sensitive.

Thanks....

0 Kudos

Cool, because other than that, I was not able to re-create your problem. We learn something new everyday!!!

Regards,

Rich Heilman

0 Kudos

Hi Rich,

I have one more question. As you know I am new at ABAP. The function RH_STRUC_GET, when ran with eval path BOSSONLY, returns a table with the org unit and the positions that are the managers.

I need to make a table from this table with two columns.

OrgUnit Manager.

So If one department has more than one manager then I will have more rows with same ID for orgUNIT but different for positions.

I cant get the logic for it. Could you guide me in the right path.

Thanks,

Mark.

0 Kudos



data: begin of itab occurs 0,
      orgunit(10) type c,
      mananger(30) type c,
      end of itab.

* This will add a record to your itab
loop at result.

  itab-orgunit = result-orgunit.   " I don't know what fields they are
  itab-manager = result-manager.
  append itab.

endloop.

Please remember to award points for helpful answers and mark this post as solved if you question has been answered. Thanks.

Regards,

Rich Heilman