This article has participated in the activity of “New person creation Ceremony”, and started the road of digging gold creation together

demand

According to the requirements, the production system will withdraw the debug permission of some accounts. Users or consultants cannot use SE16/SE16N to debug data after they need to change the status of documents. Now a general program is made to query and change the data of the bottom table.

V1: General idea of function operation: Dynamically generate OOALV according to the table name and field name entered on the selection screen, query corresponding data, and realize the data of the bottom table that can be updated

V2: New: Save change logs and optimize programs

V3: Fixed: String length after special conversion routine ALPHA conversion is too long

Currently the program is the final version of V3, what new ideas will be updated in the later stage


One, achieve the effect

1.1 Enter the table name

1.2 Select fields in the table

1.3 perform

Checkbox is not available. At least one of the keywords must have a value (in low) as the query condition

1.4 Enter the conditions and click Query

1.5 Before data modification

1.6 Select update field checlbox to change state and then [Change data]

Change the approval status to 4 and click Update data, prompting to check the update field

1.7 Continue after this option is selected

See this data in the bottom table after update, it has been updated

1.8 Added Modified log table

Viewing Change Logs

Second, the code

2.1 the main program

*&---------------------------------------------------------------------* *& Report ZTEST_UPDATE_DATA_COMMON *& Description: the dynamically generated alv and update the bottom table data * & implementation -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- * * & the Author: *& Date:20220223
*&---------------------------------------------------------------------*

REPORT ztest_update_data_common.

INCLUDE:ztest_update_data_common_top,
        ztest_update_data_common_cls,
        ztest_update_data_common_evt,
        ztest_update_data_common_f01.

AT SELECTION-SCREEN ON  VALUE-REQUEST FOR s_tabnam-low.
  PERFORM frm_request_f4_tab USING 'S_TABNAM-LOW'.

AT SELECTION-SCREEN ON  VALUE-REQUEST FOR s_flnam-low.
  PERFORM frm_request_f4_field USING 'S_FLNAM-LOW'.

INITIALIZATION.

START-OF-SELECTION.

  PERFORM frm_check_input_or_auth.

  CALL SCREEN 100.* Use OOALV * Container NAME: GV_CONCopy the code

2.2 INCLUDE

2.2.1 TOP

* & -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - * * & contains ZTEST_UPDATE_DATA_COMMON_TOP *&---------------------------------------------------------------------* TABLES:ztest_d_com_tab,dd03d. DATA:go_100_cc TYPE REF TO cl_gui_custom_container, go_100_split TYPE REF TO cl_gui_splitter_container. DATA:gt_fieldcat_200 TYPE lvc_t_fcat, gt_fieldcat_300 TYPE lvc_t_fcat, * gs_fieldcat TYPE lvc_s_fcat, gs_layout TYPE lvc_s_layo, gs_stable TYPE lvc_s_stbl, go_200_cc TYPE REF TO cl_gui_container, go_300_cc TYPE REF TO cl_gui_container, go_200_grid TYPE REF TO cl_gui_alv_grid, go_300_grid TYPE REF TO cl_gui_alv_grid, gs_200_disvariant TYPE disvariant, gs_300_disvariant TYPE disvariant, gv_200_fill TYPEboolean,
     gv_300_fill              TYPE                   boolean,
     gt_200_toolbar_ex        TYPE                   ui_functions,
     gt_300_toolbar_ex        TYPE                   ui_functions,

     gt_fields_t              TYPE STANDARD TABLE OF dd03p,
     gt_fields                TYPE TABLE OF          ztest_s_field_com,
     gs_field                 TYPE                   ztest_s_field_com
     .

FIELD-SYMBOLS:<ft_dyn_table> TYPE STANDARD TABLE.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS:
s_tabnam FOR ztset_d_com_tab-tabname MODIF ID g1 NO INTERVALS NO-EXTENSION,
s_flnam FOR dd03d-fieldname MODIF ID g1 NO INTERVALS.

SELECTION-SCREEN ULINE.

SELECTION-SCREEN END OF BLOCK b1.
Copy the code

Ztest_s_field_com is the structure used by the alV above in the screen as follows

ZOPTION is the threshold for subsequent SQL writingTable name configuration table: ZTEST_D_COM_TABText table: ZTEST_D_COM_TABTLog table: ZTEST_D_COM_TCLOG

2.2.2 CLS

User Command and other implementation methods

Dynamic SQL query and dynamic SQL update base table data are in here

* & -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - * * & contains ZTEST_UPDATE_DATA_COMMON_CLS *&---------------------------------------------------------------------* CLASS lcl_event_receiver_200 DEFINITION. PUBLIC  SECTION. CLASS-METHODS: * handle_double_click FOR EVENT double_click OF cl_gui_alv_grid * IMPORTING * e_row * e_column * es_row_no, * * handle_top_of_page FOR EVENT top_of_page OF cl_gui_alv_grid * IMPORTING * e_dyndoc_id, * * handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid * IMPORTING * e_row_id * e_column_id, handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid IMPORTING e_object e_interactive, handle_command FOR EVENT user_command OF cl_gui_alv_grid IMPORTING e_ucomm. PRIVATE SECTION. ENDCLASS."lcl_event_receiver_200 DEFINITION CLASS lcl_event_receiver_200 IMPLEMENTATION. * METHOD handle_double_click. * * ENDMETHOD. * * METHOD handle_top_of_page. * * ENDMETHOD. * * METHOD handle_hotspot_click. * * ENDMETHOD. METHOD handle_toolbar. * DATA:ls_tb TYPE stb_button. FIELD-SYMBOLS:
      
        TYPE stb_button. * -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- * * add button * -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- * * delimiter APPEND INITIAL LINE TO E_object ->mt_toolbar core APPEND Core APPEND Core APPEND INITIAL LINE TO E_object ->mt_toolbar ASSIGNING 
       
        . 
        
         -butn_type = 0."
        
       
      0 button;2 button list.
    <fs_s_tb>-function = 'EXEC'.
    <fs_s_tb>-icon = icon_execute_object.
    <fs_s_tb>-text = text-002.** Remove buttons that may affect results * LOOP AT e_object->mt_toolbar INTO ls_tb. * IF ls_tb-function EQ'&LOCAL&CUT' OR ls_tb-function EQ '&LOCAL&PASTE'
