""Agregarlo a tu código
TYPE-POOLS: SLIS.
TYPE-POOLS : ICON.
DATA: CL_GUI_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
GRID_ALV TYPE REF TO CL_GUI_ALV_GRID,
CLASS gcl_event definition.
public section.
* Tool bar
METHODS:
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object
e_interactive,
*handling menu buttons
handle_menu_button FOR EVENT menu_button of CL_GUI_ALV_GRID IMPORTING E_OBJECT E_UCOMM,
* Status bar
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
endclass.
* create the relevant buttons on the toolbars
METHOD handle_toolbar.
* This method handles the user interaction with the tool bar.
DATA: ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
"MOVE 2 TO LS_TOOLBAR-BUTN_TYPE.
MOVE : 'REFRESH' TO ls_toolbar-function,"Function code = Codigo funcion
ICON_REFRESH TO ls_toolbar-icon,"Name of an Icon = Nombre del icono
'Refrescar :) ' TO ls_toolbar-quickinfo,"Quickinfo for an icon = Texto cuando paso el mouse
1 TO ls_toolbar-butn_type,"Toolbar button type
'' TO ls_toolbar-disabled,"Disabled = Desabilitar el boton pero si se muestra 'X'
'REFRESH' TO ls_toolbar-text."Text = Texto en el boton
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE : 'HELLO' TO ls_toolbar-function,"Function code = Codigo funcion
' ' TO ls_toolbar-icon,"Name of an Icon = Nombre del icono
' ' TO ls_toolbar-quickinfo,"Quickinfo for an icon = Texto cuando paso el mouse
' ' TO ls_toolbar-butn_type,"Toolbar button type
'' TO ls_toolbar-disabled,"Disabled = Desabilitar el boton pero si se muestra 'X'
'HELLO' TO ls_toolbar-text."Text = Texto en el boton
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE : 'BYE' TO ls_toolbar-function,"Function code = Codigo funcion
' ' TO ls_toolbar-icon,"Name of an Icon = Nombre del icono
' ' TO ls_toolbar-quickinfo,"Quickinfo for an icon = Texto cuando paso el mouse
2 TO ls_toolbar-butn_type,"Toolbar button type
'' TO ls_toolbar-disabled,"Disabled = Desabilitar el boton pero si se muestra 'X'
'BYE' TO ls_toolbar-text."Text = Texto en el boton
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD.
class gcl_event implementation.
METHOD handle_user_command.
CASE e_ucomm.
when 'REFRESH'.
MESSAGE s001(zalv) WITH 'No. of rows selected'.
MESSAGE 'RERESHED DATA' TYPE 'I'.
WHEN 'HELLO'.
MESSAGE 'HELLO' TYPE 'I'.
WHEN 'REFRESH1'.
MESSAGE 'REFRESH' TYPE 'I'.
WHEN 'BYE1'.
MESSAGE 'Hasta la vista baby' TYPE 'I'.
ENDCASE.
ENDMETHOD.
METHOD HANDLE_MENU_BUTTON. " * handle own menubuttons
IF E_UCOMM = 'REFRESH'.
CALL METHOD e_object->add_function
EXPORTING
fcode = 'REFRESH1'
text = 'Refrescando'.
ENDIF.
IF E_UCOMM = 'BYE'.
CALL METHOD e_object->add_function
EXPORTING
fcode = 'BYE1'
text = 'Hasta la vista'.
ENDIF.
ENDMETHOD.
endclass.
" referencia a la clase glc_event creada en el anterior include
DATA: GO_EVENT TYPE REF TO GCL_EVENT.
CREATE OBJECT GO_EVENT. " creando objeto go_event
set handler GO_EVENT->handle_toolbar for GRID_ALV.
set handler GO_EVENT->handle_user_command for GRID_ALV.
set handler GO_EVENT->HANDLE_MENU_BUTTON for GRID_ALV.
lunes, 9 de febrero de 2015
miércoles, 4 de febrero de 2015
Reporte simple usando ABAP OO
REPORT ZABAP_OO_01.
PARAMETERS: P_EBELN TYPE EKKO-EBELN.
CLASS A DEFINITION.
PUBLIC SECTION.
TYPES: BEGIN OF TT,
EBELN TYPE EKKO-EBELN,
BUKRS TYPE EKKO-BUKRS,
BSTYP TYPE EKKO-BSTYP,
END OF TT.
DATA: TI TYPE STANDARD TABLE OF TT.
METHODS: GET_EKKO,
DISPLAY_EKKO.
ENDCLASS.
CLASS A IMPLEMENTATION.
METHOD GET_EKKO.
SELECT EBELN BUKRS BSTYP FROM EKKO INTO TABLE TI WHERE EBELN = P_EBELN.
ENDMETHOD.
METHOD DISPLAY_EKKO.
FIELD-SYMBOLS: <FS> TYPE TT.
LOOP AT TI ASSIGNING <FS>.
WRITE: / <FS>-EBELN,
/ <FS>-BUKRS,
/ <FS>-BSTYP.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA: A1 TYPE REF TO A.
CREATE OBJECT A1.
A1->GET_EKKO( ).
A1->DISPLAY_EKKO( ).
PARAMETERS: P_EBELN TYPE EKKO-EBELN.
CLASS A DEFINITION.
PUBLIC SECTION.
TYPES: BEGIN OF TT,
EBELN TYPE EKKO-EBELN,
BUKRS TYPE EKKO-BUKRS,
BSTYP TYPE EKKO-BSTYP,
END OF TT.
DATA: TI TYPE STANDARD TABLE OF TT.
METHODS: GET_EKKO,
DISPLAY_EKKO.
ENDCLASS.
CLASS A IMPLEMENTATION.
METHOD GET_EKKO.
SELECT EBELN BUKRS BSTYP FROM EKKO INTO TABLE TI WHERE EBELN = P_EBELN.
ENDMETHOD.
METHOD DISPLAY_EKKO.
FIELD-SYMBOLS: <FS> TYPE TT.
LOOP AT TI ASSIGNING <FS>.
WRITE: / <FS>-EBELN,
/ <FS>-BUKRS,
/ <FS>-BSTYP.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA: A1 TYPE REF TO A.
CREATE OBJECT A1.
A1->GET_EKKO( ).
A1->DISPLAY_EKKO( ).
Suscribirse a:
Entradas (Atom)