BC400 Unit 4

这个元旦过的可真久,今天才拿出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可以嵌套

·   

two kinds of structure:

 

·   

DATA <name> TYPE <structure_type>.
These kinds of structures serve as the target fields for database accesses or for calculations performed locally within the program. You can declare these types of structures either in the ABAP Dictionary or locally within your program.

 

·   

<ABAP-Dictionary-Structure>.
These types of structures are technically administered in their own area. From Release 4.0, TABLES structures only serve as interface structures for screens. This statement may only be used for tables whose non-key fields are all numeric.

 

 

 

1. Global Structure

ABAP Dictionary中新建STRUDTURE时需注意:

货币字段的type通常是CURR,必须指定它的相关单位字段,typeCUKY

长度、重量等数值字段的type通常是QUAN,必须指定它的相关单位字段,typeUNIT

 

.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,可以用TYPESDATA

 

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

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值