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: 

Subtotal of the columns in the ALV

Former Member
0 Kudos

Hi,

I want to do the Subtotal of the columns in the ALV by using any of the FMs:

ALV_OPTIONS_FOR_SUBTOTALS

ALV_SUBTOTALS_GET

ALV_SUBTOTALS_GET_H

But since the functional documentation is not available.

I am not getting how to use.

Please provide me the code or reply me about how to go about.

Thanks & Regards,

Pooja

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

did you check here

The functions you are referring may be internally used by the mainfunctions. check in the above thread you can see the example on that.

9 REPLIES 9

Former Member
0 Kudos

Hi Pooja,

we are defining the sub-totals in sortcatalog and grand totals in field catalog.

With Regards,

Narasimha Rao.

former_member188685
Active Contributor
0 Kudos

did you check here

The functions you are referring may be internally used by the mainfunctions. check in the above thread you can see the example on that.

0 Kudos

Hi,

Consider i have 3 fields

lifnr curr DMBTR

5600 GBP 1000

5600 GBP 1000

5600 USD 1000

5600 TND 1000

5601 GBP 1000

5602 GBP 1000

I want output to be :

lifnr curr DMBTR

5600 GBP 1000

5600 GBP 1000

5600 USD 1000

5600 TND 1000

-


5600 GBP 2000

USD 1000

TND 1000

-


5601 GBP 1000

________________

5601 GBP 1000

5602 GBP 1000

_________________

5602 GBP 1000

Actually i tried using the using subtotal option here:

**Method 1:

lv_fieldname = lc_lifnr.

lw_sort-spos = 1.

lw_sort-fieldname = lv_fieldname.

lw_sort-up = c_mark.

lw_sort-subtot = 'X'.

APPEND lw_sort TO i_sort.

Next i tried using the modifying field catalog like this

**Method 2:

LOOP AT i_fieldcat INTO wa_fieldcat.

IF wa_fieldcat-fieldname EQ 'DMBTR'.

wa_fieldcat-do_sum = 'X'.

ENDIF.

IF wa_fieldcat-fieldname EQ 'WRBTR'.

wa_fieldcat-do_sum = 'X'.

ENDIF.

MODIFY i_fieldcat FROM wa_fieldcat

TRANSPORTING do_sum .

ENDLOOP.

But both the methods didnt work .

So kindly tel me how to go about?

Regards,

Pooja

0 Kudos

sort part is ok.

Fieldcatalog part.

LOOP AT i_fieldcat INTO wa_fieldcat.
IF wa_fieldcat-fieldname EQ 'DMBTR'.
wa_fieldcat-do_sum = 'X'.
MODIFY i_fieldcat FROM wa_fieldcat
TRANSPORTING do_sum .
ENDIF.
IF wa_fieldcat-fieldname EQ 'WRBTR'.
wa_fieldcat-do_sum = 'X'.
MODIFY i_fieldcat FROM wa_fieldcat
TRANSPORTING do_sum .
ENDIF.
clear wa_fieldcat.
ENDLOOP.

and how are you -population the i_fieldcat..?

for currency fields are you giving the reference fields.

0 Kudos

Hi Vijay,

Thanks for ur reply.

I am filling the field catalog manually as shown below:

*local currency

lw_fieldcat-tabname = 'I_OUTPUT'.

lw_fieldcat-fieldname = 'LCURR'.

lw_fieldcat-outputlen = 12.

lw_fieldcat-seltext_l = text-004.

APPEND lw_fieldcat TO i_fieldcat.

CLEAR lw_fieldcat.

*Amount O/s [local]

lw_fieldcat-tabname = 'I_OUTPUT'.

lw_fieldcat-fieldname = 'DMBTR'.

lw_fieldcat-outputlen = 15.

lw_fieldcat-seltext_l = text-005.

APPEND lw_fieldcat TO i_fieldcat.

CLEAR lw_fieldcat.

*Document currency

lw_fieldcat-tabname = 'I_OUTPUT'.

lw_fieldcat-fieldname = 'DCURR'.

lw_fieldcat-outputlen = 15.

lw_fieldcat-seltext_l = text-006.

APPEND lw_fieldcat TO i_fieldcat.

CLEAR lw_fieldcat.

*Amount O/s [document]

lw_fieldcat-tabname = 'I_OUTPUT'.

lw_fieldcat-fieldname = 'WRBTR'.

lw_fieldcat-outputlen = 15.

lw_fieldcat-seltext_l = text-007.

APPEND lw_fieldcat TO i_fieldcat.

CLEAR lw_fieldcat.

I didnt understand "for currency fields are you giving the reference fields.????". How should give reference fields for it?

Regards,

Pooja

0 Kudos

Hi,

In fieldcatalogue use the following :

Reftab and RefFld and from the database table for the currency field under consideration get the respective reference table and field and pass it to your field catalogue....

0 Kudos

take example

fcat-REF_FIELD = 'DMBTR'.
fcat-ref_table = 'MSEG'.
 fcat-cfieldname = 'L_CURR'.    
  fcat-ctabname = 'I_OUTPUT'.

if you are populating manually what is the problem in adding the DO_SUM = 'X' , for that you are looping and doing.

*Amount O/s local
lw_fieldcat-tabname = 'I_OUTPUT'.
lw_fieldcat-fieldname = 'DMBTR'.
lw_fieldcat-outputlen = 15.
lw_fieldcat-do_sum = 'X'.
lw_fieldcat-seltext_l = text-005.
APPEND lw_fieldcat TO i_fieldcat.
CLEAR lw_fieldcat.
...

*Amount O/s document
lw_fieldcat-tabname = 'I_OUTPUT'.
lw_fieldcat-fieldname = 'WRBTR'.
lw_fieldcat-outputlen = 15.
lw_fieldcat-do_sum = 'X'.
lw_fieldcat-seltext_l = text-007.
APPEND lw_fieldcat TO i_fieldcat.
CLEAR lw_fieldcat.

0 Kudos

Hi Vijay,

Thanks, the problem is solved.

I was not referencing the document curr with the document amount. I used a struture and in that i used the reference field and ref table which is same as mentioned by you above.

Yes, thats correct i could have added the do_sum directly.

I need not have used modify_alv. I didnt realise that at the time of coding.

Regards,

Pooja

former_member203501
Active Contributor