简体   繁体   English

创建结构的“数据”和“类型”之间有什么区别?

[英]What is the difference between "Data" and "Types" creating a structure?

I found 2 examples for creating a structure.我找到了 2 个创建结构的示例。

This one with TYPES :这个带有TYPES

TYPES : BEGIN OF employee_information,
            name TYPE c LENGTH 20,
            surname TYPE c LENGTH 20,
            tel_no TYPE n LENGTH 12,
          END OF employee_information.

and this other one with DATA :而另一个带有DATA

DATA : BEGIN OF employee_information,
            name TYPE c LENGTH 20,
            surname TYPE c LENGTH 20,
            tel_no TYPE n LENGTH 12,
          END OF employee_information.

I read the documentation topic " The Statements TYPES and DATA " in the SAP Library, but I don't understand why we use these distinct terms TYPES and DATA for creating a structured data type.我阅读了 SAP 库中的文档主题“ 语句类型和数据”,但我不明白为什么我们使用这些不同的术语TYPESDATA来创建结构化数据类型。

Can you explain the difference?你能解释一下区别吗?

First of all, creating a TYPE is the newer and recommended method to use.首先,创建 TYPE 是较新且推荐使用的方法。

When you create a DATA, lets say for an internal table;创建 DATA 时,可以说是内部表;

DATA: BEGIN OF employee_information OCCURS 0,             "itab with header line
            name TYPE c LENGTH 20,
            surname TYPE c LENGTH 20,
            tel_no TYPE n LENGTH 12,
      END OF employee_information.

You can have the internal table with header line.您可以拥有带有标题行的内部表格。 But this is the old method.但这是旧方法。

When you use TYPE in order to declare an internal table you can use its headerline and its content simultaneously;当你使用 TYPE 来声明一个内部表时,你可以同时使用它的标题和它的内容;

  TYPES: BEGIN OF t_employee_information,
            name TYPE c LENGTH 20,
            surname TYPE c LENGTH 20,
            tel_no TYPE n LENGTH 12,
  END OF t_employee_information.

  DATA: employee_information TYPE STANDARD TABLE OF t_employee_information INITIAL SIZE 0,      "itab
        employee_information TYPE t_employee_information.                    "work area (header line)

For example: You can use this TYPE in order to create as many internal tables as you want such as:例如:您可以使用此 TYPE 来创建任意数量的内部表,例如:

  DATA: employee_information_1 TYPE TABLE OF t_employee_information, "itab1
        employee_information_1 TYPE t_employee_information.          "work area1 (header line)
  DATA: employee_information_2 TYPE TABLE OF t_employee_information, "itab2
        employee_information_2 TYPE t_employee_information.          "work area2 (header line)
  DATA: employee_information_3 TYPE TABLE OF t_employee_information, "itab3
        employee_information_3 TYPE t_employee_information.          "work area3 (header line)

The TYPES statement creates a data type which are templates for creating data objects. TYPES语句创建一个数据类型,它是用于创建数据对象的模板。
The DATA statement creates a data object which is an instance of a data type and occupies as much memory space as its type specifies. DATA语句创建一个数据对象,它是数据类型的一个实例,占用的内存空间与其类型指定的一样多。

The first thing is that this code you posted is surely wrong, you started the type as employee_information and ended it as personel_bilgileri .第一件事是,您发布的这段代码肯定是错误的,您将类型开头为employee_information并以personel_bilgileri结尾。

The thing is that the second declaration defines employee_information variable which has the structure of name, surname and tel_no .问题是第二个声明定义了employee_information变量,该变量具有name, surname and tel_no的结构。 In the second case you define a type employee_information .在第二种情况下,您定义了一个类型employee_information Then you can define a variable of this structured type for example as DATA: l_str_employee_information TYPE employee_information`.然后你可以定义一个这种结构化类型的变量,例如DATA: l_str_employee_information TYPE employee_information`。

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

相关问题 数据模型和数据结构有什么区别? - What is the difference between data model and data structure? 概率数据结构和草图之间有什么区别? - What is the difference between a probabilistic data structure and a sketch? “容器”和“数据结构”之间有什么区别? - What is the difference between a “container” and a “data structure”? 复合数据类型和数据结构之间有什么区别? - What is the difference between a composite data type and a data structure? 抽象数据类型和逻辑数据结构有什么区别? - What is the difference between Abstract Data Type and Logical Data Structure? 在数据结构中,普通堆和二进制堆有什么区别? - In data structure, what is the difference between an ordinary heap and a binary heap? 数据结构树和图有什么区别? - What's the difference between the data structure Tree and Graph? 数据库和数据结构的区别? - difference between database and data structure? 在像C这样的编程语言的上下文中,数组数据结构和数组数据类型之间有什么区别? - What is the difference between an Array Data Structure and an Array Data-type in the context of a programming language like C? 数据结构堆栈和硬件堆栈之间有区别吗? - Is there a difference between data structure stack and hardware stack?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM