Application Development and Automation 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: 
Read only

ALV class include?

Former Member
0 Likes
1,301

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.

10 REPLIES 10
Read only

Former Member
0 Likes
1,254

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

Read only

Former Member
0 Likes
1,254

Hi Ambi,

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

Regards,

John.

Read only

0 Likes
1,254

I agree, I usually put the event receiver class in the main program if its a report program, or if it is a modual pool program, I create a separate include for class definitions/implementations.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,254

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.

Read only

0 Likes
1,254

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.

Read only

Former Member
0 Likes
1,254

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.

Read only

0 Likes
1,254

hey

i solved the above problem.

reason is i have to check Object with initial flag and include refresh grid method.

sorry thanks for your assistance.

Read only

0 Likes
1,254

Just before CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' you need to add an IF:

IF G_CUSTOM_CONTAINER IS INITIAL.

In the ELSE condition you need to do the REFRESH call.

I think you had this in your first code posting.

Not sure what is going on with FIELDCATALOG_TMP and FIELDCATALOG, probably because I cannot see your subroutines.

Read only

0 Likes
1,254

hai thanks for your reply.

i got your point. one more thing ..is

I added REFRESH Button to ALVgrid at screen 200.

In screen 100 i have 3 push button calling same grid

with different query.

i want to show this refresh button in grid only when Push button2 is clicked.other click of push button 1 and 3 should not be displayed this grid toolbar refresh button.

i dont know how to hide only this refresh button from

this code.

ambichan

Read only

0 Likes
1,254

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.