Skip to Content
author's profile photo Former Member
Former Member

conditional deletion in Internal Table

Hello Gurus,

I am trying to delete selective rows based on the following conditions:

As seen in the screenshot, the first column contains Handling Codes and the last column contains counter values.

If a Handling Code contains MULTIPLE rows with counter value '0', ONLY ONE row must be displayed. It could be the first or last. (0000379651)

If a Handling Code contains only a SINGLE row with counter value '0', it must be displayed. (0000379831)

If a Handling Code contains MULTIPLE rows with counter value '1', ALL rows must be displayed. (0000379834)

If a Handling Code contains MULTIPLE rows with counter values '1' and '0', ALL rows containing value '1' must be displayed and those containing '0' must be omitted. (0000380009)

Plainly said all highlighted rows have to be deleted/suppressed.

How can I achieve this in a routine which I am programming in an APD?

Pls Help. Many Thanks.

SD

Moderator Message: We do not consider it good style to ask questions before trying to find the solution yourself. Please refer in your text also to what you have done already to solve the problem and what resources you have searched or used.

Message was edited by: Kesavadas Thekkillath

9613.gif (11.4 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Feb 26, 2013 at 02:47 PM

    Hi Sebastian,

    This is internal table operation logic. Before passing the internal table to the FM display, use the following logic, U should be able to proceed.

    loop at t_final into wa_final.

    at new vorgangsnummer.

    Aflag = 1.

    endat.

    If Aflag = 0 and wa_final-zahler eq 0 and Bflag = 1..

    delete table t_final from wa_final.

    endif.

    if wa_final-zahler eq 0.

    Bflag = 1.

    endif.

    clear Aflag.

    endloop.

    Thanks

    Vivek

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Sebastian,

      It might be because u did not have another condition for your requirement.

      " If a Handling Code contains MULTIPLE rows with counter value '0', ONLY ONE row must be displayed. It could be the first or last. (0000379651) ".

      And Plz be sure of data consistency after using merge by having diff test data.

      Did u try the above logic I gave. It involves only one loop operation for the requirement.

      Thanks

      Vivek

  • Posted on Feb 26, 2013 at 02:57 PM

    Hi Sebastian,

    You can use this:-

    LOOP AT it_tab INTO wa_tab.

    IF <condition > = fullfilled.

    DELETE it_tab INDEX sy-tabix.

    ENDIF.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 26, 2013 at 03:50 PM

    delete i WHERE a is INITIAL
    AND d EQ 0.

    Where A is first and D is last column.

    Please check and let me know if there are any issues.

    Regards

    Dnyan

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.