‎2008 Jun 25 10:43 AM
i have two dynamic tables, <fs_t1> and <fs_t2> . they have the same structure. one is a table built from the user uploaded excel sheet and the other is a table built from the database. now i want to compare the two tables field by field. If some field does not match, i need to store a error message in some table specifying the field name which does not match. can anyone tell me how do i go about this????
‎2008 Jun 25 10:47 AM
Sort the tables. Check that they have the same number of entries. If they do, loop through one table into a workarea (wa1). Read a record with the SAME index (sy-tabix), in the other table into a workarea (wa2). Check each field of WA1 is the same as the fields in WA2. If these are field-symbol workareas, where you don't know the structure until runtime, then run through all the fields using
ASSIGN COMPONENT number OF STRUCTURE...
matt
‎2008 Jun 25 11:03 AM
During the building of the dynamic internal tables, count the no. of fields of tables.
then
loop at <fs_t1> assigning to <fs_wa1>.
do v_var1 times.
assign component v_var1 of structure <fs_wa1> to <fs_f1>.
read table <fs_t2> assigning to <fs_wa2> with key field1 = <fs_wa>-field1.
if sy-subrc eq 0.
assign v_var1 of structure <fs_wa2> to <fs_f2>.
if <fs_f1> eq <fs_f2>.
continue.
else.
*move to the error internal table.
endif.
clear: <fs_f1>, <fs_f2>,<fs_wa2>.
enddo.
endloop.Regards
Kannaiah
‎2008 Jun 25 11:16 AM
‎2008 Jun 25 11:30 AM
describe table <fs_t2> lines v_line1.
loop at <fs_t1> assigning to <fs_wa1>.
do v_var1 times.
assign component v_var1 of structure <fs_wa1> to <fs_f1>.
if v_count LE v_line1.
read table <fs_t2> assigning to <fs_wa2> index v_count .
if sy-subrc eq 0.
assign v_var1 of structure <fs_wa2> to <fs_f2>.
if <fs_f1> eq <fs_f2>.
continue.
else.
*move to the error internal table.
endif.
endif.
clear: <fs_f1>, <fs_f2>,<fs_wa2>.
enddo.
v_count = v_count + 1.
endloop.Regards
Kannaiah