REPORT  z_barry_alv_tree1_bom MESSAGE-ID oo.
TABLES: stpox.
INCLUDE <icon>.
CLASS: cl_gui_column_tree DEFINITION LOAD,
       cl_gui_cfw DEFINITION
LOAD .
DATA: tree1  TYPE REF TO cl_gui_alv_tree ,
      mr_toolbar TYPE REF TO
cl_gui_toolbar .
DATA: gs_stpox       TYPE stpox,
      gt_stpox       TYPE stpox OCCURS
0,
      gt_fieldcatalog  TYPE lvc_t_fcat,
      gt_item_layout   TYPE
lvc_t_laci,
      gs_item_layout   TYPE lvc_s_laci,
      okcode          
LIKE sy-ucomm .
TYPES: BEGIN OF gs_f.
        INCLUDE STRUCTURE stpox.
TYPES:
node_key      TYPE lvc_nkey,
       END   OF gs_f.
DATA: gs_xstpox      
TYPE gs_f ,
      gt_xstpox       TYPE gs_f OCCURS 0.
DATA:
l_custom_container TYPE REF TO cl_gui_custom_container.
DATA:  wa_topmat TYPE cstmat,
       wa_dstst TYPE
csdata-xfeld.
DATA: it_matcat TYPE STANDARD TABLE OF cscmat.
PARAMETERS: p_matnr LIKE mara-matnr DEFAULT 'YW25K',
            p_werks
LIKE ekpo-werks DEFAULT '1010' .
START-OF-SELECTION.
  PERFORM getdata.
  CALL SCREEN 9000.
*&---------------------------------------------------------------------*
*&     
Form 
getdata
*&---------------------------------------------------------------------*
FORM
getdata.
  CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
    EXPORTING
     
capid                 = 'CAD1'      " p_capid
      datuv                 =
sy-datum
      mehrs                 = 'X'         "p_mehrs
     
stlal                 = '01'     "可选BOM
      stlan                 =
'2'      "BOM 用途
      mtnrv                 = P_MATNR
     
werks                 = P_WERKS
      emeng                 = 1
   
IMPORTING
      topmat                = wa_topmat
     
dstst                 = wa_dstst
    TABLES
      stb                   =
gt_stpox
      matcat                = it_matcat
    EXCEPTIONS
     
alt_not_found         = 1
      call_invalid          = 2
     
material_not_found    = 3
      missing_authorization = 4
     
no_bom_found          = 5
      no_plant_data         = 6
     
no_suitable_bom_found = 7
      conversion_error      = 8
     
OTHERS                = 9.
  CASE sy-subrc .
    WHEN 1 .
      MESSAGE
e899(fi) WITH 'alt_not_found'.
    WHEN 2 .
      MESSAGE e899(fi) WITH
'call_invalid '.
    WHEN 3 .
      MESSAGE e899(fi) WITH
'material_not_found'.
    WHEN 4 .
      MESSAGE e899(fi) WITH
'missing_authorization'.
    WHEN 5 .
      MESSAGE e899(fi) WITH
'no_bom_found'.
    WHEN 6 .
      MESSAGE e899(fi) WITH
'no_plant_data'.
    WHEN 7 .
      MESSAGE e899(fi) WITH
'no_suitable_bom_found'.
    WHEN 8 .
      MESSAGE e899(fi) WITH
'conversion_error'.
    WHEN 9 .
      MESSAGE e899(fi) WITH 'OTHERS
Error'.
  ENDCASE.
  LOOP AT gt_stpox INTO gs_stpox.
    MOVE-CORRESPONDING gs_stpox TO
gs_xstpox .
    APPEND gs_xstpox TO gt_xstpox.
  ENDLOOP.
ENDFORM.                   
"getdata
*----------------------------------------------------------------------*

MODULE status_9000
OUTPUT
*----------------------------------------------------------------------*
MODULE
status_9000 OUTPUT.
  SET PF-STATUS 'MAIN'.
  SET TITLEBAR 'TITLE'.
 
IF tree1 IS INITIAL.
    PERFORM init_tree.
  ENDIF.
  CALL METHOD
