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: 

Internal tables

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

describe line of table itab1 count 1 = 25.

describe line table tab2 count2 =26

if count1 = count2.

endif.

6 REPLIES 6

Former Member
0 Kudos

Use

if itab1[] = itab2[].

Reward points if helpful.

Regards.

Srikanta Gope

Former Member

Former Member
0 Kudos

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

Former Member
0 Kudos

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>

Former Member
0 Kudos

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.

Former Member
0 Kudos

describe line of table itab1 count 1 = 25.

describe line table tab2 count2 =26

if count1 = count2.

endif.