ALV Tree Control树控件

news2024/11/14 14:34:53

ALV Tree Control
CL_GUI_ALV_TREE

效果: 

自定义函数调用,在函数里画屏幕定义树控件显示

FUNCTION ZFI_YSYWLX_HELP_NEW .
*"----------------------------------------------------------------------
*"*"本地接口:
*"  IMPORTING
*"     REFERENCE(S_BS_CODE) TYPE  /SDF/IVIS_DC_SELTAB OPTIONAL
*"     REFERENCE(S_YTBM) TYPE  /SDF/IVIS_DC_SELTAB OPTIONAL
*"     REFERENCE(S_HKONT) TYPE  /SDF/IVIS_DC_SELTAB OPTIONAL
*"     REFERENCE(I_BUKRS) TYPE  BUKRS OPTIONAL
*"  EXPORTING
*"     REFERENCE(E_CANC) TYPE  C
*"  TABLES
*"      ET_DATA TYPE  ZFI_T_YSYWLX_HELP_YB
*"----------------------------------------------------------------------
  DATA LS_ALV_TREE_SEL TYPE TY_ALV_TREE.
  DATA LS_DATA TYPE ZFI_S_YSYWLX_HELP_YB.
  DATA LS_ZTFI0005_1 TYPE ZTFI0005_1.
  DATA LS_YTBM TYPE /SDF/IVIS_DC_SELTAB_ITEM.
  DATA LT_YTBM TYPE /SDF/IVIS_DC_SELTAB.

  FIELD-SYMBOLS <LF_ALV_TREE> TYPE TY_ALV_TREE.

  REFRESH: GT_ALV_TREE,GT_FIELDCATALOG,GT_ALV_TREE_YB,GT_ALV_TREE_SEL.
  CLEAR: G_CANC.

  "公司关联到业态
  LT_YTBM[] = S_YTBM[].
  IF S_YTBM[] IS INITIAL AND I_BUKRS IS NOT INITIAL.
    SELECT SINGLE *
      FROM ZTFI0005_1
      INTO LS_ZTFI0005_1
      WHERE BUKRS = I_BUKRS.
    IF LS_ZTFI0005_1-YWLX1 IS NOT INITIAL.
      LS_YTBM-SIGN = 'I'.
      LS_YTBM-OPTION = 'EQ'.
      LS_YTBM-LOW = LS_ZTFI0005_1-YWLX1.
      APPEND LS_YTBM TO LT_YTBM.
    ENDIF.
    IF LS_ZTFI0005_1-YWLX2 IS NOT INITIAL.
      LS_YTBM-SIGN = 'I'.
      LS_YTBM-OPTION = 'EQ'.
      LS_YTBM-LOW = LS_ZTFI0005_1-YWLX2.
      APPEND LS_YTBM TO LT_YTBM.
    ENDIF.
    IF LS_ZTFI0005_1-YWLX3 IS NOT INITIAL.
      LS_YTBM-SIGN = 'I'.
      LS_YTBM-OPTION = 'EQ'.
      LS_YTBM-LOW = LS_ZTFI0005_1-YWLX3.
      APPEND LS_YTBM TO LT_YTBM.
    ENDIF.
  ENDIF.
*  IF lt_ytbm[] IS NOT INITIAL AND s_hkont[] IS INITIAL.
  "添加通用业态
  LS_YTBM-SIGN = 'I'.
  LS_YTBM-OPTION = 'EQ'.
  LS_YTBM-LOW = 'Z000'.
  APPEND LS_YTBM TO LT_YTBM.
*  ENDIF.

  SELECT A~BS_CODE, A~YTBM, BS_DESCR, CATELOG, DESCR, CATELOG1, DESCR1,
         CATELOG2, DESCR2, CATELOG3, DESCR3, CATELOG4, DESCR4, GTEXT
    FROM ZTFI1040_C06 AS A
    LEFT JOIN TGSBT AS B
    ON  A~YTBM  = B~GSBER
    AND B~SPRAS = @SY-LANGU
    LEFT JOIN ZTFI1040_C06_01 AS C
    ON  A~BS_CODE = C~BS_CODE
    INTO CORRESPONDING FIELDS OF TABLE @GT_ALV_TREE
    WHERE A~BS_CODE IN @S_BS_CODE
      AND A~YTBM IN @LT_YTBM
      AND C~HKONT IN @S_HKONT
      AND XFLAG = ''.

  SORT GT_ALV_TREE BY YTBM BS_CODE.
  DELETE ADJACENT DUPLICATES FROM GT_ALV_TREE COMPARING YTBM BS_CODE.

  IF GT_ALV_TREE[] IS INITIAL.
    "一般层无数据
    E_CANC = '1'.
    EXIT.
  ENDIF.

  LOOP AT GT_ALV_TREE ASSIGNING <LF_ALV_TREE>.
    IF <LF_ALV_TREE>-YTBM = 'Z000'.
      "通用业态显示到 分类1
      CLEAR: <LF_ALV_TREE>-CATELOG2,<LF_ALV_TREE>-CATELOG3,<LF_ALV_TREE>-CATELOG4.
    ELSE.
      "非通过业态显示到 大类科目
      CLEAR: <LF_ALV_TREE>-CATELOG1,<LF_ALV_TREE>-CATELOG2,<LF_ALV_TREE>-CATELOG3,<LF_ALV_TREE>-CATELOG4.
    ENDIF.
  ENDLOOP.

  GT_ALV_TREE_SEL[] = GT_ALV_TREE[].
  "TREE INIT
  IF G_ALV_TREE IS NOT INITIAL.
    G_ALV_TREE->FREE( ).
    GV_CONTAINER->FREE( ).
    CALL METHOD CL_GUI_CFW=>FLUSH.
    CLEAR:G_ALV_TREE,GV_CONTAINER.
  ENDIF.
  "alv 树形展示,供用户选择数据
  CALL SCREEN 9001 STARTING AT 15 1.
  E_CANC = G_CANC.
  CHECK E_CANC = ''.

  LOOP AT GT_ALV_TREE_SEL INTO LS_ALV_TREE_SEL WHERE SEL = 'X'.
    MOVE-CORRESPONDING LS_ALV_TREE_SEL TO LS_DATA.
    APPEND LS_DATA TO ET_DATA.
  ENDLOOP.
ENDFUNCTION.

top include定义: 

FUNCTION-POOL ZFG_FI_YWLX_HELP.             "MESSAGE-ID ..

* INCLUDE LZFG_FI_YWLX_HELPD...              " Local class definition

TYPES:
  BEGIN OF ty_alv_tree,
    ytbm        TYPE ztfi1040_c06-ytbm,      "业态编码
    catelog     TYPE ztfi1040_c06-catelog,   "大类科目
    catelog1    TYPE ztfi1040_c06-catelog1,  "分类1
    catelog2    TYPE ztfi1040_c06-catelog2,  "分类2
    catelog3    TYPE ztfi1040_c06-catelog3,  "分类3
    catelog4    TYPE ztfi1040_c06-catelog4,  "分类4
    bs_code     TYPE ztfi1040_c06-bs_code,   "业务类型编码
    bs_descr    TYPE ztfi1040_c06-bs_descr,  "业务类型-描述
    descr       TYPE ztfi1040_c06-descr,     "大类科目-描述
    descr1      TYPE ztfi1040_c06-descr1,    "分类1-描述
    descr2      TYPE ztfi1040_c06-descr2,    "分类2-描述
    descr3      TYPE ztfi1040_c06-descr3,    "分类3-描述
    descr4      TYPE ztfi1040_c06-descr4,    "分类4-描述
    bs_type     TYPE ztfi1040_c06-bs_type,   "业务类型属性
    gtext       TYPE tgsbt-gtext,            "业态编码-描述
    description TYPE text128,                "描述
    hkont       TYPE ztfi1040_c06_01-hkont,  "财务科目代码
    sel         TYPE c,
  END OF ty_alv_tree.

DATA gt_alv_tree TYPE TABLE OF ty_alv_tree.
DATA gt_alv_tree_sel TYPE TABLE OF ty_alv_tree.
DATA gt_alv_tree_yb TYPE TABLE OF ty_alv_tree.

DATA g_canc TYPE c.

DATA g_alv_tree      TYPE REF TO cl_gui_alv_tree.
DATA gv_container    TYPE REF TO cl_gui_custom_container.
DATA gt_fieldcatalog TYPE lvc_t_fcat.

CLASS lcl_tree_event_receiver DEFINITION.

  PUBLIC SECTION.
*§2. Define an event handler method for each event you want to react to.

* 'sender' is an implicit event parameter that is provided by
* ABAP Objects runtime system. It contains a reference to the
* object that fired the event. You may directly use it to
* call methods of this instance.
    METHODS checkbox_change  FOR EVENT checkbox_change
                  OF cl_gui_alv_tree
      IMPORTING checked
                  fieldname
                  node_key.
ENDCLASS.

