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
644

Hello,

I want to tune the below code, plz help

&----


*& Report ZGET_WORKLIST_ALL_USERS

*&

&----


*&

*&

&----


REPORT ZGET_WORKLIST_ALL_USERS.

TABLES ZIT_ERROR_TAB.

DATA WA_ZIT_ERROR_TAB TYPE ZIT_ERROR_TAB.

*data : T1 type i,

  • T2 type i,

  • T3 type i.

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,

  • it_error_tab TYPE STRING,

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.

*GET RUN TIME FIELD T1.

*SELECT bname FROM usr02 INTO TABLE lt_user.

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

*SELECT bname FROM usr02 INTO TABLE lt_user where bname = '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

  • LANGUAGE = SY-LANGU

  • TRANSLATE_WI_TEXT = ' '

  • IM_TASK_FILTER =

  • IM_STATUS_FILTER =

  • IM_ITEM_TYPE_FILTER =

IMPORTING

  • RETURN_CODE =

worklist = lt_worklist

  • DEADLINE_ITEMS =

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.

*WRITE: / 'Runtime T3= t2-t1 seconds', T3.

5 REPLIES 5
Read only

Former Member
0 Likes
620

Please format the above code so that it ll be easy for us to help you.

Read only

0 Likes
620

Plz find formatted code

REPORT ZGET_WORKLIST_ALL_USERS.

TABLES ZIT_ERROR_TAB.

DATA WA_ZIT_ERROR_TAB TYPE ZIT_ERROR_TAB.

*data : T1 type i,

  • T2 type i,

  • T3 type i.

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,

  • it_error_tab TYPE STRING,

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.

*GET RUN TIME FIELD T1.

*SELECT bname FROM usr02 INTO TABLE lt_user.

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

*SELECT bname FROM usr02 INTO TABLE lt_user where bname = '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

  • LANGUAGE = SY-LANGU

  • TRANSLATE_WI_TEXT = ' '

  • IM_TASK_FILTER =

  • IM_STATUS_FILTER =

  • IM_ITEM_TYPE_FILTER =

IMPORTING

  • RETURN_CODE =

worklist = lt_worklist

  • DEADLINE_ITEMS =

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.

*WRITE: / 'Runtime T3= t2-t1 seconds', T3.

Read only

0 Likes
620

Plz find formatted code

REPORT ZGET_WORKLIST_ALL_USERS.

TABLES ZIT_ERROR_TAB.

DATA WA_ZIT_ERROR_TAB TYPE ZIT_ERROR_TAB.

*data : T1 type i,

  • T2 type i,

  • T3 type i.

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,

  • it_error_tab TYPE STRING,

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.

*GET RUN TIME FIELD T1.

*SELECT bname FROM usr02 INTO TABLE lt_user.

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

*SELECT bname FROM usr02 INTO TABLE lt_user where bname = '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

  • LANGUAGE = SY-LANGU

  • TRANSLATE_WI_TEXT = ' '

  • IM_TASK_FILTER =

  • IM_STATUS_FILTER =

  • IM_ITEM_TYPE_FILTER =

IMPORTING

  • RETURN_CODE =

worklist = lt_worklist

  • DEADLINE_ITEMS =

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.

*WRITE: / 'Runtime T3= t2-t1 seconds', T3.

Read only

Former Member
0 Likes
620

REPORT ZGET_WORKLIST_ALL_USERS. 


 *GET RUN TIME FIELD T1. 

*SELECT bname FROM usr02 INTO TABLE lt_user. 

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

*SELECT bname FROM usr02 INTO TABLE lt_user where bname = '106953'. 

SORT lt_user. DELETE ADJACENT DUPLICATES FROM lt_user. 

LOOP AT lt_user INTO ls_user. 


 loop at lt_worklist into wa_lt_worklist. 


endloop. ENDLOOP. 

use code, use preview and edit !!!!

And actually I don't see what problem you, maybe you are processing just too much!!!

Read only

Former Member
0 Likes
620

If you cannot format your code, it's a dead giveaway that you haven't read . Please read it before posting here.

Thread locked.

Rob