在sap中很多地方使用了集(set)来存储层次关系的数据,如:
Cost Center Group
Cost Element Group
Order Group
Statistical Key Figure Group
Activity Type Group
Profit Center Group
Business Process Group
Cost Object Group
Account Group
WBS Element Group
Fund Group
Functional Area Group
Grant Group
Business Entities Set
Real Estate Set
Buildings Set
Rental Units Set
Rental Agreements Set
Management Contracts Set
Settlement Units Set
General Contracts Set
... 等等....,具体参见SETCLS表.
相关TCODE
GS01
GS02
GS03
GS04
相关数据表
setcls:Set Classes(SETCLASS(4))
SETCLST: Set Class Descriptions(LANGU(2),SETCLASS(4))
setheader:Set Header and Directory(SETCLASS(4),SUBCLASS(10),SETNAME(24))
setnode:Lower-level sets in sets((SETCLASS(4),SUBCLASS(10),SETNAME(24),LINEID(10))
setleaf:Values in Sets(SETCLASS(4),SUBCLASS(10),SETNAME(24),LINEID(10))
相关函数
'G_SET_GET_ALL_VALUES'
'G_SET_FETCH'
代码样例
该样例代码是提取某个成本中心组下的成本中心到range: s_kostl
*&---------------------------------------------------------------------*
*& Form GET_TREE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_kostl.
data: l_count type i.
data: begin of i_tree occurs 0,
setname like setnode-setname,
end of i_tree.
data: i_subtree like i_tree occurs 0 with header line,
i_temptree like i_tree occurs 0 with header line.
select setname into i_tree
from setheader
where setclass = '0101' and subclass = '1000'
and setname in s_cengrp.
read table i_setheader with key setname = i_tree-setname.
if sy-subrc = 0.
append i_tree to i_tree.
endif.
endselect.
i_subtree[] = i_tree[].
l_count = 1.
while l_count > 0.
read table i_subtree index 1.
delete i_subtree index 1.
select subsetname as setname
into table i_temptree
from setnode
where setclass = '0101'
and subclass = '1000' and subsetcls = '0101'
and subsetscls = '1000' and setname = i_subtree-setname.
append lines of i_temptree to i_tree.
append lines of i_temptree to i_subtree.
describe table i_subtree lines l_count.
endwhile.
select valsign as sign valoption as option
valfrom as low valto as high
into table s_kostl
from setleaf
for all entries in i_tree
where setclass = '0101'
and subclass = '1000' and setname = i_tree-setname.
endform. " GET_KOSTL
代码二
DATA: t_set_values TYPE TABLE OF rgsb4.
CALL FUNCTION 'G_SET_GET_ALL_VALUES'
EXPORTING
client = sy-mandt
setnr = 'NP_SLOC_SERV'
table = 'MARD'
class = '0000'
fieldname = 'LGORT'
TABLES
set_values = t_set_values
EXCEPTIONS
set_not_found = 1
OTHERS = 2.
代码三
REPORT YTEST_GRP .
* -- Constant for the Set Class
CONSTANTS: c_cls_0106 TYPE rgsbs-class VALUE '0106'.
DATA: l_wa_set_lines_basic TYPE rgsbv,
l_wa_hdr TYPE rgsbs,
l_i_for_lin TYPE STANDARD TABLE OF rgsbf,
l_i_set_lines_basic TYPE STANDARD TABLE OF rgsbv,
l_i_set_lines_data TYPE STANDARD TABLE OF rgsb3,
l_i_set_lines_multi TYPE STANDARD TABLE OF rgsb2,
l_i_set_lines_single TYPE STANDARD TABLE OF rgsb1.
DATA: l_v_setnr TYPE char50.
PARAMETERS: p_PCGRP type PCGRP, " Profit Centre Group
p_kokrs type kokrs. " Controlling Area
CONCATENATE p_kokrs p_pcgrp INTO l_v_setnr.
*-- Get the Set description
CALL FUNCTION 'G_SET_FETCH'
EXPORTING
class = c_cls_0106
setnr = l_v_setnr
IMPORTING
set_header = l_wa_hdr
TABLES
formula_lines = l_i_for_lin
set_lines_basic = l_i_set_lines_basic
set_lines_data = l_i_set_lines_data
set_lines_multi = l_i_set_lines_multi
set_lines_single = l_i_set_lines_single
EXCEPTIONS
no_authority = 1
set_is_broken = 2
set_not_found = 3
OTHERS = 4.
*-- handle your exceptions here
loop at l_i_set_lines_basic into l_wa_set_lines_basic.
write :/ l_wa_set_lines_basic-from,
l_wa_set_lines_basic-to,
l_wa_set_lines_basic-title.
endloop.
参考:https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/5541
分享到:
相关推荐
ABAP - Keyword Documentation This documentation describes the syntax and meaning of the keywords of the ABAP language and its object-oriented part ABAP Objects. Alongside this, language frameworks ...
CD260-ABAP-in-Eclipse-开发-CN CD260-ABAP-in-Eclipse-开发-CNCD260-ABAP-in-Eclipse-开发-CNCD260-ABAP-in-Eclipse-开发-CN
ABAP-培训教材附录 ABAP-培训教材ABAP-培训教材ABAP-培训教材ABAP-培训教材
eclipse-abap-keywordcolors eclipse-abap-关键字颜色
本文档是《SAP中文教材全系列之ABAP-BC400_ZH》,为SAP ABAP编程语言的学习提供参考。文档包含了详细的ABAP课程内容,旨在帮助学员理解并掌握ABAP编程的基础知识和高级技能。以下将详细阐释文档所涵盖的知识点。 ...
ABAP-学习笔记-通用
"ABAP-EXCEL编程"的主题旨在教授如何使用ABAP与Microsoft Excel进行交互。 在ABAP中操作Excel文件,主要涉及到以下知识点: 1. **RFC函数调用**:SAP与外部系统交互,包括Excel,常常通过Remote Function Call ...
"ABAP-ALV进阶知识点详解" ABAP-ALV进阶是指在SAP系统中使用ABAP语言开发的高级列表查看器(ALV)。ALV是SAP系统中心的列表标准,可以在ABAP程序中进行报表输出。下面是ABAP-ALV进阶的知识点详解: 一、ALV概要 ...
SAP-ABAP-Certification-Review.pdf
ABAP-数据类型学习笔记
ABAP-选择屏幕 Dynpros 基础 Dynpros 是ABAP编程语言中的一种基础组件,用于构建交互式用户界面。通过本文,我们将了解 Dynpros 的基本结构、屏幕元素的构成、屏幕事件等知识点。 屏幕元素 在 Dynpros 中,屏幕...
### SAP-ABAP-OO 实现 CL-SALV-TABLE 的关键知识点 #### 1. ABAP 面向对象的 ALV 显示方法 在 SAP 的 ABAP 环境中,ALV (Application List Viewer) 是一种非常常用的技术,用于在屏幕上以表格的形式展示数据。传统...
ABAP-OLE开发是SAP系统中的一种技术,它允许ABAP编程语言与外部对象链接和嵌入(OLE)应用程序进行交互。OLE自动化是Windows环境中的一种技术,它使得不同的应用程序可以共享数据和服务,通常用于控制一个应用程序...
### ABAP - ALV知识点详解 #### 一、ALV(Application List Viewer)概述 ALV,即Application List Viewer,是SAP系统中用于展示数据列表的一种通用工具。它能够帮助用户灵活地处理数据,包括排序、筛选等功能,...
标题“abap-ALV.rar_ABAP系统ALV_abap_abap开发alv”暗示我们将深入探讨ABAP ALV的使用,特别是在ABAP系统中的应用以及如何进行开发。 描述中提到“ABAP ALV总结,ALV格式,REUSE_ALV_GRID_DISPLAY_LVC函数使用”,...
ABAP-透明表学习笔记.py
这个名为"SAP资料集有ABAP-PP-MM-RFC-BAPI-JCO等.rar"的压缩包文件包含了多个与SAP相关的学习资料,涵盖了许多关键模块和技术,包括ABAP编程、生产计划(PP)、物料管理(MM)、远程功能调用(RFC)、业务对象接口...
在SAP编程中,ABAP-OLE(Object Linking and Embedding)是一种技术,它允许SAP应用程序与外部非SAP系统进行交互,例如创建、读取、更新和删除Excel电子表格。在上述代码中,我们看到了一个名为`ZWM_015`的报告,它...
在“web-dynpro-abap-ui-element-tree”这个主题中,我们主要探讨的是Web Dynpro ABAP中的UI元素树结构,以及如何在Chapter 1, Curriculum (CV) Introduction中理解和应用这些知识。 在Web Dynpro ABAP中,UI元素是...
ABAP-子程序宏函数学习笔记.py