CLASS lcl_tree_event_receiver IMPLEMENTATION.
*§3. Implement your event handler methods.
  METHOD checkbox_change.
    PERFORM f_checkbox_change USING checked
                                  fieldname
                                  node_key.

  ENDMETHOD.

ENDCLASS.

 屏幕PBO定义

*----------------------------------------------------------------------*
***INCLUDE LZFG_FI_YWLX_HELPO01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  STATUS_9001  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_9001 OUTPUT.
  SET PF-STATUS '9001'.
  SET TITLEBAR '9001'.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  M_BUILD_TREE_9001  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE m_build_tree_9001 OUTPUT.
  IF g_alv_tree IS INITIAL.
    PERFORM f_init_tree.

    CALL METHOD cl_gui_cfw=>flush
      EXCEPTIONS
        cntl_system_error = 1
        cntl_error        = 2.
    IF sy-subrc NE 0.
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = 'Automation Queue failure'(801)
          txt1  = 'Internal error:'(802)
          txt2  = 'A method in the automation queue'(803)
          txt3  = 'caused a failure.'(804).
    ENDIF.
  ELSE.
    CALL METHOD g_alv_tree->frontend_update.
    CALL METHOD cl_gui_cfw=>flush.
  ENDIF.
ENDMODULE.

PAI定义

*----------------------------------------------------------------------*
***INCLUDE LZFG_FI_YWLX_HELPI01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9001  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_9001 INPUT.
  CASE sy-ucomm.
    WHEN 'ZOK'.
*      PERFORM f_get_selected_data.
      LEAVE TO SCREEN 0.
    WHEN 'CANC'.
      g_canc = 'X'.
      LEAVE TO SCREEN 0.
    WHEN OTHERS.
  ENDCASE.
ENDMODULE.

form定义

*----------------------------------------------------------------------*
***INCLUDE LZFG_FI_YWLX_HELPF01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Form  F_INIT_TREE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_init_tree .
  DATA ls_hierarchy_header TYPE treev_hhdr.

  CREATE OBJECT gv_container
    EXPORTING
      container_name = 'G_TREE_YB'.

* create tree control
  CREATE OBJECT g_alv_tree
    EXPORTING
      parent                      = gv_container
      node_selection_mode         = cl_gui_column_tree=>node_sel_mode_single
      item_selection              = 'X'
      no_html_header              = 'X'
      no_toolbar                  = ''
    EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      create_error                = 3
      lifetime_error              = 4
      illegal_node_selection_mode = 5
      failed                      = 6
      illegal_column_name         = 7.
  IF sy-subrc <> 0.
    MESSAGE x208(00) WITH 'ERROR'.                          "#EC NOTEXT
  ENDIF.

  PERFORM f_build_hierarchy_header CHANGING ls_hierarchy_header.

  PERFORM f_build_fieldcatalog.

* (even after this method call). You can change data of your table
* by calling methods of CL_GUI_ALV_TREE.
* Furthermore, the output table 'gt_outtab' must be global and can
* only be used for one ALV Tree Control.
  CALL METHOD g_alv_tree->set_table_for_first_display
    EXPORTING
      is_hierarchy_header = ls_hierarchy_header
    CHANGING
      it_fieldcatalog     = gt_fieldcatalog
      it_outtab           = gt_alv_tree_yb.

  PERFORM f_create_hierarchy.

  PERFORM f_register_events.
* Update calculations which were initially defined by field DO_SUM
* of the fieldcatalog. (see build_fieldcatalog).
  CALL METHOD g_alv_tree->update_calculations.

* Send data to frontend.
  CALL METHOD g_alv_tree->frontend_update.
ENDFORM.

FORM f_build_hierarchy_header CHANGING
                               ps_hierarchy_header TYPE treev_hhdr.

  ps_hierarchy_header-heading = '业务类型层级'(300).
  ps_hierarchy_header-tooltip = '业务类型层级'(400).
  ps_hierarchy_header-width = 80.
  ps_hierarchy_header-width_pix = ''.

ENDFORM.

FORM f_build_fieldcatalog .
  DATA: ls_fieldcatalog TYPE lvc_s_fcat.

  REFRESH gt_fieldcatalog.

  ls_fieldcatalog-fieldname = 'DESCRIPTION'.
  ls_fieldcatalog-coltext = '描述'.
  ls_fieldcatalog-outputlen = 100.
  APPEND ls_fieldcatalog TO gt_fieldcatalog.

ENDFORM.

