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

Former Member
0 Likes
879

Hi ,

i have a requirment as below :

grid display output as :

a1 plant1 10

a1 plant1 20

---sub total 30

a1 plant2 30

a1 plant2 40

---subtotal 70

---grandtotal 70 + 30

a2 plant1 10

--subtotal 10

a2 plant2 20

---subtotal 20

a2 plant3 30

subtotal 30

grand toatal 10 + 20+ 30.

the requirment is to display subtotal and grand total.. as an extra rows in the alv grid display .Any suggestions regarding this pls.

Thanks,

Vind.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
847

hi

chk this example n use accordingly:

1.

Define SORT table and FIELDCATALOG table .

Data :i_field type slis_t_fieldcat_alv,

w_field like line of i_field,

i_sort type slis_t_sortinfo_alv,

w_sort like line of i_sort.

2.Grand Total

While buildingfieldcatalog,We have to set DO_SUM = 'X' for quantity field .

ex.

w_field-fieldname = 'MENGE'.

w_field-tabname = 'I_TAB'.

w_field-DO_SUM = 'X'.

append w_field to i_field.

clear w_field.

3.Subtotal

Whenever WERKS is changed Subtotal is displayed .

Build sort table .

Clear: w_sort,i_sort[].

w_sort-spos = 1.

w_sort-fieldname = 'WERKS'.

w_sort-up = 'X'.

w_sort-subtot = 'X'.

append w_sort to i_sort.

clear w_sort.

**reward if helpful

regards,

madhu

6 REPLIES 6
Read only

Former Member
0 Likes
848

hi

chk this example n use accordingly:

1.

Define SORT table and FIELDCATALOG table .

Data :i_field type slis_t_fieldcat_alv,

w_field like line of i_field,

i_sort type slis_t_sortinfo_alv,

w_sort like line of i_sort.

2.Grand Total

While buildingfieldcatalog,We have to set DO_SUM = 'X' for quantity field .

ex.

w_field-fieldname = 'MENGE'.

w_field-tabname = 'I_TAB'.

w_field-DO_SUM = 'X'.

append w_field to i_field.

clear w_field.

3.Subtotal

Whenever WERKS is changed Subtotal is displayed .

Build sort table .

Clear: w_sort,i_sort[].

w_sort-spos = 1.

w_sort-fieldname = 'WERKS'.

w_sort-up = 'X'.

w_sort-subtot = 'X'.

append w_sort to i_sort.

clear w_sort.

**reward if helpful

regards,

madhu

Read only

Former Member
0 Likes
847

Hi,

You can build a sort internal table and pass it to the ALV FM..

Ex..

Steps

1) For the fields quantity have DO_SUM = 'X' in the field catalog internal table.

2) Prepare a sort internal table with the customer field..

DATA: T_SORT TYPE SLIS_T_SORTINFO_ALV.

DATA: S_SORT LIKE LINE OF T_SORT.

S_SORT-SPOS = '1'.

S_SORT-FIELDNAME = 'FIRST FIELD NAME'. "In your a1 value.

S_SORT-UP = 'X'.

S_SORT-SUBTOT = 'X'.

APPEND S_SORT TO T_SORT.

S_SORT-SPOS = '2'.

S_SORT-FIELDNAME = 'SECOND FIELD NAME'. "In your plant1 value.

S_SORT-UP = 'X'.

S_SORT-SUBTOT = 'X'.

APPEND S_SORT TO T_SORT.

3)

Pass the internal table T_SORT to the parameter IT_SORT when calling the Function module.

Thanks

Naren

Read only

0 Likes
847

HI,

From the below code am able to get the subtotal but not the grand total any idea pls..

Thanks,

Vind.

Read only

0 Likes
847

hi,

do like this for grand total...

fieldcatalog-fieldname = 'NETPR'.

fieldcatalog-seltext_m = 'Net Price'.

fieldcatalog-col_pos = 7.

fieldcatalog-outputlen = 15.

<b>fieldcatalog-do_sum = 'X'. "Display column total</b>

fieldcatalog-datatype = 'CURR'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

**reward if helpful

regards,

madhu

Read only

0 Likes
847

Hi Madhumitha ,

I think you have missunderstood a part of the requirment , actually the grand total i am looking for is not at the end of the page but bascially in b/w as per the example i menctioned..

Grand total = subtotal 1 + subtotal 2 . where different plant with same 'group' (EG :a1 , a2 ..) 'TOTAL' .

Thanks,

vind.

Read only

Former Member
0 Likes
847

Hi,

Check this example..THis works fine for me..

TYPE-POOLS slis.

DATA: BEGIN OF itab OCCURS 0,

field1(2) TYPE c,

field2(6) TYPE c,

stprs LIKE mbew-stprs,

END OF itab.

itab-field1 = 'A1'.itab-field2 = 'PLANT1'.itab-stprs = '10'.

APPEND itab.

itab-field1 = 'A1'.itab-field2 = 'PLANT1'.itab-stprs = '20'.

APPEND itab.

itab-field1 = 'A1'.itab-field2 = 'PLANT2'.itab-stprs = '30'.

APPEND itab.

itab-field1 = 'A1'.itab-field2 = 'PLANT2'.itab-stprs = '40'.

APPEND itab.

itab-field1 = 'A2'.itab-field2 = 'PLANT1'.itab-stprs = '10'.

APPEND itab.

itab-field1 = 'A2'.itab-field2 = 'PLANT2'.itab-stprs = '20'.

APPEND itab.

DATA: t_sort TYPE slis_t_sortinfo_alv.

DATA: s_sort LIKE LINE OF t_sort.

DATA: t_fcat TYPE slis_t_fieldcat_alv.

DATA: s_fcat LIKE LINE OF t_fcat.

  • Sort internal table/

s_sort-spos = '1'.

s_sort-fieldname = 'FIELD1'.

s_sort-up = 'X'.

s_sort-subtot = 'X'.

APPEND s_sort TO t_sort.

s_sort-spos = '2'.

s_sort-fieldname = 'FIELD2'.

s_sort-up = 'X'.

s_sort-subtot = 'X'.

APPEND s_sort TO t_sort.

  • Field catalog.

s_fcat-fieldname = 'FIELD1'.

s_fcat-seltext_m = 'Field1'.

s_fcat-tabname = 'ITAB'.

APPEND s_fcat TO t_fcat.

s_fcat-fieldname = 'FIELD2'.

s_fcat-seltext_m = 'Field1'.

s_fcat-tabname = 'ITAB'.

APPEND s_fcat TO t_fcat.

s_fcat-fieldname = 'STPRS'.

s_fcat-seltext_m = 'Amount'.

s_fcat-tabname = 'ITAB'.

s_fcat-do_sum = 'X'.

APPEND s_fcat TO t_fcat.

DATA: v_repid TYPE sy-repid.

v_repid = sy-repid.

  • Call the ALV.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = v_repid

it_fieldcat = t_fcat

it_sort = t_sort

TABLES

t_outtab = itab.

THanks,

Naren