cancel
Showing results for 
Search instead for 
Did you mean: 

Need help in optimizing the code

0 Kudos
LOOP AT gi_wtkt_sl_delete_msp INTO lwa_wtkt_sl_del.
DELETE FROM ztsd_wtkt_sl
WHERE zzvbeln EQ lwa_wtkt_sl_del-zzvbeln AND
zzposnr EQ lwa_wtkt_sl_del-zzposnr.
IF sy-subrc EQ 0.
g_no_deleted = g_no_deleted + sy-dbcnt.

DELETE gi_wtkt_sl_delete_fp
WHERE zzvbeln EQ lwa_wtkt_sl_del-zzvbeln AND
zzposnr EQ lwa_wtkt_sl_del-zzposnr. ENDIF.

ENDLOOP.

can you suggest how performance can be optimized for the above code.

vijay_hariharan
Contributor
0 Kudos

Hello,

Just a small part of the code would typically not be enough to optimize the code.. You may need to check if you can reduce the number of records during selection from the corresponding tables themselves so the Loop has reduced number of records.. You may provide further details to get suitable responses..

Regards,
Vijay

Sandra_Rossi
Active Contributor
0 Kudos

Please edit your answer, select your code and press the "CODE" button to make it correctly colorized/indented, so that it's easier for anyone to read it. Thank you.

Accepted Solutions (0)

Answers (3)

Answers (3)

ThorstenHoefer
Active Contributor

Hi saisindhusha,

delete the records directly from the database by the internal table as source

https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abapdelete_source.htm#!ABAP_ALTERNATIVE_2...

DELETE ztsd_wtkt_sl from table gi_wtkt_sl_delete_msp

Greetings

matt
Active Contributor

Define the internal tables as HASHED with unique keys, or SORTED if you don't have unique keys. You'll need to modify your DELETE statement so it works with HASHED tables though.

former_member539238
Participant
0 Kudos
LOOP AT gi_wtkt_sl_delete_msp INTO lwa_wtkt_sl_del.
	DELETE FROM ztsd_wtkt_sl WHERE zzvbeln EQ lwa_wtkt_sl_del-zzvbeln 
				   AND zzposnr EQ lwa_wtkt_sl_del-zzposnr.
	IF sy-subrc EQ 0.
		g_no_deleted = g_no_deleted + sy-dbcnt.
		DELETE gi_wtkt_sl_delete_fp WHERE zzvbeln EQ lwa_wtkt_sl_del-zzvbeln 
					      AND zzposnr EQ lwa_wtkt_sl_del-zzposnr. 
	ENDIF.
ENDLOOP.

Organizing the code