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 new button to ALV application toolbar?

Former Member
0 Kudos
748

Hi!

Does anyone know how to <b>add a new pushbutton to the standard ALV application toolbar</b> generated by function module 'REUSE_ALV_GRID_DISPLAY'?

Thank you for all your help!

- Mari

4 REPLIES 4

Former Member
0 Kudos
137

1 . *Function module to display the ALV report

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = W_REPID

I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

2. FORM PF_STATUS using RT_EXTAB TYPE SLIS_T_EXTAB.

SET PF-STATUS 'STANDARD1' .

ENDFORM. "PF_STATUS

double click on STANDARD1' and add ur new button

3.FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM

P_SELFLD TYPE SLIS_SELFIELD.

DATA : L_REP_MODE. "report mode

CASE P_UCOMM.

when 'XXXX'.

ENDCASE.

Former Member
0 Kudos
137

hi,

check this code..

set pf-status and add ur custom buttons there.

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

Setting the pf_status which are from ALV Grid function

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

FORM set_pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'DELE'.

ENDFORM. "Set_pf_status

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

*User command.

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

  • code to ur buttons and place ur logic here

FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

case r_ucomm.

    • when delete button is click on alv tool bar

when '%CI'.

leave to screen 0 .

    • when cancel button is click on alv toobar

when '%CJ'.

leave to screen 0 .

endcase.

ENDFORM. "User_command

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = w_repid

I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'

<b> I_CALLBACK_USER_COMMAND = 'USER_COMMAND'</b>

IT_FIELDCAT = gt_fieldcat[]

I_SAVE = 'A'

TABLES

T_outtab = ITAB

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

regards

CNU

ferry_lianto
Active Contributor
0 Kudos
137

Hi Mari,

Please take one sample standard ALV Program then go to SE41.

Give the program name, and choose the status which is available. 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,

Ferry Lianto

Former Member
0 Kudos
137

To solve the problem I used the solution in answer number three - but I created my own GUI with selected elements from "ALV-GUIs" in a standard SAP program.

Thank you very much for great help!

- Mari