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

about alv layout

Former Member
0 Likes
1,216

i used CL_GUI_ALV_GRID>->set_table_for_first_display

to display alv

but why the subtotal and total button are gray in the toolbar.

i searched the help, but there is no parameter to adjust the layout.

who met such problem, please give me a favor

thank u in advance

Kevin

i used CL_GUI_ALV_GRID>->set_table_for_first_display

to display alv

but why the subtotal and total button are gray in the toolbar.

i searched the help, but there is no parameter to adjust the layout.

who met such problem, please give me a favor

thank u in advance

Kevin

10 REPLIES 10
Read only

former_member194669
Active Contributor
0 Likes
1,194

Hi,

In the field catalog field in which field you want to make sum to be populate with


i_fieldcat-do_sum = 'X'.

aRs

Read only

0 Likes
1,194

i mean total&subtotal button are gray.

Read only

former_member194669
Active Contributor
0 Likes
1,194

Have you populate the field catalog DO_SUM" against field you want to total?

if you done, button will get enabled

aRs

Read only

0 Likes
1,194

Hello, aRs,

thanks for your quick reply.

would u please give some sample code

thank u,

Read only

former_member194669
Active Contributor
0 Likes
1,194

Hi,


it is not calculated in the class but you pass some values to the grid in the field catalogue like this:

CALL METHOD mygrid->set_table_for_first_display
EXPORTING
it_toolbar_excluding = t_fcodes[]
CHANGING
it_outtab = mytable[]
it_fieldcatalog = field_catal[].


for your field catalogue you can fill the table so

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
ct_fieldcat = field_catal.

field_catal is of type lvc_t_fcat and this one has among others fields DO_SUM. 

For example:if you want to sum airline fare

field_catal-fieldname = 'FARE'
field_catal-do_sum = 'X'. 
modify field_catal.

aRs

Read only

Former Member
0 Likes
1,194
Add Default Sorting to ALVgrid report   

In order to display an ALV report with specific columns already sorted by default you will need to build a 
sort catalogue. This is fairly straight forward and is done in the following way:

        Step 1. Add data declaration for sort catalogue
        Step 2. Add code to build sort catalogue table  
        Step 3. Update 'gd_tree->set_table_for_first_display' method call to include parameter 'it_sort'
 

*  ALV data declarations
  data: it_sortcat     type LVC_T_SORT,
        it_sortcatdb   type LVC_T_SORT.
perform build_sortcat.

*&------------------------------------------------------------------*
*&      Form  build_sortcat
*&------------------------------------------------------------------*
*       Build Sort catalog
*-------------------------------------------------------------------*
FORM build_sortcat .
  wa_sort-spos      = 1.
  wa_sort-fieldname = 'EBELN'.
  wa_sort-SUBTOT    = 'X'. "subtotals any totals column by this field
*  gd_sortcat-tabname
  APPEND wa_sort TO it_sortcat.

  wa_sort-spos      = 2.
  wa_sort-fieldname = 'EBELP'.
*  gd_sortcat-tabname
  APPEND wa_sort TO it_sortcat.
ENDFORM.                    " build_sortcat

 CALL METHOD gd_tree->set_table_for_first_display
    EXPORTING
      is_layout       = gd_layout
    CHANGING
      it_fieldcatalog = gd_fieldcat
      it_sort         = it_sortcat
      it_outtab       = it_report.      



 
 

rewaard points if it is usefull ...

Girish

Read only

0 Likes
1,194

why the button is gray, i mean i cannot use the button of subtotal & total.

Read only

0 Likes
1,194

the button of subtotal & total & average can not be used, always is gray

Why???

Read only

0 Likes
1,194

the problem have been sloved.

the field u wanna total or sutotal shouldnot be defined into ‘Char' type.

Read only

0 Likes
1,194

the problem have been sloved.

the field u wanna total or sutotal shouldnot be defined into ‘Char' type.