*        OR ls_tb-function EQ '&LOCAL&APPEND' OR ls_tb-function EQ '&LOCAL&INSERT_ROW'
*         OR ls_tb-function EQ '&LOCAL&DELETE_ROW' OR ls_tb-function EQ '&LOCAL&COPY_ROW'.
*        DELETE e_object->mt_toolbar INDEX sy-tabix.
*      ENDIF.

*    ENDLOOP.

  ENDMETHOD.

  METHOD handle_command.

    DATA:lv_tabname(30) TYPE          c,
         lt_where_tab   TYPE          rsds_where_tab,
         lv_where_tab   TYPE          sychar72,
         lv_where_tab1  TYPE          sychar72,
         lv_key_init    TYPE          sap_bool,
         lt_celltab     TYPE          lvc_t_styl,
         lt_celltab_t   TYPE TABLE OF lvc_s_styl,
         ls_celltab     TYPE          lvc_s_styl,

*         struct_type    TYPE REF TO   cl_abap_structdescr,
*         lt_comp_tab    TYPE          cl_abap_structdescr=>component_table,
*         ls_comp_tab    LIKE LINE OF  lt_comp_tab,
*         lo_type        TYPE REF TO   cl_abap_datadescr,
*         lv_str         TYPE          string,
         lv_value       TYPE          string,
         lv_convt       TYPE          rs38l_fnam,
         lv_length      TYPE          int4
         .

    FIELD-SYMBOLS:<fs_dyn_wa> TYPE            any,
                  <ft_tab>    TYPE ANY TABLE.

    lv_tabname = s_tabnam-low.
    gs_stable-row = 'X'.
    gs_stable-col = 'X'.

    IF go_200_grid IS BOUND.

      CALL METHOD go_200_grid->refresh_table_display
        EXPORTING
          is_stable = gs_stable
        EXCEPTIONS
          finished  = 1
          OTHERS    = 2.

    ENDIF.

    CASE e_ucomm.
      WHEN 'EXEC'* Make sure the primary key has a value LOOP AT gt_fields INTO gs_field WHERE key_flag EQ abap_true. IF gs_field-low IS NOT initial. lv_key_init = abap_true. EXIT. ENDIF. ENDLOOP. IF lv_key_init NE abap_true.MESSAGE i147(zps) WITH text-009.
        ELSE.

