Quantcast
Channel: SCN : Blog List - ABAP Development
Viewing all articles
Browse latest Browse all 943

New ABAP Features with ABAP 7.40

$
0
0

With the release of AS ABAP 7.40 the ABAP language has some nice new features. Following are few of them –

 

1.    Introduction of real expression oriented feature –

Suppose we have to output a value of column of an internal table for a particular row along with a string.

In earlier releases code look like this –

                        1.png

In SAP 7.40 code is

a.       In-line expression with helper variable, which removes concatenate statement.

     2.png

 

b.      Table expression with helper variable, which removes READ TABLE statement.

3.png

 

 

2.    New style of data declarations

In Prior releases values cannot be assigned in line with data declaration, but possible with release 7.40

                     4.png

          5.png

3.    New Constructor Operators

3.1.        Instantiation Operator NEW

The instantiation operatorNEWis a constructor operator that creates an object reference of class or data.

a.     Syntax ->

…. NEW dTyp | # ( val) …

Creates a data object of data type dTyp or data type of value val having value val

Example ->

6.png

b.     Syntax ->

…. NEW my_class | #(  p1 = v1 p2 = v2 … ) …

Creates an instance of class my_classor depending on the operand type and passes parameter list to instance constructor.

Example ->

7.png

 

3.2.        Constructor Operator VALUE

The value operatorVALUEis a constructor operator that constructs a value for the type specified withtype.

a)            ... VALUE dTyp|#( ) ...

   

Constructs an initial value for any data type.

b)           ... VALUE dTyp|#( comp1 = a1 comp2 = a2 ... ) ...

Constructs a structure where for each component a value can be assigned.

c)            ... VALUE dTyp|#( ( ... ) ( ... ) ... ) ...

Constructs an internal table, where for each line a value can be assigned.

                8.png

 

3.3.        Reference Operator REF

REF Operator is an alternative to the following abap statement.

GET REFERENCE OF dobj INTO r_obj.

Syntax ->

     ... REF dTyp|#(dobj ) ...

3.4.        Casting Operator CAST

CAST Operator performs the narrow or wide cast

 

                9.png

3.5.        Conditional Operator COND

New Conditional operator which assigns the value to an object based on some condition.

Syntax ->

... COND dTyp|#(WHEN log_exp1 THEN result1
                [ WHEN log_exp2 THEN result2 ]
                ...
                [ ELSE resultn ] ) ...

Example ->

                10.png

3.6.        Conditional Operator SWITCH

New Conditional operator which assigns the value to an object based on some condition.

Syntax ->

... SWITCH dTyp|#( operand
                    WHEN const1 THEN result1
                  [ WHEN const2 THEN result2 ]
                  ...
                  [ ELSE resultn ] ) ...

AMAZING !!! UNBELIEVABLE !!!


Viewing all articles
Browse latest Browse all 943

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>