ABAP 7.40 - MESH的限制?

时间:2018-06-06 15:45:23

标签: sap abap

网格有任何已知限制吗? 我知道,表类型需要是非泛型的。

但可以,5-key-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-types\to_excludes[ wf_check ].

  break myuser.

转储为“CX_ITAB_LINE_NOT_FOUND”。

但我确切地说,它是如何写的。而且,我认为,这必须有效,因为我使用这种方法根据第一个表的关键条目从另一个表中获取子集。我试图添加额外的关联参数,它们不再转储,但无论如何,只返回第二个表的一条记录。

我似乎忽略了一些基本的东西,但是哪一个?

1 个答案:

答案 0 :(得分:2)

ABAP documentation, a mesh path expression中所述,"网状路径表达式的结果是来自网状路径的最后一个路径节点的一行"。

PS:有一些程序DEMO_MESH_EXPRESSION *可用于网状路径表达式。这是一个较短的独立演示程序,取自chapter 12 of blog post ABAP 7.40 Quick Reference

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-developers\my_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-managers\my_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-managers\my_employees[ <ls_thomas> ].
SKIP.
WRITE: / |Thomas's "any" Employee name: { thomas_employee-name }|.