2007 Aug 01 1:26 PM
Need to know how to compare fields in Internal Tables.
The Requirement is : to compare The fields in both the internal tables are the same.
There are about 20-21 fields in the internal tables.
Please suggest.
Thanks
2007 Aug 01 2:24 PM
describe line of table itab1 count 1 = 25.
describe line table tab2 count2 =26
if count1 = count2.
endif.
Need to know how to compare fields in Internal Tables.
The Requirement is : to compare The fields in both the internal tables are the same.
There are about 20-21 fields in the internal tables.
Please suggest.
Thanks
2007 Aug 01 1:28 PM
Use
if itab1[] = itab2[].
Reward points if helpful.
Regards.
Srikanta Gope
2007 Aug 01 1:30 PM
Hi,
Look at the below link
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3841358411d1829f0000e829fbfe/content.htm
Regards
Sudheer
2007 Aug 01 1:31 PM
For tables without header line...
u can use :
CHECK itab1 EQ itab2.
and for itabs with header line..
CHECK itab1[] EQ itab2[].
Reward if useful
Regards
Prax
2007 Aug 01 1:31 PM
DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA: ITAB LIKE TABLE OF LINE,
JTAB LIKE TABLE OF LINE.
DO 3 TIMES.
LINE-COL1 = SY-INDEX.
LINE-COL2 = SY-INDEX ** 2.
APPEND LINE TO ITAB.
ENDDO.
MOVE ITAB TO JTAB.
LINE-COL1 = 10. LINE-COL2 = 20.
APPEND LINE TO ITAB.
IF ITAB GT JTAB.
WRITE / 'ITAB GT JTAB'.
ENDIF.
APPEND LINE TO JTAB.
IF ITAB EQ JTAB.
WRITE / 'ITAB EQ JTAB'.
ENDIF.
LINE-COL1 = 30. LINE-COL2 = 80.
APPEND LINE TO ITAB.
IF JTAB LE ITAB.
WRITE / 'JTAB LE ITAB'.
ENDIF.
LINE-COL1 = 50. LINE-COL2 = 60.
APPEND LINE TO JTAB.
IF ITAB NE JTAB.
WRITE / 'ITAB NE JTAB'.
ENDIF.
IF ITAB LT JTAB.
WRITE / 'ITAB LT JTAB'.
ENDIF.
The output is:
ITAB GT JTAB
ITAB EQ JTAB
JTAB LE ITAB
ITAB NE JTAB
ITAB LT JTAB
This example creates two standard tables, ITAB and JTAB. ITAB is filled with 3 lines and copied to JTAB. Then, another line is appended to ITAB and the first logical expression tests whether ITAB is greater than JTAB. After appending the same line to JTAB, the second logical expression tests whether both tables are equal. Then, another line is appended to ITAB and the third logical expressions tests whether JTAB is less than or equal to ITAB. Next, another line is appended to JTAB. Its contents are unequal to the contents of the last line of ITAB. The next logical expressions test whether ITAB is not equal to JTAB. The first table field whose contents are different in ITAB and JTAB is COL1 in the last line of the table: 30 in ITAB and 50 in JTAB. Therefore, in the last logical expression, ITAB is less than JTAB.
regards,
srinivas
<b>*reward for useful answers*</b>
2007 Aug 01 1:32 PM
This is an example of parallel processing.
The internal table with more entries should be used in outer loop.
Describe table it1 value v1.
Describe table it2 value v2.
IF v1 > v2.
Loop at it1.
Read table it2 with key keyfield2 = it1-keyfield1.
IF it1 = it2.
Fields are compared.
ELSE.
Fields are different.
ENDIF.
ENDLOOP.
ELSE.
vice versa.
ENDIF.
2007 Aug 01 2:24 PM
describe line of table itab1 count 1 = 25.
describe line table tab2 count2 =26
if count1 = count2.
endif.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |