2013 Feb 26 12:36 PM
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
2013 Feb 26 2: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
2013 Feb 28 1:24 PM
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
2013 Feb 28 1:25 PM
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
2013 Feb 28 2:15 PM
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
2013 Feb 26 2: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.
2013 Feb 26 3: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
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |