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: 

Push buttons inALV

Former Member
0 Kudos

Hi

can any one tl me hw to add pushbuttons in ALV grid display/list display.

my requirement is when i click the pushbutton(back) then it wl go back to the editor from list/grid display.

thanks in advance

6 REPLIES 6

Former Member
0 Kudos

GO to SE41 copy the status STANDARD from the program SAPLKKBL..And give the status name and your program name.

In the parameter I_CALLBACK_PF_STATUS_SET give the form name 'PF_STATUS_SET'.

In the subroutine.

FORM PF_STATUS_SET.

SET PF-STATUS 'STATUS NAME THAT YOU GAVE IN SE41'.

ENDFORM.

  • For user command pass the parameter I_CALLBACK_USER_COMMAND with the user command subroutine name..

FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

...

IF R_UCOMM = ''.

...

ENDIF.

ENDFORM.

  • Example

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = lv_repid

I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_SET'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

............

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

USER COMMAND can be used for achieving your requirements.

In this program, just copy the pf-status of standard program SAPLSALV into your program. Then add an extra function code CHNG to the toolbar.

This will work.

Just check this simple code.

REPORT ZSHAIL_MULTIPLY .

TYPE-POOLS: slis.

DATA: BEGIN OF i_data OCCURS 0,

qmnum LIKE qmel-qmnum,

qmart LIKE qmel-qmart,

qmtxt LIKE qmel-qmtxt,

ws_row TYPE i,

ws_char(5) TYPE c,

chk,

END OF i_data.

DATA: report_id LIKE sy-repid.

DATA: ws_title TYPE lvc_title VALUE 'An ALV Report'.

DATA: i_layout TYPE slis_layout_alv.

DATA: i_fieldcat TYPE slis_t_fieldcat_alv.

DATA: i_events TYPE slis_t_event.

DATA: i_header TYPE slis_t_listheader.

DATA: i_extab TYPE slis_t_extab.

SELECT qmnum qmart qmtxt INTO TABLE i_data FROM qmel

WHERE qmnum <= '00030000010'.

LOOP AT i_data.

i_data-ws_row = sy-tabix.

i_data-ws_char = 'AAAAA'.

MODIFY i_data.

ENDLOOP.

report_id = sy-repid.

PERFORM f1000_layout_init CHANGING i_layout.

PERFORM f2000_fieldcat_init CHANGING i_fieldcat.

PERFORM f4000_events_init CHANGING i_events.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = report_id

i_grid_title = ws_title

is_layout = i_layout

it_fieldcat = i_fieldcat

i_save = 'A'

it_events = i_events

TABLES

t_outtab = i_data

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.

FORM f1000_layout_init USING i_layout TYPE slis_layout_alv.

CLEAR i_layout.

i_layout-colwidth_optimize = 'X'.

i_layout-edit = 'X'.

ENDFORM.

FORM f2000_fieldcat_init CHANGING i_fieldcat TYPE slis_t_fieldcat_alv.

DATA: line_fieldcat TYPE slis_fieldcat_alv.

CLEAR line_fieldcat.

line_fieldcat-fieldname = 'QMNUM'. " The field name and the table

line_fieldcat-tabname = 'I_DATA'. " name are the two minimum req.

line_fieldcat-key = 'X'. " Specifies the column as a key (Blue)

line_fieldcat-seltext_m = 'Notification No.'. " Column Header

APPEND line_fieldcat TO i_fieldcat.

CLEAR line_fieldcat.

line_fieldcat-fieldname = 'QMART'.

line_fieldcat-ref_tabname = 'I_DATA'.

line_fieldcat-hotspot = 'X'. " Shows the field as a hotspot.

line_fieldcat-seltext_m = 'Notif Type'.

APPEND line_fieldcat TO i_fieldcat.

CLEAR line_fieldcat.

line_fieldcat-fieldname = 'QMTXT'.

line_fieldcat-tabname = 'I_DATA'.

line_fieldcat-seltext_m = 'Description'.

APPEND line_fieldcat TO i_fieldcat.

CLEAR line_fieldcat.

line_fieldcat-fieldname = 'WS_ROW'.

line_fieldcat-tabname = 'I_DATA'.

line_fieldcat-seltext_m = 'Row Number'.

APPEND line_fieldcat TO i_fieldcat.

ENDFORM.

FORM f4000_events_init CHANGING i_events TYPE slis_t_event.

DATA: line_event TYPE slis_alv_event.

CLEAR line_event.

line_event-name = 'TOP_OF_PAGE'.

line_event-form = 'F4100_TOP_OF_PAGE'.

APPEND line_event TO i_events.

CLEAR line_event.

line_event-name = 'PF_STATUS_SET'.

line_event-form = 'F4200_PF_STATUS_SET'.

APPEND line_event TO i_events.

CLEAR line_event.

line_event-name = 'USER_COMMAND'.

line_event-form = 'F4300_USER_COMMAND'.

APPEND line_event TO i_events.

ENDFORM. " f3000_events_init

FORM f4200_pf_status_set USING i_extab TYPE slis_t_extab.

REFRESH i_extab.

SET PF-STATUS 'MENU' EXCLUDING i_extab.

ENDFORM.

FORM f4300_user_command USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield.

CASE ucomm.

WHEN 'CHNG'.

message i001(zmess).

endcase.

ENDFORM.

0 Kudos

hi

thanq,but user-command is mandatory r optional.

0 Kudos

hey can u tl me clearly,it's getting confused,

let me know clear directions plz

0 Kudos

Hi

Use SET PF STATUS in your report

Regards

Pavan

Former Member
0 Kudos

Hi

using SET PF STATUS.u can do that

Here is the sample code.If you are using reuse_alv_grid_display, no need to write code in PBO.

Just double click the 'TEST' which is written in code.Then create a GUI Status.In Application toolbar,type the name of the button you want(say BUTTON).Then double click that name.Then enter the ICON name and function text.Activate it.This itself will work.If you want all the functionalities,then try to do as Vinod told.

TYPE-POOLS: slis.

DATA: i_qmel LIKE qmel OCCURS 0.
data v_repid type repid.
SELECT * FROM qmel INTO TABLE i_qmel.

v_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = v_repid
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
i_structure_name = 'QMEL'
TABLES
t_outtab = i_qmel
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.

form set_pf_status using rt_extab type slis_t_extab.
set pf-status 'TEST'.
endform.

FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
data lv_ucomm type sy-ucomm.
lv_ucomm
= sy-ucomm.
CASE lv_ucomm.
WHEN 'BUTTON'. "Double Click line Item
call transaction 'MM01'.
endcase.
endform. 

Regards

Pavan

Former Member
0 Kudos

Have a look at the demo program BCALV_TEST_GRID - in the selection screen (which is very long!) there is the option to set a row or column as buttons, e.g. "Button on Column Level".

Jonathan