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: 

alv counting logic

Former Member
0 Kudos
174

hi experts,

           i need help for buiding logic for counting row based on material number and plant and year.

      

       matnr                             plant                               year                         count

00000000000001                    1000                                   2014                        2

00000000000001                    1000                                    2014                       2

00000000000001                     1000                                   2013                       1

00000000000002                      1000                                   2014                      1

counting of alv based on matnr plant and year.

i need the output like this and help for the same

thanks in advance,

vinod

1 ACCEPTED SOLUTION

Former Member
0 Kudos
90

While looping on your internal table, use AT END OF year.

LV_VAL will keep the number of counts of same MATNR, Plant and YEAR.

DATA: lv_val type i.


SORT: i_tab by MATNR PLANT YEAR.

LOOP AT i_tab into s_tab.

lv_val = lv_val + 1.

AT END OF year.

Clear: lv_val.

ENDAT.

ENDLOOP.

4 REPLIES 4

Former Member
0 Kudos
91

While looping on your internal table, use AT END OF year.

LV_VAL will keep the number of counts of same MATNR, Plant and YEAR.

DATA: lv_val type i.


SORT: i_tab by MATNR PLANT YEAR.

LOOP AT i_tab into s_tab.

lv_val = lv_val + 1.

AT END OF year.

Clear: lv_val.

ENDAT.

ENDLOOP.

Former Member
0 Kudos
90

hi lokesh,

          thanks for ur response,this count is based on all three fields matnr,plant and year,

how to do tat.

0 Kudos
90

As I explained in sample code, use at end of.

This is how you can achieve.

Search on "AT END OF" control level statement.

~Lokesh

0 Kudos
90

thank u soo much