1 2 3 Previous Next


42 Posts

The next two  Blogs might be a bit boring for you. But that will not hinder me from telling you, which types of memory an ABAP program can access and what kind of data can be addressed there. I will start with the most general memory and will work my way down to the individual ones. If you prefer it another way around, you must read this Blog bottom up.


SAP System


The most general entity we have in an ABAP based SAP world is what was called R/3 System in ancient times. Let’s call it SAP System now. Technically, such a SAP System is based on the SAP Web Application Server ABAP (containing the former SAP Basis), which is part of SAP  NetWeaver.  From everywhere in such a SAP System, you can access the same persistent data of its central database.  But since a SAP System normally runs on several application servers, there is no transient memory that can be accessed from everywhere in the system. For that we have to step one level down.


Application Server


A SAP System is distributed among  one or more application servers. On each application server an instance of the SAP System is running. The common memory of an application server is its Shared Memory. Every ABAP program running on an application server has access to the Shared Memory. There are two ways of how you can access the Shared Memory from an ABAP program:


  • Before Release 6.40, you could only use the well known EXPORT and IMPORT statements to store and read data clusters in the Shared Memory. With the additions SHARED MEMORY or SHARED BUFFER, data clusters are stored in or read from so called application buffers of the Shared Memory. The two application buffers differ in respect to how the system behaves when reaching the memory limit. Data clusters in Shared Memory are stored in memory tables that reflect the structure of an INDX type database table.
  • As of Release 6.40, you can also store and access Shared Objects in the Shared Memory. Shared Objects are instances of shared memory-enabled classes that are stored in an area of the shared memory. An area in the Shared Memory is managed by an area class. The instances of an area class are used as area handles. In an ABAP program, you access an area and its Shared Objects via area handles. For example, a shared object is generated with the addition AREA HANDLE of statement CREATE OBJECT.


User Session


When  an user or an application (e.g. via RFC) logs on to a SAP system, he, she, or it connects to a certain application server where an User Session is created. The common memory of  an User Session is the so called SAP Memory. ABAP programs have access to SPA/GPA parameters stored in the SAP memory. SPA/GPA parameters (or SET/GET parameters) are set using SET PARAMETER and read with GET PARAMETER. Input fields on dynpro screens can be linked with SPA/GPA parameters. When a screen is called, the default values of such input fields are taken from the SAP Memory. When the screen is left, the field values are stored in SAP Memory (that’s why you always find the name of the last edited program in the input field of the ABAP

Editor SE38). SPA/GPA parameters are managed in the database table TPARA.


Main Session


For each User Session, at least one so called Main Session (or External Session) is created. In dialog processing, one User Session can manage up to six Main Sessions, where each Main Session is connected to a window on the screen. Additional Main Sessions are opened with the GUI function Create a new Session or with the addition STARTING NEW TASK during a remote function call (RFC). The memory area  of  a Main Session, that can be accessed from several ABAP programs is the so called ABAP Memory. You access the ABAP Memory with the EXPORT and IMPORT statements again. This time, you use the addition MEMORY ID. With that you store or read a data cluster with a specific id in the ABAP Memory. An ABAP Memory and its lifetime  is connected to a call sequence. A call sequence is created if you can return from a called ABAP program to the calling ABAP program. The respective statements are SUBMIT AND RETURN and CALL TRANSACTION. All programs of a call sequence have access to the same ABAP Memory. When a call sequence is finished, the respective ABAP Memory is deleted.


Internal Session


For each call of an ABAP program, a so called Internal Session is created in the Main Session. The Internal Session contains all the ABAP program's own data and objects during the execution of the program. That's what you mostly work with! (DATA, CREATE OBJECT and all that stuff!) Other ABAP programs (their

data, and their objects) can be loaded into the same Internal Session via external procedure calls (more about this in the next  Blog). An Internal Session lives as long, as its first ABAP Program (the main program) is executed. During call sequences, the respective internal sessions are stacked. You can stack maximally nine internal sessions.


Technical note: From a conceptual point of view it is always OK to speak of “loading programs into an Internal Session”. But technically, each Internal Session is subdivided into PXA and Roll Area. The PXA (Program Execution Area) is a shared memory for the byte codes of all programs running concurrently at any one time on an application server. Only the Roll Area is the memory that is actually reserved for the data and objects of each individual internal session. Just if anybody asks …

You find the latest version of the ABAP Keyword documentation under:


Besides minor changes, ABAP for 7.03/7.31 (7.0, EhP3 and 7.3, EhP1) is the same as for 7.02.

The documentation for 7.03/7.31 has been cleaned up in regard to known errors and enhanced by some rewritten chapters:


 Feel free to distribute this information.

In my last year's blog I wrote A new "Schwarte" has arrived! and the eybrows of some community evangelists went up - how dare I!

OK folks, let those eybrows come down. Now the tome is available in English too.

What's the difference to the online documentation? I myself checked and corrected the translation line by line for month ...



This one might be interesting for you, if you search for memory leaks.

Instances of classes or simply "objects" are created by CREATE OBJECT. Anonymous data objects are created by CREATE DATA. After creation, references (object references and data references) contained in reference variables are pointing to these objects. We all know that the objects are kept alive by these references and that they are deleted by the garbage collector if they are not referenced any more. But what kind of references are keeping objects alive? Let's have look.

We start with the memory where objects are stored. In the working memory of an ABAP program (the well known roll area of an internal session) we can distinguish two further memory areas:

  • The heap - the heap is the memory where all objects created by the CREATE statements, i.e. instances of classes and anonymous data objects, are stored.
  • The stack - the stack is the memory where the (named) data objects of programs and procedures are stacked. The memory occupied by the local data of a procedure (including methods) is popped from the stack, when the execution of the procedure has finished.

Now it is easy to distinguish two types of reference variables:

  • Heap references -heap references point to objects and parts of objects in the heap. Heap references are created when new objects are created with CREATE OBJECT or CREATE DATA. But you can also create heap references using the statement GET REFERENCE or the addition REFERENCE INTO for data objects or part of data objects in the heap.
  • Stack references - stack references. point to objects and parts of objects in the stack. Stack references can be created only using the statement GET REFERENCE or the addition REFERENCE INTO for data objects or part of data objects in the stack.

An object reference is always pointing to an instance of a class in the heap and therefore an object reference is always a heap reference

A data reference is a heap reference, if it points to an instance attribute or a part of an instance attribut of an object in the heap, or if it points to an anonymous data object or a part of an anonymous data object in the heap. A data reference is a stack reference, if it points to a data object or a part of a data object on the stack. A part of an instance attribute or of a data object can be a component of a structure, a line of an internal table, or a section specified by an offset and length.

And now about keeping objects alive:

  • Heap references pointing to objects or parts of objects in the heap keep the objects alive.
  • Stack references pointing to (data) objects or parts of (data) objects in the stack do not keep the objects alive.

With other words and for example: A data reference pointing to a line of an internal table that is an instance attribute of an object keeps the object alive, even if you have cleared the object reference variable!

    DATA itab TYPE TABLE OF i.
    METHODS constructor.

  METHOD constructor.
    APPEND 1 TO itab.

DATA: oref TYPE REF TO cls,
      dref TYPE REF TO data.

  CLEAR oref.
  IF dref IS BOUND.
    MESSAGE 'Alive!' TYPE 'I'.

And even more: Field symbols pointing to objects or part of objects in the heap (if you use the statement ASSIGN or the addition ASSIGNING for heap objects or part of heap objects) also keep the objects alive!

Last but not least a word about validity: Since heap references keep objects alive, as a rule they are always valid (IS BOUND is true). But ABAP wouldn't be ABAP if there were not one exception from that rule: Internal tables are dynamic data objects with an own memory management that is independent from CREATE and garbage collection. A data reference pointing to a line of an internal table in the heap is a heap reference and keeps the table and its surrounding object alive. Nevertheless, it can become invalid (IS BOUND is false) if the internal table line is deleted from the table. For strings you could expect the same, but ABAP does not allow you to point to sections of strings with references or field symbols. Stack references can always become invalid of course, if the referenced objects are popped from the stack.


Situation before 7.02


Before Release 7.02 there was no way to suppress warnings from the syntax check. Warnings and messages from the extended program check could be suppressed by pseudo comments. The latter had an unclear correlation with the target statement, e.g.:

DATA html_tag TYPE string     "#EC NEEDED

              VALUE ``. "#EC NOTEXT  

If you needed more than one pseudo comment, you had to spilt a statment into several lines.  Also, using pseudo comments in chained statements can be problematic.


Situation as of 7.02


Pragmas offer an uniform mechanism to suppress warnings from compiler and SLIN. They are placed inside a statement, e.g.:


LOOP AT ... WHERE ... ##PRIMKEY[...].

Pragmas always only affect the current statement. A pragmas can only occur:

    • At the end of a line; possibly followed by a sentence delimiter ( . , : )

    • But not after a statement delimiter

Pragmas are case insensitive and begin with two characters ## and can have parameter tokens:




The parameter tokens are matched against syntax warnings.


Pragmas applicable for syntax warnings are documented in the long texts of the syntax warnings.


Pragmas applicaple for SLIN warnings and messages are documented in the SLIN error report. An alphabetical mappling list of old SLIN pseudo comments vs. new pragmas is shown by my program ABAP_SLIN_PRAGMAS.


</p><p>Motivation and Usage for Syntax Warnings*

The ABAP compiler was improved in the following ways. The improvements are backward compatible. You don't have to do anything with your programs but can simply benefit from the improvements.

Multi Pass Compiler

You might have not noticed it, but the ABAP compiler up to Release 7.01 has some flaws. Before the dawn of ABAP Objects it operated with one pass processing only. With the introduction of ABAP Objects, a restricted two pass processing was introduced, Nevertheless, when developers started to create complicated relations between classes and interfaces it was found that some correct programs do not compile. In fact, this can be shown by a rather simple example of two public classes with cross references:

    TYPES type11
          TYPE cl_test_2=>type22.
    TYPES type12
          TYPE i.

    TYPES type21
          TYPE cl_test_1=>type12.
    TYPES type22
          TYPE i.

In Release 7.01 there are syntax errors in both classes (even after activating them)!

This is solved in Release 7.02. After the introduction of a robust multi pass processing for global classes, global interfaces and type pools, the syntax errors do not occurr any more.

Load on Demand

Up to Release 7.01, the ABAP compiler could only load external definitions (e.g. TYPE-POOLs, classes and interfaces) at certain times. The definitions were loaded as soon as possible to minimize compilation errors. If definitions refer to other definitions, further definitions had to be loaded in the same moment. As a consequence, a significant amount of definition were loaded that were not needed. Further consequences were a costly dependency administration, a high recompilation frequency (e.g. changes of dictionary types affected many ABAP loads that didn't really use the type), and code instability (syntax errors in definitions "far away" affected many programs that didn't really need these definitions). Workarounds that avoided such dependencies were dynamic techniques and usage of unsafe types, e.g. parameters typed REF TO OBJECT. Those techniques bypassed static checks and negatively affected code robustness and maintainability.

This issues are solved in Release 7.02, because external definitions are only loaded when actually required (i.e. on demand). Example:

DATA: obj TYPE REF TO iface.  "Definition of iface not loaded
var = iface=>const.           "Definition of iface loaded 

As an interesting consequence for ABAP developers there is no need for some explicit usage declarations any more and the following statements became obsolete:


