7.4 Release News - Support Package 08


Overview

Alright, now we arrived to our last 7.4 release news post (for a while), namely the Support Package Stack 08, that gives us additional new features and extends existing ones. Of course, there are many of them again, but as you already know, I will only demonstrate you the most interesting ones, that are the followings:

  • predicative method calls >> using predicate methods within logical expressions
    [IF order->is_closed( ) ...],
  • internal table filtering >> selecting or removing rows effectively from an internal table
    [DATA(...) = FILTER #( ... USING KEY ... WHERE ... )],
  • new way of defining fields list in SELECT >> listing fields easily in a complex SELECT
    [SELECT scarr~carrname spfli~* sflight~fldate],
  • inline declaration for SELECT >> storing data from the database without defining internal tables
    [SELECT ... INTO TABLE @DATA(flight_schedules)].


Predicative Method Calls

Let's imagine that we have a class, named cl_order that has a method, called is_closed() with a single boolean returning parameter.

...
CLASS cl_order DEFINITION.
  PUBLIC SECTION.
    METHODS is_closed RETURNING VALUE(closed) TYPE abap_bool.
    ...
ENDCLASS.
...

Previously, if we would like to evaluate the result of a predicate method in a logical expression, first we needed to save the result of the method call, then evaluate it.

Thanks to 7.4 SP08, we can use predicate method calls in logical expressions like this (note that this works as if their return value had a boolean data type):

...
DATA(order) = NEW cl_order( ).

IF order->is_closed( ).
  ...
ENDIF.
...


Table Filtering

Next feature is filtering internal tables, thereby constructing other new internal tables. To make it simple, I would say that we can think of it as a short form of

  • the INSERT ... INTO TABLE within a LOOP AT ... WHERE ... ENDLOOP,
  • or the DELETE itab WHERE NOT ....

The mechanism is the following

  • the rows are taken from the source table, employees according to the WHERE clause,
  • then inserting into the target table, essex_employees.

If you have read my previous post about the FOR ... IN itab expression, then you could observe that we could achieve the same results by specifying a FOR expression within a VALUE expression. For this purpose, I would recommend the FILTER, in order to get thinner and much readable code.

...
DATA employees TYPE STANDARD TABLE OF employee WITH EMPTY KEY
                                               WITH NON-UNIQUE SORTED KEY employee_location
                                               COMPONENTS zip_code city.

DATA(essex_employees) = 
  FILTER #( employees USING KEY employee_location
    WHERE zip_code = '34221' AND
          city     = 'Essex' 
  ).
...

To get records that do not meet the WHERE condition, we can use the EXCEPT addition of the FILTER.

...
DATA(not_essex_employees) = 
  FILTER #( employees EXCEPT USING KEY employee_location
    WHERE zip_code = '34221' AND
          city     = 'Essex' 
  ).
...


New Column List Specification after SELECT

Before 7.4 SP08, if we constructed a complex SELECT with let's say some joins, then in case of using all fields from a data source, we had to specify the list of fields one by one.

But from now on, we have the chance to use this short form, if we want to use all fields from a data source: data_source~*, thereby eliminating many unnecessary lines of code.

...
SELECT scarr~carrname spfli~* sflight~fldate
  FROM ( ( scarr INNER JOIN spfli ON spfli~carrid = scarr~carrid )
  INNER JOIN sflight ON sflight~carrid = spfli~carrid AND
                        sflight~connid = spfli~connid )
  INTO @DATA(flight_schedules).
...


Inline Declarations for the Target Area of SELECT

If you have read my previous articles about using Inline Declarations, then it should be familiar to you. It's a fantastic new feature that eliminates the need of defining complex target structures for internal tables to store the data that we get from a SELECT, for example.

Instead, we only need to specify a short inline declaration, like this after the INTO TABLE @DATA(internal_table_name).

...
SELECT scarr~carrname spfli~* sflight~fldate
  FROM ( ( scarr INNER JOIN spfli ON spfli~carrid = scarr~carrid )
  INNER JOIN sflight ON sflight~carrid = spfli~carrid AND
                        sflight~connid = spfli~connid )
  INTO TABLE @DATA(flight_schedules).
...


Summary

Alright! That was about the new features of the 7.4 Release, I hope you enjoyed it, and could convience you to use these fantastic features, in order to get a thinner, more readable and transparent codes than before!

Now, go and try it out! If you don't have any access to any 7.4 based SAP system, then I recommend to watch my colleague's setup guide.

Stay tuned, keep reading! If you want to get notification about the newest posts, follow me or subscribe to our newsletter!

If you liked it, please share it! Thanks!

blog comments powered by Disqus