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: 

Problem with Toolbars in LVC_S_LAYO

rahul2000
Contributor
0 Kudos

Dear all,

i am using structure LVC_S_LAYO.

Here in my toolbar some icons like show next,summation are inactive.

Also i am using LVC_T_FCAT where i have set DO_SUM = 'X'.

When i see in debugging the value X is getting passed from my it_fieldcatalog table but still

the sum of the desired column is not displayed.what must be the problem?

Why are these icons inactive in the toolbar.?What should i do to Activate them?

5 REPLIES 5

Sougata
Active Contributor
0 Kudos

The column you want to sum, the data type of that variable must be declared as type integer (type i) or packed (type p).

Cheers,

Sougata.

Former Member
0 Kudos

Rahul,

Can you paste your code?

Regards,

Satish

rahul2000
Contributor
0 Kudos

Dear Sougata,

I am still unable to display the sum by declaring hte column i want to sum up as P or I.

What can be the problem?

Former Member
0 Kudos

If you are using the OO model cl_gui_alv_grid you won´t need any of the fcat models as the sum facility is included on the standard toolbar.

Just select the column and then press the SUM button.

If you switch to the OO model you don`t need to do very much coding and there are a lot less chances of getting errors.

However if you DO program the toolbar then you will need some code like

1) in the constructor set the handler for the ON TOOLBAR event.

SET HANDLER z_object->on_toolbar FOR grid1.

also have one for ON_USER_COMMAND

SET HANDLER z_object->on_user_command FOR grid1.

2) in the the toolbar method activate the buttons you need

For example

method ON_TOOLBAR.

type-pools icon.

CLEAR ls_toolbar.

MOVE 0 TO ls_toolbar-butn_type.

MOVE 'EXIT' TO ls_toolbar-function.

MOVE space TO ls_toolbar-disabled.

MOVE icon_system_end TO ls_toolbar-icon.

MOVE 'Click2Exit' TO ls_toolbar-quickinfo.

APPEND ls_toolbar TO e_object->mt_toolbar.

CLEAR ls_toolbar.

MOVE 0 TO ls_toolbar-butn_type.

MOVE 'SAVE' TO ls_toolbar-function.

MOVE space TO ls_toolbar-disabled.

MOVE icon_system_save TO ls_toolbar-icon.

MOVE 'Save data' TO ls_toolbar-quickinfo.

APPEND ls_toolbar TO e_object->mt_toolbar.

CLEAR ls_toolbar.

MOVE 0 TO ls_toolbar-butn_type.

MOVE 'EDIT' TO ls_toolbar-function.

MOVE space TO ls_toolbar-disabled.

MOVE icon_toggle_display_change TO ls_toolbar-icon.

MOVE 'Edit data' TO ls_toolbar-quickinfo.

MOVE 'EDIT' TO ls_toolbar-text.

APPEND ls_toolbar TO e_object->mt_toolbar.

CLEAR ls_toolbar.

MOVE 0 TO ls_toolbar-butn_type.

MOVE 'PROC' TO ls_toolbar-function.

MOVE space TO ls_toolbar-disabled.

MOVE icon_businav_process TO ls_toolbar-icon.

MOVE 'Process.' TO ls_toolbar-quickinfo.

MOVE 'PROC' TO ls_toolbar-text.

APPEND ls_toolbar TO e_object->mt_toolbar.

CLEAR ls_toolbar.

MOVE 0 TO ls_toolbar-butn_type.

MOVE 'EXCEL' TO ls_toolbar-function.

MOVE space TO ls_toolbar-disabled.

MOVE icon_xxl TO ls_toolbar-icon.

MOVE 'Excel' TO ls_toolbar-quickinfo.

MOVE 'EXCEL' TO ls_toolbar-text.

APPEND ls_toolbar TO e_object->mt_toolbar.

MOVE 0 TO ls_toolbar-butn_type.

MOVE 'REFR' TO ls_toolbar-function.

MOVE space TO ls_toolbar-disabled.

MOVE icon_refresh TO ls_toolbar-icon.

MOVE 'Refresh' TO ls_toolbar-quickinfo.

MOVE 'REFR' TO ls_toolbar-text.

APPEND ls_toolbar TO e_object->mt_toolbar.

  • ...

endmethod.

What the above code does is set the variable E_UCOMM with the value in the toolbar function for example if I press the EXCEL button E_UCOMM is set to EXCEL.

Now the method ON_USER_COMMAND is called where you can then choose your method / action for the toolbar.

method ON_USER_COMMAND.

  • FOR EVENT before_user_command OF cl_gui_alv_grid

  • IMPORTING

  • e_ucomm

  • sender.

CASE e_ucomm.

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'EXCEL'.

CALL METHOD me->download_to_excel.

WHEN 'SAVE'.

WHEN 'PROC'.

CALL METHOD me->process.

WHEN 'REFR'.

CALL METHOD me->refresh.

ENDCASE.

  • ...

endmethod.

Note that the routine ON Data Changed Finished is always called before the user command handling if you set a handler for the event data changed finished;

Your data of course must still be correct for summing it must be NUMERIC.

Cheers

jimbo

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

If you are making do_sum for the field in field catalog, then it will display the total for the field.It is not having any relation with sum icon.