Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

comparison of 2 internal tables and pass the values in new internal tables?

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

Former Member
Former Member replied

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

customersortl
110  yb06
139  yb04
150  yb07

file2

customersortl
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.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question