‎2011 Jul 29 9:47 AM
how can i show the value inside an object? see example below..
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.
Write: itab, jtab.
because i want to know why itab is greater than jtab?.
like in JavaScript you can show the object by console.log(object).. how about in abap?
‎2011 Jul 29 11:28 AM
Hello,
Your need will arise if actually tables have same number of rows, So first check the num of rows in each table and if diff, simply compare the count and find the (n+1) row in larger table where n is the no. of rows in smaller table.
However, if they have same no. of rows, you need to compare line by line if you want to write down where was the difference.
==============
data: lv_tabix type sy-tabix,
line1 like line of jtab.
Sort: itab, jtab.
loop at itab into line.
lv_tabix = sy-tabix.
READ TABLE jtab into line1 index lv_tabix.
if sy-subrc = 0.
if line > line1.
WRITE: / 'ITAB GT JTAB'.
write:/ line-col1, line-col2, line1-col1, line1-col2.
EXIT.
elseif line1 > line.
WRITE: / 'JTAB GT ITAB'.
write:/ line1-col1, line1-col2, line-col1, line-col2.
EXIT.
endif.
endif.
AT LAST.
WRITE: / 'Equal tables'.
endat.
endloop.
====================================
‎2011 Jul 29 9:54 AM
data: lines1 type i.
data: lines2 type i.
DESCRIBE TABLE itab lines Lines1.
DESCRIBE TABLE jtab lines Lines2.
this will return the number of records in itab table.
and now u can check or know which Internal table has more records
Edited by: ssm on Jul 29, 2011 2:24 PM
‎2011 Jul 29 11:28 AM
Hello,
Your need will arise if actually tables have same number of rows, So first check the num of rows in each table and if diff, simply compare the count and find the (n+1) row in larger table where n is the no. of rows in smaller table.
However, if they have same no. of rows, you need to compare line by line if you want to write down where was the difference.
==============
data: lv_tabix type sy-tabix,
line1 like line of jtab.
Sort: itab, jtab.
loop at itab into line.
lv_tabix = sy-tabix.
READ TABLE jtab into line1 index lv_tabix.
if sy-subrc = 0.
if line > line1.
WRITE: / 'ITAB GT JTAB'.
write:/ line-col1, line-col2, line1-col1, line1-col2.
EXIT.
elseif line1 > line.
WRITE: / 'JTAB GT ITAB'.
write:/ line1-col1, line1-col2, line-col1, line-col2.
EXIT.
endif.
endif.
AT LAST.
WRITE: / 'Equal tables'.
endat.
endloop.
====================================