OO ALV USING CUSTOM CONTAINER WITH DOUBLE CLICK EVENT


TYPES : BEGIN OF tab,

carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
countryfr TYPE spfli-countryfr,
cityfrom TYPE spfli-cityfrom,
airpfrom TYPE spfli-airpfrom,
countryto TYPE spfli-countryto,
cityto TYPE spfli-cityto,
airpto TYPE spfli-airpto,
END OF tab.

DATA : it_spfli TYPE TABLE OF tab,
wa_spfli TYPE tab,
ok_code TYPE sy-ucomm,
o_cust TYPE REF TO cl_gui_custom_container,
o_alv TYPE REF TO cl_gui_alv_grid,
it_fcat TYPE lvc_t_fcat,
wa_fcat TYPE lvc_s_fcat .

DATA : IT_SFLIGHT TYPE TABLE OF SFLIGHT.
DATA : O_DOCK TYPE REF TO CL_GUI_DOCKING_CONTAINER,
O_ALV1 TYPE REF TO CL_GUI_ALV_GRID.

SELECT-OPTIONS : s_carr FOR wa_spfli-carrid.

CLASS HANDLE_EVENT DEFINITION.
PUBLIC SECTION.
CLASSMETHODS : HANDLE_DOUBLE_CLICK  

          FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID IMPORTING e_row .

ENDCLASS.

CLASS HANDLE_EVENT IMPLEMENTATION.
METHOD handle_double_click.
READ TABLE IT_SPFLI INTO WA_SPFLI INDEX E_ROW.
SELECT * FROM SFLIGHT INTO TABLE IT_SFLIGHT WHERE CARRID = WA_SPFLI-CARRID.
CALL SCREEN 200.
ENDMETHOD.
ENDCLASS.


START-OF-SELECTION.

PERFORM DATA_FETCH.
PERFORM BUILD_FIELDCATALOG.
CALL SCREEN 100.

form DATA_FETCH .
SELECT carrid
connid
countryfr
cityfrom
airpfrom
countryto
cityto
airpto FROM spfli INTO TABLE it_spfli WHERE carrid IN s_carr.
endform.                    ” DATA_FETCH

form BUILD_FIELDCATALOG .
CLEAR wa_fcat.
WA_FCAT-col_pos = 1.
WA_FCAT-fieldname = ‘CARRID’.
WA_FCAT-tabname = ‘IT_SPFLI’.
WA_FCAT-COLTEXT = ‘CARRID’.
APPEND wa_fcat TO IT_FCAT.
CLEAR wa_fcat.

WA_FCAT-col_pos = 2.
WA_FCAT-fieldname = ‘CONNID’.
WA_FCAT-tabname = ‘IT_SPFLI’.
WA_FCAT-COLTEXT = ‘CONNID’.
APPEND wa_fcat TO IT_FCAT.
CLEAR wa_fcat.

WA_FCAT-col_pos = 3.
WA_FCAT-fieldname = ‘COUNTRYFR’.
WA_FCAT-tabname = ‘IT_SPFLI’.
WA_FCAT-COLTEXT = ‘COUNTRY FROM’.
APPEND wa_fcat TO IT_FCAT.
CLEAR wa_fcat.

WA_FCAT-col_pos = 4.
WA_FCAT-fieldname = ‘CITYFROM’.
WA_FCAT-tabname = ‘IT_SPFLI’.
WA_FCAT-COLTEXT = ‘COUNTRY TO’..
APPEND wa_fcat TO IT_FCAT.
CLEAR wa_fcat.

WA_FCAT-col_pos = 5.
WA_FCAT-fieldname = ‘AIRPFROM’.
WA_FCAT-tabname = ‘IT_SPFLI’.
WA_FCAT-COLTEXT = ‘AIRPORT FROM’.
APPEND wa_fcat TO IT_FCAT.
CLEAR wa_fcat.

WA_FCAT-col_pos = 6.
WA_FCAT-fieldname = ‘COUNTRYTO’.
WA_FCAT-tabname = ‘IT_SPFLI’.
WA_FCAT-COLTEXT = ‘COUNTRY TO’.
APPEND wa_fcat TO IT_FCAT.
CLEAR wa_fcat.

WA_FCAT-col_pos = 7.
WA_FCAT-fieldname = ‘CITYTO’.
WA_FCAT-tabname = ‘IT_SPFLI’.
WA_FCAT-COLTEXT = ‘CITY TO’.
APPEND wa_fcat TO IT_FCAT.
CLEAR wa_fcat.

WA_FCAT-col_pos = 8.
WA_FCAT-fieldname = ‘AIRPTO’.
WA_FCAT-tabname = ‘IT_SPFLI’.
WA_FCAT-COLTEXT = ‘AIRPORT TO’.
APPEND wa_fcat TO IT_FCAT.
CLEAR wa_fcat.
endform.                    ” BUILD_FIELDCATALOG

module STATUS_0100 output.
SET PF-STATUS ‘STAT’.
SET TITLEBAR ‘TITLT’.

endmodule.                 ” STATUS_0100  OUTPUT

module DISPLAY_ALV output.

IF o_cust IS NOT BOUND.
CREATE OBJECT o_cust
EXPORTING
container_name              = ‘CONTAINER’.
ENDIF.

IF O_ALV IS NOT BOUND.
CREATE OBJECT o_alv
EXPORTING
i_parent          = O_CUST.

SET HANDLER HANDLE_EVENT=>HANDLE_DOUBLE_CLICK FOR O_ALV.

CALL METHOD o_alv->set_table_for_first_display
CHANGING
it_outtab                     = IT_SPFLI
it_fieldcatalog               = IT_FCAT.

ENDIF.
endmodule.                 ” DISPLAY_ALV  OUTPUT

module USER_COMMAND_0100 input.
CASE  OK_CODE.
WHEN ‘BACK’.
LEAVE TO SCREEN 0.
ENDCASE.
endmodule.                 ” USER_COMMAND_0100  INPUT

module STATUS_0200 output.
SET PF-STATUS ‘STSA’.
*  SET TITLEBAR ‘xxx’.
IF O_DOCK IS NOT BOUND.
CREATE OBJECT o_dock
EXPORTING
side              = CL_GUI_DOCKING_CONTAINER=>dock_at_left
extension         = 5000.
ENDIF.


IF O_ALV1 IS NOT BOUND.
CREATE OBJECT o_alv1
EXPORTING
i_parent          = O_DOCK.

CALL METHOD o_alv1->set_table_for_first_display
EXPORTING
i_structure_name              = ‘SFLIGHT’
CHANGING
it_outtab                     = IT_SFLIGHT.

ENDIF.
CALL METHOD o_alv1->refresh_table_display.


endmodule.                 ” STATUS_0200  OUTPUT

module USER_COMMAND_0200 input.
CASE OK_CODE.
WHEN  ‘BACK’.
LEAVE TO SCREEN 0.
ENDCASE.
endmodule.                 ” USER_COMMAND_0200  INPUT

  SCREEN 100 FLOW LOGIC

PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
MODULE DISPLAY_ALV.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.

 


SCREEN 200 FLOW LOGIC

PROCESS BEFORE OUTPUT.
MODULE STATUS_0200.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0200.


 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s