News in ABAP with the Enhancement Package 2 for SAP NetWeaver 7.0
Decimal Floating Point Numbers
New predefined (standard) ABAP Types are available as of SAP NetWeaver 7.0 EhP2: DECFLOAT16 and DECFLOAT34.
Decimal floating point numbers are introduced in SAP NetWeaver 7.0 EhP2 to overcome the drawbacks of binary floating point numbers: Type f data objects cannot represent every decimal number precisely due to the internal binary representation. Results of calculations may depend on the platform, there is no rounding to a specific number of decimal places, division by powers of 10 is inexact, and no uniform behavior exists across database systems.
Decimal floating point numbers have a range larger than type f, while the calculation accuracy is identical to type p.
Decimal floating point arithmetic is used for calculations. The algorithm for this arithmetic is similar to using “pencil and paper”. Interim results use numbers with 16 (decfloat16) or 34 (decfloat34) decimal places.
The generic type decfloat is also available as ofSAP NetWeaver 7.0 EhP2.
If we have many identical unused static data objects in our program, this can lead to a significant waste of memory. One example could be an instance attribute with a static structure which is initial in most of the classes instances. Another example could be an internal table where a large number of columns is not used for many table lines.
As of SAP NetWeaver 7.0 EhP2 boxed components may be used to reduce the memory consumption of static data objects. For the time being, boxed components can be:
• Substructures of nested structures
• Structured attributes of classes and interfaces
These are called static boxes.
Secondary Keys for Internal Tables
As of SAP NetWeaver 7.0 EhP2 it is possible to define secondary keys for internal tables. Secondary keys can be hashed or sorted. A sorted secondary key may be either unique or non-unique. The maximum number of secondary keys per internal table is 15.
SQL Streams and Locators
For normal access to large objects (LOBs), ABAP data objects of the types string and xstring are used, into which the entire LOB is transferred for read
access, and from which the entire LOB is taken for write access. Depending on the string length, this may lead to a high memory consumption on the
application server. For certain operations on the LOB (e.g. copying the LOB on the database table, storing the LOB in a data object different from a string or
xstring), it is not necessary to realize the complete LOB in the ABAP program. Memory consumption can be reduced and the program performance with regard to the runtime can be improved by omitting unnecessary data transports. This is permitted by the usage of streaming and / or locator objects (LOB handles).
SQL streams and locators are supported as of SAP NetWeaver 7.0 EhP2.
New String expressions
This functionality available as of SAP NetWeaver 7.0 EhP2 offers string templates and string expressions. A string expression formulates an operation with character-like operands. The result of a string expression is a character string. A string expression consists either of one string template or of two or more operands concatenated as a character string using the string operator &&. Each of the operands can itself be a string template. The following formatting options exist: width, align, pad, case, sign, exponent, decimals, zero, style, currency, number, date, time, timestamp, timezone, country.
Regular Expressions (REGEX)
Also available are regular expression defining search pattern used in the statements FIND and REPLACE, and in the string functions COUNT( ), CONTAINS… ( ), FIND( ), MATCH( ), REPLACE( ), SUBSTRING( )
Memory Optimization when Copying Dynamic Data Objects
When values are assigned between strings and between internal tables, they are sharedto save runtime and memory.
Sharing is also used to pass values to procedures. Therefore, there is no major difference with regard to runtime requirements between passing values and
passing references for strings and internal tables.
SAP Education course BC402 – Advanced ABAP provides you with in deep information about all this ABAP news, next to very important ABAP concepts and techniques you can find on the Web page for this course.