Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

conditional deletion in Internal Table

Former Member
0 Likes
913

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

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

6 REPLIES 6
Read only

Former Member
0 Likes
880

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

Read only

0 Likes
880

Hi Vivek,

thanks for your reply. I have used the following logic...

1. copied all records with counter value '0' in internal table it_1

2. deleted adjacent duplicates in it_1. Hence i am left with the desired records

3. copied all records with counter value '1' in internal table it_2

4. merged it_1 and it_2.

This logic works fine. The only problem is that in case of handling number 0000380009 I am left with 2 records i.e. one record with value '1' and the other with value '0'. How do I overcome this? I have attached the code.

Thanks,

SD

Read only

0 Likes
880

Hi Vivek,

thanks for your reply. I have used the following logic...

1. copied all records with counter value '0' in internal table it_1

2. deleted adjacent duplicates in it_1. Hence i am left with the desired records

3. copied all records with counter value '1' in internal table it_2

4. merged it_1 and it_2.

This logic works fine. The only problem is that in case of handling number 0000380009 I am left with 2 records i.e. one record with value '1' and the other with value '0'. How do I overcome this? I have attached the code.

Thanks,

SD

Read only

0 Likes
880

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

Read only

bishwajit_das
Active Contributor
0 Likes
880

Hi Sebastian,

You can use this:-

LOOP AT it_tab INTO wa_tab.

IF <condition > = fullfilled.

       DELETE it_tab INDEX sy-tabix.

ENDIF.

ENDLOOP.

Read only

Former Member
0 Likes
880

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