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: 

How to add a button to the Standard Toolbar in ALV ?

Former Member
0 Kudos

Hi All,

If i add a button it should be displayed along with

the standard icons of the toolbar.

Plz guide me.

Thx in advance.

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

Hi,

Take one sample standard ALV Program and go to se41.

and give the program name, and choose the status which is available. and click the copy status button and give your program and status name. copy the status and save , activate. then see the components in the pf-status .

now add your own buttons in the status which you copied and activate. give the status in PF-status form.

for normal alv's this is the way.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
............ 

FORM set_pf_status USING rt_extab TYPE slis_t_extab

SET PF-STATUS 'STATUS' EXCLUDING rt_extab.

ENDFORM.



FORM user_command USING r_ucomm LIKE sy-ucomm 
rs_selfield TYPE slis_selfield.
CASE R_UCOMM.
WHEN 'XXXX'.
"Do some thing,,,
ENDCASE.

ENDFORM.

Regards

vijay

8 REPLIES 8

Former Member
0 Kudos

Hi Albert,

Copy any standard GUI STATUS(from function group SALV) to your program.Add the button to your copied GUI STATUS.Activate your GUI STATUS in the program write the code like this

FORM pf_status_set USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'STATUS1' .

ENDFORM. "PF_STATUS_SET

Pass this form name to your ALV FM.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = g_repid

i_callback_pf_status_set = 'PF_STATUS_SET'

i_callback_user_command = 'USER_COMMAND'

is_layout = i_layout

it_fieldcat = i_fieldcat[]

TABLES

t_outtab = p_out

EXCEPTIONS

program_error = 1

OTHERS = 2.

Former Member
0 Kudos

Hi albert,

1. The important things are :

a) New PF-STATUS is required , say 'ABCD'.

b) Handle user_commmand

2. First of all, from Function group SALV,

copy the STANDARD gui status to your program,

from SE80, by right clicking.

3. come to your program.

start-of-selection.

SET PF-STATUS 'ABCD'.

4. Double click ABCD and activate the gui status.

5. In gui status, add your own button with

your own OKCODE.

Save and activate.

6. AT USER-COMMAND.

IF sy-ucomm = 'MYFCODE'.

This will solve your problem.

I tried at my end, it works fantastic.

regards,

amit m.

Former Member
0 Kudos

Hi Albert.

You need to do a few things for that :

- Create your own GUI status by copying STANDARD_FULLSCREEN from function group SLVC_FULLSCREEN.

- Set your own PF-Status using the Exclude table because otherwise your exclude table would become meaningless.

- define a subroutine to handle the user commands.

Sample implementation :

FORM pf_status USING extab TYPE slis_t_extab.

extab = pf_exclude.

SET PF-STATUS 'STANDARD' EXCLUDING extab.

ENDFORM. "PF_STATUS

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = repid

i_callback_user_command = 'USER_COMMAND'

i_callback_pf_status_set = 'PF_STATUS'

is_layout = layout

it_fieldcat = fieldcat

it_excluding = pf_exclude

TABLES

t_outtab = itab

EXCEPTIONS

OTHERS = 0.

FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

ENDFORM.

Please reward points if found helpful.

0 Kudos

Guys ,

Thx for all the inputs.

I will mark the answers accordingly.

Samant,

Can you please tell the usage of exclude table in the pf_status subroutine.

0 Kudos

Hi,

excluding option is used to exclude the Button which you don't to want to use in the ALV output toolbar.

those buttons okcode you append to extab and then pass it to set pf-status while setting it with exclude option.

FORM set_pf_status USING rt_extab TYPE slis_t_extab.
<b>append 'OKCODE1' to rt_extab.
append 'OKCODE2' to rt_extab.</b>
SET PF-STATUS 'STATUS' EXCLUDING rt_extab.
ENDFORM.

Regards

vijay

0 Kudos

Vijay,

Thx for your input.

The Button to the toolbar is working fine..

regards,

Albert

0 Kudos

haah,it is nice to see icon on ALV but,

case r_ucom is important * what it will do?!

in main program you must set pf_status.

former_member188685
Active Contributor
0 Kudos

Hi,

Take one sample standard ALV Program and go to se41.

and give the program name, and choose the status which is available. and click the copy status button and give your program and status name. copy the status and save , activate. then see the components in the pf-status .

now add your own buttons in the status which you copied and activate. give the status in PF-status form.

for normal alv's this is the way.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
............ 

FORM set_pf_status USING rt_extab TYPE slis_t_extab

SET PF-STATUS 'STATUS' EXCLUDING rt_extab.

ENDFORM.



FORM user_command USING r_ucomm LIKE sy-ucomm 
rs_selfield TYPE slis_selfield.
CASE R_UCOMM.
WHEN 'XXXX'.
"Do some thing,,,
ENDCASE.

ENDFORM.

Regards

vijay