how can i use a class in a abap program?
hi guys,
i created my first class - ztest1. there is a method called test.
this is the test code in the method test.
method TEST.
data: imara type mara.
select * from mara into corresponding fields of imara.
write: / imara-MATNR.
endselect.
endmethod.
how can fields (e.g. mara-matnr) from the select statement be used by a abap program?
cheers,
Could any of you answer my question?
Hallo 007, Hope it helps U.
---------
*Classes / Objects
CLASS lcl_event_handler_alv DEFINITION DEFERRED.
DATA : alv_event_handler TYPE REF TO lcl_event_handler_alv.
*----------------------------------------------------------------------*
* INCLUDE ZCL_MAINTAIN_PLINT_CFG_00CL1 *
*----------------------------------------------------------------------*
* Klassen
CLASS lcl_event_handler_alv DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
catch_dblclick FOR EVENT double_click
OF cl_gui_alv_grid
IMPORTING e_row e_column,
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm
.
ENDCLASS.
CLASS lcl_event_handler_alv IMPLEMENTATION.
METHOD catch_dblclick.
lv_index_itab_format_types = e_row.
READ TABLE itab_format_types INDEX lv_index_itab_format_types INTO
wa_format_types.
*
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'DBLCLICK_ALV'
* IMPORTING
* RC =
.
ENDMETHOD.
METHOD handle_user_command.
DATA: lt_rows TYPE lvc_t_row.
CASE e_ucomm.
WHEN 'DELETE_SEARCH_ITEM'.
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'DELETE_SEARCH_ITEM'
* IMPORTING
* RC =
.
ENDCASE.
ENDMETHOD.
ENDCLASS.
*************************************************
*in PBO.
-------
*----------------------------------------------------------------------*
* INCLUDE ZCL_MAINTAIN_PLINT_CFG_00O01 *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'PF_MAINTAIN_PLINT_CFG_00'.
SET TITLEBAR 'TITLE_MAINTAIN_FORMAT_TYPES'.
IF obj_docking_container IS INITIAL.
CREATE OBJECT obj_docking_container
EXPORTING
* PARENT =
* REPID =
* DYNNR =
* SIDE = DOCK_AT_TOP
extension = 350
* STYLE =
* LIFETIME = lifetime_default
* CAPTION =
metric = 0
* RATIO =
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL METHOD obj_docking_container->dock_at
EXPORTING
side = cl_gui_docking_container=>dock_at_top
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CREATE OBJECT obj_alv_grid
EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
i_parent = obj_docking_container
* I_APPL_EVENTS = space
* I_PARENTDBG =
* I_APPLOGPARENT =
* I_GRAPHICSPARENT =
* I_USE_VARIANT_CLASS = SPACE
* I_NAME =
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
lv_layo_alv-sel_mode = 'B'.
CALL METHOD obj_alv_grid->set_table_for_first_display
EXPORTING
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
* I_CONSISTENCY_CHECK =
i_structure_name = 'ZCL_FORMAT_TYPES'
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
is_layout = lv_layo_alv
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
CHANGING
it_outtab = itab_format_types
* IT_FIELDCATALOG =
* IT_SORT =
* IT_FILTER =
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.
SET HANDLER
alv_event_handler->catch_dblclick FOR obj_alv_grid.
SET HANDLER
alv_event_handler->handle_user_command FOR obj_alv_grid.
ELSE.
ENDIF.
* checks, what the active Tab is then choose the Status
CASE tabstripcontrol_001-activetab.
WHEN 'TAB1'.
WHEN 'TAB2'.
ENDCASE.
ENDMODULE. " STATUS_0100 OUTPUT
...............
all the best...Sri
It is very kind of you to answer my question, Sri.
Thanks.
I will try best to study the source code.
Have a good day