ABAP DEMO ALVtree显示BOM层级
展示效果:
*&---------------------------------------------------------------------*
*& Report YCX_015
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ycx_015 MESSAGE-ID zpp01. 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 ,
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 . 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 mast-matnr OBLIGATORY,
p_werks LIKE mast-werks OBLIGATORY,
p_stlal LIKE mast-stlal OBLIGATORY DEFAULT '', "可选的 BOM
p_capid LIKE rc29l-capid OBLIGATORY DEFAULT 'PP01'. "BOM应用程序 *PARAMETERS: p_matnr LIKE mara-matnr, "DEFAULT 'YW25K',
* p_werks LIKE ekpo-werks. "DEFAULT '1010' . START-OF-SELECTION.
PERFORM getdata.
CALL SCREEN . *&---------------------------------------------------------------------*
*& Form getdata
*&---------------------------------------------------------------------*
FORM getdata. *&bom explosion
* CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
** EXPORTING
** FTREL = ' '
** ALEKZ = ' '
** ALTVO = ' '
** AUFSW = ' '
** AUMGB = ' '
** AUMNG = 0
** AUSKZ = ' '
** AMIND = ' '
** BAGRP = ' '
** BEIKZ = ' '
** BESSL = ' '
** BGIXO = ' '
** BREMS = ' '
** CAPID = 'STD1'
** CHLST = ' '
** COSPR = ' '
** CUOBJ = 000000000000000
** CUOVS = 0
** CUOLS = ' '
** DATUV = 00000000
** DELNL = ' '
** DRLDT = ' '
** EHNDL = ' '
** EMENG = 0
** ERSKZ = ' '
** ERSSL = ' '
** FBSTP = ' '
** KNFBA = ' '
** KSBVO = ' '
** MBWLS = ' '
** MKTLS = 'X'
** MDMPS = ' '
** MEHRS = ' '
** MKMAT = ' '
** MMAPS = ' '
** SALWW = ' '
** SPLWW = ' '
** MMORY = ' '
** MTNRV = ' '
** NLINK = ' '
** POSTP = ' '
** RNDKZ = ' '
** RVREL = ' '
** SANFR = ' '
** SANIN = ' '
** SANKA = ' '
** SANKO = ' '
** SANVS = ' '
** SCHGT = ' '
** STKKZ = ' '
** STLAL = ' '
** STLAN = ' '
** STPST = 0
** SVWVO = 'X'
** WERKS = ' '
** NORVL = ' '
** MDNOT = ' '
** PANOT = ' '
** QVERW = ' '
** VERID = ' '
** VRSVO = 'X'
** IMPORTING
** TOPMAT =
** DSTST =
* TABLES
* STB =
** 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 CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
capid = p_capid "'CAD1'
datuv = sy-datum
emeng = '' "基本用量
mtnrv = p_matnr
werks = p_werks
mktls = 'X' "p_key
mehrs = 'X' "p_mehrs
stlal = p_stlal "可选BOM
stlan = '' "BOM 用途
* emeng = 1
IMPORTING
topmat = wa_topmat
dstst = wa_dstst
TABLES
stb = gt_stpox
matcat = it_matcat
EXCEPTIONS
alt_not_found =
call_invalid =
material_not_found =
missing_authorization =
no_bom_found =
no_plant_data =
no_suitable_bom_found =
conversion_error =
OTHERS = .
* 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 '&F03' OR '&F15' OR '&F12'."'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
*&---------------------------------------------------------------------*
*& Module EXIT INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE exit INPUT.
CASE okcode.
WHEN '&F03' OR '&F15' OR '&F12'."'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.
*&---------------------------------------------------------------------*
*& 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 =
cntl_system_error =
create_error =
lifetime_error =
lifetime_dynpro_dynpro_link = .
IF sy-subrc <> .
MESSAGE e000() WITH '创建容器:TREE1 错误'.
ENDIF.
ENDIF.
CREATE OBJECT tree1
EXPORTING
parent = l_custom_container
* parent = cl_gui_container=>d0
node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
item_selection = 'X'
no_html_header = 'X'
no_toolbar = ' '
EXCEPTIONS
cntl_error =
cntl_system_error =
create_error =
lifetime_error =
illegal_node_selection_mode =
failed =
illegal_column_name = .
IF sy-subrc <> .
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 ''.
l_key = ''.
WHEN ''.
l_key = l1.
WHEN ''.
l_key = l2.
WHEN ''.
l_key = l3.
WHEN ''.
l_key = l4.
WHEN ''.
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 ''.
l1 = l_last_key.
WHEN ''.
l2 = l_last_key.
WHEN ''.
l3 = l_last_key.
WHEN ''.
l4 = l_last_key.
WHEN ''.
l5 = l_last_key.
WHEN ''.
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 = .
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() 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
GUI状态:
SCREEN 9000 最简单的方式创建屏幕
ABAP DEMO ALVtree显示BOM层级的更多相关文章
- ALVtree 显示BOM结构
REPORT z_barry_alv_tree1_bom MESSAGE-ID oo. TABLES: stpox.INCLUDE <icon>. CLASS: cl_gui_col ...
- 不显示BOM清单的版本
应用 Oracle Bill Of Materiel 层 Level Function 函数名 Funcgtion Name BOM_BOMFDBOM 表单名 Form Name BOMFDBOM ...
- 【ABAP系列】SAP BOM反查
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP BOM反查 前言部分 ...
- 【ABAP系列】SAP ABAP实现LOG显示的方法
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP实现LOG显示的 ...
- InteractiveHtmlBom 在手机上无法显示 BOM List 和装配图的问题
InteractiveHtmlBom 在手机上无法显示 BOM List 和装配图的问题 InteractiveHtmlBom 插件是一款用于 KiCad BOM 装配图生成插件. 最近新生成的 文件 ...
- ABAP DEMO
sap Program DEMO 介绍 Program Description BALVBT01 Example SAP program for displying multiple ALV repo ...
- Android学习小Demo一个显示行线的自定义EditText
今天在处理一个EditText的时候,想着把EditText做成像一本作业本上的纸一样,每一行都可以由线条隔开,具体效果如下: 1)最开始的思路 一开始的想法是很简单的,找出每一行的高度,然后一行一行 ...
- [原创]java WEB学习笔记30:Cookie Demo 之显示最近浏览的记录
本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...
- 按树型显示BOM的结构
在制造企业中,生产的每一个产品都由一道或多道工序组成,在组成成品之前,每一道工序经由物料--物料组成半成品,或物料--半成品组成新的半成品,亦或由半成品--半成品组成新的半成品.复杂的成品经由多道工序 ...
随机推荐
- python为什么不需要重载函数
https://www.cnblogs.com/erbaodabao0611/p/7490439.html
- [LuoguP1462]通往奥格瑞玛的道路
题目链接 题意简述:现在有一个图,每经过一个点就会交钱,走一条路就会扣血.在血量>0的前提下,要从1走到n点,并且要求路径上交钱的最大值最小. 解题思路:首先最大值最小,我们选择二分.目前有两个 ...
- Apache Kylin在4399大数据平台的应用
来自:AI前线(微信号:ai-front),作者:林兴财,编辑:Natalie作者介绍:林兴财,毕业于厦门大学计算机科学与技术专业.有多年的嵌入式开发.系统运维经验,现就职于四三九九网络股份有限公司, ...
- MongoDB dataSize如何比storageSize更大?
原文 https://stackoverflow.com/questions/34054780/how-can-mongodb-datasize-be-larger-than-storages ...
- RookeyFrame 还原 软删除的数据 怎么硬删除 或者 怎么还原
列表搜索栏上有个删除图标,可以进入回收站 如图:
- php 简单使用redis 队列示例
public function redisAction(){ $redis = new Redis(); $redis->connect('127.0.0.1', 6379); echo &qu ...
- 数码管一些列功能的verilog实现
将数码管各段发光元件的正极连在一起称为共阳数码管,且该共点击链接电路电源的正极,而各段的负极连接驱动电路.它适用于低电平有效的驱动电路,当某段的驱动电平为低电平时,该段发亮:将数码管各段发光元件的负极 ...
- Cogs 452. Nim游戏!(博弈)
Nim游戏! ★ 输入文件:nim!.in 输出文件:nim!.out 简单对比 时间限制:1 s 内存限制:128 MB 甲,乙两个人玩Nim取石子游戏. nim游戏的规则是这样的:地上有n堆石子( ...
- Java 死锁以及死锁的产生
public class DeadLockSample { public static void main(String[] args) { DeadLock d1 = new DeadLock(tr ...
- LeetCode之打家劫舍
1. 问题 在一条直线上,有n个房屋,每个房屋中有数量不等的财宝,有一个盗 贼希望从房屋中盗取财宝,由于房屋中有报警器,如果同时从相邻的两个房屋中盗取财宝就会触发报警器.问在不触发报警器的前提下,最多 ...