‎2009 Jun 10 1:40 PM
Hi,
I want to compare the a field with its previous value in a internal table
i am using the following logic
flag = 0.
loop at it where x_field = s_field.
if not of flag is intial.
if it_field2 = v_field2.
-
-
endif.
endif.
move it_field2 to v_field.
endloop.
i dont want to use flag in this case can any one help.
thanks.
‎2009 Jun 10 1:48 PM
Hi,
data: tabix type sy-tabix.
loop at itab into wa1.
read table itab into wa2 index tabix.
if sy-subrc = 0.
wa2-f1 is previous value of this field.
compare wa1-f1 and wa2-f1.
endif.
tabix = sy-tabix.
endloop.Thanks,
Naveen Inuganti.
‎2009 Jun 10 1:51 PM
Hi,
If you are not using the where clause in the LOOP then use AT-NEW inside the loop.
Regards,
Ankur Parab
‎2009 Jun 10 1:56 PM
Hello Gayatri,
Try like this:
DATA:
v_index TYPE i.
LOOP AT itab INTO wa1.
v_index = sy-tabix - 1.
IF v_index GT 0.
READ TABLE itab INTO wa2 INDEX v_index.
IF sy-subrc = 0.
* Compare WA1 & WA2
ENDIF.
ENDIF.
ENDLOOP.Hope this helps.
BR,
Suhas
‎2009 Jun 10 1:59 PM
HI,
Clear v_field2
loop at it where x_field = s_field.
if it_field2 = v_field2.
" The previous value is same with the present value
endif.
move it_field2 to v_field.
endloop.
‎2009 Jun 10 2:15 PM
clear w_previousvalue.
loop at it where x_field = s_field.
if it-field1 = w_previousvalue AND
NOT w_previousvalue IS INITIAL.
do required processing
else.
do required processing.
endif.
w_previousvalue = it-field1.
endloop.