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: 

total value in alv

Former Member
0 Kudos

hi

in alv.. how we put the total for the particular column?

what is the basic purpose of layout in alv ?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

After populating the fieldcatelog, you can loop thru the internal table can capture the field that you want to total on:

    LOOP AT p_alv_catalog INTO wa_fieldcat.
      CASE wa_fieldcat-fieldname.
        when 'WRBTR'.     " Field needs to totalized
          wa_fieldcat-do_sum = 'X'.
          ENDCASE.
      MODIFY p_alv_catalog FROM wa_fieldcat.
      CLEAR wa_fieldcat.
    ENDLOOP.

Here is the documentation from SAP help on ALV layout:

***********************************************************************************************

You use layouts to tailor the outputted list to your individual requirements. Layouts describe the list formatting options and include:

List settings, such as column selection, column sequence, and column width.

Filter settings

Sort settings

Totals, averages, maximum / minimum

Subtotals

Display options

Graphic

View templates

Layout is the new term for display variant as of Release 4.6C.

Features

The edition options for layouts depend on the relevant ALV Grid Control:

In all ALV Grid Controls, you can:

Choose one of the standard layouts delivered with the standard system.

Change the current layout.

In ALV Grid Controls that use only the standard layouts, you cannot save your changes to the current layout. When you choose layouts, only the standard layouts are proposed.

In some ALV Grid Controls, you can also save the layout you defined as your own Layout.

User-defined layouts are generally saved for all users. They can then be used by all users – that is, all users can then choose from the user-defined layouts as well as the standard layouts.

In some ALV Grid Controls, you can also save the layout you defined as a user-specific layout. You are the only user that can use this layout.

<i>Please reward points for helpful answer.</i>

8 REPLIES 8

Former Member
0 Kudos

I can help with getting the ALV to show the total: When defining the field catalog, set the DO_SUM component to 'X'. ALV creates totals for columns with this setting. See below.

DATA: l_fieldcat TYPE slis_fieldcat_alv.

CLEAR l_fieldcat.

l_fieldcat-tabname = 'FUNDINT'.

l_fieldcat-fix_column = 'X'.

l_fieldcat-no_out = 'O'.

l_fieldcat-fieldname = 'GEBER'.

l_fieldcat-seltext_l = 'Fund'.

APPEND l_fieldcat TO p_fieldtab.

l_fieldcat-fieldname = 'DMBTR'.

l_fieldcat-seltext_l = 'Avg Daily Balance'.

<b> l_fieldcat-do_sum = 'X'.</b>

APPEND l_fieldcat TO p_fieldtab.

Former Member
0 Kudos

Hi,

In SLIS_T_FIELDCAT_ALV,there is a field called 'do_sum' which cab be set in case you need to add a particular column.While preparing the fieldcatalog for the particular column,just mark do_sum to X.

Hope it works.

Thanks,

Sandeep.

Pawan_Kesari
Active Contributor
0 Kudos

to get sum set the field DO_SUM in fielcatelog to 'X'.

Layout strucrure is used to vary/change the layout of output. This strcuture contains attributed which is valid for whole report.. for example report title, display sum on top, there are many .. you can check the structire of layout

Former Member
0 Kudos

HI,

while creating field-catalog specifies the fied DO_SUM = 'X' to which column you want to perform total.

DATA: fieldcat type LVC_T_FCAT.

fieldcat-fieldname = < >. " specifies the name
fieldcat-do_sum = 'X'. " total calculation for column.

we use layout to display output in different layouts like.......

IS_LAYOUT-ZEBRA: X=striped (zebra) pattern

IS_LAYOUT-BOX_FIELDNAME: insert column checkbox for each row to select row.

follow this link for knowing use of layout.

http://abap-gallery.blogspot.com/2007/07/change-layout-format-in-alv.html

regards,

Ashok Reddy

Former Member
0 Kudos

After populating the fieldcatelog, you can loop thru the internal table can capture the field that you want to total on:

    LOOP AT p_alv_catalog INTO wa_fieldcat.
      CASE wa_fieldcat-fieldname.
        when 'WRBTR'.     " Field needs to totalized
          wa_fieldcat-do_sum = 'X'.
          ENDCASE.
      MODIFY p_alv_catalog FROM wa_fieldcat.
      CLEAR wa_fieldcat.
    ENDLOOP.

Here is the documentation from SAP help on ALV layout:

***********************************************************************************************

You use layouts to tailor the outputted list to your individual requirements. Layouts describe the list formatting options and include:

List settings, such as column selection, column sequence, and column width.

Filter settings

Sort settings

Totals, averages, maximum / minimum

Subtotals

Display options

Graphic

View templates

Layout is the new term for display variant as of Release 4.6C.

Features

The edition options for layouts depend on the relevant ALV Grid Control:

In all ALV Grid Controls, you can:

Choose one of the standard layouts delivered with the standard system.

Change the current layout.

In ALV Grid Controls that use only the standard layouts, you cannot save your changes to the current layout. When you choose layouts, only the standard layouts are proposed.

In some ALV Grid Controls, you can also save the layout you defined as your own Layout.

User-defined layouts are generally saved for all users. They can then be used by all users – that is, all users can then choose from the user-defined layouts as well as the standard layouts.

In some ALV Grid Controls, you can also save the layout you defined as a user-specific layout. You are the only user that can use this layout.

<i>Please reward points for helpful answer.</i>

0 Kudos

for eg.. i did like this but output not came

data w_fcat type slis_fieldcat_alv.

w_fcat-tabname = 'IT_MARA'.

W_FCAT-FIELDNAME = 'MATNR'.

W_FCAT-REF_TABNAME = 'MARA'.

W_FCAT-REF_FIELDNAME = 'MATNR'.

W_FCAT-OUTPUTLEN = '20'.

W_FCAT-DO_SUM = 'X'.

append w_fcat to i_fcat.

clear w_fcat.

0 Kudos

THANKS I GOT THE ANSWER

0 Kudos

Selva Sir

please assign points to all thankful answers

dont forget