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: 

Custom button on a editable alv grid

Former Member
0 Kudos

Hi experts,

I'm using an editable alv like this:

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
       EXPORTING
            i_callback_program            = gd_repid
            i_callback_user_command  = 'USER_COMMAND'
*            I_STRUCTURE_NAME       = 'ZPEDAUTOMTAB'


            is_layout_lvc           = gd_layout
            it_fieldcat_lvc         = it_fieldcat
            i_save                  = 'X'
       TABLES
            t_outtab                = gt_zpedautomtab
       EXCEPTIONS
            program_error           = 1
            OTHERS                  = 2.

Does anybody know if i can add a custom button to the header or anywhere else to program a custom action?

If it is not; i can use another type of editable alv that lets me do that; if that exists.

Tank-you.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

1) Create a new GUI (let's say Z_GUI) in SE41 by copying the standard GUI status STANDARD from the program.

Then add a button in the application toolbar.

2) Create a subroutine SET_PF_STATUS in your program with the following code..

SET PF-STATUS 'Z_GUI'.

3) Pass the subroutine 'SET_PF_STATUS' in the parameter I_CALLBACK_PF_STATUS_SET of the function module.

Thanks

Naren

3 REPLIES 3

Former Member
0 Kudos

Hi,

1) Create a new GUI (let's say Z_GUI) in SE41 by copying the standard GUI status STANDARD from the program.

Then add a button in the application toolbar.

2) Create a subroutine SET_PF_STATUS in your program with the following code..

SET PF-STATUS 'Z_GUI'.

3) Pass the subroutine 'SET_PF_STATUS' in the parameter I_CALLBACK_PF_STATUS_SET of the function module.

Thanks

Naren

0 Kudos

¡Tank you very much!

Both your help has been really helpful to solve my problem.

glio_ad
Active Participant
0 Kudos

Hi

Check the following template code and adjust accordingly:

  • Call the ALV

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = w_repid

i_callback_pf_status_set = 'PF_STATUS_SET'

i_callback_user_command = 'LINE_CLICK'

i_callback_top_of_page = 'TOP_ROUTINE'

i_callback_html_end_of_list = 'EOL_LOG'

i_grid_title = text-ttl

is_layout = my_layout

it_fieldcat = it_fieldcatalog

it_sort = it_sort

i_save = g_save

i_grid_settings = lc_glay

is_variant = w_variant

is_print = my_print

TABLES

t_outtab = i_out

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 top_routine

&----


FORM top_routine.

  • { Local

DATA:

w_page(5) TYPE c,

l_line TYPE slis_entry,

lh_top TYPE slis_listheader,

lt_top TYPE slis_t_listheader.

  • }

DEFINE top_line.

clear lh_top.

lh_top-typ = &1.

lh_top-key = &2.

lh_top-info = &3.

append lh_top to lt_top.

END-OF-DEFINITION.

WRITE sy-datum TO l_line.

top_line 'S' text-t01 l_line.

WRITE sy-uname TO l_line.

top_line 'S' text-t02 l_line.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = lt_top.

ENDFORM. "top_routine

&----


*& Form pf_status_set

&----


FORM pf_status_set USING extab TYPE slis_t_extab.

data: wa_extab like LINE OF extab.

wa_extab-fcode = '&REFRESH'.

append wa_extab to extab.

wa_extab-fcode = 'MODE'.

append wa_extab to extab.

SET PF-STATUS 'ZSD_DA01' EXCLUDING extab.

ENDFORM. "pf_status_set

&----


*& Form line_click

&----


FORM line_click USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield.

DATA: wl_ucomm LIKE sy-ucomm.

DATA: es_l TYPE slis_layout_alv,

es_fld TYPE slis_t_fieldcat_alv,

es_sort TYPE slis_t_sortinfo_alv,

es_mark TYPE slis_t_fieldcat_alv.

wl_ucomm = sy-ucomm.

CLEAR sy-ucomm.

CASE wl_ucomm.

  • Set printing mode

WHEN 'MODE'.

IF w_mode = 'O'.

w_mode = 'T'.

w_mode_txt = text-018.

ELSE.

w_mode = 'O'.

w_mode_txt = text-019.

ENDIF.

SET PF-STATUS 'ZSD_DA01'.

  • Exit Functions

WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.

LEAVE TO SCREEN 0.

  • Show Log

WHEN 'LOG'.

selfield-refresh = 'X'.

PERFORM log_show.

  • Issue output

WHEN 'ISSUE'.

selfield-refresh = 'X'.

PERFORM print_deliveries.

  • Select all

WHEN 'SALL'.

selfield-refresh = 'X'.

LOOP AT i_out.

i_out-box = 'X'.

MODIFY i_out.

ENDLOOP.

  • Deselect all

WHEN 'DSAL'.

selfield-refresh = 'X'.

LOOP AT i_out.

i_out-box = ' '.

MODIFY i_out.

ENDLOOP.

ENDCASE.

  • Handle User clicks

CASE selfield-fieldname.

  • Display Vendor Master

WHEN 'KUNNR' OR 'KUNAG'.

IF NOT selfield-value IS INITIAL.

READ TABLE i_out INDEX selfield-tabindex.

IF selfield-fieldname = 'KUNAG'.

SET PARAMETER ID 'KUN' FIELD i_out-kunag.

ELSEIF selfield-fieldname = 'KUNNR'.

SET PARAMETER ID 'KUN' FIELD i_out-kunnr.

ENDIF.

SET PARAMETER ID 'BUK' FIELD i_out-bukrs_vf.

SET PARAMETER ID 'VKO' FIELD i_out-vkorg.

SET PARAMETER ID 'VTW' FIELD i_out-vtweg.

SET PARAMETER ID 'SPA' FIELD i_out-spart.

CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.

ENDIF.

  • Go To VL03N

WHEN 'VBELN'.

READ TABLE i_out INDEX selfield-tabindex.

IF NOT i_out-vbeln IS INITIAL.

SET PARAMETER ID 'VL' FIELD i_out-vbeln.

CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.

ENDIF.

  • Go To VA03

WHEN 'VGBEL'.

READ TABLE i_out INDEX selfield-tabindex.

IF NOT i_out-vgbel IS INITIAL.

SET PARAMETER ID 'AUN' FIELD i_out-vgbel.

CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

ENDIF.

ENDCASE.

ENDFORM. "line_click

Please, reward if helpful

Regards,

George