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: 

distinct and sum in alv report

Former Member
0 Kudos
238

i have 6 row of 1 matnr

and i have to display only 1 with the sum of each field

example:

300032 3 4 1

300032 3 3 3

300032 2 2 2

i want

<b>300032 8 9 7</b>

how?

thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
106

Hi,

this should help u to do so

----


S o r t a n d S u b t o t a l

Below is Structure Sort (SLIS_T_SORTINFO_ALV).

  • information for sort and subtotals

TYPES: BEGIN OF SLIS_SORTINFO_ALV,

SPOS LIKE ALVDYNP-SORTPOS,

FIELDNAME TYPE SLIS_FIELDNAME,

TABNAME TYPE SLIS_FIELDNAME,

UP LIKE ALVDYNP-SORTUP, “Ascending

DOWN LIKE ALVDYNP-SORTDOWN, “Descending

GROUP LIKE ALVDYNP-GROUPLEVEL, “Grouping

SUBTOT LIKE ALVDYNP-SUBTOTALS, “Field Subtotal

COMP(1) TYPE C,

EXPA(1) TYPE C,

END OF SLIS_SORTINFO_ALV.

TYPES: SLIS_T_SORTINFO_ALV TYPE SLIS_SORTINFO_ALV OCCURS 1.

Every field to be configured is added to SLIS_T_SORTINFO_ALV. This table will be use as input parameter of function “REUSE_ALV_LIST_DISPLAY”.

12 REPLIES 12

Former Member
0 Kudos
106

Hi

Use Collect statament to append the record to output table.

DATA: BEGIN OF ITAB OCCURS 0,

KEY

FIELD1 TYPE I,

FIELD2 TYPE I,

FIELD3 TYPE I,

END OF ITAB.

ITAB-KEY = '300032'.

ITAB-FIELD1 = 3.

ITAB-FIELD2 = 4.

ITAB-FIELD3 = 1.

COLLECT ITAB.

ITAB-KEY = '300032'.

ITAB-FIELD1 = 2.

ITAB-FIELD2 = 2.

ITAB-FIELD3 = 2.

COLLECT ITAB.

ITAB-KEY = '300032'.

ITAB-FIELD1 = 3.

ITAB-FIELD2 = 3.

ITAB-FIELD3 = 3.

COLLECT ITAB.

Max

Message was edited by: max bianchi

Message was edited by: max bianchi

Former Member
0 Kudos
106

sort itab.

loop at itab.

v_quantity1 = v_quantity1 + itab-quantity1.

*--use these many variables to store.

at end of matnr.

read table itab index v_index.

itab2-matnr = itab1-matnr.

itab2-quantity1 = v_quantity1.

*--and so onn.

append itab2.

clear v_quantity1,etc..

endat.

endloop.

0 Kudos
106

or use COLLECT STATEMENT.

loop at itab.

itab2 = itab.

collect itab2.

endloop.

regards

srikanth

0 Kudos
106

1.how i can made collect to wa_record?

2.there is not simple func to make it,as i click on the matnr is making it to 1 row?

sreemsft
Contributor
0 Kudos
106

Yes.

Collect would solve your problem.

Collect will add all numeric fields.

Make sure that the Value 300032 will be a assigned to a character field.

Thanks,

Sreekanth

Former Member
0 Kudos
107

Hi,

this should help u to do so

----


S o r t a n d S u b t o t a l

Below is Structure Sort (SLIS_T_SORTINFO_ALV).

  • information for sort and subtotals

TYPES: BEGIN OF SLIS_SORTINFO_ALV,

SPOS LIKE ALVDYNP-SORTPOS,

FIELDNAME TYPE SLIS_FIELDNAME,

TABNAME TYPE SLIS_FIELDNAME,

UP LIKE ALVDYNP-SORTUP, “Ascending

DOWN LIKE ALVDYNP-SORTDOWN, “Descending

GROUP LIKE ALVDYNP-GROUPLEVEL, “Grouping

SUBTOT LIKE ALVDYNP-SUBTOTALS, “Field Subtotal

COMP(1) TYPE C,

EXPA(1) TYPE C,

END OF SLIS_SORTINFO_ALV.

TYPES: SLIS_T_SORTINFO_ALV TYPE SLIS_SORTINFO_ALV OCCURS 1.

Every field to be configured is added to SLIS_T_SORTINFO_ALV. This table will be use as input parameter of function “REUSE_ALV_LIST_DISPLAY”.

0 Kudos
106

how i connect this to the func REUSE_ALV_LIST_DISPLAY

0 Kudos
106

i made this and it's not working

loop at it_record into wa_record.

wa_record = itab1.

append itab1.

collect itab1.

endloop.

0 Kudos
106

loop at it_record into wa_record.

<b>wa_record = itab1.</b> IS WRONG

append itab1. NO NEED OF APPEND HERE

ITAB1 = WA_RECORD. -> RIGHT Statement.

collect itab1.

endloop.

check this now.

0 Kudos
106

great

thanks.

Former Member
0 Kudos
106

Hi,

U can check this simple code.

data: itab1 like standard table of itab with header line.

loop at itab.

at end of matnr.

read table itab index sy-tabix.

sum.

move-corresponding itab to itab1.

append itab1.

endat.

endloop.

Regards,

Neelima.

0 Kudos
106

no it's not working