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

alv button

Former Member
0 Likes
649

i want to create a button that after the alv grid is display i will be able to push a botton that will show the option i filled in the selection screen

in order to create the alv report i am using factory method.

thanks

4 REPLIES 4
Read only

Former Member
0 Likes
565

Hi ami,

Add Button to ALV Toolbar with REUSE_ALV_LIST_DISPLAY

you should copy the 'STANDARD' GUI status from program SAPLKKBL using transaction SE90 >Programming SubObjects> Gui Status.

Execute this transaction to get to next screen. select status using checkbox. click on GUI Status --> Copy.

Enter your Z program name and the name you what for this status - you can keep it as 'STANDARD' to be simple.

Then you can edit the new status to add or delete buttons. This will also bring in the standard SAP ALV functionality such as sorting/subtotaling etc...

When you call 'REUSE_ALV_GRID_DISPLAY' make sure you pass it the new status name.

an example

call function 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = 'ZSDBOLST_REPORT'

i_callback_pf_status_set = 'STANDARD' <----


i_callback_user_command = 'USER_COMMAND'

i_structure_name = 'I_BOLACT'

i_grid_title = 'BOL Action Report'(031)

is_layout = gs_layout

it_fieldcat = gt_fieldcat[]

i_save = 'A'

is_variant = v_variant

TABLES

t_outtab = i_bolact

EXCEPTIONS

program_error = 1

others = 2.

As identified with the FM's help you can do the following.

1). Using SE80 (I think) you can copy a GUI status from one program to another. It mentions which one in the FM's help.

2). Create a form named like so:

Code:

  • Form Set_pf_status

  • Notes: Called by FM REUSE_ALV_GRID_DISPLAY

FORM set_pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'ZSTANDARD'.

ENDFORM. "Set_pf_status

In the above case the GUI status copied was named ZSTANDARD and adjusted accordingly, adding and removing the desired buttons. A button was added called '%DELETE'.

3). Create the following report:

Code:

  • Form User_command

  • Notes: Called by FM REUSE_ALV_GRID_DISPLAY

  • Detects whether the icon/button for

  • 'Return Tag Deletion' has been pressed. If it has then

  • detect whether any rows have been highlighted and then

  • set the delete flag.

FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

DATA: li_count TYPE I.

IF r_ucomm EQ '%DELETE'.

LOOP AT %g00 WHERE mark EQ 'X'.

ADD 1 TO li_count.

ENDLOOP.

IF li_count GT 0.

gc_delete_flag = 'X'.

r_ucomm = '&F03'. "Back arraow

ELSE.

MESSAGE W000 WITH 'Please highlight the rows to be deleted!'.

ENDIF.

ENDIF.

ENDFORM. "User_command

As I've added an extra button to indicate which records should be deleted I need to identify a form to be called to process when this button is chosen.

Then when you call the ALV function you to specify the following extra details:

Code:

call function 'REUSE_ALV_GRID_DISPLAY'

exporting i_callback_program = gc_repid

I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

i_grid_title = lc_grid_title

is_layout = lc_layout

it_fieldcat = gt_fieldcat

it_sort = sort

i_save = l_save

is_reprep_id = l_bbs_id

is_variant = l_variant

tables t_outtab = %g00

exceptions program_error = 1

others = 2.

The parameters in capitals are the extra ones that need to be added.

thanks

shankar.

Read only

Former Member
0 Likes
565

This is how I added a button to my repport ....

class lcl_event_receiver implementation.

method handle_toolbar.

  • Part I: Define a menu button including a function code that

  • is evaluated in 'handle_MENU_BUTTON

  • append a separator to normal toolbar

clear gs_toolbar.

move 3 to gs_toolbar-butn_type.

append gs_toolbar to e_object->mt_toolbar.

  • append a menut o switch between detail levels.

clear gs_toolbar.

move 'ATTENDANCE' to gs_toolbar-function.

  • --> This function code is evaluated in 'handle_menu_button'

move icon_detail to gs_toolbar-icon.

move 'Switch to Table...'(101) to gs_toolbar-quickinfo.

move 2 to gs_toolbar-butn_type.

move space to gs_toolbar-disabled.

append gs_toolbar to e_object->mt_toolbar.

endmethod.

method handle_menu_button.

  • Part II: Evaluate 'e_ucomm' to see which menu button of the toolbar

  • has been clicked on.

  • Define then the corresponding menu.

  • The menu contains function codes that are evaluated

  • in 'handle_user_command'.

  • handle own menubuttons

if e_ucomm = 'ATTENDANCE'.

call method e_object->add_function

exporting fcode = 'PSV1'

text = text-100. "Overview

endif.

endmethod.

Read only

Former Member
0 Likes
565

hiiiii

go throgh following link..it is having step by step process for creating button on ALV

regards

twinkal

Read only

Former Member
0 Likes
565

hi,

Plz refer to this link.

[http://abapreports.blogspot.com/2008/06/push-button-on-alv-grid-output-sample.html]

You have got sample code there.

Regards

Sumit Agarwal