05-18-2012 3:22 AM
Dear Experts,
I have a row counting field in the report output.
The data is sorted on one field (EQUNR)
My requirement is the counter field is to restart when a new value starts for EQUNR.
I could achieve this with the following code, but this does not work when single EQUNR value is queried.
When debugged I understand this is not the way to achieve the result.
data cnt type i.
data eqp type char18.
loop at itab into wa.
eqp = wa-equnr.
loop at itab into wa.
if wa-equnr = eqp.
cnt = cnt + 1.
wa-count = cnt .
MODIFY TABLE ITAB FROM WA TRANSPORTING count.
else.
cnt = 0.
endif.
endloop.
endloop.
(Screenshots attached)
Can someone help.
Regards
Jogeswara Rao
05-18-2012 3:39 AM
Hi,
Use Control break events. use AT NEW equnr to reset the counter.
Search scn with control break events, there are many posts on this topic.
http://wiki.sdn.sap.com/wiki/display/Snippets/control+break+events
Thanks & Regards
Bala Krishna
05-18-2012 3:39 AM
Hi,
Use Control break events. use AT NEW equnr to reset the counter.
Search scn with control break events, there are many posts on this topic.
http://wiki.sdn.sap.com/wiki/display/Snippets/control+break+events
Thanks & Regards
Bala Krishna
05-18-2012 3:45 AM
05-18-2012 3:54 AM
TYPES : BEGIN OF ty_itab,
equnr TYPE equnr,
count TYPE i,
num TYPE c length 10,
date TYPE d,
END OF ty_itab.
DATA : i_itab TYPE STANDARD TABLE OF ty_itab,
WA_itab TYPE ty_itab,
v_num TYPE i.
FIELD-SYMBOLS : <fs_line> TYPE ANY.
* Selection logic
...
...
SORT i_itab BY equnr.
LOOP AT i_itab ASSIGNING <fs_line>.
AT NEW equnr.
CLEAR : v_num.
ENDAT.
<fs_line>-count = v_num.
v_num = v_num + 1.
ENDLOOP.
Thanks & Regards
Bala Krishna
05-18-2012 3:58 AM