*          struct_type ?= cl_abap_typedescr=>describe_by_name( s_tabnam-low ).* lt_comp_tab = struct_type->get_components()."LOOP AT gt_fields INTO gs_field WHERE low IS NOT INITIAL. * READ TABLE lt_comp_tab INTO Ls_comp_tab WITH KEY name = gs_field-fieldname. * IF sy-subrc EQ0.
*
*              lo_type = ls_comp_tab-type.
*              lv_str = lo_type->absolute_name.
*              REPLACE ALL OCCURRENCES OF '\TYPE=' IN lv_str WITH ``.
*              "(delete all \TYPE= from lv_string) * IF sy-subrc EQ 0. * IF sy-subrc EQ 0. CLEAR:lv_value. IF gs_field-convexit IS NOT initial. lv_convt = 'CONVERSION_EXIT_' && gs_field-convexit && '_INPUT'. CALL FUNCTION lv_convt EXPORTING input = gs_field-low IMPORTING output = lv_value. IF lv_value IS NOT INITIAL. IF strlen(lv_value) > gs_field-length. Lv_length = strlen(lv_value) - gs_field-length. lv_value = lv_value+lv_length(gs_field-length). ENDIF. * END ADD gs_field-low = lv_value. ENDIF. IF gs_field-high IS NOT INITIAL. CALL FUNCTION lv_convt EXPORTING input = gs_field-high IMPORTING output = lv_value. IF lv_value IS NOT INITIAL. gs_field-high = lv_value. ENDIF. ENDIF. ENDIF. * ENDIF. * ENDIF. IF gs_field-zoption EQ 'BETWEEN'. IF gs_field-low IS NOT INITIAL AND gs_field-high IS NOT INITIAL. lv_where_tab = '''' && gs_field-low && ''''.  lv_where_tab1 = '''' && gs_field-high && ''''. CONCATENATE gs_field-fieldname gs_field-zoption lv_where_tab 'AND' lv_where_tab1 INTO lv_where_tab SEPARATED BY ' '. ELSE. MESSAGE i147(zps) WITH text-010. CLEAR:lt_where_tab. IF 
      
        IS NOT INITIAL. CLEAR:
       
        . ENDIF. EXIT. ENDIF. ELSEIF gs_field-zoption EQ 'LIKE'. lv_where_tab  = '''' && '%' && gs_field-low && '%' && ''''. CONCATENATE gs_field-fieldname gs_field-zoption lv_where_tab INTO lv_where_tab SEPARATED BY ' '. ELSE. lv_where_tab = '''' && gs_field-low && ''''. CONCATENATE gs_field-fieldname gs_field-zoption lv_where_tab INTO lv_where_tab SEPARATED BY ' '. ENDIF. IF lt_where_tab IS NOT INITIAL. CONCATENATE 'AND' lv_where_tab INTO LV_where_tab SEPARATED BY ".endif.append lv_where_tab TO lt_where_tab.endloop. * Get the current ALV contents IF 
        
          IS ASSIGNED AND lt_where_tab IS NOT INITIAL. SELECT * INTO CORRESPONDING FIELDS OF TABLE < ft_dyn_TABLE > FROM (lv_tabname) WHERE (lt_where_tab). IF go_300_grid IS BOUND AND sy-subrc EQ 0. * Setting Unchecked The update field cannot be edited CLEAR:lt_celltab,lt_celltab_t. LOOP AT gt_fields INTO gs_field WHERE key_flag NE abap_true. IF gs_field-zif_edit NE abap_true. ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled. ELSEIF gs_field-zif_edit EQ abap_true. ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled. ENDIF. ls_celltab-fieldname = gs_field-fieldname. APPEND Ls_celltab TO lt_celltab_t. ENDLOOP. * IF lt_celltab_t IS NOT initial.sort, lt_celltab_t IS NOT initial.sort lt_celltab_t BY fieldname. APPEND LINES OF lt_celltab_t TO lt_celltab. ENDIF. LOOP AT 
         
           ASSIGNING 
          
           . ASSIGN COMPONENT 'CELLTAB' OF STRUCTURE 
           
             TO 
            
             . IF sy-subrc EQ 0. 
             
               = lt_celltab. ENDIF. ENDLOOP. IF 
              
                IS ASSIGNED. 
               
                 = 
                
                 . ENDIF. CALL METHOD go_300_grid->refresh_table_display EXPORTING is_stable = gs_stable EXCEPTIONS finished = 1 OTHERS = 2. ENDIF. ENDIF. ENDIF. WHEN OTHERS. ENDCASE. ENDMETHOD. ENDCLASS. CLASS lcl_event_receiver_300 DEFINITION. PUBLIC SECTION. CLASS-METHODS: handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid IMPORTING e_object e_interactive, handle_command FOR EVENT user_command OF cl_gui_alv_grid IMPORTING e_ucomm. PRIVATE SECTION. ENDCLASS. "
                
               
              
             
            
           
          
         
        
       
      lcl_event_receiver_300 DEFINITION CLASS lcl_event_receiver_300 IMPLEMENTATION. METHOD handle_toolbar. * DATA:ls_tb TYPE stb_button. FIELD-SYMBOLS:<fs_s_tb> TYPE stb_button. * -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- * * add button * -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- * * delimiter APPEND INITIAL LINE TO e_object->mt_toolbar ASSIGNING <fs_s_tb>. <fs_s_tb>-butn_type =3.APPEND INITIAL LINE TO E_object ->mt_toolbar exchange <fs_s_tb>. <fs_s_tb>-butn_type =0."0 button; 2 button list. 
      
       -function = 'UPD_DATA'. 
       
        -icon = icon_budget_update. 
        
         -text = text-003. ** * LOOP AT e_object->mt_toolbar INTO ls_tb. * IF ls_tb-function EQ '&LOCAL&CUT' OR ls_tb-function EQ '&LOCAL&PASTE' * OR ls_tb-function EQ '&LOCAL&APPEND' OR ls_tb-function EQ '&LOCAL&INSERT_ROW' * OR ls_tb-function EQ '&LOCAL&DELETE_ROW' OR ls_tb-function EQ '&LOCAL©_ROW'. * DELETE e_object->mt_toolbar INDEX sy-tabix. * ENDIF. * ENDLOOP. ENDMETHOD. METHOD handle_command. DATA:lv_tabname TYPE tabname, * lv_fieldname TYPE dd03d-fieldname, lt_where_tab TYPE rsds_where_tab, lv_where_tab TYPE sychar72, lv_value TYPE string, lv_count TYPE int2, * lv_fail TYPE sap_bool, lv_str TYPE string, lv_chgid TYPE int4, lv_tabix TYPE sy-tabix, ls_tclog TYPE ztest_d_com_tclog, lt_tclog TYPE TABLE OF ztest_d_com_tclog . FIELD-SYMBOLS:
         
           TYPE any, 
          
            TYPE any, 
           
             TYPE any, 
            
              TYPE any.lv_tabname = s_tabnam-low. CASE e_ucomm. WHEN 'UPD_DATA'. * Update bottom table data according to ALV IF 
             
               IS ASSIGNED. READ TABLE gt_fields WITH KEY zif_edit = abap_true TRANSPORTING NO FIELDS. IF sy-subrc NE 0. MESSAGE i147(zps) CLEAR:lt_where_tab, lt_tCLOg,lv_count. IF 
              
                IS assign. LOOP AT 
               
                 Exchange: Exchange 
                
                 . Lv_tabix = sy-tabix. * log table SELECT MAX(zchgid) INTO LV_chgid FROM ztest_d_com_tclog WHERE zchguser EQ sy-uname. IF sy-subrc NE 0. lv_chgid = 0. ENDIF. CLEAR:lt_where_tab,lv_value,ls_tclog. ls_tclog-zchguser = sy-uname. ls_tclog-zchgdb = s_tabnam-low. CALL FUNCTION 'IB_CONVERT_INTO_TIMESTAMP' EXPORTING i_datlo = sy-datum i_timlo = sy-timlo i_tzone = sy-zonlo IMPORTING e_timestamp = ls_tclog-zchgtimes. LOOP AT gt_fields INTO gs_field. ls_tclog-zchgfield = gs_field-fieldname. ls_tclog-zchgid = lv_chgid = lv_chgid + 1. IF lv_chgid GE 9999999999. MESSAGE E147 (ZPS) WITH 'Current user modify table record will exceed 9999999999 limit, please clean up first! '. ENDIF. ASSIGN COMPONENT gs_field-fieldname OF STRUCTURE 
                 
                   TO 
                  
                   . IF sy-subrc EQ 0. IF gs_field-zif_edit NE abap_true. lv_where_tab = '''' && 
                   
                     && ''''. CONCATENATE gs_field-fieldname 'EQ' lv_where_tab INTO lv_where_tab SEPARATED BY ' '. IF lt_where_tab IS NOT INITIAL. CONCATENATE 'AND' lv_where_tab INTO lv_where_tab SEPARATED BY ' '. ENDIF. APPEND lv_where_tab TO lt_where_tab. IF 
                    
                      IS ASSIGNED. READ TABLE 
                     
                       ASSIGNING 
                      
                        INDEX lv_tabix. IF sy-subrc EQ 0. ASSIGN COMPONENT gs_field-fieldname OF STRUCTURE 
                       
                         TO 
                        
                         . IF sy-subrc EQ 0. ls_tclog-zfroval = 
                         
                          . ENDIF. ENDIF. ENDIF. CLEAR:ls_tclog-zaftval. APPEND ls_tclog TO lt_tclog. ELSE. lv_str = '''' && 
                          
                            && ''''. CONCATENATE gs_field-fieldname '=' lv_str INTO lv_str SEPARATED BY ' '. IF lv_value IS NOT INITIAL. CONCATENATE lv_value lv_str INTO lv_value SEPARATED BY ' '. ELSE. lv_value = lv_str. ENDIF. IF 
                           
                             IS ASSIGNED. READ TABLE 
                            
                              ASSIGNING 
                             
                               INDEX lv_tabix. IF sy-subrc EQ 0. ASSIGN COMPONENT gs_field-fieldname OF STRUCTURE 
                              
                                TO 
                               
                                . IF sy-subrc EQ 0. ls_tclog-zfroval = 
                                
                                 . ENDIF. ENDIF. ENDIF. ls_tclog-zaftval = 
                                 
                                  . APPEND ls_tclog TO lt_tclog. ENDIF. ENDIF. ENDLOOP. IF lv_value IS NOT INITIAL AND Lt_where_tab IS NOT INITIAL. * Update value and save to log table CLEAR:lv_str. LOOP AT lt_tclog INTO ls_tclog. IF ls_tclog-zfroval NE ls_tclog-zaftval AND ls_tclog-zaftval IS NOT INITIAL. lv_str = 'X'. EXIT. ENDIF. ENDLOOP. IF NOT lv_str IS INITIAL. UPDATE (lv_tabname) SET (lv_value) WHERE (lt_where_tab). IF sy-subrc NE 0. ROLLBACK WORK. * lv_fail = abap_true. MESSAGE I147 (ZPS) WITH text-013.exit.else. * IF lt_tclog IS NOT initial. MODIFY ztest_d_com_tclog FROM TABLE Lt_tclog.endif.endif. COMMIT WORK. * Count the number of updates lv_count = lv_count + 1.endif.endif.endloop. ENDIF. * IF lv_fail NE abap_true. * IF 
                                  
                                    IS ASSIGNED. * * lv_count = lines( 
                                   
                                     ). * * ENDIF. IF lv_count GE 1. MESSAGE i147(zps) WITH text-014 lv_count. ENDIF. * ENDIF. ENDIF. ELSE. MESSAGE i147(zps) WITH text-011. ENDIF. WHEN OTHERS. ENDCASE. gs_stable-row = 'X'. gs_stable-col = 'X'. IF go_300_grid IS BOUND. CALL METHOD go_300_grid->refresh_table_display EXPORTING is_stable = gs_stable EXCEPTIONS finished = 1 OTHERS = 2. ENDIF. ENDMETHOD. ENDCLASS.
                                   
                                  
                                 
                                
                               
                              
                             
                            
                           
                          
                         
                        
                       
                      
                     
                    
                   
                  
                 
                
               
              
             
            
           
          
         
        
       
      Copy the code

2.2.3 EVT

Initialize the dynamic ALV, obtain data, and split containers

*----------------------------------------------------------------------* ***INCLUDE ZTEST_UPDATE_DATA_COMMON_EVT. * -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - * *&---------------------------------------------------------------------* *& Module STATUS_0100 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE status_0100 OUTPUT. SET PF-STATUS'ZSTATUS'.
  SET TITLEBAR 'ZT001'.
ENDMODULE.                 " STATUS_0100 OUTPUT *&---------------------------------------------------------------------* *& Module USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE user_command_0100 INPUT. DATA:ok_code LIKE sy-ucomm, save_ok LIKE sy-ucomm. save_ok = ok_code. CLEAR:ok_code. CASE save_ok. WHEN '&F03' OR '&F15' OR '&F12'. LEAVE TO SCREEN 0. * WHEN . WHEN OTHERS. ENDCASE. ENDMODULE. " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Module  SCR_100_INIT  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE scr_100_init OUTPUT.

  PERFORM frm_get_data.
*  PERFORM frm_set_display_param.

ENDMODULE.                 " SCR_100_INIT OUTPUT *&---------------------------------------------------------------------* *& Module ALV_SCREEN_SPLITER OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE alv_screen_spliter OUTPUT. * "alv splitter
  IF go_100_split IS NOT BOUND.

    IF go_100_cc IS NOT BOUND.

      CREATE OBJECT go_100_cc
        EXPORTING
          container_name = 'GC_CON'.

    ENDIF.

    CREATE OBJECT go_100_split
      EXPORTING
        parent  = go_100_cc
        rows    = 2
        columns = 1.

    IF go_200_cc IS NOT BOUND.

      CALL METHOD go_100_split->get_container
        EXPORTING
          row       = 1
          column    = 1
        RECEIVING
          container = go_200_cc.

      CALL METHOD go_100_split->set_column_width
        EXPORTING
          id    = 1
          width = 100.

    ENDIF.

    IF go_300_cc IS NOT BOUND.

      CALL METHOD go_100_split->get_container
        EXPORTING
          row       = 2
          column    = 1
        RECEIVING
          container = go_300_cc. "go_container CALL METHOD go_100_split->set_column_width EXPORTING id = 2 width = 100. ENDIF. ENDIF. ENDMODULE. "ALV_SCREEN_SPLITER OUTPUT *&---------------------------------------------------------------------* *& Module SCR_100_DSP  OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE scr_100_dsp OUTPUT. IF gv_200_fill NE abap_true. IF go_200_grid IS NOT BOUND. CREATE OBJECT go_200_grid EXPORTING i_parent = go_200_cc. ENDIF. PERFORM frm_set_fieldcat USING200 CHANGING gt_fieldcat_200.

    PERFORM frm_set_layout USING 200CHANGING Gs_layout. * Save format CLEAR gs_200_disvaried. gs_200_disvarie-report = SY-repID. gs_200_disvarie-handle ='200'.
    gs_200_disvariant-username = sy-uname.

