‎2009 Apr 08 2:14 PM
Dear All,
I have one ITAB with content
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
I have one more itab with content
1
2
3
4
5
6
7
8
9
10
Now, I want my final itab with
11
12
13
14
15
16
17
18
19
20
How can I do this without using loop statement ?
As of now I have both the tables data in one final tab.
Now, I've to delete the duplicates and originals which are having duplicates from this final table.
Any clues ?
FYI...
TYPES: BEGIN OF ty_tab,
field1 TYPE char50,
END OF ty_tab.
DATA: it_tab1 TYPE STANDARD TABLE OF ty_tab,
it_tab2 TYPE STANDARD TABLE OF ty_tab,
it_final TYPE STANDARD TABLE OF ty_tab.
DATA: lv_fname TYPE string.
Data: r_field1 like RSDSSELOPT.
PARAMETERS: p_file1 TYPE rlgrap-filename,
p_file2 TYPE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file1.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file2.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file2.
r_field1-sign = 'I'.
START-OF-SELECTION.
IF p_file1 IS NOT INITIAL.
CLEAR lv_fname.
lv_fname = p_file1.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_fname
* FILETYPE = 'ASC'
TABLES
data_tab = it_tab1
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
IF p_file2 IS NOT INITIAL.
CLEAR lv_fname.
lv_fname = p_file2.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_fname
* FILETYPE = 'ASC'
TABLES
data_tab = it_tab2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
SORT: it_tab1,it_tab2.
APPEND: LINES OF it_tab1 TO it_final,
LINES OF it_tab2 TO it_final.
SORT it_final by field1.
" DELETE originals and duplicates with duplicates ?????
* Download
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = 'C:\Temp\File1.txt'
TABLES
data_tab = it_final
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards,
Deepu.K
‎2009 Apr 08 2:27 PM
Hi use delete adjacent duplicates to delete the duplicates, and then use delete with index to delete the originals. You can do it easily with loop statement. Dont know why you have this restriction. Orelse you have to have some extra field in internal table to mark duplicates and delete the internal table where field = 'X'.
‎2009 Apr 08 2:16 PM
Hi,
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING .... --> YOUR FIELD.
REGARDS,
R K.
‎2009 Apr 08 2:18 PM
APPEND: LINES OF it_tab1 TO it_final,
LINES OF it_tab2 TO it_final.
SORT it_final by field1.
delete ADJACENT duplicates from it_final comparing field1.
‎2009 Apr 08 2:21 PM
Delete adjacent duplicates will delete only the duplicates but i want the originals also to be deleted.
Hope I'm clear !!!!
‎2009 Apr 08 2:30 PM
loop at itab.
read table jtab where f1 = itab-f1.
if sy-subrc eq 0.
delete itab.
endif.
endloop.
‎2009 Apr 08 2:20 PM
If both of the itabs have the same structure, append the lines of one itab to another and then use the delete duplicate statement, else there is no way but to loop and compare.
regards,
Advait
‎2009 Apr 08 2:22 PM
HI,
do in this manner it will solve your problem:
1) sort final tab
2) delete adjacent duplicates from final tab comparing field name
3) delete the rows 1 to 10 using index from final tab
syntax: DELETE <itab> [FROM <n1>] [TO <n2>]
all lines between <n1> and <n2> are deleted
hope it will help you
regards
rahul
‎2009 Apr 08 2:27 PM
Hi use delete adjacent duplicates to delete the duplicates, and then use delete with index to delete the originals. You can do it easily with loop statement. Dont know why you have this restriction. Orelse you have to have some extra field in internal table to mark duplicates and delete the internal table where field = 'X'.
‎2009 Apr 08 3:12 PM
suppose the first table is itab1 and second is itab2 with header and fields are f1 in both tables..
data: index type i,
loop at itab1.
index = sy-tabix.
read itab2 with key f1 = itab1-f1.
if sy-subrc eq 0.
delete itab1 index index.
endif.
endloop.Hope this satisfies your requirement.
Regards,
Lalit Mohan Gupta.
‎2009 Apr 08 3:25 PM
suppose the first table is itab1 and second is itab2 with header and fields are f1 in both tables..
Loop at itab2.
delete itab1 where field = itab2-field.
endloop.
Kiran
‎2009 Apr 08 3:35 PM
Hi,
Without any loop statement you may need to define 2 range like internal tables IR_TAB1 and IR_TAB2 corresponding to IT_TAB1 and IT_TAB2 and put entries of IT* to IR* (a function module for that ???) then do this.
DELETE it_final where <fieldvalue> IN ir_tab1 and <fieldvalue> IN ir_tab2.
This does not fully answer to your question but doing so may help you to find a way to solve your problem.
Issa