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: 

problem in ALV

Former Member
0 Kudos

Hi all,

I am having a problem in which suppose if i am getting duplicate records on the basis of vbeln and zposn, i have to sum up all the fields related to currency. and also there is field called zattnmnt which is numeric and the average of all duplicate records of this field should be displayed.

for eg., my records are

vbeln-zposn-zattnmnt-tot

001-10001-70-----5000

001-10001-100----4000

001-10001-50-----3000

the o/p should be displayed as

001-10001-73-----12000

help me in this context

7 REPLIES 7

rainer_hbenthal
Active Contributor
0 Kudos

ALV cant condense rows, it can add summarizing rows. You have to code that for your own. See online help fot statement collect, this might by helpful.

Vinod_Chandran
Active Contributor
0 Kudos

Hi Ateeq,

You can do this inside the ALV itself using the SORT option. Here is that sample code.

DATA: wa_layout TYPE slis_layout_alv,

it_sort TYPE slis_t_sortinfo_alv,

wa_sort TYPE slis_sortinfo_alv.

CLEAR wm_sort.

wm_sort-fieldname = 'MATNR'.

wm_sort-tabname = 'IT_SORT'.

wm_sort-up = 'X'.

wm_sort-subtot = 'X'.

APPEND wa_sort TO it_sort.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = w_repid

i_callback_top_of_page = 'ALV_TOP_OF_PAGE'

i_callback_html_top_of_page = 'ALV_HTML_TOP_OF_PAGE'

is_layout = wa_layout

it_fieldcat = it_fieldcat

it_events = it_events

it_sort = it_sort

i_default = 'X'

....

....

Cheers

Vinod

Message was edited by: Vinod C

0 Kudos

You then will have 4 rows, not one.

0 Kudos

with collect statement my problem is half solved. remaining is i have to find the average of the field

%atmnt if 3 records were printed.

i.e., %atmnt/3

plz help me in this work

0 Kudos

Hi

You can use the event ALV GROUPLEVEL_CHANGE to calucalate and write the average.

Max

0 Kudos

sorry, i couldn't specify the problem to u..

If there are 3 duplicate records. only the summarized record will be displayed. the duplicate records will not be be displayed. the totals are the sum of 3 records and the %attmnt (numeric field) is also showing the sum. now i have to find the average of the %attmnt and display it instead of sum.

thanx 4 ur spirit in responding quickly.

0 Kudos

Why dont you calculate your average in ABAP and then pass it to ALV.

Create a new internal table

VBELN, VBPOS, COUNT, ATTMNT,

( Use Collect to populate this table . While collecting always sset count as '1'. After populating this table calculate average as ATTMNT / COUNT and modify this table. Loop at your original table, and modify individual lines by matching VBELN/VBPOS from second table).

Then pass this table to ALV.

Cheers