FM for Editable ALV Popup plus Clipboard Function
Posted: Sun Aug 14, 2022 2:23 pm
Moin.
Das Dynpro 100
Der GUI Status MAIN100
Der GUI Title AUSW
Die Struktur ZTAB4000
The Function Module
The TOP Include
Caller Test
Das Dynpro 100
Der GUI Status MAIN100
Der GUI Title AUSW
Die Struktur ZTAB4000
The Function Module
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
- FUNCTION z_bc_alv_popup.
- *"----------------------------------------------------------------------
- *"*"Local Interface:
- *" IMPORTING
- *" VALUE(I_STRUC) TYPE DD02L-TABNAME DEFAULT 'ZCVI_CUST2BP'
- *" VALUE(I_WIDTH) TYPE SY-CUCOL DEFAULT '200'
- *" VALUE(I_HEIGHT) TYPE SY-CUROW DEFAULT '20'
- *" VALUE(I_TITLE) TYPE CHAR80 DEFAULT 'Popup'
- *" VALUE(I_EDIT) TYPE XFELD DEFAULT ' '
- *" CHANGING
- *" REFERENCE(DATA) TYPE ANY TABLE
- *"----------------------------------------------------------------------
- EXIT.
- EXIT.
- gv_title = i_title.
- gv_structure_name = i_struc.
- gv_allowedit = i_edit.
- CALL SCREEN 100 STARTING AT 1 1
- ENDING AT i_width i_height.
- EXIT.
- *---------------------------------------------------------------------*
- * MODULE PBO OUTPUT *
- *---------------------------------------------------------------------*
- MODULE pbo OUTPUT.
- CREATE OBJECT lo_split
- EXPORTING
- parent = cl_gui_container=>screen1
- rows = 1
- columns = 1
- no_autodef_progid_dynnr = 'X'.
- lo_split->set_border( 'X' ).
- * lo_split->set_column_width( EXPORTING id = 1
- * width = 20 ).
- * lo_split->set_column_width( EXPORTING id = 2
- * width = 40 ).
- * Left: List of reports
- lo_container = lo_split->get_container( row = 1
- column = 1 ).
- CREATE OBJECT grid1
- EXPORTING
- i_parent = lo_container.
- ELSE.
- * Hintergrund
- CREATE OBJECT grid1
- EXPORTING
- i_parent = g_dock_container.
- *--Creating an instance for the event handler
- CREATE OBJECT gr_event_handler .
- *----Preparing field catalog.
- *----Preparing layout structure
- *----Preparing Disable Toolbar Buttons
- PERFORM change_buttons .
- * is_variant-report = sy-repid.
- * is_variant-variant = '/GLOB_DEF'.
- CALL METHOD grid1->set_table_for_first_display
- EXPORTING
- " is_variant = is_variant
- " i_save = 'A'
- is_layout = gs_layout
- it_toolbar_excluding = lt_exclude
- CHANGING
- it_outtab = <data>[]
- it_fieldcatalog = gt_fieldcat[].
- *--Registering handler methods to handle ALV Grid events JG
- SET HANDLER gr_event_handler->handle_toolbar FOR grid1.
- SET HANDLER gr_event_handler->handle_user_command FOR grid1.
- * activate toolbar
- CALL METHOD grid1->set_toolbar_interactive.
- * Der GRID1 wird noch refreshed
- CALL METHOD grid1->refresh_table_display.
- SET PF-STATUS 'MAIN100'.
- SET TITLEBAR 'AUSW' WITH gv_title.
- *---------------------------------------------------------------------*
- * MODULE PAI INPUT *
- *---------------------------------------------------------------------*
- * to react on oi_custom_events:
- CALL METHOD cl_gui_cfw=>dispatch.
- CASE ok_code.
- PERFORM exit_program.
- * do nothing
- CLEAR ok_code.
- *---------------------------------------------------------------------*
- * FORM EXIT_PROGRAM *
- *---------------------------------------------------------------------*
- FORM exit_program.
- SET SCREEN 0.
- LEAVE SCREEN.
- *&--------------------------------------------------------------------*
- *& Form Change_buttons
- *&--------------------------------------------------------------------*
- * text
- *---------------------------------------------------------------------*
- FORM change_buttons .
- * Kein Symbol für Drucken / Graphik / Info
- ls_exclude = cl_gui_alv_grid=>mc_fc_print_back.
- ls_exclude = cl_gui_alv_grid=>mc_fc_graph.
- ls_exclude = cl_gui_alv_grid=>mc_fc_info.
- *&--------------------------------------------------------------------*
- *& Form prepare_layout
- *&--------------------------------------------------------------------*
- * text
- *---------------------------------------------------------------------*
- * -->PS_LAYOUT text
- *---------------------------------------------------------------------*
- gs_layout-zebra = 'X' .
- gs_layout-cwidth_opt ='X'.
- gs_layout-numc_total = ' '.
- gs_layout-no_merging = 'X'.
- gs_layout-no_rowmark = ' '.
- "gs_layout-sel_mode = 'A'.
- gs_layout-edit = gv_edit.
- gs_layout-edit_mode = 'X'.
- "ps_layout-ctab_fname = 'CELLCOLORS'." cellcolors
- * ps_layout-grid_title = 'Flights' .
- * ps_layout-smalltitle = 'X' .
- *&--------------------------------------------------------------------*
- *& Form handle_toolbar
- *&--------------------------------------------------------------------*
- * text
- *---------------------------------------------------------------------*
- * -->I_OBJECT text
- *---------------------------------------------------------------------*
- e_interactive .
- * Seperator
- CLEAR ls_toolbar.
- * Button Read/Edit
- CLEAR ls_toolbar.
- "MOVE ' TOGGLE Selection'(201) TO ls_toolbar-text.
- * Seperator
- CLEAR ls_toolbar.
- * Button PASTE Data from Clipboard
- CLEAR ls_toolbar.
- " MOVE ' Compare'(204) TO ls_toolbar-text.
- * Seperator
- CLEAR ls_toolbar.
- * Button COPY Data to Clipboard
- CLEAR ls_toolbar.
- " MOVE ' Compare'(204) TO ls_toolbar-text.
- *&---------------------------------------------------------------------*
- *& Form handle_user_command
- *&---------------------------------------------------------------------*
- * text
- *----------------------------------------------------------------------*
- CASE i_ucomm .
- gs_layout-edit = space.
- ELSE.
- gs_layout-edit = 'X'.
- ELSE.
- gs_layout-edit = space.
- "set_frontend_layout
- CALL METHOD grid1->set_frontend_layout
- EXPORTING
- is_layout = gs_layout.
- CALL METHOD cl_gui_frontend_services=>clipboard_import
- IMPORTING
- * length =
- EXCEPTIONS
- cntl_error = 1
- error_no_gui = 2
- not_supported_by_gui = 3
- OTHERS = 4.
- PERFORM create_itab_from_clip_board.
- REFRESH gt_clip_data.
- PERFORM create_htab_itab .
- CALL METHOD cl_gui_frontend_services=>clipboard_export
- EXPORTING
- no_auth_check = 'X'
- IMPORTING
- CHANGING
- rc = lv_rc
- EXCEPTIONS
- cntl_error = 1
- error_no_gui = 2
- not_supported_by_gui = 3
- no_authority = 4
- OTHERS = 5.
- ENDCASE .
- i = lines( <data> ).
- SET TITLEBAR 'AUSW' WITH lv_tit.
- lv_stable-row = 'X'.
- CALL METHOD grid1->refresh_table_display
- EXPORTING
- is_stable = lv_stable
- EXCEPTIONS
- finished = 1
- OTHERS = 2.
- *&--------------------------------------------------------------------*
- *& Form prepare_field_catalog
- *&--------------------------------------------------------------------*
- * text
- *---------------------------------------------------------------------*
- * -->PT_FIELDCATtext
- *---------------------------------------------------------------------*
- CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
- EXPORTING
- i_structure_name = gv_structure_name
- CHANGING
- ct_fieldcat = pt_fieldcat[]
- EXCEPTIONS
- inconsistent_interface = 1
- program_error = 2
- OTHERS = 3.
- *--Exception handling
- FORM create_htab_itab.
- "gv_structure_name
- INCLUDE STRUCTURE dfies.
- lv_query_table = gv_structure_name.
- CALL FUNCTION 'DDIF_FIELDINFO_GET'
- EXPORTING
- tabname = lv_query_table
- * FIELDNAME = ' '
- * LANGU = SY-LANGU
- * LFIELDNAME = ' '
- * ALL_TYPES = ' '
- * GROUP_NAMES = ' '
- IMPORTING
- * X030L_WA =
- ddobjtype = table_type
- * DFIES_WA =
- * LINES_DESCR =
- dfies_tab = table_structure
- * FIXED_VALUES =
- EXCEPTIONS
- not_found = 1
- internal_error = 2
- OTHERS = 3.
- i = lines( table_structure ).
- CLEAR lv_res.
- gs_clip_data-wa = lv_res.
- *&---------------------------------------------------------------------*
- *& Form create Structure / itab dynamically
- *&---------------------------------------------------------------------*
- * text
- *----------------------------------------------------------------------*
- DATA:
- l_ref_type_descr_ddic TYPE REF TO cl_abap_typedescr,
- l_ref_type_descr_line TYPE REF TO cl_abap_typedescr,
- l_ref_struct_descr_line TYPE REF TO cl_abap_structdescr,
- l_tab_component TYPE cl_abap_structdescr=>component_table.
- DATA:
- lop_tabledescr TYPE REF TO cl_abap_tabledescr,
- ldp_dynaic_record TYPE REF TO data,
- ldp_dyn_table TYPE REF TO data,
- lop_strucdescr TYPE REF TO cl_abap_structdescr.
- l_ref_type_descr_ddic = cl_abap_typedescr=>describe_by_name( i_tdef ).
- l_ref_struct_descr_line ?= l_ref_type_descr_ddic.
- l_tab_component = l_ref_struct_descr_line->get_components( ).
- lop_strucdescr = cl_abap_structdescr=>create( l_tab_component ).
- CREATE DATA ldp_dynaic_record TYPE HANDLE lop_strucdescr.
- lop_tabledescr ?= cl_abap_tabledescr=>create( p_line_type = lop_strucdescr ).
- CREATE DATA ldp_dyn_table TYPE HANDLE lop_tabledescr.
- FORM create_itab_from_clip_board.
- <f> = ls_tmp.
- <data>[] = <dyn_tab>[].
- GeSHi ©
The TOP Include
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
- * INCLUDE LZBCPOPUPD... " Local class definition
- * Tabellen der Varianten
- * ltdx
- * Ltdxd
- * Ltdxs
- ht(1) VALUE %_horizontal_tab,
- cr_lf(2) VALUE %_cr_lf.
- * ALV Datenquelle DATA cellcolors TYPE lvc_t_scol .
- *FIELD-SYMBOLS <Clip_data> type any TABLE. ."table of ZSTRINGSTRUC." table of strings
- *FIELD-SYMBOLS <Clip_data_s> type ZSTRINGSTRUC-str." strings
- * Grid Parameter
- g_container TYPE scrfname VALUE 'GRID1',
- grid1 TYPE REF TO cl_gui_alv_grid,
- lo_split TYPE REF TO cl_gui_splitter_container,
- lo_container TYPE REF TO cl_gui_container,
- g_dock_container TYPE REF TO cl_gui_docking_container,
- cl_gui_custom_container_obj TYPE REF TO cl_gui_custom_container.
- "is_variant TYPE disvariant.
- *--- Field catalog table
- *--- Layout structure
- * LT_EXCLUDE => Exclude Std. Buttons in toolbar
- ls_exclude TYPE ui_func.
- *---------------------------------------------------------------------*
- * CLASS lcl_event_handler DEFINITION
- *---------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------*
- PUBLIC SECTION .
- *--To add new functional buttons to the ALV toolbar
- handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
- IMPORTING e_object e_interactive ,
- *--To implement user commands
- handle_user_command
- FOR EVENT user_command OF cl_gui_alv_grid
- IMPORTING e_ucomm .
- PRIVATE SECTION.
- *---------------------------------------------------------------------*
- * CLASS lcl_event_handler IMPLEMENTATION
- *---------------------------------------------------------------------*
- *
- *---------------------------------------------------------------------*
- *--Handle Toolbar
- METHOD handle_toolbar.
- *--Handle User Command
- METHOD handle_user_command .
- GeSHi ©
Caller Test
- Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
- *&---------------------------------------------------------------------*
- *& Report ZTEST_Z_BC_ALV_POPUP
- *&
- *&---------------------------------------------------------------------*
- *&
- *&
- *&---------------------------------------------------------------------*
- REPORT ztest_z_bc_alv_popup.
- CALL FUNCTION 'Z_BC_ALV_POPUP'
- EXPORTING
- i_struc = 'MAKT'
- i_width = '150'
- i_height = '25'
- I_EDIT = 'X'
- CHANGING
- GeSHi ©