Application Development and Automation 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: 
Read only

alv counting logic

Former Member
0 Likes
992

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
Read only

Former Member
0 Likes
908

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
Read only

Former Member
0 Likes
909

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.

Read only

Former Member
0 Likes
908

hi lokesh,

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

how to do tat.

Read only

0 Likes
908

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

Read only

0 Likes
908

thank u soo much