*    CREATE OBJECT go_event.
*    SET HANDLER lcl_event_receiver_200=>handle_double_click FOR go_200_grid.     "Through-double-click event SET HANDLER lcl_EVENT_receiver_200 =>handle_toolbar FOR GO_200_grid."Toolbar SET HANDLER lCL_EVENT_receiver_200 => HANDLE_command FOR GO_200_grid."Custom event * Primary key setting unavailable update PERFORM FRM_init_STYLE_TAB. * Cancel part of the button PERFORM FRM_BUILD_EXCL_FUNC_rSTGR USING 200 CHANGING * PERFORM FRM_set_list_dropdown. * First display ALV GO_200_GRID ->set_table_for_first_display( EXPORTING is_variant = gs_200_disvariant i_save = 'U' is_layout = gs_layout it_toolbar_excluding = gt_200_toolbar_ex CHANGING it_fieldcatalog = gt_fieldcat_200 it_outtab = gt_fields ). gv_200_fill = abap_true. CALL METHOD go_200_grid->register_edit_event "To register an edit event, Otherwise the update event EXPORTING i_event_id = cl_GUI_alv_grid => Mc_evt_modified.else. * Refresh ALV go_200_grid->refresh_table_display().  ENDIF. * CALL METHOD cl_gui_cfw=>flush. ENDMODULE." SCR_100_DSP OUTPUT *&---------------------------------------------------------------------* *& Module SCR_300_INIT OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* *MODULE scr_300_init OUTPUT. * *ENDMODULE. "SCR_300_INIT OUTPUT *&---------------------------------------------------------------------* *& Module SCR_300_DSP OUTPUT *&---------------------------------------------------------------------* * text * -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- * MODULE scr_300_dsp OUTPUT. * initializes the dynamic structure, the table DATA: * dref_str TYPE REF TO data, dref_tab TYPE REF TO data, * dref_s TYPE REF TO data, * elem_type TYPE REF TO cl_abap_elemdescr, struct_type TYPE REF TO cl_abap_structdescr, lo_struct_include TYPE REF TO cl_abap_structdescr, table_type TYPE REF TO cl_abap_tabledescr, lt_comp_tab TYPE cl_abap_structdescr=>component_table, lt_component_include TYPE cl_abap_structdescr=>component_table, Ls_comp_tab LIKE LINE OF lt_comp_tab, lv_tabix TYPE sy-tabix. * obtain screen_0100 value DATA:lt_fields_t TYPE TABLE OF dd03p, ls_field_t TYPE dd03p, Lv_tabname TYPE DD03p-tabname. * ASSIGN IF gt_fields_t IS NOT initial. CLEAR:lt_comp_tab. * Create dynamic structure * elem_type? Elemdescr =>get_string(). * CREATE DATA dref_s TYPE HANDLE elem_type. = cl_abap_typedescr=>describe_by_name( s_tabnam-low )."Lt_comp_tab = struct_type->get_components()."The various field components that make up the structure are lv_TABNAME = s_tabnam-low. CALL FUNCTION'DDIF_TABL_GET'
      EXPORTING
        name          = lv_tabname
        langu         = sy-langu
      TABLES
        dd03p_tab     = lt_fields_t
      EXCEPTIONS
        illegal_input = 1
        OTHERS        = 2.
    IF sy-subrc EQ 0.

      LOOP AT lt_fields_t INTO ls_field_t WHERE fieldname EQ '.INCLUDE'. CLEAR:lt_component_include. lo_struct_include ? = cl_abap_typedescr=>describe_by_name( ls_field_t-precfield ). lt_component_include = lo_struct_include->get_components( ).append LINES OF LT_component_include TO lt_comp_tab.endloop.endif. lo_struct_include ? = cl_abap_typedescr=>describe_by_name('ZTEST_S_FIELD_COM' ).
    lt_component_include = lo_struct_include->get_components( ).

    LOOP AT lt_component_include INTO ls_comp_tab.
      IF ls_comp_tab-name EQ 'CELLTAB'.
        APPEND ls_comp_tab TO lt_comp_tab.
      ENDIF.
    ENDLOOP.

    LOOP AT lt_comp_tab INTO ls_comp_tab.
      lv_tabix = sy-tabix.
*      READ TABLE gt_fields_t INTO ls_field_t WITH KEY fieldname = gs_field-fieldname.
*      IF sy-subrc EQ 0.
*
*        ls_comp_tab-name = ls_field_t-fieldname."Add a member to the structure * ls_comp_tab-type = elem_type."INSERT ls_comp_tab INTO lt_comp_tab INDEX lv_index. * * endif. READ TABLE gt_fields WITH KEY fieldName = ls_comp_tab-name TRANSPORTING NO FIELDS. IF sy-subrc NE0 AND ls_comp-tab-name NE 'CELLTAB'.
        DELETE lt_comp_tab INDEX lv_tabix.
      ENDIF.

    ENDLOOP.

    IF lt_comp_tab IS NOT INITIAL.

      struct_type = cl_abap_structdescr=>create( lt_comp_tab[] ).
*      CREATE DATA dref_str TYPE HANDLE struct_type."Use structure type object to create structure object * lo_lineType? = cl_abap_structdescr=>create( p_components = lt_component ). table_type = cl_abap_tabledescr=>create( p_line_type = struct_type ). CREATE DATA dref_tab TYPE HANDLE table_type. ASSIGN dref_tab->* TO 
      
       . ENDIF. ELSE. LEAVE TO SCREEN 0.endif. * Sets alv IF gv_300_fill NE abap_true. IF GO_300_grid IS NOT bound. CREATE OBJECT go_300_grid EXPORTING i_parent = go_300_cc. ENDIF. PERFORM frm_set_fieldcat USING 300 CHANGING gt_fieldcat_300. PERFORM frm_set_layout USING 300 CHANGING Gs_layout. * Save format CLEAR gs_300_disvaried. gs_300_disvarie-report = SY-repID. gs_300_disvarie-handle = '200'. gs_300_disvariant-username = sy-uname. * CREATE OBJECT go_event. SET HANDLER lcl_event_receiver_300=>handle_toolbar FOR go_300_grid. "
      Toolbar SET HANDLER lCL_EVENT_receiver_300 => HANDLE_command FOR GO_300_grid."Custom event * Cancel part button PERFORM FRM_build_EXCL_func_rSTGR USING 300 CHANGING gT_300_toolbar_ex. * ALV is displayed for the first time go_300_grid->set_table_for_first_display( EXPORTING is_variant = gs_300_disvariant i_save = 'U' is_layout = gs_layout it_toolbar_excluding = gt_300_toolbar_ex CHANGING it_fieldcatalog = gt_fieldcat_300 it_outtab = 
      
        ). Gv_200_fill = abap_true.else. * Refresh ALV go_300_grid->refresh_table_display().endif.endmodule."
       SCR_300_DSP  OUTPUT
