1 2 3 Previous Next

horst.keller

42 Posts

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

http://help.sap.com/abapdocu_731/en/index.htm
http://help.sap.com/abapdocu_731/de/index.htm

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 ...

Cheers!

Horst

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!

CLASS cls DEFINITION.
  PUBLIC SECTION.
    DATA itab TYPE TABLE OF i.
    METHODS constructor.
ENDCLASS.

CLASS cls IMPLEMENTATION.
  METHOD constructor.
    APPEND 1 TO itab.
  ENDMETHOD.
ENDCLASS.

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

START-OF-SELECTION.
  CREATE OBJECT oref.
  READ TABLE oref->itab INDEX 1 REFERENCE INTO dref.
  CLEAR oref.
  WAIT UP TO 1 SECONDS.
  IF dref IS BOUND.
    MESSAGE 'Alive!' TYPE 'I'.
  ENDIF.

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:

 

##PRAGMA[PAR1][PAR2]

 

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:

CLASS cl_test_1 DEFINITION PUBLIC.
  PUBLIC SECTION.
    TYPES type11
          TYPE cl_test_2=>type22.
    TYPES type12
          TYPE i.
ENDCLASS.

CLASS cl_test_2 DEFINITION PUBLIC.
  PUBLIC SECTION.
    TYPES type21
          TYPE cl_test_1=>type12.
    TYPES type22
          TYPE i.
ENDCLASS.

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:

  • TYPE-POOLS
  • CLASS ... DEFINITION LOAD
  • INTERFACE ... LOAD

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).

Performancce

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 ...

Introduction

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

Outlook

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

Reference information about these features can be found here:

http://help.sap.com/abapdocu_702/en/index.htm?url=abennews-71.htm 

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):

http://help.sap.com/abapdocu_702/en/index.htm
http://help.sap.com/abapdocu_702/de/index.htm

 

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!

Horst

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?

 

Cheers!

Horst

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

The translation to English is on its way.

Best

Horst 

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 quiet 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!

Best

Horst 

 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:

image

Here is a glimpse of a typical chapter:

image

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.

TRY.
    CREATE OBJECT sql.
    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.
    ELSE.
      WRITE / 'No entry found'.
    ENDIF.
    result->close( ).
  CATCH cx_sql_exception INTO exc.
    MESSAGE exc TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.  

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

http://help.sap.com/abapdocu_70/en/ABENADBC.htm

http://www.sappro.com/article.cfm?id=3375 
(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.

image

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).

Hi folks,

 

It's quiet a time that I have published my last ABAP Geek but yesterday I stumbled across a feature that I don't want to hold back.

You might be well aware of the so called "Dynamic Selections" that are offered at the selection screens of good old logical databases. They allow you to define selections for nodes of the logical database that are not offered statically. But did you know how easy it is to utilize these dynamic selections within any program? Well, I didn't.

All you have to do is to call the two function modules FREE_SELECTIONS_INIT and FREE_SELECTIONS_DIALOG. The following example source code is a kind of fully fledged data browser for arbitrary database tables that allows you to freely define the selection conditions:

 

PARAMETERS dbtab TYPE tabname DEFAULT 'SPFLI'.

TYPE-POOLS rsds.

DATA tadir_wa  TYPE tadir.
DATA selid     TYPE  rsdynsel-selid.
DATA field_tab TYPE TABLE OF rsdsfields.
DATA table_tab TYPE TABLE OF rsdstabs.
DATA table     LIKE LINE OF table_tab.
DATA cond_tab  TYPE  rsds_twhere.
DATA cond      LIKE LINE OF cond_tab.
DATA dref      TYPE REF TO data.
DATA alv       TYPE REF TO cl_salv_table.

FIELD-SYMBOLS 

 TYPE STANDARD TABLE.

SELECT SINGLE *
       FROM tadir
       INTO tadir_wa
       WHERE pgmid = 'R3TR' AND
             object = 'TABL' AND
             obj_name = dbtab.
IF sy-subrc <> 0.
  MESSAGE 'Database not found' TYPE 'I' DISPLAY LIKE 'E'.
  LEAVE PROGRAM.
ENDIF.

table-prim_tab = dbtab.
APPEND table TO table_tab.
CALL FUNCTION 'FREE_SELECTIONS_INIT'
  EXPORTING
    kind         = 'T'
  IMPORTING
    selection_id = selid
  TABLES
    tables_tab   = table_tab
  EXCEPTIONS
    OTHERS       = 4.
IF sy-subrc <> 0.
  MESSAGE 'Error in initialization' TYPE 'I' DISPLAY LIKE 'E'.
  LEAVE PROGRAM.
ENDIF.

CALL FUNCTION 'FREE_SELECTIONS_DIALOG'
  EXPORTING
    selection_id  = selid
    title         = 'Free Selection'
    as_window     = ' '
  IMPORTING
    where_clauses = cond_tab
  TABLES
    fields_tab    = field_tab
  EXCEPTIONS
    OTHERS        = 4.
IF sy-subrc <> 0.
  MESSAGE 'No free selection created' TYPE 'I'.
  LEAVE PROGRAM.
ENDIF.

READ TABLE cond_tab WITH KEY tablename = dbtab INTO cond.
IF sy-subrc <> 0.
  MESSAGE 'Error in condition' TYPE 'I' DISPLAY LIKE 'E'.
  LEAVE PROGRAM.
ENDIF.

CREATE DATA dref TYPE TABLE OF (dbtab).
ASSIGN dref->* TO .

TRY.
    SELECT *
           FROM (dbtab)
           INTO TABLE 
           WHERE (cond-where_tab).
  CATCH cx_sy_dynamic_osql_error.
    MESSAGE 'Error in dynamic Open SQL' TYPE 'I' DISPLAY LIKE 'E'.
    LEAVE PROGRAM.
ENDTRY.

TRY.
    cl_salv_table=>factory(
      IMPORTING r_salv_table = alv
      CHANGING  t_table      =  ).
    alv->display( ).
  CATCH cx_salv_msg.
    MESSAGE 'Error in ALV display' TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.  

 

Passing kind "T" to function module FREE_SELECTIONS_INIT prepares a dynamic selection for a database table entered via a parameter. Passing the result of FREE_SELECTIONS_INIT to FREE_SELECTIONS_DIALOG calls a special selection screen, where you can select the database fields and the respective selections.

After selecting Save, you receive a ready to use dynamic WHERE-condition via parameter WHERE_CLAUSES (another parameter FIELD_RANGES would return a respective RANGES table).

The rest is history: a SELECT statement with dynamic tokens, a target table that is created dynamiclally, and some ALV display.

Cheers!

 

Horst

 

PS: Of course, this program is part of the ABAP Example Library now. 

 

 

 

 

 

 

 

Actions

Filter Blog

By date:
By tag: