on 09-05-2014 9:25 PM
Hello, I have a minor issue. I want to write an end routine for a field called 'ZIND_F'. Logic is this:
If the first 3 characters of Result_Fields-ZIND_F is 'KTH', then delete that record.
I don't know in abap how to say delete that record.
Can some body please help me?
Thanks.
This is not ABAP training forum.
Message was edited by: Pravender Kumar
Hi Venkat!
How say Nanda, ideally you should realize delete in your initial routine for better performance.
Suvesh routine is correct.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raf,
Before providing piece of code to Venkat , i did similar code on COSTCENTER, while writing here I forget to replace with costcener-->w_ZIND_F. Here is the correct code.
data: w_ZIND_F type data element of ZIND_F.
loop at SOURCE_PACKAGE ASSIGNING <source_fields>.
clear : w_ZIND_F.
w_ZIND_F = <source_fields>-ZIND_F+0(3).
if w_ZIND_F eq 'KTH'.
DELETE SOURCE_PACKAGE INDEX sy-tabix.
endif.
endloop.
Thank you,
Nanda
ABAP code that does a DELETE operation directly on a table via a sy-tabix index should be avoided as much as possible.
When you directly delete entries from the internal table, the sy-tabix value gets messed up. If you ever try to enhance the logic for some additional operation, you will start to see the problems coming in. And then you will most likely end up writing a new LOOP statement and abadoning this LOOP just for this purpose of deletion of records - a big performance hit with 02 x LOOP statements.
It's like working with 10 stacking blocks to reach a certain height - when you step on the 10th block, you take your 1st block and stack it again on top to become the "11th" block.
Suvesh's solution is a much "cleaner" option.
Here is the code in start routine if field ZIND_F in source_structure.
data: w_ZIND_F type data element of ZIND_F.
loop at SOURCE_PACKAGE ASSIGNING <source_fields>.
clear : w_ZIND_F.
w_ZIND_F = <source_fields>-ZIND_F+0(3).
if w_ZIND_F eq 'KTH'.
DELETE SOURCE_PACKAGE INDEX sy-tabix.
endif.
endloop.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
DELETE RESULT_FIELDS WHERE ZIND_F+0(3) = 'KTH'.
Is this correct? if yes mark it as correct
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.