Copy the code

2.2.4 F01

Select the screen search help implementation, ALV Layout; Fieldcat Settings and so on

* & -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - * * & contains ZTEST_UPDATE_DATA_COMMON_F01 * & -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - * *&---------------------------------------------------------------------* *& Form frm_request_f4_tab * & -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - * * access can modify the table *----------------------------------------------------------------------* * -->P_0045 text *----------------------------------------------------------------------* FORM frm_request_f4_tab USING pv_field TYPE help_info-dynprofld."Ztest_d_com_tabt is the text table DATA for ztest_d_com_tab: BEGIN OF ls_value_tab, tabname TYPE ztest_d_com_tab-tabname, tabdesc TYPE ztest_d_com_tabt-tabdesc, END OF ls_value_tab, lt_value_tab LIKE TABLE OF ls_value_tab, lt_tab LIKE STANDARD TABLE OF ls_value_tab. DEFINE lm_modify_tab. ls_value_tab-tabname = &1. ls_value_tab-tabdesc = &2. CLEAR ls_value_tab. END-OF DEFINITION. * Table Table description * Apply external links even if there is no English description, empty description should be taken out OF SELECT a~tabname,b~tabdesc FROM ztest_d_com_tab AS a LEFT OUTER JOIN ztest_d_com_tabt AS b ON a~tabname EQ b~tabname INTO CORRESPONDING FIELDS OF TABLE @lt_tab WHERE b~spras EQ @sy-langu. IF sy-subrc EQ 0. LOOP AT lt_tab INTO ls_value_tab. Lm_modify_tab ls_value_tab-tabname ls_value_tab-tabdesc. ENDLOOP. * Set search result CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING retfield = 'TABNAME' dynpprog = sy-repid dynpnr = sy-dynnr dynprofield = pv_field value_org = 'S' TABLES value_tab = lt_value_tab EXCEPTIONS parameter_error = 1 no_values_found = 2 OTHERS = 3. IF sy-subrc <> 0. * Implement suitable error handling here ENDIF. ENDIF. ENDFORM. "frm_request_f4_tab *&---------------------------------------------------------------------* *& Form FRM_REQUEST_F4_FIELD  *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_0055 text *----------------------------------------------------------------------* FORM frm_request_f4_field USING pv_field TYPE help_info-dynprofld. DATA:lt_fields TYPE STANDARD TABLE OF dd03p, ls_field TYPE dd03p, lv_tab TYPE ddobjname, lv_str TYPE string. DATA: BEGIN OF ls_value_tab, fieldname TYPE dd03p-fieldname, fieldtext TYPE dd03p-ddtext, END OF ls_value_tab, lt_value_tab LIKE STANDARD TABLE OF ls_value_tab. DEFINE lm_modify_field. ls_value_tab-fieldname = &1.
    ls_value_tab-fieldtext = &2.APPEND ls_value_tab TO lt_value_tab. CLEAR ls_value_tab. END-OF-DEFINITION. lv_str = s_tabnam-low. lv_tab = lv_str. CALL  FUNCTION'DDIF_TABL_GET'
    EXPORTING
      name          = lv_tab
      langu         = sy-langu
    TABLES
      dd03p_tab     = lt_fields
    EXCEPTIONS
      illegal_input = 1
      OTHERS        = 2.
  IF sy-subrc EQ 0.

    LOOP AT lt_fields INTO ls_field.

      IF ls_field-fieldname EQ 'MANDT' OR ls_field-fieldname EQ '.INCLUDE' OR ls_field-keyflag EQ 'X'.continue. ELSE. Lm_modify_field ls_field-fieldName ls_field-ddtext.endif.endloop. * Sets the search result CALL FUNCTION'F4IF_INT_TABLE_VALUE_REQUEST'
      EXPORTING
        retfield        = 'FIELDNAME'
        dynpprog        = sy-repid
        dynpnr          = sy-dynnr
        dynprofield     = pv_field
        value_org       = 'S'
      TABLES
        value_tab       = lt_value_tab
      EXCEPTIONS
        parameter_error = 1
        no_values_found = 2
        OTHERS          = 3.
    IF sy-subrc <> 0.
*   Implement suitable error handling here
    ENDIF.

  ENDIF.


