Skip to Content
author's profile photo Former Member
Former Member

ALV Push buttons

Hi,

Can any one tell me how to insert pysh buttons in ALV grid using classes and if possiable send me the code.

Points will be rewarded for the helpful answers.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 07:05 AM

    Hi,

    PLzz do reward if it helps.

    ----


    • CLASS L_CL_EVENTS DEFINITION *

    ----


    • Class for inserting buttons on the toolbar *

    ----


    CLASS l_cl_events DEFINITION.

    PUBLIC SECTION.

    METHODS:

    toolbar FOR EVENT toolbar

    OF cl_gui_alv_grid

    IMPORTING e_object

    e_interactive,

    user_command FOR EVENT user_command

    OF cl_gui_alv_grid

    IMPORTING e_ucomm .

    ENDCLASS. " L_CL_EVENTS DEFINITION

    ----


    • CLASS L_CL_EVENTS IMPLEMENTATION *

    ----


    • Implementation of class L_CL_EVENTS *

    ----


    CLASS l_cl_events IMPLEMENTATION.

    METHOD toolbar.

    PERFORM event_toolbar USING e_object.

    ENDMETHOD. " TOOLBAR

    METHOD user_command.

    PERFORM event_ucomm USING e_ucomm.

    ENDMETHOD. " USER_COMMAND

    ENDCLASS. " L_CL_EVENTS IMPLEMENTATION

    DATA:

    • To create instance for cl_gui_custom_container

    g_grid TYPE REF TO cl_gui_custom_container,

    • To create instance for cl_gui_alv_grid

    g_alv TYPE REF TO cl_gui_alv_grid,

    • To create instance for l_cl_events

    g_events TYPE REF TO l_cl_events,

    • To assign name for custom container

    g_container TYPE scrfname VALUE 'CONTAINER',

    • To assign layout

    g_fcatlayo TYPE lvc_s_layo.

    ----


    • FORM EVENT_TOOLBAR *

    ----


    • Setting toolbar in the alv grid *

    ----


    • -->E_OBJECT TYPE REF TO CL_ALV_EVENT_TOOLBAR_SET *

    ----


    FORM event_toolbar USING e_object

    TYPE REF TO cl_alv_event_toolbar_set.

    • Local declaration for the button.

    DATA: ls_toolbar TYPE stb_button.

    • To add Approve button

    ls_toolbar-function = c_app_rej

    ls_toolbar-butn_type = c_zero.

    ls_toolbar-text = text-001.

    APPEND ls_toolbar TO e_object->mt_toolbar.

    • To add Reject button

    CLEAR ls_toolbar.

    ls_toolbar-function = c_fcode_rej.

    ls_toolbar-butn_type = c_zero.

    ls_toolbar-text = text-013.

    APPEND ls_toolbar TO e_object->mt_toolbar.

    ENDFORM. " EVENT_TOOLBAR

    ----


    • FORM EVENT_UCOMM *

    ----


    • After Input in the ALV grid,if user select record and press *

    • approve or reject then the record will get updated *

    ----


    • --> PR_ucomm type sy-ucomm *

    ----


    FORM event_ucomm USING pr_ucomm LIKE sy-ucomm.

    CASE pr_ucomm.

    • If e_ucomm contains 'APP' i.e.function code for Approve button

    WHEN c_fcode_approve. " To approve selected record

    PERFORM app_timesheet USING c_approve_status.

    • If e_ucomm contains 'REJ' i.e. function code for Reject

    WHEN c_fcode_rej. " To reject selected record

    PERFORM app_timesheet USING c_rej_status.

    ENDCASE. " CASE E_UCOMM

    ENDFORM. " EVENT_UCOMM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 07:12 AM

    Hi,

    CLASS lcl_event_receiver DEFINITION.

    PUBLIC SECTION.

    METHODS:

    handle_double_click

    FOR EVENT double_click OF cl_gui_alv_grid

    IMPORTING e_row e_column.

    METHODS: handle_button_click

    FOR EVENT button_click OF cl_gui_alv_grid

    IMPORTING es_col_id es_row_no.

    ENDCLASS. "LCL_EVENT_RECEIVER DEFINITION

    ----


    • CLASS LCL_EVENT_RECEIVER IMPLEMENTATION

    ----


    *

    ----


    CLASS lcl_event_receiver IMPLEMENTATION.

    METHOD handle_double_click.

    ENDMETHOD. "HANDLE_DOUBLE_CLICK

    METHOD handle_button_click.

    ENDMETHOD. "HANDLE_BUTTON_CLICK

    ENDCLASS. "lcl_event_receiver IMPLEMENTATION

    after creating the object of this class.

    set the handler ..

    eg

    SET HANDLER w_event_receiver->handle_button_click FOR w_grid.

    and use this logic to create button.

    create a two fields in the internal table.

    eg

    button (30) type c

    push type LVC_S_STYL.

    ls_styl-fieldname = 'BUTTON'.

    ls_styl-style = cl_gui_alv_grid=>mc_style_button.

    APPEND ls_styl TO itab-push.

    and in the fieldcatalog u should pass

    data: w_mylayout type lvc_s_layo.

    w_mylayout-stylefname = 'PUSH'.

    and then pass it to

    CALL METHOD w_grid->set_table_for_first_display

    EXPORTING

    is_layout = w_mylayout

    CHANGING

    it_outtab = t_manpower

    it_fieldcatalog = ist_fcat[]

    EXCEPTIONS

    invalid_parameter_combination = 1

    program_error = 2

    too_many_lines = 3

    OTHERS = 4.

    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,

    Santosh Thorat

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 07:27 AM

    hi ,

    we can add push buttons in alv grid using oops concept.

    we create a container and call the screen for display with the push button if you want.

    Reward Points if found helpfull..

    Cheers,

    Chandra Sekhar.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.