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

Performance Tuning Tips for the below code

Former Member
0 Likes
778
REPORT ZGET_WORKLIST_ALL_USERS.

TABLES ZIT_ERROR_TAB.

DATA WA_ZIT_ERROR_TAB TYPE ZIT_ERROR_TAB.

DATA: lt_user TYPE zuser_tt,
ls_user TYPE zuser_sty.

DATA: lt_worklist TYPE uwlitemlist,
lt_messages TYPE TABLE OF swr_messag,
lt_mess_struct TYPE TABLE OF swr_mstruc.



DATA: CREATED_TIME(22) type c,

wa_lt_worklist like line of lt_worklist,
go_sys_exception TYPE REF TO cx_ai_system_fault,
employee_data TYPE REF TO ZPI_CO_SI_EP001_ACTION_ITEM_MA,
output type ZPI_MT_EP001_ACTION_ITEM,
employee_rec type ZPI_DT_EP001_ACTION_ITEM_SUMMA,
employee type ZPI_DT_EP001_ACTION_ITEM_S_TAB,
n type i.



n = 1.





SELECT bname FROM usr02 INTO TABLE lt_user where bname between '101930' and '106953'.



SORT lt_user.



DELETE ADJACENT DUPLICATES FROM lt_user.



LOOP AT lt_user INTO ls_user.

CLEAR lt_worklist.

CLEAR lt_messages.


CLEAR lt_mess_struct.



CALL FUNCTION 'SWN_UWL_GET_WORKLIST'


EXPORTING

user = ls_user-bname
IMPORTING


worklist = lt_worklist

TABLES
message_lines = lt_messages


message_struct = lt_mess_struct.



loop at lt_worklist into wa_lt_worklist.


employee_rec-USER_ID = wa_lt_worklist-USER_ID.

employee_rec-SUBJECT = wa_lt_worklist-SUBJECT.


CREATED_TIME = wa_lt_worklist-CREATED_TIME.

employee_rec-CREATED_TIME = CREATED_TIME+0(14).


employee_rec-FORWARDED_BY = wa_lt_worklist-FORWARDED_BY.


employee_rec-IDENTITY_NUMBER = n.


append employee_rec to employee.

clear employee_rec.


n = n + 1.

endloop.


ENDLOOP.



output-MT_EP001_ACTION_ITEM-SUMMARY_EMAIL_ACTION_ITEM = employee.


TRY.

CREATE OBJECT employee_data.

call method employee_data->UPLOAD_ACTION_ITEM


EXPORTING

OUTPUT = output.

commit work.

CATCH cx_ai_system_fault INTO go_sys_exception.


WA_ZIT_ERROR_TAB-message = go_sys_exception->errortext.

WA_ZIT_ERROR_TAB-code = go_sys_exception->code.

WA_ZIT_ERROR_TAB-errordate = sy-datum.


insert into ZIT_ERROR_TAB values wa_ZIT_ERROR_TAB.


ENDTRY.


WRITE: / 'no of records', n.

*GET RUN TIME FIELD T2.


* T3 = T2 - T1.

* T3 = T3 / 1000000.

*WRITE: / 'Runtime T1', T1.
*WRITE: / 'Runtime T2', T2.

- Draft saved at

Moderator message - please do some work yourself before posting code - and format it as well - post locked.

Edited by: Rob Burbank on May 18, 2009 12:31 PM

5 REPLIES 5
Read only

Former Member
0 Likes
753

Hello Friends,

I am trying to perform tune the given code. I am not finding anything which can be improved. can you plz give any tip.

Thanks and Regards,

sameer.

Read only

0 Likes
753

Have you already established, where exactly in your code the 'problem' is? Is the LOOP within LOOP giving you problems, is it the COMMIT (create employee), or the function module which is called xxx times?

There could be several ways of approving, but you should first do a performance trace to determine the exact point(s).

Read only

Former Member
0 Likes
753

SORT lt_user. --->>> by xxx ascending yyy descending..

CLEAR lt_worklist.

CLEAR lt_messages.

CLEAR lt_mess_struct. -


>> clear : xxx, yyy, zzz. collective clear.

n type i.

n = 1.---> n type i value 1.

created_time = wa_lt_worklist-created_time.

employee_rec-created_time = created_time+0(14).

---> directly employee_rec-created_time = wa_lt_worklist-created_time+0(14)

You are not using tables parameters...so why to clear add send them to function modules!

(lt_messages & lt_mess_struct)

INSERT into zit_error_tab values wa_zit_error_tab.

---> append wa_zit_error_tab to zit_error_tab values ..can't use this???

Edited by: Veeranji Reddy on May 18, 2009 11:33 AM

Read only

ThomasZloch
Active Contributor
0 Likes
753

> I am not finding anything which can be improved

Great, so why post here at all?

Read only

0 Likes
753

no need of few statements like

the "delete adjacent" as there can be ONLY 1 entry possible for 1 bname.

sort statement should be written with a field name on which u want to sort.

avoid the loop inside loop when ever possible.