cl_gui_cfw=>flush.
ENDMODULE.                 " PBO_9000 
OUTPUT
*----------------------------------------------------------------------*

MODULE user_command_9000
INPUT
*----------------------------------------------------------------------*
MODULE
user_command_9000 INPUT.
  CASE okcode.
    WHEN 'EXIT' OR 'BACK' OR
'CANC'.
      CALL METHOD tree1->free.
      LEAVE PROGRAM .
    WHEN OTHERS.
      CALL METHOD cl_gui_cfw=>dispatch.
 
ENDCASE.
  CLEAR okcode.
  CALL METHOD
cl_gui_cfw=>flush.
ENDMODULE.                 " okcode  INPUT
*&---------------------------------------------------------------------*
*&     
Form 
init_tree
*&---------------------------------------------------------------------*
FORM
init_tree .
  PERFORM build_fieldcatalog.
*  IF sy-batch IS INITIAL.
*    CREATE OBJECT
l_custom_container
*      EXPORTING
*        container_name              =
'TREE1'
*      EXCEPTIONS
*        cntl_error                  =
1
*        cntl_system_error           = 2
*       
create_error                = 3
*        lifetime_error              =
4
*        lifetime_dynpro_dynpro_link = 5.
*    IF sy-subrc <>
0.
*      MESSAGE e000 WITH '创建容器:TREE1 错误'.
*    ENDIF.

ENDIF.
  CREATE OBJECT tree1
    EXPORTING
*     
parent                      = l_custom_container
     
parent                      = cl_gui_container=>screen0
     
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 e000 WITH '创建TREE错误'.
  ENDIF.
  DATA l_hierarchy_header TYPE treev_hhdr.
  PERFORM
build_hierarchy_header CHANGING l_hierarchy_header.
  DATA: ls_variant TYPE disvariant.
  ls_variant-report =
sy-repid.
  CALL METHOD tree1->set_table_for_first_display
   
EXPORTING
      is_hierarchy_header = l_hierarchy_header
     
i_background_id     = 'ALV_BACKGROUND'
      i_save              =
'A'
      is_variant          = ls_variant
    CHANGING
     
it_outtab           = gt_stpox "table must be emty !!
     
it_fieldcatalog     = gt_fieldcatalog.
  DATA: l1 TYPE lvc_nkey ,l2 TYPE lvc_nkey ,l3 TYPE lvc_nkey ,l4 TYPE
lvc_nkey ,
        l5 TYPE lvc_nkey ,l6 TYPE lvc_nkey ,l7 TYPE lvc_nkey ,l8
TYPE lvc_nkey ,
        l_key TYPE lvc_nkey,
        l_last_key TYPE
lvc_nkey  ,
        added .
  LOOP AT gt_xstpox INTO gs_xstpox .
    MOVE-CORRESPONDING gs_xstpox TO gs_stpox.
    CASE gs_stpox-stufe .
      WHEN '1'.
        l_key =
''.
      WHEN '2'.
        l_key = l1.
      WHEN '3'.
       
l_key = l2.
      WHEN '4'.
        l_key = l3.
      WHEN
'5'.
        l_key = l4.
      WHEN '6'.
        l_key = l5.
   
ENDCASE.
    PERFORM add_complete_line USING  gs_stpox
l_key
                            CHANGING l_last_key.
   
gs_xstpox-node_key = l_last_key.
    CASE gs_stpox-stufe .
      WHEN '1'.
        l1 =
l_last_key.
      WHEN '2'.
        l2 = l_last_key.
      WHEN
'3'.
        l3 = l_last_key.
      WHEN '4'.
        l4 =
l_last_key.
      WHEN '5'.
        l5 = l_last_key.
      WHEN
'6'.
        l6 = l_last_key.
    ENDCASE.
    MODIFY gt_xstpox FROM gs_xstpox .
  ENDLOOP.
  CALL METHOD tree1->update_calculations.
  CALL METHOD
tree1->frontend_update.
ENDFORM.                    " init_tree
*&---------------------------------------------------------------------*
*&     
Form 
build_fieldcatalog
*&---------------------------------------------------------------------*
FORM
build_fieldcatalog.
  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
   
EXPORTING
      i_structure_name = 'STPOX'
    CHANGING
     
ct_fieldcat      = gt_fieldcatalog.
  DATA: ls_fieldcatalog TYPE lvc_s_fcat.
  LOOP AT gt_fieldcatalog INTO
ls_fieldcatalog.
*    CASE ls_fieldcatalog-fieldname.
*      WHEN 'CARRID'
OR 'CONNID' OR 'FLDATE'.
*        ls_fieldcatalog-no_out = 'X'.
*       
ls_fieldcatalog-key    = ''.
*      WHEN 'PRICE' OR 'SEATSOCC' OR 'SEATSMAX'
OR 'PAYMENTSUM'.
**        ls_fieldcatalog-do_sum = 'X'.
*      WHEN
'PLANETYPE'.
*        ls_fieldcatalog-edit = 'X'.
*       
ls_fieldcatalog-style = cl_gui_alv_grid=>mc_style_enabled .
*   
ENDCASE.
    MODIFY gt_fieldcatalog FROM ls_fieldcatalog.
 
ENDLOOP.
ENDFORM.                               " build_fieldcatalog
*&---------------------------------------------------------------------*
*&     
Form 
build_hierarchy_header
*&---------------------------------------------------------------------*
FORM
build_hierarchy_header CHANGING
                              
p_hierarchy_header TYPE treev_hhdr.
*
  p_hierarchy_header-heading =
'BOM层次'.
  p_hierarchy_header-tooltip = 'ToolTip'.
 
p_hierarchy_header-width = 30.
  p_hierarchy_header-width_pix =
''.
*
ENDFORM.                               "
build_hierarchy_header
*&---------------------------------------------------------------------*
*&     
Form 
add_complete_line
*&---------------------------------------------------------------------*
FORM
add_complete_line USING  ps_stpox TYPE stpox
                              
p_relat_key TYPE lvc_nkey
                     CHANGING  p_node_key TYPE
lvc_nkey.
  DATA: l_node_text TYPE lvc_value.
* set item-layout
  DATA:
lt_item_layout TYPE lvc_t_layi,
        ls_item_layout TYPE lvc_s_layi.
 
DATA: stufe_num(2) TYPE n.
  ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
 
ls_item_layout-class     = cl_gui_column_tree=>item_class_text.

ls_item_layout-editable  = 'X'.
*  ls_item_layout-chosen    = 'X'.  "
设置为选中状态
  APPEND ls_item_layout TO lt_item_layout.
*  l_node_text =  ps_stpox-ojtxp.
  stufe_num = ps_stpox-stufe.
 
CONCATENATE stufe_num ',' ps_stpox-ojtxp INTO l_node_text.
  CALL METHOD tree1->add_node
    EXPORTING
      i_relat_node_key
= p_relat_key
      i_relationship   =
cl_gui_column_tree=>relat_last_child
      is_outtab_line   =
ps_stpox
      i_node_text      = l_node_text
      it_item_layout   =
lt_item_layout
    IMPORTING
      e_new_node_key   =
p_node_key.
ENDFORM.                               " add_complete_line

ALVtree 显示BOM结构的更多相关文章

  1. ABAP DEMO ALVtree显示BOM层级

    展示效果: *&---------------------------------------------------------------------* *& Report YCX ...

  2. 按树型显示BOM的结构

    在制造企业中,生产的每一个产品都由一道或多道工序组成,在组成成品之前,每一道工序经由物料--物料组成半成品,或物料--半成品组成新的半成品,亦或由半成品--半成品组成新的半成品.复杂的成品经由多道工序 ...

  3. 【转】linux tree命令以树形结构显示文件目录结构 ---- 不错

    原文网址:http://jingyan.baidu.com/article/acf728fd19c7eff8e510a3eb.html 今天小编来给分享Linux 系统下一个非常有用的命令的使用:tr ...

  4. 不显示BOM清单的版本

    应用 Oracle Bill Of   Materiel 层 Level Function 函数名 Funcgtion Name BOM_BOMFDBOM 表单名 Form Name BOMFDBOM ...

  5. 配置Tomcat直接显示目录结构和文件列表

    Tomcat是直接显示目录结构和文件列表,只是在配置里面给关闭了. 关键在这里:\conf\web.xml 这个文件有一段配置直接控制Tomcat是允许显示目录结构和文件列表. <servlet ...

  6. 【IntelliJ IDEA】idea导入项目只显示项目中的文件,不显示项目结构

    导入项目之后,只显示项目文件,不显示项目结构 解决方法 1.点击file->project structure..->Modules 点击右上角+加号 ->import Module ...

  7. Winform中实现向窗体中拖放照片并显示以及拖放文件夹显示树形结构(附代码下载)

    场景 向窗体中拖拽照片并显示效果 向窗体中拖拽文件夹并显示树形结构效果 注: 博客主页: https://blog.csdn.net/badao_liumang_qizhi 关注公众号 霸道的程序猿 ...

  8. InteractiveHtmlBom 在手机上无法显示 BOM List 和装配图的问题

    InteractiveHtmlBom 在手机上无法显示 BOM List 和装配图的问题 InteractiveHtmlBom 插件是一款用于 KiCad BOM 装配图生成插件. 最近新生成的 文件 ...

  9. 如何使用Shell写一个显示目录结构的命令?

    公众号关注 「开源Linux」 回复「学习」,有我为您特别筛选的学习资料~ 在Linux中使用Shell写一个显示目录结构的命令,快速寻找目录结构. 1.代码 #!/usr/bin/env bash ...

随机推荐

  1. iOS学习笔记03-UITableView

    一.UITableView基本介绍 默认的UITableView有2种风格: UITableViewStylePlain(不分组) UITableViewStyleGrouped(分组) UITabl ...

  2. 【(最小权点基)tarjan强连通分量缩点+tarjan模板】HDU 5934 Bomb

    [AC] #include<bits/stdc++.h> using namespace std; typedef long long ll; int n; ; ; const int i ...

  3. kali 1.1.0 boot failed

    从几个月前的14.10 daily 版本就有U盘刻录无法启动的现象,相关bug可参见:         https://bugs.launchpad.net/ubunt ... reator/+bug ...

  4. bzoj2120 数颜色 莫队 带修改

    [bzoj2120]数颜色 Description 墨墨购买了一套N支彩色画笔(其中有些颜色可能相同),摆成一排,你需要回答墨墨的提问.墨墨会像你发布如下指令: 1. Q L R代表询问你从第L支画笔 ...

  5. SpringBoot消失的Web.xml

    Filter 过滤器作为web.xml中重要的一部分,有着相当高的出场率,SpringBoot会默认注册几个Filter ApplicationContextHeaderFilter Characte ...

  6. Lucky and Good Months by Gregorian Calendar(poj 3393)

    大致题意: 科普文一篇,文章80%都是无用信息,因为都是常识,但是又不得不看,因为有20%是常人不知道的历史常识. 定义: Goog month : 该月第一个工作日为星期一的月份 Luckly mo ...

  7. msp430项目编程33

    msp430中项目---简易示波器系统 1.电路工作原理 2.代码(显示部分) 3.代码(功能实现) 4.项目总结

  8. list或map 打印成json 方便调试

    private final Logger logger = Logger.getLogger(this.getClass()); logger.info(JSON.toJSONStringWithDa ...

  9. [TJOI2019]唱、跳、rap和篮球_生成函数_容斥原理_ntt

    [TJOI2019]唱.跳.rap和篮球 这么多人过没人写题解啊 那我就随便说说了嗷 这题第一步挺套路的,就是题目要求不能存在balabala的时候考虑正难则反,要求必须存在的方案数然后用总数减,往往 ...

  10. pandaboard安装ubuntu14.04系统遇到的问题

    按照该网址步骤安装https://www.eewiki.net/display/linuxonarm/PandaBoard 在linux kernel的./build_kernel.sh时,自动安装交 ...