惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
WordPress大学
WordPress大学
T
Tailwind CSS Blog
V
Visual Studio Blog
月光博客
月光博客
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Last Week in AI
Last Week in AI
阮一峰的网络日志
阮一峰的网络日志
量子位
有赞技术团队
有赞技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
Jina AI
Jina AI
雷峰网
雷峰网
博客园 - 【当耐特】
博客园 - 叶小钗
美团技术团队
宝玉的分享
宝玉的分享
IT之家
IT之家

博客园 - hyladmin

动态生成收藏夹菜单 配料计算方法(笨方法) 常用的对话框函数使用 SAP各模块简介 BOM展开函数 有关FIELD-SYMBOLS的用法 SAP control编程快速入门 SAP函数大荟萃 ABAP 的 Message Box 的用法 SAP MM 移动类型 SAP库存类型与库存状态 替代物料操作详解 SAP中几种特殊物料 SAP系统中如何处理代管料 SAP BOM分析 SAP FI/CO 基本概念 SAP中库存周转率算法 SAP期初数据导入 SAP FI T-CODE
內表定义模式
hyladmin · 2008-12-05 · via 博客园 - hyladmin

根椐程序中实际的需要,内表有很多不同的定义及使用方式,下面对几种常见方式一一举例说明。

1.使用TYPE叙述(定义类型)
TYPES <t> <type> OCCURS <n>
  宣告一个阵列<t>,型态为<type>,长度为<n>
         Example:
                  TYPES A TYPE I OCCURS 10.
                  A是个10个元素的数值Internal Table
         Example:
                  TYPES: BEGIN OF LINE,
                         COL1 TYPE I,
                         COL3 TYPE I,
                         END OF LINE.
                  TYPES ITAB TYPE LINE OCCURS 10.
                 宣告一个Internal Table ITAB,总共有10个元素,其WORK AREA名称
                 为LINE
2.使用DATA叙述(定义变量)
若使用DATA叙述来宣告Internal Table,可分成要不要有HEADER LINE, HEADER LINE就是所谓的WORK AREA,用在资料的存取上.
DATA <f> <type> OCCURS <n> [WITH HEADER LINE]
3.直接宣告,不使用WORK AREA
DATA: BEGIN OF <f> OCCURS <n>,
              <component宣告>
            END OF <f>.
4.其它定义方法
(1) DATA : itab1 TYPE HASHED TABLE OF i WITH UNIQUE KEY table_line.
(2) DATA: ftab2 TYPE SORTED TABLE OF f WITH NON-UNIQUE KEY table_line.
注:In internal tables it is possible to address the complete table line in a key specification by using the pseudo component TABLE_LINE. This is useful especially for tables whose line type has no structure.eg:
DATA: BEGIN OF line,
          col1 TYPE i,
          col2 TYPE i,
       END OF line.
DATA itab LIKE SORTED TABLE OF line WITH UNIQUE KEY table_line.
   (3) DATA: BEGIN OF line,
         land(3) TYPE c,
         name(10) TYPE c,
         age TYPE i,
         weight TYPE p DECIMALS 2,
        END OF line.
DATA itab LIKE STANDARD TABLE OF line WITH NON-UNIQUE KEY land.
(3) DATA mytab1 LIKE STANDARD TABLE OF MARA WITH HEADER LINE.
DATA mytab2 LIKE MARA OCCURS 10 WITH HEADER LINE.
同样定义一个带表头行的内表,但mytab1是经过排序的,执行效率要高于mytab2
(4) DATA : itab LIKE STANDARD TABLE OF SPFLI,
  Wa LIKE LINE OF ITAB.

5. SELECT中内表的动态指定
   SELECT * INTO CORRESPONDING FIELDS OF TABLE itab
   FROM (g_tabname)
WHERE aufnr IN t_aufnr AND arbpl IN t_arbpl AND vbeln IN t_vbeln.

1. Standard tables have an internal linear index. The system can access records either by using the table index or the key. The response time for key access is proportional to the number of entries in the table. The key of a standard table is always non-unique.
2. Sorted tables are always saved sorted by the key. The system can access records either by using the table index or the key. The response time for key access is logarithmically proportional to the number of table entries, since the system uses a binary search .
Standard tables and sorted tables are known generically as index tables.
3. Hashed tables have no linear index. You can only access a hashed table using its key. The response time is independent of the number of table entries, and is constant, since the system access the table entries using a hash algorithm. The key of a hashed table must be unique. When you define the table, you must specify the key as UNIQUE.