on 04-11-2006 8:36 AM
Hi,
I have to compare the workarea of 2 internal tables comparing all fields of the workareas. One work area has fields from the flat file and the other workarea has fields from the master table. If all the fields of the work areas are same then we do not update the master table. Each workarea has 15 fields without explicitly mentioning the field names is there a way of comparing all fields ??
Thanks in advance.
let ITAB be the first internal table.WA BE THE WORK AREA
ITAB1 be the second internal table.WA1 BE THE WORK AREA
CREATE ATHIRD ITABLE , LET IT BE ITAB2.
ITAB2[] = ITAB[].
APPEND ITAB2.
U CAN USE THE FOLLOWING LOGIC.
LOOP AT ITAB1 TO WA1.
APPEND ITAB1 TO ITAB2.
ENDLOOP.
SORT ITAB2.
DELETE ADJACENT DUPLICATES FROM ITAB2 COMPARING ALL FIELDS.
DESCRIBE TABLE ITAB LINE V_LINE
DESCRIBE TABLE ITAB2 LINES V_LINE2.
IF V_LINE = V_LINE2.
"MEANS ALL THE RECORDS ARE SAME".
ELSE.
"DIFFERENT."
LOOP AT ITAB2.
IF SY-TAIX > V_LINE.
UPDATE DBTAB.
ENDIF.
ENDLOOP.
ENDIF.
Message was edited by: Hymavathi Oruganti
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Reshmi,
You can compare internal tables using the foll.concept.
Suppose itab1 and itab2 are two int.tables.
when you say
if itab1 < itab2.
1) no:of entries in both tables are compared.
2) if no: of entries are same, content of 1st entry of 1st table will be compared with that of 2nd table and so on.
3)Else , one with greater no: of entries will be greater.
I think same logic is applicable to their workareas also.
Just check the following link for more details.
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3841358411d1829f0000e829fbfe/content.htm
Regards,
SP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
if itab1_wa <> itab2_wa .
"they are not equal.
else.
"they are equal.
endif.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Rashmi,
If your fields are of same field definations and in same order, then you can directlry compare like,
if wa_file <> wa_master.
update...
endif.
regards,
Naimesh
Reward points, if it is useful..!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Reshmi
one of the best solution to do that is to add a field in the 2 tables where you'll store the concatenation of the 15 first fields.
ex :
data : begin of Tab1 occurs 0,
field1
field2
...
field15
field16(200) type c,
end of Tab1
data : Tab2 like tab1 occurs 0 with header line.
concatenate tab1-field1 tab1-field2 tab1-field3...
into tab1-field16.
concatenate tab2-field1 tab2-field2 tab2-field3...
into tab2-field16.
*AND you just have to loop on the table you want and *compare with the other one on the field 'field16'
loop at tab1.
if tab1-field16 <> tab2-field16
...
...
Hope this helps,
Erwan.
Hi Rashmi
Try like this...
LOOP AT it_ekko.
READ TABLE it_mseg WITH KEY ebeln = it_ekko-ebeln.
IF sy-subrc <> 0.
DELETE it_ekko.
continue.
ENDIF.
ENDLOOP.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.