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

Code optimzation issue

Former Member
0 Likes
552

Hi All,

I have following code in one z program for Organization structure. But there is big performance issue, because the function module 'RH_STRUC_GET_MULTIPLE_ROOTS' is fetching approximately 7000 records for each Org unit. Then it loops through the internal table and assigns Sign = I option = EQ. There are total 355 org unit in the selection. Therefore program is looping through 355 * 7000 = records. Two tables lt_obj and lr_hrg have only PERNR field in them.

Please help in optimizing the code. The standard function module is taking lot of time. Is there any other equivalent FM for this.

CALL FUNCTION 'RH_STRUC_GET_MULTIPLE_ROOTS'

EXPORTING

act_wegid = p_wegid

act_begda = p_edate

act_endda = p_edate

TABLES

root_objects = lt_root

result_objec = lt_objec

EXCEPTIONS

no_plvar_found = 1

no_entry_found = 2

path_not_found = 3

root_not_found = 4

OTHERS = 5.

IF sy-subrc IS INITIAL.

DELETE lt_objec WHERE otype NE g_otype.

ENDIF.

LOOP AT lt_objec INTO ls_objec.

rs_obj-sign = 'I'.

rs_obj-option = 'EQ'.

rs_obj-low = ls_objec-objid.

APPEND rs_obj TO pr_obj.

ENDLOOP.

SORT lt_obj BY otype objid.

DELETE ADJACENT DUPLICATES FROM lt_obj COMPARING otype objid.

DELETE lt_obj WHERE objid NOT IN lr_hrg.

DELETE lt_obj WHERE objid NOT IN lr_csg.

DELETE lt_obj WHERE objid NOT IN lr_org.

DELETE lt_obj WHERE objid NOT IN lr_pos.

DELETE lt_obj WHERE objid NOT IN lr_func.

DELETE lt_obj WHERE objid NOT IN lr_orgl.

Thanks.

3 REPLIES 3
Read only

Former Member
0 Likes
493

Hi Sonali,

If structure of IT_OBJEC and IT_OBJ is same you can use APPEND LINES OF IT_OBJEC TO IT_OBJ.

Sort it and delete adjacent duplicates.

Let me know if this does not helps.

Mubeen

Read only

0 Likes
493

The tables have different structures.

Read only

Former Member
0 Likes
493

copy and create a zfm of this standard fm and add checks inside the fm itself before any selct query it is using.