cancel
Showing results for 
Search instead for 
Did you mean: 

End Routine Query

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

fcorodriguezl
Contributor
0 Kudos

Hi Venkat!

How say Nanda, ideally you should realize delete in your initial routine for better performance.

Suvesh routine is correct.

Regards.

RafkeMagic
Active Contributor
0 Kudos

I'd say both are incorrect...

first one should be deleting from RESULT_PACKAGE (which is the table)

second one should do a check on w_ZIND_F (instead of w_COSTCENTER - no clue where that all of a sudden came from?)

ccc_ccc
Active Contributor
0 Kudos

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

former_member182429
Active Participant
0 Kudos

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.

ccc_ccc
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

DELETE RESULT_FIELDS WHERE ZIND_F+0(3) = 'KTH'.

Is this correct? if yes mark it as correct