User Tools

Site Tools


misc:abap

Ausgabe in Report

WRITE 'Konstanter Text'.

sprintf

WRITE <f1> TO <f2> [<option>].

To move values between the components of structures, use the statement

MOVE-CORRESPONDING <struct1> TO <struct2>.

To reset a variable <f> to the appropriate initial value for its type, use the statement

CLEAR <f>.

To assign the result of a mathematical calculation to a variable, use the COMPUTE statement or the assignment operator '='.

COMPUTE <n> = <expression>.
<n> = <expression>.

Addition

<p> = <n> + <m>.
ADD <n> TO <m>.

Subtraction

<p> = <m> - <n>.
SUBTRACT <n> FROM <m>.

Multiplication

<p> = <m> * <n>.
MULTIPLY <m> BY <n>.

Division

<p> = <m> / <n>.
DIVIDE <m> BY <n>.

Integer division

<p> = <m> DIV <n>.

Remainder of division

<p> = <m> MOD <n>.

Powers

<p> = <m> ** <n>.

In the same way that you can transfer values component by component between structures using the MOVE-CORRESPONDING statement, you can also perform arithmetic operations between the components of structures using the following statements:

ADD-CORRESPONDING, SUBTRACT-CORRESPONDING, MULTIPLY-CORRESPONDING, DIVIDE-CORRESPONDING

Absolute value of argument.

ABS

Sign of argument:

SIGN

Smallest integer value not smaller than the argument.

CEIL

Largest integer value not larger than the argument.

FLOOR

Integer part of argument.

TRUNC

Fraction part of argument.

FRAC

If the Fixed point arithmetic attribute is set, the decimal places are also taken into account in arithmetic operations. Calculations with packed numbers in ABAP use the same arithmetic as a pocket calculator. Intermediate results are calculated using up to 31 digits (before and after the decimal point). You should therefore always set the Fixed point arithmetic attribute when you use type P fields.

String Manipulations

  SHIFT <c> [BY <n> PLACES] [<mode>].
  REPLACE <str1> WITH <str2> INTO <c> [LENGTH <l>].
  TRANSLATE <c> TO UPPER CASE.
  TRANSLATE <c> TO LOWER CASE.
  CONVERT TEXT <c> INTO SORTABLE CODE <sc>.
  SET LOCALE LANGUAGE <lg> [COUNTRY <cy>] [MODIFIER <m>].
  SEARCH <c> FOR <str> <options>.
  [COMPUTE] <n> = STRLEN( <c> ).
  CONDENSE <c> [[NO-GAPS].
  CONCATENATE <c1> ... <cn> INTO <c> [SEPARATED BY <s>].
  SPLIT <c> AT <del> INTO <c1> ... <cn>.
  MOVE <c1> TO <c2> PERCENTAGE <p> [RIGHT].

Processing Sections of Strings: You can address a section of a string in any statement in which non-numeric elementary ABAP types or structures that do not contain internal tables occur using the following syntax:

<f>[[+<o>][[(<l>)]

Setting Bits: In a hexadecimal field (type X), you can set or read individual bits.

SET BIT <n> OF <f> [[TO <b>].
GET BIT <n> OF <f> INTO <b>.
BIT-NOT <y>
<y> BIT-AND <z>
<y> BIT-XOR <z>
<y> BIT-OR <z>

Field Symbols (entspricht etwa dereferenzierten C Pointer *p)

FIELD-SYMBOLS <FS> [[<type>|STRUCTURE <s> DEFAULT <wa>].
ASSIGN <f> TO <FS>.                 // static assign
ASSIGN <f>[[+<o>][[(<l>)] TO <FS>.    // assign with Offset Specification
ASSIGN (<f>) TO <FS>.               // dynamic assign
ASSIGN COMPONENT <comp> OF STRUCTURE <s> TO <FS>.
ASSIGN ... TO <FS> CASTING.         // Zuweisung auf Speicherbereich ohne Rücksicht auf Struktur

Reference Variables Reference variables contain references. The actual contents of a reference variable, namely the value of a reference, is not visible in an ABAP program. ABAP contains data references and object references. Consequently, there are two kinds of data reference variables - data reference variables and object reference variables.

TYPES <t_dref> TYPE REF TO DATA.
DATA <dref> TYPE REF TO DATA.

Constructor

CREATE DATA <dref> TYPE <type>|LIKE <obj>.

Class.forName(“name”).newInstance()

CREATE DATA <dref> TYPE (<name>).

Comparison

EQ equal to
=  equal to
NE not equal to
<> not equal to
>< not equal to
LT less than
< less than
LE less than or equal to
<= less than or equal to
GT greater than
> greater than
GE greater than or equal to
>= greater than or equal to

Comparing Strings

CO Contains Only
CN Contains Not only
CA Contains Any
NA contains Not Any
CS Contains String
NS contains No String
CP Matches pattern
NP Does not match pattern
misc/abap.txt · Last modified: 2010/05/29 00:08 (external edit)