这个元旦过的可真久,今天才拿出unit4的笔记。不过,迟做总比不做好啊,继续努力!!!
图太多,先贴文字吧。
(无图版)
Unit 4 ABAP Statements and Data Declarations
Contents:
Types
Data objects
Elementary data object
Structures
Internal tables
Return codes
Types可以定义为全局的或本地的
Local types: 本地使用/只有technical属性没有特定语义的type.
(only technical attributes, not semantic attributes. only used locally)
Global types: = ABAP Dictionary types, 需要被程序外使用,或有特定语义的type
Global types: create on SE11 à Data type à
· | Data elements contain a complete description of the technical attributes of an elementary field, along with semantic information. | |
· | Structure types can consist of elementary components. Alternatively, each component can itself have a structured type. This allows you to construct nested structure types of any depth you want. Note that you can also use the line type of a transparent table (that is one defined as a database table) as a structured type. | |
· | Table types are types used to define internal tables. |
Data element的技术属性:
l Field label:
l Field documentation(F1)
l Search help
A data element can be linked to a search help.
Data element 和 Domain(数据元素 和 域)
–
数据元素完全是对字段的描述,包括语义和字段技术 属性。
–
语义字段属性包括字段文档和标签,它们直接保存在 数据元素定义中。与之对应的是域,域保存了例如数 据类型、字段长度等技术信息。
–
为了提供更好的重用性和统一性,技术信息通常都是 指定到域,而不直接定义到数据元素。
–
数据元素可以用来定义程序内部的变量和声明透明表 的字段。
SE84(Repository Info System)
Local types:
在程序里声明
l Synax:
TYPES: <user_type> TYPE <type>
Define data element定义数据对象
DATA: <v1> TYPE <type>.
DATA: <v2> LIKE <data object>.
Text symbol
COMPUTE:
计算,关键字COMPUTE可选
COMPUTE result = a * b / c. <==> result = a * b / c.
Watch Point ?
定义STRUCTURE
Structure允许ABAPer把不同的变量绑定在同一个object
STRUCTURE可以嵌套
| |||
|
| ||
|
|
1. Global Structure
在ABAP Dictionary中新建STRUDTURE时需注意:
货币字段的type通常是CURR,必须指定它的相关单位字段,type是CUKY 。
长度、重量等数值字段的type通常是QUAN,必须指定它的相关单位字段,type是UNIT 。
.eg. Transp. Table SBOOK
FIELD | DATA ELEMENT | DATA TYPE | REF. TABLE | REF. FIELD |
FORCURAM | S_F_CUR_PR | CURR | SBOOK | FORCURKEY |
FORCURKEY | S_CURR | CUKY |
|
|
LUGGWEIGHT | S_LUGWEIGH | QUAN | SBOOK | WUNIT |
WUNIT | S_WEIUNIT | UNIT |
|
|
2. Local Structure
在程序中定义本地Structure,可以用TYPES或DATA
Structure中的字段使用<sturcture>-<field_name>方式引用
MOVE-CORRESPONDING <R1> TO <R2>
Where used list
3 kinds of internal table:
| Index tables | Hash table | |
Table kind | Standard table | Sorted table | Hashed table |
Index | V | V |
|
Key | V | V | V |
Unique/Non-unique key | Non-unique | Unique | Non-unique | Unique |
Access using | Mainly index | Mainly keys | Keys only |
定义Internal TABLE
TYPES:<itab> TYPE <table kind> OF <line type> WITH NON-UNIQUE KEY <key1> <key2>….
DATA <itab> TYPE <type>.
Operate Internal Table
Message
Syntax:
a) MESSAGE ID ‘<message class>’ TYPE ‘<message type>’ NUMBER <message number> WITH <var1> <var2>….
b) MESSAGE <message type><message number> WITH <var1> <var2>…
【REPORT … MESSAGE-ID <message class>.】
.eg. a) MESSAGE ID '00' TYPE 'I' NUMBER 001 WITH 'No data.'.
b) MESSAGE I001 WITH 'No data.'.
【REPORT ... MESSAGE-ID 00】