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

ALV class include?

I wrote alv program as below.

i dont know where to put this below CLASS in dynpro

module. either PBO or PAI.

when i keep this in ordinary report it works fine.

but when i use in dynpro screen its not working.

could you pls suggest.

CLASS lcl_event_receiver DEFINITION DEFERRED.

DATA:

go_grid TYPE REF TO cl_gui_alv_grid,

go_custom_container TYPE REF TO cl_gui_custom_container,

o_event_receiver TYPE REF TO lcl_event_receiver.

CLASS lcl_event_receiver DEFINITION.

PUBLIC SECTION.

METHODS:

handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid

IMPORTING

e_object e_interactive,

handle_user_command FOR EVENT user_command OF cl_gui_alv_grid

IMPORTING e_ucomm.

ENDCLASS.

----


  • CLASS lcl_event_receiver IMPLEMENTATION

----


CLASS lcl_event_receiver IMPLEMENTATION.

METHOD handle_toolbar.

  • Event handler method for event toolbar.

CONSTANTS:

  • Constants for button type

c_button_normal TYPE i VALUE 0,

c_menu_and_default_button TYPE i VALUE 1,

c_menu TYPE i VALUE 2,

c_separator TYPE i VALUE 3,

c_radio_button TYPE i VALUE 4,

c_checkbox TYPE i VALUE 5,

c_menu_entry TYPE i VALUE 6.

DATA:

ls_toolbar TYPE stb_button.

  • Append seperator to the normal toolbar

CLEAR ls_toolbar.

MOVE c_separator TO ls_toolbar-butn_type..

APPEND ls_toolbar TO e_object->mt_toolbar.

  • Append a new button that to the toolbar. Use E_OBJECT of

  • event toolbar. E_OBJECT is of type CL_ALV_EVENT_TOOLBAR_SET.

  • This class has one attribute MT_TOOLBAR which is of table type

  • TTB_BUTTON. The structure is STB_BUTTON

CLEAR ls_toolbar.

MOVE 'REFRESH' TO ls_toolbar-function.

MOVE icon_REFRESH TO ls_toolbar-icon.

MOVE 'Change flight' TO ls_toolbar-quickinfo.

MOVE 'Refresh' TO ls_toolbar-text.

MOVE ' ' TO ls_toolbar-disabled.

APPEND ls_toolbar TO e_object->mt_toolbar.

ENDMETHOD.

METHOD handle_user_command.

  • Handle own functions defined in the toolbar

CASE e_ucomm.

WHEN 'REFRESH'.

  • Read data from table SFLIGHT

SELECT * FROM sflight INTO TABLE gi_sflight.

CALL METHOD go_grid->refresh_table_display.

CALL METHOD cl_gui_cfw=>flush.

  • LEAVE TO SCREEN 0.

ENDCASE.

ENDMETHOD.

ENDCLASS.

&----


*& Module STATUS_0300 OUTPUT

&----


  • text

----


MODULE STATUS_0300 OUTPUT.

  • Create objects

IF go_custom_container IS INITIAL.

CREATE OBJECT go_custom_container

EXPORTING container_name = 'ZCUSTOM'.

CREATE OBJECT go_grid

EXPORTING

i_parent = go_custom_container.

CREATE OBJECT o_event_receiver.

SET HANDLER o_event_receiver->handle_user_command FOR go_grid.

SET HANDLER o_event_receiver->handle_toolbar FOR go_grid.

Perform Loaddata.

ENDIF.

ENDMODULE. " STATUS_0300 OUTPUT

FORM Loaddata.

  • Read data from table SFLIGHT

SELECT * FROM sflight INTO TABLE gi_sflight.

  • Load data into the grid and display them

CALL METHOD go_grid->set_table_for_first_display

EXPORTING i_structure_name = 'SFLIGHT'

CHANGING it_outtab = gi_sflight.

CALL METHOD go_grid->set_toolbar_interactive.

ENDFORM.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 25, 2005 at 02:35 PM

    Hi,

    I would recommend to put this in a seperate include with name <program_name>_lcl and insert a include statement next to your include <program_name>_top.

    regards

    Siggi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 25, 2005 at 03:06 PM

    Hi Ambi,

    Or just add the CLASS in the main program as it's only small.

    Regards,

    John.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 26, 2005 at 02:15 AM

    hey

    i have put the classes in data declaration include file at top. Here my problem is.

    when i click push button from screen. I get ALV grid displaying next screen with my respective query values. Next i clicked Refresh button newly created in toolbar of ALVgrid. it works fine.(using refresh grid method.)

    but when i get back from the grid screen and start from first screen by clicking

    push button, the ALV grid displays with same values at when i clicked the refresh button.

    i debugged each time i get stored internal table with new values but not updated

    to alv grid why?

    does the below ALV function works for only first display time?

    CALL METHOD GRID_REPORT->SET_TABLE_FOR_FIRST_DISPLAY.

    ambichan.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Are you sure, you are putting new values in the internal table ? Last time I checked your code, both had the same line:

      Select * from sflight into table gt_flight.

      The above code was before you call the method <b>set_table_for_first_display</b> and <b>refresh_table_display</b>.

      Also check whether your event is getting triggered. Put a breakpoint in your event method.

      Let us know how it turned out.

      Regards,

      Subramanian V.

  • author's profile photo Former Member
    Former Member
    Posted on Jan 26, 2005 at 04:26 AM

    am sorry,I have put the real code below.

    I commented all Class and event methods.

    i am passing date from before screen to this grid screen by name IMPODAY.

    when first time i select date and pass to query,query works out and displaying well.

    when i get back to original screen and again select different date

    its giving previous display itself.(not getting new query output.)

    i debugged the program till the select query internal table its working fine

    even in internal table i am holding the values but its not displaying

    in GRID. I am wondering why.

    MODULE REPORTSTATUS_PBO200 OUTPUT.

    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

    EXPORTING

    I_STRUCTURE_NAME = 'ZMW0001'

    CHANGING

    CT_FIELDCAT = FIELDCATALOG_TMP

    EXCEPTIONS

    INCONSISTENT_INTERFACE = 1

    PROGRAM_ERROR = 2

    OTHERS = 3.

    IF SY-SUBRC <> 0.

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

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

    ENDIF.

    PERFORM FIELDCATALOG_OPP.

    CREATE OBJECT G_CUSTOM_CONTAINER

    EXPORTING CONTAINER_NAME = G_CONTAINER.

    CREATE OBJECT GRID_REPORT

    EXPORTING I_PARENT = G_CUSTOM_CONTAINER.

    PERFORM PREPARE_LAYOUT.

    PERFORM HIDE_TOOLBAR.

    SELECT * FROM ZMW0001

    INTO TABLE SDYN_ITAB WHERE IMPORTDAY = IMPODAY.

    SORT SDYN_ITAB BY STATUS.

    CALL METHOD GRID_REPORT->SET_TABLE_FOR_FIRST_DISPLAY

    EXPORTING

    it_toolbar_excluding = lt_toolbar_excluding

    is_layout = ps_layout

    CHANGING IT_FIELDCATALOG = FIELDCATALOG

    IT_OUTTAB = SDYN_ITAB

    EXCEPTIONS

    invalid_parameter_combination = 1

    program_error = 2

    too_many_lines = 3

    others = 4.

    ENDMODULE.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      this is my part of the code.

      CREATE OBJECT o_event_receiver.

      SET HANDLER o_event_receiver->handle_user_command FOR GRID_REPORT.

      SET HANDLER o_event_receiver->handle_toolbar FOR GRID_REPORT.

      CALL METHOD GRID_REPORT->SET_TABLE_FOR_FIRST_DISPLAY

      EXPORTING

      it_toolbar_excluding = lt_toolbar_excluding

      is_layout = ps_layout

      CHANGING IT_FIELDCATALOG = FIELDCATALOG

      IT_OUTTAB = SDYN_ITAB

      EXCEPTIONS

      invalid_parameter_combination = 1

      program_error = 2

      too_many_lines = 3

      others = 4.

      CALL METHOD GRID_REPORT->set_toolbar_interactive.

      how can i give condition here to display refresh button only at timing of click at push button 2.

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.