[ABAP] Logische Operatoren

Bedeutung                       Operator  Ausdruck

gleich / equal                  =         a EQ '100'
ungleich / not equal            <>        a NE '100'
größer als / greater than       >         a GT '100'
größer gleich / greater equal   >=        a GE '100'
kleiner / less than             <         a LT '100'
kleiner gleich / less equal     <=        a LE '100'
zwischen, between                         a BETWEEN b and c
Initialwert                               a IS INITIAL
UND / AND                                 a = b AND c < d
ODER / OR                                 a = b OR c < d
NICHT / NOT                               a NOT IS INITIAL

* logische Ausdrücke immer in Klammern setzen und Leerzeichen beachten
NOT ( ( a < b ) OR ( d < '2.5' ) )

[ABAP] Interne Tabelle vorbelegen / VALUE als Wertoperator

TYPES: BEGIN OF s_bestand,
         isbn     TYPE n LENGTH 10,
         titel    TYPE string,
         bestand  TYPE i,
         autor    TYPE n,
       END OF s_bestand.

TYPES: t_bestand TYPE STANDARD TABLE OF s_bestand WITH DEFAULT KEY. " KEY-Angabe zwingend notwendig

* iTab mit Werten füllen
DATA(it_bestand) = VALUE t_bestand( ( isbn = '1234567823' titel = 'Titel1' bestand = 1 autor = 'Horst' )
                                    ( isbn = '3233423434' titel = 'Titel2' bestand = 2 autor = 'Udo' ) ).

* oder

DO 5 TIMES.
  DATA(l_wa) = VALUE s_bestand( isbn = '1234567823' titel = 'Titel1' bestand = 1 autor = 'Horst' ).
  APPEND l_wa TO it_bestand.
ENDDO.

* Testausgabe
LOOP AT it_bestand INTO DATA(wa_bestand).
  WRITE: / | { wa_bestand-isbn } \| { wa_bestand-titel } \| { wa_bestand-bestand } \| { wa_bestand-autor } |.
ENDLOOP.

weiterführende Info: Link

[ABAP] Substrings

* alte Variante
DATA: tel TYPE string.
DATA: vor TYPE string.

tel = '+49-(0)1234-556677'.
vor = tel+0(3). " -> '+49' (name+start(length))

tel+1(2) = '42'. " '49' durch '42' im String ersetzen

WRITE: / tel.
WRITE: / vor.

* neu ab 7.02
res = substring( val = 'ABCDEFGH' off = 3 len = 4 ).    " DEFG
res = substring_from( val = 'ABCDEFGH' sub = 'DEF' ).   " DEFGH
res = substring_after( val = 'ABCDEFGH' sub = 'DEF' ).  " GH
res = substring_before( val = 'ABCDEFGH' sub = 'DEF' ). " ABC
res = substring_to( val = 'ABCDEFGH' sub = 'DEF' ).     " ABCDEF