ENDFORM.                    " FRM_REQUEST_F4_FIELD *&---------------------------------------------------------------------* *& Form FRM_SHOWDATA_VIA_SEL * & -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - * * will change the data *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* *FORM frm_showdata_via_sel . * ** PERFORM frm_set_fieldcat. * *ENDFORM. "FRM_SHOWDATA_VIA_SEL *&---------------------------------------------------------------------* *& Form FRM_GET_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text * -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- * FORM frm_get_data. * obtain screen_0100 value DATA: ls_field_t TYPE dd03p, lv_tabname TYPE dd03p-tabname. lv_tabname = s_tabnam-low. CALL FUNCTION'DDIF_TABL_GET'
    EXPORTING
      name          = lv_tabname
      langu         = sy-langu
    TABLES
      dd03p_tab     = gt_fields_t
    EXCEPTIONS
      illegal_input = 1
      OTHERS        = 2.
  IF sy-subrc EQ 0.

    LOOP AT gt_fields_t INTO ls_field_t.

      CLEAR:gs_field.

      IF ls_field_t-fieldname EQ 'MANDT' OR ls_field_t-fieldname EQ '.INCLUDE'.
        CONTINUE.
      ELSE.

        IF ls_field_t-keyflag EQ 'X'. gs_field-convexit = ls_field_t-convexit. gs_field-length = ls_field_t-leng. gs_field-fieldname = ls_field_t-fieldname.  gs_field-ddtext = ls_field_t-ddtext. gs_field-zoption ='EQ'.  "DEFAULT EQ gs_field-key_flag = ls_field_t-keyflag. APPEND gs_field TO gt_fields. ELSE. READ TABLE s_flnam WITH KEY low = ls_field_t-fieldname TRANSPORTING NO FIELDS. IF sy-subrc EQ 0. gs_field-convexit = ls_field_t-convexit. gs_field-length = ls_field_t-leng. gs_field-fieldname = ls_field_t-fieldname. gs_field-ddtext = ls_field_t-ddtext. gs_field-zoption = 'EQ'. "DEFAULT   EQ
            APPEND gs_field TO gt_fields.

          ENDIF.

        ENDIF.
      ENDIF.

    ENDLOOP.

  ELSE.

    MESSAGE e147(zps)WITH 'TABNAME ERROR! '. ENDIF. ENDFORM. " FRM_GET_DATA *&---------------------------------------------------------------------* *& Form FRM_SET_DISPLAY_PARAM *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* *FORM frm_set_display_param . * *ENDFORM. " FRM_SET_DISPLAY_PARAM *&---------------------------------------------------------------------* *& Form FRM_SET_FIELDCAT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_set_fieldcat USING pv_cc TYPE int2 CHANGING pt_fieldcat. DATA:ls_field_t TYPE dd03p, lv_edit TYPE sap_bool. IF pv_cc EQ 200. PERFORM frm_fill_fieldcat USING 'ZTEST_S_FIELD_COM' 'FIELDNAME' 'FIELDNAME' text-004 '' '' '' '' '' 'X' CHANGING pt_fieldcat. PERFORM frm_fill_fieldcat USING 'ZTEST_S_FIELD_COM' 'DDTEXT' 'DDTEXT' text-015 '' '' '' '' '' 'X' CHANGING pt_fieldcat. PERFORM frm_fill_fieldcat USING 'ZTEST_S_FIELD_COM' 'ZOPTION' 'ZOPTION' text-005 '' '' '' 'X' '' '' CHANGING pt_fieldcat. PERFORM frm_fill_fieldcat USING 'ZTSET_S_FIELD_COM' 'LOW' 'LOW' text-006 '' '' '' 'X' '' '' CHANGING pt_fieldcat. PERFORM frm_fill_fieldcat USING 'ZTEST_S_FIELD_COM' 'HIGH' 'HIGH' text-007 '' '' '' 'X' '' '' CHANGING pt_fieldcat. PERFORM frm_fill_fieldcat USING 'ZTEST_S_FIELD_COM' 'ZIF_EDIT' 'ZIF_EDIT' text-008 'X' '' '' 'X' '' '' CHANGING pt_fieldcat. ELSEIF pv_cc EQ 300. LOOP AT gt_fields_t INTO ls_field_t. IF ls_field_t-fieldname EQ 'MANDT' OR ls_field_t-fieldname EQ '.INCLUDE'. CONTINUE. ELSE. IF ls_field_t-keyflag EQ abap_true. PERFORM frm_fill_fieldcat USING s_tabnam-low ls_field_t-fieldname ls_field_t-fieldname ls_field_t-ddtext '' '' '' '' '' 'X' CHANGING pt_fieldcat. ELSE. READ TABLE s_flnam WITH KEY low= ls_field_t-fieldname TRANSPORTING NO FIELDS.
          IF sy-subrc EQ 0.* CLEAR:lv_edit. * READ TABLE gt_fields WITH KEY fieldname = ls_field_t-fieldname * zif_edit = abap_true TRANSPORTING NO  FIELDS. * IF sy-subrc EQ0.
*              lv_edit = abap_true.
*            ENDIF.
            lv_edit = abap_true.

            PERFORM frm_fill_fieldcat USING
                  s_tabnam-low ls_field_t-fieldname ls_field_t-fieldname ls_field_t-ddtext ' ' ' ' ' ' lv_edit ' ' 'X'
            CHANGING pt_fieldcat.

          ENDIF.

        ENDIF.

      ENDIF.

    ENDLOOP.

  ENDIF.

ENDFORM.                    " FRM_SET_FIELDCAT *&---------------------------------------------------------------------* *& Form FRM_CHECK_INPUT_OR_AUTH *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_check_input_or_auth. DATA:lv_msg TYPE String. IF s_tabnam IS INITIAL OR s_flnam IS initial.message w147(ZPS) WITH ' '. STOP. ENDIF. ENDFORM. " FRM_CHECK_INPUT_OR_AUTH

*&---------------------------------------------------------------------*
*&      Form  frm_fill_fieldcat
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->PV_REFTABLE   text
*      -->PV_REFFIELD   text
*      -->PV_FIELDNAME  text
*      -->PV_COLTEXT    text
*      -->PV_CHECKBOX   text
*      -->PV_NOZERO     text
*      -->PV_OUTPUTLEN  text
*      -->PV_EDIT       text
*      -->PCT_FIELDCAT  text
*----------------------------------------------------------------------*
FORM frm_fill_fieldcat USING pv_reftable
      pv_reffield
      pv_fieldname
      pv_coltext
      pv_checkbox
      pv_nozero
      pv_outputlen
      pv_edit
      pv_hotspot
      pv_key
*      pv_style
CHANGING pct_fieldcat TYPE lvc_t_fcat.
  DATA: ls_fieldcat TYPE lvc_s_fcat.
  ls_fieldcat-ref_table = pv_reftable .
  ls_fieldcat-ref_field = pv_reffield .
  ls_fieldcat-fieldname = pv_fieldname .
*  IF pv_fieldname EQ 'ZOPTION'.
*    ls_fieldcat-drdn_hndl = '1'.
*  ENDIF.
  ls_fieldcat-coltext = pv_coltext .
  ls_fieldcat-checkbox = pv_checkbox.           "Multiple checkbox ls_fieldCAT -no_zero = pv_nozero."Remove leading zeros * ls_fieldcat-outputlen = pv_outputlen. ls_fieldcat-edit = pv_edit."Editable ls_fieldcat-hotspot = pv_hotspot."Click the event ls_fieldcat-key = pv_key. * ls_fieldcat-style = pv_style. * ls_fieldcat-DRDN_FIELD = pv_ * IF pv_fieldName EQ'ZOPTION'.
