Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Comparing the fields of one file to another file

Former Member
0 Kudos

Hi guys,

Is it possible to compare the fields of one file to another file using ABAP?

I have a file extracted from SAP and I want to compare my extracted file to another file using ABAP?

How am I going to do it?

Thanks a lot!

Rgds,

Mark

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi mark,

I don't think it is possible. You may need to read it into internal table and then compare.

Still you can try class CL_GUI_FRONTEND_SERVICES and see if you have any method to compare the files.

Regards,

Atish

6 REPLIES 6

Former Member
0 Kudos

Hi mark,

I don't think it is possible. You may need to read it into internal table and then compare.

Still you can try class CL_GUI_FRONTEND_SERVICES and see if you have any method to compare the files.

Regards,

Atish

0 Kudos

Hi Atish,

Thank you so much...

With the first option (reading into itab)... How is it being done?

How am i going to upload the files and read its contents?

Please note also the header of the file is not always the same...

Thanks a lot!

Rgds,

mark

0 Kudos

Hi Mark,

You need to use FM GUI_UPLOAD to read the data into ITAB. Just search the forum you have lots of sample code of the same. Once you read the data use LOOP ..ENDLOOP and READ to compare two tables data.

Regards,

Atish

0 Kudos

Mark,

How to read the file from appli. server to internal table:

DATA : v_fpath TYPE salfile-longname VALUE

'/data/sapdata/inc/inbox/ppm_maint_plan'.

DATA : BEGIN OF i_records OCCURS 0,

rec TYPE string ,

END OF i_records.

DATA : BEGIN OF it_input,

tplnr LIKE iflot-tplnr,

stjobno(22),

date1(10),

frequency(10),

sortfield(20),

ilart LIKE t353i-ilart,

END OF it_input.

OPEN DATASET v_fpath FOR INPUT IN TEXT MODE.

DO.

READ DATASET v_fpath_te INTO i_records-rec .

IF sy-subrc EQ 0.

SPLIT i_records-rec AT c_coma INTO it_input-tplnr

it_input-stjobno

it_input-date1

it_input-frequency

it_input-sortfield

it_input-ilart.

APPEND it_input.

CLEAR it_input.

ELSE.

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET v_fpath .

Note : it_input is the internal table .If you don't know the columns structure.Declare your internal table (it_input ) fileds as "char" with some length.

Do same thing for another file.

SORT : both internal tables.

LOOP AT it_input.

LOOP AT SECON_internaltable.

compare the fields here..

ENDLOOP.

ENDLOOP.

Pls. reward if useful....

amit_khare
Active Contributor
0 Kudos

first upload both files data

in two internal tables (say itab, ptab)

of same type.

eg: data :

begin of itab occurs 0,

f(500) type c,

end of itab.

then just compare like this.

if itab[ ] = ptab[]

Former Member
0 Kudos

can use this FM

DATA: ld_filename TYPE string,

  • Pre version 4.7 declaration e_file like rlgrap-filename.

DATA: begin of it_datatab occurs 0,

row(500) type c,

end of it_datatab.

call function 'GUI_DOWNLOAD'

exporting

filename = ld_filename

filetype = 'ASC'

tables

data_tab = it_datatab[]

exceptions

file_open_error = 1

file_write_error = 2

others = 3.

Link: [Abap Tips & Notes|http://abap4beginner.blogspot.com]

Edited by: anuar jusoh on May 13, 2008 5:55 AM

Edited by: anuar jusoh on May 13, 2008 5:59 AM