2008 Dec 03 9:02 AM
in my report at one point they are collecting all the records into one internal table using the syntax
collect rrb_tab.
but im getting double records in some cases . so i want to avoid that.
so after this collect statement can i use delete adjacent duplicate syntax as follows
collect rrb_ab.
DELETE ADJACENT DUPLICATES FROM RRB_TAB.
plz suggest me if i an use like this
2008 Dec 03 9:06 AM
Hi
its better 2 use the comparing option...
DELETE ADJACENT DUPLICATES FROM RRB_TAB COMPARING field1field2.
or
DELETE ADJACENT DUPLICATES FROM RRB_TAB COMPARING ALL FIELDS.
the former will compare the fileds n if ny duplicated in dose fields, only den it will delete dose records.
the latter,it will compare all de fields...if ny 2 records, with all fields same, it wil delete.
Regards
Winnie
in my report at one point they are collecting all the records into one internal table using the syntax
collect rrb_tab.
but im getting double records in some cases . so i want to avoid that.
so after this collect statement can i use delete adjacent duplicate syntax as follows
collect rrb_ab.
DELETE ADJACENT DUPLICATES FROM RRB_TAB.
plz suggest me if i an use like this
2008 Dec 03 9:04 AM
2008 Dec 03 9:05 AM
Hi ,
First Sort the fields..and then delete adjacent duplicates comparing sorted fields..
Regards,
Sachin M M
2008 Dec 03 9:05 AM
use Addition
... COMPARING {comp1 comp2 ...}|{ALL FIELDS}
with delete adjus.....
2008 Dec 03 9:05 AM
ya you can try using that.
delete adjacent duplicates from rrb_tab based on the field which you want to comapre by adding
delete adjacent duplicates from rrb_tab comparing(fields)
Edited by: Rahul Kumar Sinha on Dec 3, 2008 10:06 AM
2008 Dec 03 9:06 AM
Hi
its better 2 use the comparing option...
DELETE ADJACENT DUPLICATES FROM RRB_TAB COMPARING field1field2.
or
DELETE ADJACENT DUPLICATES FROM RRB_TAB COMPARING ALL FIELDS.
the former will compare the fileds n if ny duplicated in dose fields, only den it will delete dose records.
the latter,it will compare all de fields...if ny 2 records, with all fields same, it wil delete.
Regards
Winnie
2008 Dec 03 9:14 AM
SORT IT_TAB1 by matnr DATS DESCENDING.
then use delete adjacent duplicates from it_itab1 comparing matnr.
2008 Dec 03 9:13 AM
Hi pavan,
you should first sort your internal table before deleting duplicates and then you can use the delete statement as below:
SORT it_cawn BY atinn atzhl
adzhl.
DELETE ADJACENT DUPLICATES FROM rrb_tab COMPARING < the fields that were used for sorting seperated by spaces/ or the key fields>.
Regards,
Nikita
2008 Dec 03 9:15 AM
Hi,
Sort the internal table by key fields and then delete it.
SORT itab BY <keyfield>.
DELETE ADJACENT DUPLICATES FROM itab COMPARING <keyfield>
Regards,
K.Tharani.
2008 Dec 03 9:34 AM
Hi,
To avoid getting duplicates in the table RRB_TAB you can define the fields that are duplicating as key fields of the internal table. That way the duplicates will be avoided when doing the collect itself. Thus avoiding the use of the statment delete adjacent duplicates..
regards,
Advait
2008 Dec 03 9:51 AM
Here is a simple example for the collect based on my reply above :
REPORT z_collect_table .
TYPES : BEGIN OF t1,
col1(20) TYPE c,
col2 TYPE i,
END OF t1.
DATA gt_tab TYPE STANDARD TABLE OF t1.
DATA gt_tab_collect TYPE STANDARD TABLE OF t1 WITH KEY col1.
DATA : gwa_tab TYPE t1.
gwa_tab-col1 = 'Sam'.
gwa_tab-col2 = 1000.
APPEND gwa_tab TO gt_tab.
gwa_tab-col1 = 'Sam'.
gwa_tab-col2 = 1000.
APPEND gwa_tab TO gt_tab.
gwa_tab-col1 = 'Sam'.
gwa_tab-col2 = 1000.
APPEND gwa_tab TO gt_tab.
gwa_tab-col1 = 'Sam'.
gwa_tab-col2 = 1000.
APPEND gwa_tab TO gt_tab.
LOOP AT gt_tab INTO gwa_tab.
COLLECT gwa_tab INTO gt_tab_collect.
ENDLOOP.
LOOP AT gt_tab_collect INTO gwa_tab.
WRITE : / gwa_tab-col1, 10 gwa_tab-col2.
ENDLOOP.
"Output of the report is :
Collect statement
Sam 4.000
regards,
Advait
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |