SAP ABAP4 Learning --- Data Type (3)

zhaozj2021-02-16  88

-------------------------------------------------- ------------------------------------ text is a fixed value. ABAP / 4 differentiate text text and digital text. Text text text text is the alphanumeric character sequence in single quotes. 'Antony smith''69190 WallDorf' text text is up to 254 characters. If a text text contains quotation marks, you must repeat quotation marks so that the system can identify the content as a text text instead of the end of the text. Write: / 'this is john''s bicycle '. Digital text Digital text is a digital sequence that may contain a leader symbol. Can contain up to 15 numbers. 123-93 456 If a non-integer value or longer number is required, the text text must be used, which is automatically converted to the correct type. (Details, see Type Conversion). '12345678901234567890' ' 0.58498' '- 8473.67' Similarly, please use text text to represent floating point values. Must follow the following format: '[

] [E] [

] '

'-12.34567'

'-765e-04'

'1234e5'

' 12e 23'

' 12.3e-4'

'1E160'

-------------------------------------------------- -----------------------------------

variable

Variables are used to keep and refer to data at a certain format at a certain name. Variables can be different in the following

name

Types of

length

structure

Variables can be declared in the program using the DATA statement (see DATA statements).

Data: S1 TYPE I,

S2 TYPE I,

Sum Type I.

....

SUM = S1 S2.

-------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The constant constant is a data object containing a value, which is determined when initialization. Confisons cannot be changed during program execution.

Declare constitutive constant statements in programs (see constants statements). If you try to figure out the other

The place is more changing, and the system will output an error message during syntax check or run.

It is also possible to declare constant in the type group of the ABAP / 4 dictionary (see Type Groups).

If you frequently need a special value in the program, use constants. In this case, do not use text.

If you need to modify this value, you can only change the declaration.

Constants Pi Type P Decimals 10 Value '3.1415926536'. You can not add quotation. Constants Pi Type P Decimals 10 Value 3.1415926536.

-------------------------------------------------- ------------------------------------

Name variable

Specify data types using the TYPE parameter: Data: Number Type P, Date Type D, HexadecAlfield Type X, Count Type I, Line (72) TYPE C, LINE (72) Value 'Test'. (Also) --- -------------------------------------------------- ------------------------------- Like parameters utilize the LIKE parameters, you can assign data types that have defined data objects to variable. The language is as follows: Syntax Data

Like

.

When using the LIKE parameter, press according to data object

Full identical type and structure creation field

.

Any data object can be used for

. Use the LIKE parameters, you can reference the data declared in the ABAP / 4 dictionary.

Icon's data type.

Data Number_1 Type P.

Data Number_2 LIKE NUMBER_1.

Data MyName Like Sy-uname.

In the example, the data object NUMBER_2 is declared with the same data type as the data object Number_1. The data object MyName has the same data type with the system-unnormal data object SY-UNAME.

The LIKE parameter is often used for the content of the Affiliated field to temporarily save the database field.

The mechanism avoids unintentional differences caused by typing errors or changing the definition of the database field. For example, if you change the properties of the database field, the system automatically changes the properties of the backup field.

Data Plane Like Sflight-Planetype.

This statement creates the same property with the ABAP / 4 Dictionary field Sflight-Planetype, named a PLANE. PlanetYpe is a column of database table sflight.

To create a data object with the same data type with the row of the existing internal table

Please use the LIKE parameters as follows: Syntax

Data

Like line of

.

under these circumstances,

It must be a data object created as an internal table (see Creating Internal Table Data Objects).

Default value for type and length

If the parameters are not specified in the DATA statement

with

Then create a character field with a length of 1 (type

C). If the length is specified, but not specified, the type field of the given length is created.

Data Textfield.

Example Creates a character field for a length of 1 TextField.

转载请注明原文地址:https://www.9cbs.com/read-12998.html

New Post(0)