ABAP

from Wikipedia, the free encyclopedia
ABAP
Paradigms : 4GL (Fourth Generation Language)
Publishing year: 1983
Developer: SAP SE
Current  version : 7.54   (September 20, 2019)
Influenced by: COBOL
Operating system : Windows , Unix / Linux , etc. v. m.
License : proprietary
www.sap.com

ABAP is a proprietary programming language of the software company SAP , which was developed for the programming of commercial applications in the SAP environment. Its basic structure is somewhat similar to the programming language COBOL .

Originally, the acronym for " A ENERAL B EPORT a ufbereitungs p ROCESSOR", as only evaluations (reports) have been programmed with this language, but no database changes could be made. In the course of the further development of the language, the abbreviation now stands for “ A dvanced B usiness A pplication P rogramming”. The scope of the language is not firmly defined and has been expanded repeatedly in the past, e.g. B. the object-oriented language commands of ABAP Objects.

Since 1990 all SAP R / 3 modules have been based on ABAP, which was taken over from the predecessor SAP R / 2 . Since the introduction of SAP NetWeaver , SAP has also been offering a process and programming environment for Java in addition to ABAP , and accordingly an ABAP-based and a Java-based application server (see SAP NetWeaver Application Server ).

properties

ABAP is a 4GL language that was specially developed for mass data processing in commercial applications. a. the following advantages over more elementary languages ​​in which such functions are in libraries:

  • Database access integrated into the language as Open SQL
  • Performance optimization of database accesses integrated into the ABAP runtime environment via SAP buffering
  • Internal tables for the dynamic storage and processing of tabular mass data in the main memory
  • Online Transaction Processing (OLTP) concept integrated in the ABAP runtime environment , in which many users access the central database at the same time
  • Interface to other programming environments integrated into the language via Remote Function Call
  • Interface to XML integrated into the language .

The integration of such functions into the language is essentially advantageous for the static verifiability and the speed of execution of programs. In return, ABAP also contains considerably more language elements than other programming languages.

ABAP supports a procedural programming model based on subroutines and function modules and, from Release 6.10, an object-oriented programming model based on classes and interfaces. Both models are interoperable.

Backward Compatibility

When developing ABAP, SAP operates the principle of downward compatibility. If an ABAP statement is replaced by a newer (e.g. more powerful) statement, the old statement does not lose its validity or function. Since the old instructions continue to exist alongside the new instructions, this results in a very extensive language scope. Old language elements should no longer be used, but they can still be used. Only when using ABAP OO (ABAP Objects) can some old components no longer be used.

The advantage is that the previous developments and customer adjustments remain functional and their behavior does not change. Developments do not have to be revised. The disadvantage, however, is that developers often still use old components, although newer and more effective (higher-performance) language components are available. For those new to the language, this means that both the old components and the new components must be learned. It also increases the complexity and the range of languages.

Old and new components can also be combined, so procedural elements can also be used in object-oriented coding (program code), while object-oriented elements can also be used in procedural coding. The power of speech can be increased through the targeted combination of new and old components.

ABAP Workbench

Programming in ABAP is supported by a development environment that is designed to enable large projects with several (hundreds) developers. An operational system must be guaranteed at all times. For this purpose, the changed objects are recorded on so-called transport requests, which are exported to the file system when released and can be imported into subsequent systems. This mechanism allows the programs to be developed separately from their productive use.

The development environment for the ABAP programming language is the ABAP Workbench , which was also developed in ABAP . In the ABAP Workbench (access via the so-called Object Navigator, transaction SE80), however, other objects such as B. BSP ( Business Server Pages , with HTML parts) can be processed.

The special feature is the so-called "forward navigation". A double click on a table name leads directly to the definition of the database table in the ABAP Dictionary, whereas a double click on a method name leads directly to this method.

The ABAP Workbench will be adapted over time to the requirements of modern software development. For example, syntax highlighting has also been supported since the last release .

Since July 2012, SAP has also been offering an ABAP development environment based on the open source platform Eclipse ("ABAP in Eclipse"). The ABAP tools can be combined with other Eclipse-based tools such as B. Integrate JEE and Android development tools. This newly designed environment specifically supports agile software development methods such as B. test-driven development. In addition to standard functions such as syntax highlighting and code completion, the new ABAP editor also offers support for refactoring such as B. Renaming methods and variables. There is also an Eclipse-based debugger. So that tools from the classic ABAP Workbench such as If, for example, SE11 can still be used, there is the option of calling up these transactions via an integrated SAP GUI within Eclipse.

Code sample

The following program outputs the contents of table TSTCT (contains texts on SAP transaction codes) in a simple list.

Report RSTSTCT1.
Tables: TSTCT.

Select * from TSTCT where SPRSL = SY-LANGU.
  Write: / TSTCT-SPRSL, TSTCT-TCODE, TSTCT-TTEXT.
Endselect.

Code example for R / 3 versions ≥ 4.7 SR 1

The following program outputs the content of table TSTC (contains SAP transaction codes) using the ABAP List Viewer.

  REPORT ztest.

  CLASS demo DEFINITION.
    PUBLIC SECTION.
      CLASS-METHODS main.
  ENDCLASS.

  CLASS demo IMPLEMENTATION.
    METHOD main.
      DATA tstc_tab TYPE STANDARD TABLE OF tstc WITH NON-UNIQUE DEFAULT KEY.
      DATA alv   TYPE REF TO cl_salv_table.
      DATA exc   TYPE REF TO cx_salv_msg.
      SELECT *
        FROM tstc
        INTO TABLE tstc_tab.
      TRY.
        cl_salv_table=>factory(
          IMPORTING r_salv_table = alv
          CHANGING t_table = tstc_tab ).
        alv->display( ).
      CATCH cx_salv_msg into exc.
          MESSAGE exc TYPE 'I'
              DISPLAY LIKE 'E'.
      ENDTRY.
    ENDMETHOD.
  ENDCLASS.

  START-OF-SELECTION.
    demo=>main( ).
  • REPORT ztest. Describes the type ( REPORT) and name ( ztest) of the program. The name is based on the namespace conventions, which state that customer-specific programs (i.e. not from SAP) must be in the customer namespace ( Z*and Y*) or in a reserved namespace (have a slash as the first and last character).
  • CLASS demo DEFINITION … ENDCLASS. Declaration part of a class demo.
  • CLASS-METHODS main. Declaration of a static method main.
  • CLASS demo IMPLEMENTATION … ENDCLASS. Implementation part of a class demowith method implementationMETHOD … ENDMETHOD
  • DATA tstc_tab TYPE STANDARD TABLE OF tstc WITH NON-UNIQUE DEFAULT KEY. This statement defines an internal table tstc_tabof the standard table type, the line type of which has the structure of a line in the database table TSTC.
  • DATA alv TYPE REF TO cl_salv_table. This statement defines a reference variable for a list viewer object.
  • DATA exc TYPE REF TO cx_salv_msg. This statement defines a reference variable for an exception object.
  • SELECT * FROM tstc INTO TABLE tstc_tab. This statement reads all data in the database table tstcinto the internal table tstc_tab. The asterisk indicates that all columns of the database table are to be written to the internal table.
  • TRY … CATCH … ENDTRY. Exception handling (available from version 4.7 SR1).
  • cl_salv_table=>factory( … ). Generation of a list viewer for the internal table.
  • alv->display( ). Calling the method of displaythe list viewer.
  • START-OF-SELECTION. Introduction of an event block (serves here as an entry point)
  • demo=>main( )Calling the method of mainthe class demo.

ABAP Objects

Under ABAP Objects refers to the object-oriented extensions of the ABAP programming language. It implements all elements of object-oriented programming (OOP) with the exception of multiple inheritance and method overloading . Interfaces and optional parameters are supported. Reflexive programming is also possible with special RTTI classes, and from version 6.40 even (limited) the dynamic generation of new types.

ABAP Objects is available from SAP Release 4.6 and has been continuously developed since then. B. supplemented by object services. The object-oriented language elements are a prerequisite for the development of modern user interfaces with controls and for the implementation of web applications and XML services in ABAP. Large parts of the ABAP Workbench itself are implemented object-oriented in ABAP Objects.

ABAP Objects restricts the scope of language of "classic" ABAP in some points. For example, internal tables with header lines are no longer allowed in the context of ABAP Objects.

Web Dynpro

As of SAP NetWeaver 7.0, WebDynpro for ABAP also allows you to develop web applications in ABAP. WebDynpro ABAP is based on Web Dynpro technology. Originally, SAP only wanted to make this technology available for the Java programming language (from NetWeaver 6.40). Due to customer inquiries (lack of Java know-how from ABAP developers or lack of SAP know-how from Java developers), SAP decided to integrate this technology in ABAP.

criticism

General

The large number of possible ABAP statements and their variants generally leads to source code that is more difficult to understand than in other common programming languages. The existing variety of ABAP statements results from the downward compatibility.

  • Assignments: For example, in addition to a mathematical form of assignment "variable = 18.", there is also the Cobol-like notation "MOVE 18 TO variable". There are also several possible notations for other tasks.
  • Significance of spaces: difference between ' +' and '  +' (plus and blank-plus)
Example: DATA myvar(3) TYPE N VALUE '123'..
' myvar+1' (without spaces) results in ' 23' (offset of a character string), ' myvar + 1' (with spaces) results in ' 124' (addition).
This similar notation for operations with very different effects is a potential source of errors.

Before release 7.1 / 7.02

Particularly before Release 7.1, details can be seen that make it difficult to use the language.

  • Expressions were only evaluated when assigned to a variable, but not in an IF condition, in a WRITE statement, or when parameters were passed to a function.
Example: IF A * B < 15.must be replaced by DATA C TYPE xxx. C = A * B. IF C < 15..
  • The result of a function call cannot be used directly in an expression.

Since release 7.1 / 7.02

With Netweaver 7.1, a number of language simplifications, in particular linked expressions, are available. These changes were later ported down to Enhancement Package 2 (7.02) for Release 7.0.

Example: IF A * B < 15.
Example: IF X->NEXT( )->NEXT( )->GET_RESULT( Y->GET_TYPE( ) ) > 20.

Since release 7.40

As of Netweaver 7.40, it is possible to note many notations that were previously only possible as complete statements as expressions in operand positions.
Example before:   DATA oref TYPE REF TO class.  CREATE OBJECT oref TYPE class EXPORTING p = 222.
Example from Release 7.40:   DATA(oref) = NEW class( 222 ).

literature

  • Horst Keller: ABAP, the official reference. Rheinwerk 2016, ISBN 978-3-8362-4109-0 .
  • Horst Keller: ABAP quick reference. Galileo Press, 2005, ISBN 3-89842-680-7 .
  • Sascha Krüger, Jörg Seelmann-Eggebert: ABAP Best Practices. Galileo Press, 2005, ISBN 3-89842-354-9 .
  • Horst Keller, Sascha Krüger: ABAP Objects - ABAP programming with SAP NetWeaver. Galileo Press, 2006, ISBN 3-89842-358-1 .
  • Horst Keller, Wolf Hagen Thümmel: ABAP programming guidelines. Galileo Press, 2009, ISBN 978-3-8362-1286-1 .
  • Andreas Wiegenstein, Markus Schumacher, Sebastian Schinzel, Frederik Weidemann: Secure ABAP programming. Galileo Press, 2009, ISBN 978-3-8362-1357-8 .
  • Hermann Gahm: ABAP Performance Tuning Galileo Press, 2009, ISBN 978-3-8362-1211-3 .
  • Bernd Matzke: ABAP / 4. Addison - Wesley, ISBN 3-8273-1372-4 .
  • Stephan Kaleske: Query reporting with SAP ERP . Galileo-Press, Bonn 2009, ISBN 978-3-8362-1433-9 (SAP PRESS).

Web links

Individual evidence

  1. ABAP - Release-dependent changes: Changes to Releases 7.5x
  2. ABAP namespaces and naming conventions ( Memento from April 1, 2013 in the Internet Archive ) - (PDF; 245 kB).