组件:Y_XIAO_01
视图:V_MAIN
窗口:W_MAIN
Application:Y_XIAO_01
添加上下文
字段
添加UI控件
绑定节点添加table列
初始化代码
METHOD wddoinit . DATA lo_nd_node TYPE REF TO if_wd_context_node. DATA lo_nd_node_info TYPE REF TO if_wd_context_node_info. DATA lt_node TYPE wd_this->elements_node. DATA ls_node TYPE wd_this->element_node. DATA:lt_attr TYPE wdr_context_attr_info_map, ls_attr TYPE wdr_context_attribute_info, ls_format TYPE wdy_attribute_format_prop. ls_node-text_1 = ‘1‘. ls_node-wrbtr = ‘100‘. APPEND ls_node TO lt_node. CLEAR ls_node. ls_node-text_1 = ‘2‘. APPEND ls_node TO lt_node. CLEAR ls_node. lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ). lo_nd_node->bind_table( new_items = lt_node set_initial_elements = abap_true ). * lo_nd_node_info = lo_nd_node->get_node_info( ). * lt_attr = lo_nd_node_info->get_attributes( ). * * ls_format-null_as_blank = ‘X‘."不显示0 * LOOP AT lt_attr INTO ls_attr. * lo_nd_node_info->set_attribute_format_props( EXPORTING name = ls_attr-name format_properties = ls_format ). * ENDLOOP. ENDMETHOD.
显示0测试结果:
初始化方法调整后代码:
METHOD wddoinit . DATA lo_nd_node TYPE REF TO if_wd_context_node. DATA lo_nd_node_info TYPE REF TO if_wd_context_node_info. DATA lt_node TYPE wd_this->elements_node. DATA ls_node TYPE wd_this->element_node. DATA:lt_attr TYPE wdr_context_attr_info_map, ls_attr TYPE wdr_context_attribute_info, ls_format TYPE wdy_attribute_format_prop. ls_node-text_1 = ‘1‘. ls_node-wrbtr = ‘100‘. APPEND ls_node TO lt_node. CLEAR ls_node. ls_node-text_1 = ‘2‘. APPEND ls_node TO lt_node. CLEAR ls_node. lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ). lo_nd_node->bind_table( new_items = lt_node set_initial_elements = abap_true ). *★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★ *去除0显示 *★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★ lo_nd_node_info = lo_nd_node->get_node_info( ). lt_attr = lo_nd_node_info->get_attributes( ). ls_format-null_as_blank = ‘X‘."不显示0 LOOP AT lt_attr INTO ls_attr. lo_nd_node_info->set_attribute_format_props( EXPORTING name = ls_attr-name format_properties = ls_format ). ENDLOOP. ENDMETHOD.
测试结果:
原文地址:https://www.cnblogs.com/SAPxiaox/p/9964311.html
时间: 2024-10-29 19:33:23