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: 

how can i compare 2 internal table's data which have same structure ?

Former Member
0 Kudos

hi friends,

i want to know how to compare 2 internal table's data which have same structure

3 REPLIES 3

Former Member

Former Member
0 Kudos

hi

TYPES: BEGIN OF ST_HRP1000,

OTYPE TYPE HRP1000-OTYPE,

OBJID TYPE HRP1001-OBJID,

STEXT TYPE HRP1000-STEXT,

END OF ST_HRP1000.

TYPES: BEGIN OF ST_HRP1001,

OTYPE TYPE HRP1000-OTYPE,

OBJID TYPE HRP1001-OBJID,

STEXT TYPE HRP1000-STEXT,

END OF ST_HRP1001.

data : it_hrp1000 type standard table of st_hrp1000.

data : wa_hrp1000 type st_hrp1000.

data : it_hrp1001 type standard table of st_hrp1001.

data : wa_hrp1001 type st_hrp1001.

select otype

objid

stext

from hrp1000

into table it_hrp1000

where otype = it_hrp1001-otype.

reward if useful

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>