01-03-2014 11:45 AM
Hello,
I created start and end routine to enhance some other data.
Actually it works fine. Results correct. But DTP needs really lot of time. In process monitor the steps transformation start, start rountine, rules and end routine do not need much time. Problem is the step "transformation end".
Can you tell me how I can optimize coding?
Global:
*$*$ begin of global - insert your declaration only below this line *-*
... "insert your code here
* 20120326 2462
* Deklaration interne Tabelle und Workarea
* Partnerrollen füllen
DATA: lt_zsd_cus_p TYPE STANDARD TABLE OF /bic/azsd_d2200
WITH NON-UNIQUE KEY salesorg
division
distr_chan
part_funct
/bic/zsd_cus_p
/bic/zsd_par_c.
DATA: ls_zsd_cus_p LIKE LINE OF lt_zsd_cus_p.
*$*$ end of global - insert your declaration only before this line *-*
Start routine:
*$*$ begin of routine - insert your code only below this line *-*
... "insert your code here
*-- fill table "MONITOR" with values of structure "MONITOR_REC"
*- to make monitor entries
... "to cancel the update process
* raise exception type CX_RSROUT_ABORT.
* 20120326 2462
* Füllen der internen Tabellen
" BREAK-POINT.
SELECT * FROM /bic/azsd_d2200
INTO TABLE lt_zsd_cus_p.
SORT lt_zsd_cus_p
BY salesorg ASCENDING
division ASCENDING
distr_chan ASCENDING
/bic/zsd_cus_p ASCENDING
part_funct ASCENDING
/bic/zsd_par_c DESCENDING.
DELETE ADJACENT DUPLICATES FROM lt_zsd_cus_p
COMPARING salesorg
division
distr_chan
/bic/zsd_cus_p
part_funct.
*$*$ end of routine - insert your code only before this line *-*
End routine:
*$*$ begin of routine - insert your code only below this line *-*
... "insert your code here
*-- fill table "MONITOR" with values of structure "MONITOR_REC"
*- to make monitor entries
... "to cancel the update process
* raise exception type CX_RSROUT_ABORT.
* 20120327 2462
* Füllen der Partnerrollen in die Attributen von 0cust_sales
DATA: lt_rp LIKE RESULT_PACKAGE.
DATA: lv_count TYPE i.
BREAK-POINT.
LOOP AT RESULT_PACKAGE ASSIGNING <result_fields>.
* Außendienstmitarbeiter 1 (zsd_adm_s)
READ TABLE lt_zsd_cus_p
INTO ls_zsd_cus_p
WITH KEY salesorg = <result_fields>-salesorg
division = <result_fields>-division
distr_chan = <result_fields>-distr_chan
/bic/zsd_cus_p = <result_fields>-cust_sales
part_funct = 'ZA'.
IF sy-subrc = '0'.
<result_fields>-/bic/zsd_adm_s = ls_zsd_cus_p-/bic/zsd_partn.
ENDIF.
CLEAR ls_zsd_cus_p.
* Außendienstmitarbeiter 2 (zsd_ad2_s)
READ TABLE lt_zsd_cus_p
INTO ls_zsd_cus_p
WITH KEY salesorg = <result_fields>-salesorg
division = <result_fields>-division
distr_chan = <result_fields>-distr_chan
/bic/zsd_cus_p = <result_fields>-cust_sales
part_funct = 'ZB'.
IF sy-subrc = '0'.
<result_fields>-/bic/zsd_ad2_s = ls_zsd_cus_p-/bic/zsd_partn.
ENDIF.
CLEAR ls_zsd_cus_p.
* Außendienstmitarbeiter 3 (zsd_ad3_s)
READ TABLE lt_zsd_cus_p
INTO ls_zsd_cus_p
WITH KEY salesorg = <result_fields>-salesorg
division = <result_fields>-division
distr_chan = <result_fields>-distr_chan
/bic/zsd_cus_p = <result_fields>-cust_sales
part_funct = 'ZC'.
IF sy-subrc = '0'.
<result_fields>-/bic/zsd_ad3_s = ls_zsd_cus_p-/bic/zsd_partn.
ENDIF.
CLEAR ls_zsd_cus_p.
* Außendienstmitarbeiter 4 (zsd_ad4_s)
READ TABLE lt_zsd_cus_p
INTO ls_zsd_cus_p
WITH KEY salesorg = <result_fields>-salesorg
division = <result_fields>-division
distr_chan = <result_fields>-distr_chan
/bic/zsd_cus_p = <result_fields>-cust_sales
part_funct = 'ZD'.
IF sy-subrc = '0'.
<result_fields>-/bic/zsd_ad4_s = ls_zsd_cus_p-/bic/zsd_partn.
ENDIF.
CLEAR ls_zsd_cus_p.
* Außendienstmitarbeiter 5 (zsd_ad5_s)
READ TABLE lt_zsd_cus_p
INTO ls_zsd_cus_p
WITH KEY salesorg = <result_fields>-salesorg
division = <result_fields>-division
distr_chan = <result_fields>-distr_chan
/bic/zsd_cus_p = <result_fields>-cust_sales
part_funct = 'ZE'.
IF sy-subrc = '0'.
<result_fields>-/bic/zsd_ad5_s = ls_zsd_cus_p-/bic/zsd_partn.
ENDIF.
CLEAR ls_zsd_cus_p.
ENDLOOP.
*$*$ end of routine - insert your code only before this line *-*
I hope you can help me!
Regards
Jesper
01-03-2014 12:20 PM
Hi Jasper,
Before looping SORT lt_zsd_cus_p BY salesorg division distr_chan /bic/zsd_cus_p part_finct and then use binary search while read internal table . check below code :
SORT lt_zsd_cus_p BY salesorg division distr_chan /bic/zsd_cus_p part_finct.
LOOP.
READ TABLE lt_zsd_cus_p
INTO ls_zsd_cus_p
WITH KEY salesorg = <result_fields>-salesorg
division = <result_fields>-division
distr_chan = <result_fields>-distr_chan
/bic/zsd_cus_p = <result_fields>-cust_sales
part_funct = 'ZA' BINARY SEARCH.
ENDLOOP
Try this . Binary search will improve performance. Please don't forget to SORT internal table else data inconsitency could be happen.
Thanks
Deependra
01-03-2014 12:20 PM
Hi Jasper,
Before looping SORT lt_zsd_cus_p BY salesorg division distr_chan /bic/zsd_cus_p part_finct and then use binary search while read internal table . check below code :
SORT lt_zsd_cus_p BY salesorg division distr_chan /bic/zsd_cus_p part_finct.
LOOP.
READ TABLE lt_zsd_cus_p
INTO ls_zsd_cus_p
WITH KEY salesorg = <result_fields>-salesorg
division = <result_fields>-division
distr_chan = <result_fields>-distr_chan
/bic/zsd_cus_p = <result_fields>-cust_sales
part_funct = 'ZA' BINARY SEARCH.
ENDLOOP
Try this . Binary search will improve performance. Please don't forget to SORT internal table else data inconsitency could be happen.
Thanks
Deependra
01-09-2014 1:54 PM
Hi,
thanks! This helped a lot. From 6 hours to 2 minutes. Perfect!
Regards
Jesper
01-03-2014 12:48 PM
Hi Jesper,
SELECT * FROM /bic/azsd_d2200
INTO TABLE lt_zsd_cus_p.
Instead select all the rows, try to use like below.
SELECT * FROM /bic/azsd_d2200
INTO TABLE lt_zsd_cus_p for all entries in SOURCE_PACKAGE
where SOURCE_PACKAGE-salesorg
division = SOURCE_PACKAGE-division
distr_chan = SOURCE_PACKAGE-istr_chan
/bic/zsd_cus_p = SOURCE_PACKAGE-cust_sales
part_funct = 'ZD'.
Arivazhagan S