ABAP basic knowledge learning

Source: Internet
Author: User

Data Type
C: String
D: The date format is yyyymmdd. For example, '2017/03'
F: The floating point length is 8.
I: integer
N: A string composed of numeric values, for example, 011, '123'
P: Number of packages used for decimal places, for example, 12.00542
T: The time format is hhmmss, for example, '14: 03: 00'
X: hexadecimal number, for example, '1a03'
* Optional *-------------------------------------------------------------------------------------*
Variable Declaration

Data [] [] [decimals]
Variable name
Variable type and length
Initial Value
Decimal places

Exp:
Data: Counter type P decimals 3.
Name (10) Type C value 'delta '.
S_date type D value '20140901 '.
Exp:
Data: Begin of person,
Name (10) type C,
Age type I,
Weight type decimals 2,
End of person.
In addition, the data declaration Commands include constants and statics ).
Exp:
Constants PI type P decimals 5 value '3. 100 '.
Statics description
The declared variable is only used in the current program and will be released automatically after completion.
Syntax:
Statics [] [] []

System Variables
The syst structure is created in the system. The columns in the system store system variables. Common System variables include:
SY-SUBRC: a variable that indicates successful execution after the system executes a command, '0' indicates successful
SY-UNAME: the username of the current user logging into SAP;
SY-DATUM: current system date;
SY-UZEIT: current system time;
SY-TCODE: the transaction code of the current program
SY-INDEX: Number of times the current loop has passed
SY-TABIX: number of internal tables currently processed
SY-TMAXL: Total number of internal tables
SY-SROWS: Total number of rows on the screen;
SY-SCOLS: Total number of columns on the screen;
SY-MANDT: client number
SY-VLINE: Draw a vertical line
SY-ULINE: Draw a horizontal line

Type description
Used to specify a data type or declare a Custom Data Type
Example:
Types: Begin of mylist,
Name (10) type C,
Number Type I,
End of mylist.
Data list type mylist.

Like description
The format is the same as the type description, as shown in figure
Data transcode like SY-TCODE.
The difference is that like is used in data items with existing values, such as system variables, while type statements use
In the specified data type.

* Optional *-------------------------------------------------------------------------------------*
Output

1. write statement
ABAP/4 is the write command used to output data on the screen, for example:
write: 'user name is: ', SY-UNAME.
II. specify the screen output position
the statement format of the specified output position is:
write: [at] [/] [] [()] item []
where:/: output in the next line
: Specifies the output row number.
(): specifies the number of output digits (length)
: specify the display format parameters, including:
left-justified data * Left-aligned
centered data * Center-aligned
right-justified data * Right-aligned
The under is displayed under the data item
NO-gap followed by display, leave no space
using edit mask: use embedded sub-element display, such as 12:03:20
using no edit mask: do not use embedded child element
the part of the NO-ZER number before 0 is not displayed
NO-sign: do not show positive and negative signs
decimals: Show decimal places
expoent: F (floating point) index value
round: rounded to the decimal point
currency: currency display
dd/mm/yy: date display format
mm/DD/YY:
YY/MM/DD:
YY/dd/mm
mm/DD/yyyy:
dd/mm/yyyy
yyyy/mm/DD:
yyyy/DD/MM:
example: 1: Write:/10 (6) 'abcdefghjk '.
the output result is abcdef.
for example, 2: Data: X type I value '11: 20: 30'.
A (5) type C value 'AB cde '.
write:/X using edit mask '__:__:__'.
write:/X using edit mask '$ ___,___'.
write:/y no-gap.
the output result is:
11:20:30
$112,030
abcdef

Example 3: Data: Len type I value 10,
Pos type I value 11,
Text (10) value '20140901'
Write 'The text ------------ appears in the text .'.
Write at pos (LEN) text.

Basic Form of write to statement
To write the content of a value (text) or source segment to the target field, you can use the write to statement:
Syntax
Write to [].

Data: Number Type F value '4. 3 ',
Text (10 ),
Float Type F,
Pack type P decimals 1.
Write number.
Write number to text exponent 2.
Write/text.
Write number to float.
Write/float.
Write number to pack.
Write/pack.
Move number to pack.
Write/pack.

Exp:
Data: Name (10) value 'source ',
Source (10) value 'antony ',
Target (10 ).
...
Write (name) to target.
Write: target.

Exp:

Data: Counter type I.
Compute counter = counter + 1.
Counter = counter + 1.
Add 1 to counter.
Here, the three statements perform the same arithmetic operation.

Output line and blank line on the screen

Use the following syntax to generate a horizontal line on the output screen:
Syntax
Uline [at [/] [] [()].
It is equivalent
Write [at [/] [] [()] SY-ULINE.
The format after at is the same as that described in the Write statement in the fixed write output (page 28) on the screen.
If there is no lattice specification, the system starts a new row and fills the row with a horizontal line. No, only the horizontal line is output according to the specified value.
Another method for generating a horizontal line is to type an appropriate number of characters in the Write statement, as shown below:
Write [at [/] [] [()] '-----...'.
Vertical Line
Use the following syntax to generate a vertical line on the output screen:
Syntax
Write [at [/] [] SY-VLINE.
Or
Write [at [/] [] '| '.
Empty row
Use the following syntax to generate a blank line on the output screen:
Syntax
Skip [].
This statement generates a blank line on the output screen starting from the beginning. If no value is specified, an empty row is input.
To set the output position to the specified row on the screen, use:
Syntax
Skip to line.
This statement allows you to move the output position up or down.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.