Modern ABAP

Terms and basics

‘(C) Brandeis Consulting’

Eclipse basics

Three live demos on the following topics:

  • Change and display mode, locks, etc.
  • Source code-based work with classes
  • Refactoring - Based on the ABAPConf 2021 presentation
‘(C) Brandeis Consulting’

Interface IF_OO_ADT_CLASSRUN

Classes that implement the interface IF_OO_ADT_CLASSRUN can be executed directly in Eclipse. The method if_oo_adt_classrun~main is called.

The importing parameter OUT has a method WRITE that can be used to output character strings to the console.

Signature of the WRITE method

write
importing data type any
name type string optional
returning value(output) type ref to
if_oo_adt_classrun_out

CLASS zbc_string_functions DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .

PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.

ENDCLASS.

CLASS zbc_string_functions IMPLEMENTATION.

METHOD if_oo_adt_classrun~main.
out->write( ‘Hello World’ ).
ENDMETHOD.

ENDCLASS.
‘(C) Brandeis Consulting’

Exercise: Hello World Create a class

Create a class with the interface IF_OO_ADT_CLASSRUN.
Implement the method MAIN
Output the text ‘HELLO WORLD’.

‘(C) Brandeis Consulting’

What is an expression?

In many programming languages, an expression is a construct that can be evaluated according to a given semantics in relation to a context, i.e., it returns a value.

Wikipedia on expressions (programming)

We call anything that returns a value an expression.

Difference between expression and statement

* As a statement: Concatenate LV_TEXT and SY-DATUM and output the result
CONCATENATE lv_text sy-datum INTO lv_result.
out->( lv_result ).

* As an expression: Concatenate LV_TEXT and SY-DATUM and output the result
out->( lv_text && sy-datum ).

The expression is the value. It no longer needs to be stored in an auxiliary variable.

‘(C) Brandeis Consulting’

Categories of expressions in ABAP

  • Data objects - Variables (fields, structures, internal tables), field symbols, references, etc.
  • Operator expressions - Operations with operators, e.g., +, -, &&, AND
    Actually always available in ABAP. Concatenation with && is explained in detail again in string processing
  • Predicates - Expressions that return a logical value
  • Function calls - Built-in functions or calls to functional methods
  • Constructor expressions - We will explain these in detail later
‘(C) Brandeis Consulting’

Predicate methods

https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenpredicative_method_calls.htm

A predicate method call is a shorthand form of the predicate expression:
... meth( ... ) IS NOT INITIAL ...

I.e., a return value means: TRUE

‘(C) Brandeis Consulting’