网格有什么已知的限制吗? 我知道,表类型必须是非通用的。
但是,是否可以将 5 键 dbtable 作为本地表类型定义的基础是不行的???(我真的很怀疑(。
我只有一个两级表层次结构,并希望检索传递主表键的第二个表 py 的所有网格结果。我只有前向关联,看看,这就是我试图实现的目标(在某些网站上找到的模式(:
TYPES: lty_types TYPE STANDARD TABLE OF zordertype WITH NON-UNIQUE KEY table_line,
lty_excludes TYPE STANDARD TABLE OF zexcludeorder WITH NON-UNIQUE key table_line.
DATA: lt_types TYPE lty_types,
lt_excludes TYPE lty_excludes.
TYPES:
BEGIN OF MESH ty_type_excludes,
types TYPE lty_types
ASSOCIATION to_excludes
TO excludes ON order_type = order_type,
excludes TYPE lty_excludes,
END OF MESH ty_type_excludes.
DATA: ls_mesh TYPE ty_type_excludes.
START-OF-SELECTION.
SELECT * FROM zordertype
INTO TABLE @lt_types
ORDER BY order_type.
SELECT * FROM zexcludeorder
INTO TABLE @lt_excludes
ORDER BY order_type.
ls_mesh-types = lt_types.
ls_mesh-excludes = lt_excludes.
DATA wf_check TYPE zorder_type VALUE 'CAT'.
DATA(chk) = ls_mesh-typesto_excludes[ wf_check ].
break myuser.
这会转储"CX_ITAB_LINE_NOT_FOUND"。
但我完全做到了,它是怎么写的。而且,我认为这必须有效,因为我使用这种方法根据第一个表的键条目从另一个表中获取子集。我尝试添加额外的关联参数,它不再转储,但无论如何,只返回了第二个表的一条记录。
我似乎忽略了一些基本的东西,但是哪一个呢?
如 ABAP 文档中所述,网格路径表达式,"网格路径表达式的结果是网格路径的最后一个路径节点的行"。
PS:有一些程序DEMO_MESH_EXPRESSION*可以玩网格路径表达式。这是一个较短的独立演示程序,摘自博客文章 ABAP 7.40 快速参考的第 12 章:
TYPES: BEGIN OF t_manager,
name TYPE char10,
salary TYPE int4,
END OF t_manager,
tt_manager TYPE SORTED TABLE OF t_manager WITH UNIQUE KEY name.
TYPES: BEGIN OF t_developer,
name TYPE char10,
salary TYPE int4,
manager TYPE char10,
END OF t_developer,
tt_developer TYPE SORTED TABLE OF t_developer WITH UNIQUE KEY name.
TYPES: BEGIN OF MESH m_team,
managers TYPE tt_manager ASSOCIATION my_employees TO developers
ON manager = name,
developers TYPE tt_developer ASSOCIATION my_manager TO managers
ON name = manager,
END OF MESH m_team.
DATA: ls_team TYPE m_team.
LS_TEAM-MANAGERS = value #(
( Name = 'Jason' Salary = 3000 )
( Name = 'Thomas' Salary = 3200 ) ).
LS_TEAM-DEVELOPERS = value #(
( Name = 'Bob' Salary = 2100 manager = 'Jason' )
( Name = 'David' Salary = 2000 manager = 'Thomas' )
( Name = 'Jack' Salary = 1000 manager = 'Thomas' )
( Name = 'Jerry' Salary = 1000 manager = 'Jason' )
( Name = 'John' Salary = 2100 manager = 'Thomas' )
( Name = 'Tom' Salary = 2000 manager = 'Jason' ) ).
" Get details of Jerry's manager
ASSIGN ls_team-developers[ name = 'Jerry' ] TO FIELD-SYMBOL(<ls_jerry>).
DATA(ls_jmanager) = ls_team-developersmy_manager[ <ls_jerry> ].
WRITE: / |Jerry's manager: { ls_jmanager-name }|,30
|Salary: { ls_jmanager-salary }|.
" Get Thomas' developers
SKIP.
WRITE: / |Thomas' developers:|.
ASSIGN ls_team-managers[ name = 'Thomas' ] TO FIELD-SYMBOL(<ls_thomas>).
LOOP AT ls_team-managersmy_employees[ <ls_thomas> ]
ASSIGNING FIELD-SYMBOL(<ls_emp>).
WRITE: / |Employee name: { <ls_emp>-name }|.
ENDLOOP.
" the result of a mesh path expression is a row from the last path node of the mesh path
DATA(thomas_employee) = ls_team-managersmy_employees[ <ls_thomas> ].
SKIP.
WRITE: / |Thomas's "any" Employee name: { thomas_employee-name }|.