Basic

Declare data objects:
predefined ABAP types
Predefined data types are provided by the ABAP runtime environment.We differentiate between incomplete types(c,n,p,and

x) and complete types (i,f,d,t,string,and xstring),depending on whether an additional length specification is required when the

corresponding data objects are declared.
Global data types
Global data types are defined in the Dictionary.They refer to predefined Dictionary types,which largely correspond to

the predefined ABAP types.
Local data types
Local data types are defined using the TYPES statement within the ABAP porgram.They can refer to predefined ABAP types

or global data types from the Dictionary.


Caution: Data objects in modules and event blocks are always global.
If the DATA statement appears between MODULE and ENDMODULE,the defined object is still a global data object that is visible

in the entire program.Likewise,data objects that you declare in an ABAP event block are visible globally.
To avoid misunderstandings,we recommend declaring such data at the start of the program and avoiding DATA statements

completely in modules and event blocks.

The TABLES statement always creates data objects that are visible porgram-wide.
Data objects that are created with the TABLES statement are always visible in the entire program,even if the statement

appears within a subroutine or a function module.(The objects can even be visible in other programs,for example when calling an

external subroutine.)

Hint: If you use the STATICS statement instead of DATA when you declare local data objects,their lifetime is extended to the

overall program lifetime.Therefore,such data objects have the same lifetime as global data objects,but their visibility is

still limited to the respective modularization unit.
You can use the STATICS statement in function mudules,subroutines,and static methods.


Each data object is filled with either a start value or the initial value at the start of its lifetime.Specifically,this is the

case when the program is loaded in memory for global data objects,and when the object is instantiated for object attributes.

Local data objects are overwritten with their start value or initial value each time they are called by the surrounding

modulariztion unit(unless they were declared with the STATICS statement).

You can define a start value with the optional VALUE addition for the DATA statement.If you do not use this addition,the

initial value for the respective data type is used.


USING NUMERIC DATA OBJECTS
There are three numeric data types in ABAP,which differ in their inner representation of values and their maximum value

range.Therefore,which data type you choose for a data object depends on its required value range.In additioon,ench of the three

data types is linked with its own arithmetic,which is used for calculations involving data objects of the respective type.We

differentiate between the following:
Type i - integer arithmetic
Type p - fixed point arithmetic
Type f - floating point arithmetic
We will examine the three numeric data types and their corresponding arithmetic methods in more detail below.We initially

assume that "pure" arithmetic expressions are involved - that is,expressions in which all the involved data objects have the

same type.We will then examine mixed arithmetic expressions and learn how the runtime environment determines which arithmetic

to use.


Types:
name_type(25) type c,
title_type(5) type c,
email_type(35) type c.
data:
begin of s_name,
prename type name_type,
surname type name_type,
title type title_type,
end of s_name.
data:
begin of s_address,
prename type name_type,
surname type name_type,
title type title_type,
email type email_type,
end of s_address.
...

move-corresponding
s_name to s_address.

You can use the Move-corresponding statement to copy the contents of a source structure to the targety structure by

component.The system then copies each source field to the target field with the same name.The conversion rules for elementary

data objects then apply.

Hint: Note that the system only searches for identically-named components,but does not check whether these identically-named

components are also compatibly typed.This can be useful,but there are dangers involed.


The ABAP Dictionary manages global information that can be used throughout the system in all Repository objects.These objects

include:
Global types
You can define simple and complex structured data types globally in the ABAP Dictionary.These global data types contain

both semantic and technical information.
Search help
Search helps control dialogs for possible entries help.Among other things,they specify which database tables and which

criteria the system should use when searching for possible entries help.

Database tables
All information about database tables,which are addressed from the SAP system,are managed in the ABAP Dictionary.Database

tables are changed in the ABAP Dictionary first and then copied to the database using the appropriate tool after they have been

activated.This procedure ensures that the information is always up-to-data.Moreover,it allows users to maintain tables in a

non-platform-specific way in the SAP system.

Development objects connected with database access
From the ABAP program,you can very easily access data from several database tables with the help of Views;Lock entries can be

created and deleted from the ABAP program using lock objects.This forms the basis of the SAP lock concept.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值