FORM f_create_hierarchy .
  DATA: lv_ytbm_key     TYPE lvc_nkey,
        lv_catelog_key  TYPE lvc_nkey,
        lv_catelog1_key TYPE lvc_nkey,
        lv_catelog2_key TYPE lvc_nkey,
        lv_catelog3_key TYPE lvc_nkey,
        lv_catelog4_key TYPE lvc_nkey,
        lv_last_key     TYPE lvc_nkey,
        lv_node_text    TYPE lvc_value,
        lv_top_key      TYPE lvc_nkey.
  DATA lt_children TYPE lvc_t_nkey.
  DATA:
    lt_item_layout TYPE lvc_t_layi,
    ls_item_layout TYPE lvc_s_layi.

  DATA ls_alv_tree TYPE ty_alv_tree.
  FIELD-SYMBOLS <lf_alv_tree> TYPE ty_alv_tree.


* Define one top node. In this way it is possible to calculate
* values for the whole hierarchy.
  CLEAR ls_item_layout.
  ls_item_layout-fieldname = '&Hierarchy'.
  ls_item_layout-class     = cl_gui_column_tree=>item_class_checkbox.
  ls_item_layout-editable  = 'X'.
  APPEND ls_item_layout TO lt_item_layout.

  CALL METHOD g_alv_tree->add_node
    EXPORTING
      i_relat_node_key = ''
      i_relationship   = cl_gui_column_tree=>relat_last_child
      i_node_text      = TEXT-001
      it_item_layout   = lt_item_layout
    IMPORTING
      e_new_node_key   = lv_top_key.

*  CALL METHOD g_alv_tree->add_node
*    EXPORTING
*      i_relat_node_key = lv_top_key
*      i_relationship   = cl_gui_column_tree=>relat_last_child
*      i_node_text      = TEXT-002
*    IMPORTING
*      e_new_node_key   = lv_top_key.

*  SORT gt_alv_tree BY ytbm DESCENDING catelog DESCENDING catelog1 DESCENDING
*                      catelog2 DESCENDING catelog3 DESCENDING catelog4 DESCENDING.
  SORT gt_alv_tree BY ytbm catelog catelog1
                      catelog2 catelog3 catelog4.

  LOOP AT gt_alv_tree ASSIGNING <lf_alv_tree>.
    AT NEW ytbm.
      CLEAR:lv_ytbm_key,lv_catelog_key,lv_catelog1_key,lv_catelog2_key,lv_catelog3_key,lv_catelog4_key.
      lv_node_text = <lf_alv_tree>-ytbm.
      IF <lf_alv_tree>-ytbm IS NOT INITIAL OR <lf_alv_tree>-gtext IS NOT INITIAL.
*        ls_alv_tree-description = <lf_alv_tree>-gtext.
        <lf_alv_tree>-description = <lf_alv_tree>-gtext.
        PERFORM f_add_node USING    <lf_alv_tree>
                                    lv_top_key
                                    lv_node_text
                               CHANGING lv_ytbm_key.
      ENDIF.
    ENDAT.
    AT NEW catelog.
      CLEAR:lv_catelog_key,lv_catelog1_key,lv_catelog2_key,lv_catelog3_key,lv_catelog4_key.
      lv_node_text = <lf_alv_tree>-catelog.
      IF <lf_alv_tree>-catelog IS NOT INITIAL OR <lf_alv_tree>-descr IS NOT INITIAL.
*        ls_alv_tree-description = <lf_alv_tree>-descr.
        <lf_alv_tree>-description = <lf_alv_tree>-descr.
        PERFORM f_add_node USING    <lf_alv_tree>
                                    lv_ytbm_key
                                    lv_node_text
                               CHANGING lv_catelog_key.
      ENDIF.
    ENDAT.
    AT NEW catelog1.
      IF <lf_alv_tree>-ytbm = 'Z000'.
        CLEAR:lv_catelog1_key,lv_catelog2_key,lv_catelog3_key,lv_catelog4_key.
        lv_node_text = <lf_alv_tree>-catelog1.
        IF <lf_alv_tree>-catelog1 IS NOT INITIAL OR <lf_alv_tree>-descr1 IS NOT INITIAL.
*        ls_alv_tree-description = <lf_alv_tree>-descr1.
          <lf_alv_tree>-description = <lf_alv_tree>-descr1.
          PERFORM f_add_node USING    <lf_alv_tree>
                                      lv_catelog_key
                                      lv_node_text
                                 CHANGING lv_catelog1_key.
        ENDIF.
      ENDIF.
    ENDAT.
*    AT NEW catelog2.
*      CLEAR:lv_catelog2_key,lv_catelog3_key,lv_catelog4_key.
*      lv_node_text = <lf_alv_tree>-catelog2.
*      IF <lf_alv_tree>-catelog2 IS NOT INITIAL OR <lf_alv_tree>-descr2 IS NOT INITIAL.
**        ls_alv_tree-description = <lf_alv_tree>-descr2.
*        <lf_alv_tree>-description = <lf_alv_tree>-descr2.
*        PERFORM f_add_node USING    <lf_alv_tree>
*                                    lv_catelog1_key
*                                    lv_node_text
*                               CHANGING lv_catelog2_key.
*      ENDIF.
*    ENDAT.
*    AT NEW catelog3.
*      CLEAR:lv_catelog3_key,lv_catelog4_key.
*      lv_node_text = <lf_alv_tree>-catelog3.
*      IF <lf_alv_tree>-catelog3 IS NOT INITIAL OR <lf_alv_tree>-descr3 IS NOT INITIAL.
**        ls_alv_tree-description = <lf_alv_tree>-descr3.
*        <lf_alv_tree>-description = <lf_alv_tree>-descr3.
*        PERFORM f_add_node USING    <lf_alv_tree>
*                                    lv_catelog2_key
*                                    lv_node_text
*                               CHANGING lv_catelog3_key.
*      ENDIF.
*    ENDAT.
*    AT NEW catelog4.
*      CLEAR:lv_catelog4_key.
*      lv_node_text = <lf_alv_tree>-catelog4.
*      IF <lf_alv_tree>-catelog4 IS NOT INITIAL OR <lf_alv_tree>-descr4 IS NOT INITIAL.
**        ls_alv_tree-description = <lf_alv_tree>-descr4.
*        <lf_alv_tree>-description = <lf_alv_tree>-descr4.
*        PERFORM f_add_node USING    <lf_alv_tree>
*                                    lv_catelog3_key
*                                    lv_node_text
*                               CHANGING lv_catelog4_key.
*      ENDIF.
*    ENDAT.

    lv_node_text = <lf_alv_tree>-bs_code.
    IF lv_catelog4_key IS INITIAL.
      lv_catelog4_key = lv_catelog3_key.
    ENDIF.
    IF lv_catelog4_key IS INITIAL.
      lv_catelog4_key = lv_catelog2_key.
    ENDIF.
    IF lv_catelog4_key IS INITIAL.
      lv_catelog4_key = lv_catelog1_key.
    ENDIF.
    IF lv_catelog4_key IS INITIAL.
      lv_catelog4_key = lv_catelog_key.
    ENDIF.
    IF lv_catelog4_key IS INITIAL.
      lv_catelog4_key = lv_ytbm_key.
    ENDIF.
    IF lv_catelog4_key IS INITIAL.
      lv_catelog4_key = lv_top_key.
    ENDIF.
*    ls_alv_tree-description = <lf_alv_tree>-bs_descr.
    <lf_alv_tree>-description = <lf_alv_tree>-bs_descr.
    PERFORM f_add_node USING    <lf_alv_tree>
                                lv_catelog4_key
                                lv_node_text
                               CHANGING lv_last_key.
  ENDLOOP.
  "展开集团层
  CALL METHOD g_alv_tree->get_children
    EXPORTING
      i_node_key         = lv_top_key
    IMPORTING
      et_children        = lt_children
    EXCEPTIONS
      historic_error     = 1
      node_key_not_found = 2.
  IF lt_children[] IS NOT INITIAL.
    CALL METHOD g_alv_tree->expand_node
      EXPORTING
        i_node_key = lv_top_key.
  ENDIF.
ENDFORM.

FORM f_add_node  USING     ps_alv_tree TYPE ty_alv_tree
                          pi_relat_key TYPE lvc_nkey
                          pi_node_text TYPE lvc_value
                CHANGING  pc_node_key TYPE lvc_nkey.

  DATA:
    lt_item_layout TYPE lvc_t_layi,
    ls_item_layout TYPE lvc_s_layi.


  CLEAR ls_item_layout.
  ls_item_layout-fieldname = '&Hierarchy'.
  ls_item_layout-class     = cl_gui_column_tree=>item_class_checkbox.
  ls_item_layout-editable  = 'X'.
  APPEND ls_item_layout TO lt_item_layout.

* add node
  CALL METHOD g_alv_tree->add_node
    EXPORTING
      i_relat_node_key = pi_relat_key
      i_relationship   = cl_gui_column_tree=>relat_last_child
      i_node_text      = pi_node_text
      is_outtab_line   = ps_alv_tree
      it_item_layout   = lt_item_layout
    IMPORTING
      e_new_node_key   = pc_node_key.

ENDFORM.

FORM f_register_events .
  DATA: lt_events         TYPE cntl_simple_events,
        ls_event          TYPE cntl_simple_event,
        lo_event_receiver TYPE REF TO lcl_tree_event_receiver.

*§4a. Frontend registration(i):  get already registered tree events.
*................................................................
* The following four tree events registers ALV Tree in the constructor
* method itself.
*    - cl_gui_column_tree=>eventid_expand_no_children
* (needed to load data to frontend when a user expands a node)
*    - cl_gui_column_tree=>eventid_header_context_men_req
* (needed for header context menu)
*    - cl_gui_column_tree=>eventid_header_click
* (allows selection of columns (only when item selection activated))
*   - cl_gui_column_tree=>eventid_item_keypress
* (needed for F1-Help (only when item selection activated))
*
* Nevertheless you have to provide their IDs again if you register
* additional events with SET_REGISTERED_EVENTS (see below).
* To do so, call first method  GET_REGISTERED_EVENTS (this way,
* all already registered events remain registered, even your own):
  CALL METHOD g_alv_tree->get_registered_events
    IMPORTING
      events = lt_events.
* (If you do not these events will be deregistered!!!).
* You do not have to register events of the toolbar again.

  ls_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.
  ls_event-appl_event = 'X'.
  APPEND ls_event TO lt_events.
*§4c. Frontend registration(iii):provide new event table to alv tree
  CALL METHOD g_alv_tree->set_registered_events
    EXPORTING
      events                    = lt_events
    EXCEPTIONS
      cntl_error                = 1
      cntl_system_error         = 2
      illegal_event_combination = 3.
  IF sy-subrc <> 0.
    MESSAGE x208(00) WITH 'ERROR'.                          "#EC NOTEXT
  ENDIF.
*--------------------
*§4d. Register events on backend (ABAP Objects event handling)
  CREATE OBJECT lo_event_receiver.
  SET HANDLER lo_event_receiver->checkbox_change FOR g_alv_tree.
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  F_CHECKBOX_CHANGE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_CHECKED  text
*      -->P_FIELDNAME  text
*      -->P_NODE_KEY  text
*----------------------------------------------------------------------*
FORM f_checkbox_change  USING    iv_checked   TYPE c
                                  iv_fieldname TYPE lvc_fname
                                  iv_node_key  TYPE lvc_nkey.
  DATA:
    ls_level_tree_output TYPE ty_alv_tree,
    lt_nkey	             TYPE lvc_t_nkey,
    lv_nkey              TYPE lvc_nkey.

  DATA:
    lt_item_layout TYPE lvc_t_layi,
    ls_item_layout TYPE lvc_s_layi.

  DATA:
    lt_item_layout_updata TYPE lvc_t_laci,
    ls_item_layout_updata TYPE lvc_s_laci.


  CALL METHOD g_alv_tree->get_outtab_line
    EXPORTING
      i_node_key    = iv_node_key
    IMPORTING
      e_outtab_line = ls_level_tree_output.

  IF iv_checked IS NOT INITIAL.
    ls_level_tree_output-sel = abap_true.
  ELSE.
    ls_level_tree_output-sel = abap_false.
  ENDIF.

  MODIFY gt_alv_tree_sel FROM ls_level_tree_output
                         TRANSPORTING sel
                         WHERE bs_code = ls_level_tree_output-bs_code.

  CALL METHOD g_alv_tree->get_subtree
    EXPORTING
      i_node_key       = iv_node_key
    IMPORTING
      et_subtree_nodes = lt_nkey.

  LOOP AT lt_nkey INTO lv_nkey.

    CLEAR lt_item_layout.
    CALL METHOD g_alv_tree->get_outtab_line
      EXPORTING
        i_node_key     = lv_nkey
      IMPORTING
        et_item_layout = lt_item_layout
        e_outtab_line  = ls_level_tree_output.

    IF iv_checked IS NOT INITIAL.
      ls_level_tree_output-sel = abap_true.
    ELSE.
      ls_level_tree_output-sel = abap_false.
    ENDIF.

    MODIFY gt_alv_tree_sel FROM ls_level_tree_output
                        TRANSPORTING sel
                               WHERE bs_code = ls_level_tree_output-bs_code.

    CLEAR ls_item_layout_updata.
    CLEAR ls_item_layout.
    CLEAR lt_item_layout_updata.

    READ TABLE lt_item_layout INTO ls_item_layout INDEX 1.

    ls_item_layout_updata-fieldname  = ls_item_layout-fieldname.
    ls_item_layout_updata-chosen     = iv_checked.
    ls_item_layout_updata-u_chosen   = 'X'.
    APPEND ls_item_layout_updata TO lt_item_layout_updata.

    CALL METHOD g_alv_tree->change_node
      EXPORTING
        i_node_key     = lv_nkey
        i_outtab_line  = ls_level_tree_output
        it_item_layout = lt_item_layout_updata.
  ENDLOOP.

  CALL METHOD g_alv_tree->frontend_update.
ENDFORM.

GUI STATUS:

SCREEN 9001逻辑流:

PROCESS BEFORE OUTPUT.
  MODULE status_9001.
  MODULE m_build_tree_9001.
*
PROCESS AFTER INPUT.
  MODULE user_command_9001.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2098243.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

zset使用lua实现取最高分数中的随机成员

zset使用lua实现取最高分数中的随机成员 这种场景适用队列中不想要先入先出、先入后出因为zset的命令都是带有排序功能的&#xff0c;所以取值时要不从大到小要不从小到大所以我使用lua实现随机取成员使用lua是因为可以保持原子性在执行过程中Lua脚本是不会被其他命令或请求打…

C语言典型例题59

《C程序设计教程&#xff08;第四版&#xff09;——谭浩强》 题目&#xff1a; 例题4.11 译密码。为使电文保密&#xff0c;往往按一定规律将其转换为密码&#xff0c;收报人再按约定的规律将其译回原文。 例如&#xff0c;可以按以下规律将电文变为密码&#xff1a; 将字母A…

我不是非酋之-天空概率

最近入坑了dnf手游&#xff0c;染上了合天空&#xff0c;大黑蛋子一个&#xff0c;突发奇想&#xff0c;模拟下合天空概率&#xff0c;看看是否真的有20%。 梳理代码逻辑如下&#xff1a; 不考虑礼包和其他东西 条件&#xff1a; 合成概率20%&#xff0c;每次需要2个装扮和一个…

格式化的磁盘数据能恢复吗?五个看完即可掌握的恢复方法

磁盘是大多数电子设备都必须具有的一个存储介质&#xff0c;在平时使用的过程中&#xff0c;很多用户为了途一时的方便&#xff0c;经常会需要一键将磁盘里面的数据执行格式化&#xff0c;以实现清空或者删除的情况。然而&#xff0c;在执行完具体的操作后&#xff0c;过了一段…

Vue(十三) 路由、路由嵌套、query、param传参、propos、replace属性。编程式路由导航,特有的生命周期函数,路由守卫

文章目录 路由1. 基本使用2. 多级(嵌套)路由3. 路由query传参4. 命名路由5. 路由param传参6. propos属性7. replace属性8. 编程式路由导航9. 缓存路由组件10. actived&#xff0c;deactived生命周期函数11. 路由守卫1、全局路由2、独享路由3、组件内路由守卫 12. 路由器工作的两…

干货含源码!如何用Java后端操作Docker(命令行篇)

目录 干货含源码&#xff01;如何用Java后端操作Docker&#xff08;命令行篇&#xff09; 一、为什么要用后端程序操作Docker 二、安装Docker 1、安装Docker 2、启动Docker 三、使用Java后端操作docker 1、构建docker镜像并生成容器 2、执行完毕后删除容器和镜像 3、在…

怎么删除谷歌浏览器的下载记录

定期删除谷歌浏览器的下载记录&#xff0c;对于保护个人隐私和提升浏览器性能都非常的重要。为了帮助大家安全的进行谷歌浏览器下载记录的清除&#xff0c;本文为大家分享了实用的操作方法&#xff0c;一起来看看吧。 删除谷歌浏览器下载记录的原因说明 1、保护隐私&#xff1…

【算法 动态规划 简单多状态 dp 问题】打家劫舍题型

打家劫舍题型 按摩师 (easy)解题思路代码 打家劫舍II &#xff08;medium&#xff09;解题思路代码 删除并获得点数&#xff08;medium&#xff09;解题思路代码 按摩师 (easy) 题目链接 该题是打家劫舍的变形 解题思路 状态表示 分析: 注意题目, 对于当天的预约, 可以接受…

车辆远控功能自动化测试方案:打造高效可靠的测试流程

随着汽车逐步走向智能化、网联化&#xff0c;整车的功能已经不再局限于驾驶员在车内进行本地操作。在远离车辆时&#xff0c;驾驶员也可以通过手机APP下发控制指令来实现对车辆的远程控制。 近几年&#xff0c;伴随远控功能项不断增多&#xff0c;其功能逻辑也越来越复杂&…

python开发--信息的增删改

部门信息的增删改 1. 增加 点击新建部门 跳转到新建部门页面&#xff1a;http://127.0.0.1:8000/depart/add/ 在views.py里面增加如下代码&#xff0c;可以将用户输入的信息添加到数据库中 def depart_add(request):if request.method GET:return render(request, depart…

STL之my_list容器

前言&#xff1a;各位老铁好久不见了&#xff0c;今天分享的知识是自己实现一个简单的list容器&#xff0c;为什么我先跳过vector容器的自我实现呢&#xff1f;我个人觉得vector相对于list的自我实现简单一点&#xff0c;所以今天先分享实现my_list的知识 我们要实现my_list&a…

machine learning - 2

泛化误差 也可以认为是预测时的误差。 训练误差 并不是越小越好&#xff0c;太小会过拟合。 获得测试集合的方法&#xff1a; 1&#xff09;&#xff1a; 2&#xff09;&#xff1a;例如&#xff1a;k-折交叉验证法&#xff0c; 就的每k个数据取一个座位测试集 3&#xff0…

nginx容器映射配置文件后,启动一直报错提示:failed (13: Permission denied)的排查

问题现象&#xff1a; 使用harbor 的install.sh 创建docker-compose之后&#xff0c;出现nginx容器一直重启。 查看日志发现是&#xff1a;配置文件无权限。报错信息如下&#xff1a; Sep 2 16:43:13 172.28.0.1 nginx[1344]: 2024/09/02 08:43:13 [emerg] 1#0: open() “/e…

网站网站建设公司用什么

随着互联网的飞速发展&#xff0c;网站已经成为企业的重要门面和宣传工具。为了在网上展示自己的品牌形象和吸引更多的客户&#xff0c;越来越多的企业选择找专业的网站建设公司进行网站建设。那么&#xff0c;网站建设公司主要使用什么技术和方法呢&#xff1f; 首先&#xff…

四、基本电路设计笔记——4.1 DC-DC稳压电路

目录 4.1 DC-DC稳压电路 4.1.1 基于MT2492的DC-DC稳压电路 &#xff08;1&#xff09;芯片参数 &#xff08;2&#xff09;芯片引脚 &#xff08;3&#xff09;输出电压设置 4.1.2 基于MT2499A的DC-DC稳压电路 &#xff08;1&#xff09;芯片参数 &#xff08;2&#xf…

【Redis】Redis 主从复制

文章目录 1 前言2 主从模式介绍3 配置 Redis 主从结构3.1 建立复制3.2 断开复制3.3 其他特性3.4 拓扑结构 4 Redis 主从复制原理4.1 复制过程4.2 PSYNC 数据同步4.3 PSYNC 运行流程 5 主从复制流程5.1 全量复制流程5.2 部分复制流程5.3 实时复制流程 1 前言 分布式系统中存在一…

鸿誉移民:定制化移民服务,吹响全球高效率移民的嘹亮号角!

鸿誉移民&#xff1a;定制化移民服务&#xff0c;吹响全球高效率移民的嘹亮号角&#xff01; 作为国内知名海外移民服务机构&#xff0c;鸿誉移民历经多年行业沉淀&#xff0c;拥有着极其丰富的移民咨询以及移民办理经验&#xff0c;并以咨询及时精准&#xff0c;签证快捷、通…

Bean 的实例化(创建 | 获取)

Spring为Bean提供了多种实例化方式&#xff0c;包括如下4种方式&#xff1a; 第一种&#xff1a;通过构造方法实例化第二种&#xff1a;通过简单工厂模式实例化第三种&#xff1a;通过factory-bean实例化&#xff08;工厂方法模式实例化&#xff09;第四种&#xff1a;通过Fact…

智能未来:低代码与AI如何重塑企业应用开发

引言 在当今瞬息万变的商业环境中&#xff0c;企业面临着前所未有的挑战与机遇。数字化转型已经成为各行各业的必然趋势&#xff0c;而在这一过程中&#xff0c;应用开发的效率与智能化程度成为企业竞争力的重要衡量标准。传统的开发模式往往需要大量的时间和资源&#xff0c;而…

【Godot4.3】基于ShapePoints的Polygon2D扩展

概述 这同样是来自2023年7月份的一项实验性工作&#xff0c;基于最初版本的ShapePoints静态函数库&#xff0c;实现了对Polygon2D节点的扩展&#xff0c;用于创建参数化图形的Polygon2D节点。 Polygon2D节点本身只能通过顶点绘制工具&#xff0c;创建很随意的多边形。通过Sha…