*
*    ls_fieldcat-drdn_field  = 'ZOPTION'.
*    ls_fieldcat-drdn_hndl   = '1' .
*
*  ENDIF.

  APPEND ls_fieldcat TO pct_fieldcat.
  CLEAR ls_fieldcat.
ENDFORM. " frm_fill_fieldcat *&---------------------------------------------------------------------* *& Form frm_set_layout *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->PCS_LAYOUT text *----------------------------------------------------------------------* FORM frm_set_layout USING pv_cc TYPE int2 CHANGING pcs_layout TYPE lvc_s_layo. CLEAR:pcs_layout. CONSTANTS: lc_stylefname LIKE pcs_layout-stylefname VALUE 'CELLTAB'. "Set the layout format pcs_layout-cwidth_opt ='X'.
*  pcs_layout-box_fname = 'SEL'.
  pcs_layout-sel_mode = 'A'.
*  IF pv_cc EQ 200.
  pcs_layout-stylefname = lc_stylefname.
*  ENDIF.
*  pcs_layout-zebra = 'X'.

ENDFORM. " FRM_SET_LAYOUT *&---------------------------------------------------------------------* *& Form FRM_INIT_STYLE_TAB *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_init_style_tab. DATA:lt_celltab TYPE lvc_t_styl, ls_celltab TYPE lvc_s_styl, l_index TYPE i. LOOP AT gt_fields INTO gs_field WHERE key_flag EQ abap_true. CLEAR : gs_field-celltab. "IF gs_field-celltab IS initial.l_index = sy-tabix. REFRESH lt_celltab.ls_celltab-fieldName ='ZIF_EDIT'.
      IF gs_field-key_flag IS NOT INITIAL.
        ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
      ELSE.
        ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
      ENDIF.
      INSERT ls_celltab INTO TABLE lt_celltab.
*      IF gs_field-zoption NE 'BETWEEN'.
*        ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
*      ELSE.
*        ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
*      ENDIF.
*      ls_celltab-fieldname = 'HIGH'.

      INSERT LINES OF lt_celltab INTO TABLE gs_field-celltab.
      MODIFY gt_fields FROM gs_field INDEX l_index.
    ENDIF.
  ENDLOOP.

ENDFORM.                    " FRM_INIT_STYLE_TAB FORM frm_build_excl_func_rstgr USING pv_cc TYPE int2 CHANGING ct_excl_func TYPE ui_functions. APPEND: cl_gui_alv_grid=>mc_fc_detail TO ct_excl_func, cl_gui_alv_grid=>mc_fc_check TO ct_excl_func, cl_gui_alv_grid=>mc_fc_loc_append_row TO ct_excl_func, cl_gui_alv_grid=>mc_fc_loc_delete_row TO ct_excl_func, cl_gui_alv_grid=>mc_fc_refresh TO ct_excl_func, cl_gui_alv_grid=>mc_fc_loc_undo TO ct_excl_func, cl_gui_alv_grid=>mc_fc_loc_cut TO ct_excl_func, cl_gui_alv_grid=>mc_fc_loc_copy TO ct_excl_func, cl_gui_alv_grid=>mc_fc_loc_copy_row TO ct_excl_func, cl_gui_alv_grid=>mc_fc_loc_paste TO ct_excl_func, cl_gui_alv_grid=>mc_fc_loc_paste_new_row TO ct_excl_func, * cl_gui_alv_grid=>mc_fg_sort TO ct_excl_func, cl_gui_alv_grid=>mc_fc_find TO ct_excl_func, cl_gui_alv_grid=>mc_fc_loc_insert_row TO ct_excl_func, cl_gui_alv_grid=>mc_fc_subtot TO ct_excl_func, cl_gui_alv_grid=>mc_mb_variant TO ct_excl_func, * cl_gui_alv_grid=>mc_mb_filter TO ct_excl_func, cl_gui_alv_grid=>mc_fc_print TO ct_excl_func, cl_gui_alv_grid=>mc_mb_view TO ct_excl_func, cl_gui_alv_grid=>mc_fc_graph TO ct_excl_func, cl_gui_alv_grid=>mc_fc_info TO ct_excl_func, cl_gui_alv_grid=>mc_mb_sum TO ct_excl_func, Cl_gui_alv_grid => Mc_mb_export TO ct_EXCL_FUNc. * 200 Screen only preserves query button IF pv_cc EQ 200.append: cl_gui_alv_grid=>mc_fc_sort_asc TO ct_excl_func, cl_gui_alv_grid=>mc_fc_sort_dsc TO ct_excl_func, cl_gui_alv_grid=>mc_fc_filter TO ct_excl_func. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_SET_LIST_DROPDOWN *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text * -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- * * FORM frm_set_list_dropdown. This method is not applicable to * * * * * DATA:gt_drp TYPE lvc_T_drop * gs_drp TYPE lvc_s_drop. * * gs_drp-handle = '1' . * gs_drp-value = 'A' . * APPEND gs_drp TO gt_drp . * * gs_drp-handle  = '1' . * gs_drp-value = 'B' . * APPEND gs_drp TO gt_drp . * * gs_drp-handle = '1' . * gs_drp-value = 'C' . * APPEND Gs_drp TO gt_drp. ** Set the corresponding field handle TO 1 in fieldcat ** Before calling ALV * CALL METHOD gs_alv-> set_DROP_down_TABLE ** EXPORTING ** it_drop_down = gt_drp. *ENDFORM. " FRM_SET_LIST_DROPDOWN
Copy the code

2.2.5 Screen related

Create a screen label 100

Create a containner inside and name it GV_CON

Set OK_CODE in the screen element listing

2.2.6 Relevant texts


conclusion

Query data, generate ALV are dynamic control, directly for the selected field update data, can realize multi-field value update at the same time, high reusability