These statements are ignored by the ABAP Compiler as of Release 7.02 and can be deleted (no need of TYPE-POOLS statement any more, see http://help.sap.com/abapdocu_702/en/index.htm?url=abaptype-pools.htm).


Even if you never stumbled over syntax errors as shown above or you don't care about load on demand, you will benefit from the new ABAP compiler which is more robust, economic and - last but not least - fast: Compilation times are reduced by 60%!

Now that Enhancement Pack 2 is available (Release 7.02), it is time to bluster about the things that have changed in ABAP and its environment. This blog and its follow ups are based on a talk (TechEd and SAP-internal) that I had prepared for the rollout of this features not less than 5 years ago ...


Up to Release 7.0, SAP followed a release policy that was strictly linear: One Release followed the other. AS ABAP, Release 7.0 followed 6.40, which followed 6.20, which followed 4.6 and so on. This policy has changed in the meanwhile. Since an upgrade of one release to a higher one always came with high efforts regarding time and costs, SAP promised its customers to keep the current releases (which are based on AS ABAP 7.0) stable for a long time. All functional enhancements delivered by SAP do not require an upgrade any more but come as Enhancement Packages (EhP) based on a strictly downward compatible basis. Therefore, we have Release 7.0 now, with optional EhPs 7.01 and 7.02. In ABAP there were no changes in 7.01 compared to 7.0.

So far so good. But of course, the ABAP group did not stop developing. In a parallel release track (7.1 -> 7.2/7.3), many new features where built in into ABAP that were demanded for a long time, as e.g. a multi-pass ABAP compiler, secondary keys for internal tables, decimal floating point numbers, improved expression handling, and so on. Good for the happy few that could work on that track. But what about the rest of us, stuck in the 7.0 world?

The good news is: Almost all new ABAP features developed up to Release 7.2/7.3 where downported to 7.02 and are available to the broad public now. All you have to do is to enhance your 7.0 system with EhP2. The only exceptions are the operational package concept and the support of class based exceptions in RFC. Both are not downward compatible. All the other developments are strictly downward compatible. The backport is based on the fact that the 7.20 kernel is a downward compatible kernel (DCK). This kernel is used for 7.02 (and is also running under 7.3 -> regarding ABAP 7.3 is the same as 7.2).

Downported features

If you enhance your 7.0 system to 7.02 you will get the 7.2 kernel and with it the following enhancements:


  • Transparent Infrastructure Improvements (Multi-Pass Compiler)

    Application development benefits without further action
  • New Facets of Existing Features (Pragmas, Boxed Components, 12h Time Format, Shared Objects Extensions, Data Declaration Extensions, basXML, UUIDs)

    Require only moderate efforts by application if to be used

  • New Features (Decimal Floating Point Numbers, Extended Expressions, Internal Table Extensions, String Processing Extensions, Database Access Extensions, Exceptions Extensions, Splitter Control, ABAP Call from ST)

    Require an active part of application development if to be used

  • Tool Improvements (Class Builder, ABAP Editor, ABAP Keyword Documentation, ABAP Debugger, ABAP Runtime Analysis, Test Tools)

    Improved productivity at application side


This blog introduces a series of blogs that will present the new features listed above. 

Reference information about these features can be found here:


Now that AS ABAP, 7.0, EhP2 is released, there are no resaons any more to restrict the Web Version of the ABAP Keyword Documentation to Release 7.0.

And here it is, the 7.02-Version (thanks to the colleagues who made it happen):



Last but not least, the 7.02-version has lots of improvements regarding contents, even for 7.0-subjects. Besides an improved structure, there is e.g. a new chapter on date-time-processing (http://help.sap.com/abapdocu_702/en/index.htm?url=abendate_time_processing.htm) or many  chapters were reworked as e.g. the one on built-in data (http://help.sap.com/abapdocu_702/en/index.htm?url=abenbuilt_in_types_complete.htm) and their implications (e.g. http://help.sap.com/abapdocu_702/en/index.htm?url=abenconversion_elementary.htm or http://help.sap.com/abapdocu_702/en/index.htm?url=abenlogexp_rules_operands.htm).

Have Fun!


PS: The 7.0-version is still available under ".../abapdocu_70/...".

You find the download here: http://www.sdn.sap.com/irj/sdn/index?rid=/library/uuid/80db43c2-9ee5-2d10-de8e-8547de363868

Use WINRAR to unpack the RAR files into one directory NWABAP702TRIAL. Open start.htm and follow the instructions. I did so and it worked!

There are already a lot of sources describing the ABAP news for 7.02, e.g. Thomas Weiss' blog What Is New in ABAP Language, ABAP Workbench, and Enhancement Framework With SAP NetWeaver 7.0 EhP2. In this blog I tell you how the ABAP Keyword documentation (what else ...) can help to improve your 7.02 experience.

The normal way of starting the docu in SAP GUI is F1 in the ABAP Editor, the i-Button in the Editor or simply calling transaction ABAPHELP. (Besides, there is a new way: activate services "/sap/public/bc/abap/docu" and "/sap/bc/abap/docu"in SICF and try program ABAP_DOCU_HTTP_CALL!)

First thing you might notice after starting the docu is, that the input field for search terms is always visible and must not be called by clicking an icon, This has significantly changed the way, how the documentation is used inside SAP:

E.g., you can enter "News" there to find all the fascinating things that have happened in ABAP between Release 7.0/7.01 and 7.02:

But you cannot only read about the news, you can even play around with new features! As of Release 7.02, the ABAP Example Library (formerly known as transaction ABAPDOCU) is fully integrated into the ABAP Keyword Documentation! The source code of existing example programs is embedded into the documentation, can be executed, debugged, and opened in the Editor. The extended search allows a fulltext search in the example source codes.

Another goodie is the display of interactive syntax diagrams that you can use to explore ABAP Statements:

Furthermore, you can set a display language of the documentation for your user that is independent from the logon languge now:


Further improvements affect the hitlist for F1-searches (more precise now), printing and download mechanisms, and internal performance (sharing of common ressources via Shared Objects).

Last but not least, how do you like the new ABAP icon?




A 7.02/7.2-version of the ABAP Reference is now available in German.

The translation to English is on its way.



Horst Keller

Community at work!

Posted by Horst Keller Oct 22, 2009

After writing my blog about the ABAP Keyword Documentation available on the Web (ABAP Keyword Documentation still publicly available) there was quite some discussion concerning its usability with different browsers.

Now I'm happy to announce that community member Markus Milleder has helped me out :-)

The solution he has proposed works fine with IE and Firefox and is already applied to the documentation (http://help.sap.com/abapdocu_70/en/index.htm, http://help.sap.com/abapdocu_70/de/index.htm) as well as to the programs generating the offline versions of the documentation from Release 7.02 on.

Thanks a lot for that!



PS: The German variable names in the script were also adjusted to English ...

The official ABAP Programming Guidelines were presented at TechEd 2009 in Phoenix and were available at the conference book store:


Here is a glimpse of a typical chapter:


All in all, there are around 120 of such rules covering an area that spans from very general subjects like "Separation of Concerns" to very special subjects like "Usage of COLLECT for internal tables".

The rules are aimed at being reasonable but not dogmatic, profound but not fundamentalist. The compliance with these guidelines should be a given for a developer and not understood as a formalistic necessity. 

Alltogether, they are more than just another collection of naming conventions ...

The public access to the ABAP Keyword Documentation announced in a preceding ABAP Easter Egg is still available but the links have changed as follows:

For the time being, the tree structure can be viewed by MS IE, but other browsers are not yet supported.

Please note that the documentation describes ABAP for coming up Release 7.0, EhP2. The features that are listed under http://help.sap.com/abapdocu_70/en/ABENNEWS-71.htm / http://help.sap.com/abapdocu_70/de/ABENNEWS-71.htm are not available in preceding releases. Nevertheless, the documents present the most up to date docomentation about ABAP in the moment and you can also get an insight into the things to come.

In the moment, you will have installed an AS ABAP 7.02 in the future, there will also be the possibility to access the ABAP Keyword documentation via an HTTP-service. The documents will be the same as in the offline version announced here, but there will be an additional possibility for searching. The search is carried out on the backend and thus not available in the offline version. As a workaround you can open the ABAP Index, the ABAP Subject Directory, or the ABAP Glossary that are offered on the start page, search there, and follow the links.

Horst Keller

ABAP Geek 15 - ADBC

Posted by Horst Keller Sep 16, 2009

ADBC is the abbreviation for "ABAP Database Connectivity" that is a class-based API for the Native SQL interface of the Application Server ABAP. ADBC allows object orientated and dynamic access to the Native SQL interface and can always be used when access to a database via the Native instead of the Open SQL interface is necessary and static EXEC SQL is not sufficient (remember that dynamic token specification is not possible in EXEC SQL).

How to find the classes of ADBC?

The ADBC classes all begin with the prefix CL_SQL_ or CX_SQL_. The most important classes are

  • CL_SQL_STATEMENT for executing SQL statements
  • CL_SQL_PREPARED_STATEMENT for creating prepared SQL statements
  • CL_SQL_CONNECTION  for administering database connections
  • CX_SQL_EXCEPTION as an exception class

How to use ADBC?

In the most simple case you use instance methods of CL_SQL_STATEMENT to exceute SQL statements that are passed to the methods. You can create DML and DDL statements, carry out queries and execute stored procedures.

A simple example

PARAMETERS key TYPE scarr-carrid.

DATA: sql      TYPE REF TO cl_sql_statement,
      result   TYPE REF TO cl_sql_result_set,
      exc      TYPE REF TO cx_sql_exception,
      stmnt    TYPE string,
      carrid   TYPE scarr-carrid,
      carrname TYPE scarr-carrname,
      dref     TYPE REF TO data,
      rc       TYPE i.

    CONCATENATE `SELECT carrid, carrname `
                `FROM scarr `
                `WHERE carrid = '` key `'`  INTO stmnt.
    result = sql->execute_query( stmnt ).
    GET REFERENCE OF carrid INTO dref.
    result->set_param( dref ).
    GET REFERENCE OF carrname INTO dref.
    result->set_param( dref ).
    rc = result->next( ).
    IF rc > 0.
      WRITE: / carrid, carrname.
      WRITE / 'No entry found'.
    result->close( ).
  CATCH cx_sql_exception INTO exc.

A SELECT statement is passed to an object of CL_SQL_STATEMENT and the method EXECUTE_QUERY is invoked. With SET_PARAM the columns of the result set are accessed in order to bind data refeferences to the individual results.

More Information


(maybe also in SDN but I didn't find it)

Regular expreesions are available in ABAP as of Release 7.0.  A regular expression is a pattern of literal and special characters that describes a set of character strings. You use regular expressions to locate or replace one or more occurrences of the character strings represented by the expression in character strings. ABAP supports regular expressions in the statements FIND and REPLACE and via the the classes CL_ABAP_REGEX and CL_ABAP_MATCHER. In an upcoming Release there will be also built-in functions that support regular expressions.

Regular express are very powerful but can also become very complicated and are not easy to maintain. Especially finding an appropriate expression for a given task might take some time and then the question remains, how to test it. If you do not want to  test your regular expressions only after including them in your application programs and if you do not want to create temporary test programs for each regular expression over and over again, you can use the program DEMO_REGEX_TOY that is delivered as of Support Package 7 of Release 7.0.


The input mask allows you to enter your regular expressions, some text, and to play around with the various options for using the regular expression.

I for myself never use a regular expression in a program without having tested it in DEMO_REGEX_TOY or it's little brother DEMO_REGEX (available as part of the ABAP Example Library as of Release 7.0, EhP2).


Filter Blog

By date:
By tag: