简体   繁体   English

ABAP:从现有数据库表创建内部表的语法

[英]ABAP: Syntax for creating internal table from existing database table

I'm new to ABAP. 我是ABAP的新手。 Started learning about internal tables. 开始学习内部表格。 I was reading on the ways to create internal tables. 我正在阅读创建内部表的方法。

I came across the following syntax to create an internal table from an existing database table: 我遇到了以下语法来从现有数据库表创建内部表:

data: it_mara type table of mara.

I'm confused since mara is a table and if both lhs and rhs are of the same type then shouldn't it be just: 我很困惑,因为mara是一个表,如果lhs和rhs属于同一类型,那么它不应该只是:

data: it_mara type mara.

What is the need to convert mara into a table when it is already a table? 当mara已经是一个表时,有什么需要将mara转换为表格?

Historical reasons (always a good guess...). 历史原因(总是很好的猜测......)。

The original and nowadays obsolete way to declare a table (with a header line was DATA it_mara TYPE mara OCCURS 10 . Without OCCURS , you didn't declare a table, so it became a structure. My guess would be that in order to maintain backwards compatibility, that wasn't changed when TYPE TABLE OF was introduced. 原始的和现在过时的方式来声明一个表(标题行是DATA it_mara TYPE mara OCCURS 10没有OCCURS ,你没有声明一个表,所以它变成了一个结构。我的猜测是为了保持倒退兼容性,引入TYPE TABLE OF时未更改。

MARA is a transparent table which means that it functions at the same time as the structure type MARA . MARA是一个透明表,这意味着它与结构类型MARA同时起作用。 This is the way SAP works. 这是SAP的工作方式。 :) :)

SAP DDIC table (transparent table, pooled table, cluster table) function as a structure . SAP DDIC表 (透明表,池表,集群表)作为结构

Internal table is a list of structure (= DDIC table ) values. 内部表是结构 (= DDIC表 )值的列表。

In your example of SAP DDIC table MARA (General Material Data), we can define it as an internal table like 在您的SAP DDIC表MARA (通用材料数据)示例中,我们可以将其定义为内部表

data: it_mara type STANDARD table of mara.

which creates an STANDARD internal table 这会创建一个STANDARD内部表

data: it_mara type SORTED table of mara.

which creates an SORTED internal table 这会创建一个SORTED内部表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM