09-17-2014 6:13 AM
hi all
one problem am facing in abap
please any one solve this...
am having 2 files in desktop i upload that files by using gui_upload,
that 2 flies having data that 2 flies data i can transfer to 2 internal tables,
ex: file1 having
customer sortl
110 yb03
139 yb04
150 yb03
2nd file having
customer sortl
110 yb03
149 yb05
160 yb04
same values i don't want in 3 and 4 internal table
pls any one help me these is my coding where was the mistake i don't no...
DATA : BEGIN OF str1,
customer TYPE kna1-kunnr,
search TYPE kna1-sortl,
* loevm TYPE kna1-loevm,
END OF str1.
DATA : BEGIN OF str2,
customer TYPE kna1-kunnr,
search TYPE kna1-sortl,
* loevm TYPE kna1-loevm,
END OF str2.
DATA: it_upload LIKE TABLE OF str1,
it_upload1 LIKE TABLE OF str2,
it_1 LIKE TABLE OF str1,
it_2 LIKE TABLE OF str2,
wa_1 LIKE str1,
wa_2 LIKE str2.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\Users\RR\Desktop\headr.txt'
HAS_FIELD_SEPARATOR = 'X'
TABLES
data_tab = it_upload.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\Users\RR\Desktop\headr1.txt'
HAS_FIELD_SEPARATOR = 'X'
TABLES
data_tab = it_upload1
loop at it_upload INTO wa_1.
read table it_upload1 INTO wa_2 with key search = wa_1-search.
APPEND wa_1 to it_1.
endloop.
loop at it_upload1 INTO wa_2.
read table it_upload1 INTO wa_1 with key search = wa_2-search.
APPEND wa_2 to it_2.
endloop.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\Users\RR\Desktop\DOWNLOAD.txt' "filepath
filetype = 'DAT'
write_field_separator = 'X'
TABLES
data_tab = it_1
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\Users\RR\Desktop\DOWNLOAD1.txt' "filepath
filetype = 'DAT'
write_field_separator = 'X'
TABLES
data_tab = it_2
09-17-2014 6:56 AM
these is actuval correct codeing...
thank u to all..
DATA : BEGIN OF str1,
customer TYPE kna1-kunnr,
search TYPE kna1-sortl,
END OF str1.
DATA : BEGIN OF str2,
customer TYPE kna1-kunnr,
search TYPE kna1-sortl,
END OF str2.
DATA: it_upload LIKE TABLE OF str1,
it_upload1 LIKE TABLE OF str2,
it_1 LIKE TABLE OF str1,
it_2 LIKE TABLE OF str2,
wa_1 LIKE str1,
wa_2 LIKE str2.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\Users\Roopa\Desktop\headr.txt'
HAS_FIELD_SEPARATOR = 'X'
TABLES
data_tab = it_upload
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\Users\Roopa\Desktop\headr1.txt'
TABLES
data_tab = it_upload1
loop at it_upload INTO wa_1.
read table it_upload1 INTO wa_2 with key search = wa_1-search.
if sy-subrc ne 0.
APPEND wa_1 to it_1.
endif.
endloop.
loop at it_upload1 INTO wa_2.
read table it_upload INTO wa_1 with key search = wa_2-search.
if sy-subrc ne 0.
APPEND wa_2 to it_2.
endif.
endloop.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\Users\Roopa\Desktop\DOWNLOAD.txt' "filepath
filetype = 'DAT'
write_field_separator = 'X'
TABLES
data_tab = it_1
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\Users\Roopa\Desktop\DOWNLOAD1.txt' "filepath
filetype = 'DAT'
write_field_separator = 'X'
TABLES
data_tab = it_2
input is :
file 1
customer | sortl |
110 | yb06 |
139 | yb04 |
150 | yb07 |
file2
customer | sortl |
110 | yb03 |
149 | yb05 |
160 | yb04 |
179 | yb08 |
170 | yb09 |
out put is
table 3
110 | yb06 |
150 | yb07 |
table4
110 | yb03 |
149 | yb05 |
179 | yb08 |
170 | yb09 |
thanks & regards,
roopa.
09-17-2014 6:19 AM
loop at it_upload INTO wa_1.
read table it_upload1 INTO wa_2 with key search = wa_1-search.
if sy-subrc ne 0.
APPEND wa_1 to it_1.
endif.
endloop.
loop at it_upload1 INTO wa_2.
read table it_upload INTO wa_1 with key search = wa_2-search.
if sy-subrc ne 0.
APPEND wa_2 to it_2.
endloop.
endif.
09-17-2014 6:32 AM
hi
ranjana,
i tried these also 3rd table is having no data
4 th table is shown correctly..
now am passing 1st file value is
customer | sortl |
110 | yb03 |
139 | yb04 |
150 | yb03 |
129 yb06
159 yb07
2nd file
customer | sortl |
110 | yb03 |
149 | yb05 |
160 | yb04 |
179 | yb08 |
170 | yb09 |
3rd internal table having only
129 | |
159 |
4th table showing corectly
149 | yb05 |
179 | yb08 |
170 | yb09 |
thanks& regards,
roopa
09-17-2014 6:41 AM
Hi Roopa,
Answer is correct if you are comparing only search term.
customer | sortl |
110 | yb03 |
149 | yb05 |
160 | yb04 |
179 | yb08 |
170 | yb09 |
because yb03 and yb04 are already in second internal table, Let me know what is esact requirement whether you want to check both field or only search field?
09-17-2014 6:22 AM
HI roopa,
at the below logic, append to it_1 instead of It_2.
loop at it_upload1 INTO wa_2.
read table it_upload1 INTO wa_1 with key search = wa_2-search.
***APPEND wa_2 to it_2.
APPEND wa_2 to it_1.
endloop.
it may help you..
Best regards,
Krishna
09-17-2014 6:39 AM
hi krishna
we can write append
loop at it_upload1 INTO wa_2.
read table it_upload1 INTO wa_1 with key search = wa_2-search.
***APPEND wa_2 to it_2.
APPEND wa_2 to it_1.
endloop.
like these
every value will pass to the 3rd table, same values we don't want different values e want.
tnaks
roopa.
09-17-2014 6:47 AM
use debug to see if field search null and all data in customer field if you see that replace with key search = wa_1-search with with key customer = wa_1-customer
09-17-2014 6:56 AM
these is actuval correct codeing...
thank u to all..
DATA : BEGIN OF str1,
customer TYPE kna1-kunnr,
search TYPE kna1-sortl,
END OF str1.
DATA : BEGIN OF str2,
customer TYPE kna1-kunnr,
search TYPE kna1-sortl,
END OF str2.
DATA: it_upload LIKE TABLE OF str1,
it_upload1 LIKE TABLE OF str2,
it_1 LIKE TABLE OF str1,
it_2 LIKE TABLE OF str2,
wa_1 LIKE str1,
wa_2 LIKE str2.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\Users\Roopa\Desktop\headr.txt'
HAS_FIELD_SEPARATOR = 'X'
TABLES
data_tab = it_upload
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\Users\Roopa\Desktop\headr1.txt'
TABLES
data_tab = it_upload1
loop at it_upload INTO wa_1.
read table it_upload1 INTO wa_2 with key search = wa_1-search.
if sy-subrc ne 0.
APPEND wa_1 to it_1.
endif.
endloop.
loop at it_upload1 INTO wa_2.
read table it_upload INTO wa_1 with key search = wa_2-search.
if sy-subrc ne 0.
APPEND wa_2 to it_2.
endif.
endloop.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\Users\Roopa\Desktop\DOWNLOAD.txt' "filepath
filetype = 'DAT'
write_field_separator = 'X'
TABLES
data_tab = it_1
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\Users\Roopa\Desktop\DOWNLOAD1.txt' "filepath
filetype = 'DAT'
write_field_separator = 'X'
TABLES
data_tab = it_2
input is :
file 1
customer | sortl |
110 | yb06 |
139 | yb04 |
150 | yb07 |
file2
customer | sortl |
110 | yb03 |
149 | yb05 |
160 | yb04 |
179 | yb08 |
170 | yb09 |
out put is
table 3
110 | yb06 |
150 | yb07 |
table4
110 | yb03 |
149 | yb05 |
179 | yb08 |
170 | yb09 |
thanks & regards,
roopa.