0% found this document useful (0 votes)
208 views31 pages

22 - SAP ABAP New Syntax

SAP ABAP new syntax, introduced in versions 7.4 and 7.5, enhances programming efficiency by allowing inline data declarations and replacing traditional statements like IF and CASE with COND and SWITCH. It introduces several new operators and expressions, such as VALUE, FILTER, and REDUCE, which streamline coding and improve readability. However, new developers may struggle with maintenance projects due to their unfamiliarity with the older syntax.

Uploaded by

P.V. Sooraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
208 views31 pages

22 - SAP ABAP New Syntax

SAP ABAP new syntax, introduced in versions 7.4 and 7.5, enhances programming efficiency by allowing inline data declarations and replacing traditional statements like IF and CASE with COND and SWITCH. It introduces several new operators and expressions, such as VALUE, FILTER, and REDUCE, which streamline coding and improve readability. However, new developers may struggle with maintenance projects due to their unfamiliarity with the older syntax.

Uploaded by

P.V. Sooraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

SAP ABAP New Syntax

1
SAP ABAP New Syntax or ABAP 7.4 / 7.5

▪ During the release of ABAP version 7.4, SAP introduced a new approach to ABAP

programming.

▪ In this new approach of ABAP programming, SAP introduced various new ABAP

elements.

▪ This new approach to ABAP programming is called as SAP ABAP new syntax.

▪ This new approach to the ABAP programming has been introduced from ABAP version

7.4 onwards, So the SAP ABAP new syntax is also called as ABAP 7.4 / 7.5
2
SAP ABAP New Syntax or ABAP 7.4 / 7.5(Contd.)

▪ These new syntax has been added without removing the old syntax.

▪ These new syntax works in both ECC and S/4 HANA systems as it is based upon ABAP

version 7.4 onwards.

3
Advantages

▪ SAP ABAP new syntax are more efficient and convenient way to write the code as we

can write the code using less number of lines.

4
Disadvantages

▪ New developers face difficulties specially in support or maintenance projects, as they

directly starts with new syntax and they have not seen the old syntax.

5
Inline Data Declarations

▪ Inline data declarations is a new way of data declaration.

▪ In old way of data declaration, we need to declare the objects like variables, types,

internal tables and work areas first then we can use those objects.

▪ The old way of declaration is called as explicit or external data declaration.

▪ In the new way of data declaration, there is no need to declare the objects separately.

▪ We can declare the object where we use it.

▪ The keyword DATA is used for inline data declarations.


6
COND Statement as a Replacement of IF

▪ We use IF as a conditional statement.

▪ In SAP ABAP new syntax, instead of IF statement, we can use the COND statement.

▪ In IF statement, we need to specify the variable which is getting filled in every condition.

▪ In COND statement, we need not to mention the variable which is getting filled in every

condition, so COND statement is more effective way for conditional logic rather than IF

statement.

7
SWITCH Statement as a Replacement of CASE

▪ We use CASE also as a conditional statement.

▪ In SAP ABAP new syntax, instead of CASE statement, we can use the SWITCH statement.

▪ In CASE statement, we need to specify the variable which is getting filled in every

condition.

▪ In SWITCH statement, we need not to mention the variable which is getting filled in

every condition.

8
String Expression as a Replacement of CONCATENATE

▪ We use CONCATENATE string operation to combine the strings.

▪ In SAP ABAP new syntax, instead of CONCATENATE, we can use the string expressions.

▪ While using string expression, we need to use the pipe( | ) symbol at the starting and at

the end.

▪ The variables must be enclosed in curly brackets{ }.

▪ There must be a space between bracket and variable.

9
String Expression as a Replacement of CONCATENATE(Contd.)

▪ The various advantages of using string expression are as follows:

⮚ There is no need of using SEPARATED BY in string expression to provide the separator

whereas in CONCATENATE we need to provide the separator using SEPARATED BY.

⮚ There is no need of type casting for numeric data types as string expression works for

both character and numeric data types whereas string operation CONCATENATE is only

applicable for character data types, for numeric data types we need to do the type

casting first.
1
0
VALUE Expression as a Replacement of APPEND

▪ We use APPEND statement to insert the records at the last of the internal table.

▪ In SAP ABAP new syntax, instead of APPEND statement, we can use VALUE expression.

▪ VALUE expression is a powerful mechanism to declare as well as initialize the internal

tables.

▪ It is a powerful utility where we can achieve the result with minimal coding.

1
1
VALUE Expression as a Replacement of APPEND(Contd.)

▪ VALUE expression is of 2 types. The 2 types are as follows:

1. Define the type before using it with VALUE keyword. The type defined is structure type

or table type.

2. Using # character for type and use it with VALUE keyword.

1
2
Use of BASE in VALUE Expression

▪ When we don’t want to overwrite the existing values of the internal table we use BASE

in value expression.

▪ The values of the BASE table acts as a initial values for the target table and after that the

new values are inserted to the target table.

▪ It is very useful in loops when we want to append the rows to the target internal table

using VALUE expression.

1
3
CORRESPONDING Operator

▪ Previously to move data to from one internal table to another internal table which has a

different structure, we need to firstly pass the data from one work area to another work

area and then use the APPEND statement to insert the data to another internal table.

▪ In SAP ABAP new syntax, The CORRESPONDING operator is used to move data between

the internal tables.

1
4
CORRESPONDING Operator( Contd.)

▪ The various version of CORRESPONDING are as follows:

⮚ CORRESPONDING - Moves data between the internal tables for the matching columns.

⮚ CORRESPONDING WITH MAPPING - This is used to map the data of one column to

another column.

⮚ CORRESPONDING WITH EXCEPT - This is used to move the data of the selected matching

columns.

1
5
ALPHA Keyword With IN or OUT as a Replacement of Conversion FM’s

▪ We use the function modules CONVERSION_EXIT_ALPHA_INPUT and

CONVERSION_EXIT_ALPHA_OUTPUT for conversions.

▪ CONVERSION_EXIT_ALPHA_INPUT is used to add the leading zero’s and

CONVERSION_EXIT_ALPHA_OUTPUT is used to remove the leading zero’s.

▪ In SAP ABAP new syntax, instead of using these function modules, we can use the

ALPHA keyword with IN which is used to add the leading zero’s and ALPHA keyword with

OUT to remove the leading zero’s.


1
6
NEW Keyword as a Replacement of CREATE OBJECT Statement

▪ We use CREATE OBJECT statement to create an object of the class.

▪ In SAP ABAP new syntax, instead of CREATE OBJECT, we can use the NEW keyword to

create an object of the class.

1
7
LET Expression

▪ A LET expression defines variables or field symbols in an expression and assign values to

them.

▪ It works as a local helper or local declarations for the expression.

▪ The various important points related to LET expression are as follows:

⮚ Variables or field-symbols defined for LET expression can’t be used outside the scope of

the expression.

1
8
LET Expression(Contd.)

⮚ Variables or field-symbols defined for LET expressions can’t be redefined even if they are

not accessible outside the scope of LET.

⮚ LET expression can be used in expressions like COND, SWITCH, VALUE, NEW, REDUCE

etc.

1
9
CONV Operator

▪ CONV operator is used to convert a value to specified datatype.

▪ Previously when we pass values to function module or class methods parameters, the

variables which are used to pass the values must have the same data type as that of

function module or class methods parameters.

▪ If the variables don’t have the same data type, then we do the type casting by taking the

helper variables and pass the helper variables.

2
0
CONV Operator( Contd.)

▪ In SAP ABAP new syntax, instead of doing the type casting using helper variables and

passing helper variables, we can use CONV operator to convert the value to specified

data type.

2
1
REDUCE Operator As a Replacement of LOOP

▪ It is also called as reduction operator.

▪ Reduce operator creates a result of specified data type after going through iterations.

▪ Previously we make a LOOP on the internal table and calculate the count, total, subtotal

etc.

▪ In SAP ABAP new syntax, instead of LOOP, we can use REDUCE operator to calculate the

count , total, subtotal etc.

2
2
REDUCE Operator As a Replacement of LOOP(Contd.)

▪ The syntax to use a REDUCE operator is as follows:

⮚ REDUCE <type>( INIT ... FOR... THEN... UNTIL... NEXT... )

▪ In the syntax - REDUCE = keyword, <type> = data type of the result , INIT = initial value ,

FOR = initialize iteration , THEN = increment , UNTIL = iteration end condition , NEXT =

operation.

▪ In the REDUCE syntax, even if THEN keyword is not specified the default increment value

is 1.
2
3
FILTER Operator

▪ FILTER operator is used to filter the internal table and getting the subset of data into a

new internal table.

▪ Previously, we filter the data by creating a loop with where condition and appending the

data to new internal table.

▪ In SAP ABAP new syntax, instead of loop with where condition and appending the

filtered data to new internal table, we can use filter operator.

2
4
FILTER Operator(Contd.)

▪ There are 2 ways to apply the FILTER operator.

⮚ FILTER with single values - In this we pass the filtering values using WHERE condition and

filtered data appears into new internal table.

⮚ FILTER with filter table - In this we need two internal tables. One internal table has the

actual data on which filtering is applied and another is filter internal table which has the

filter values used for filtering.

2
5
FILTER Operator(Contd.)

▪ The various important points related to FILTER operator are as follows:

⮚ The internal table on which FILTER operator is used must have at least one sorted key or

one hash key used for access. Filter operation will not work on internal table without

a sort key or hash key.

⮚ The boolean operators OR cannot be used in the WHERE condition.

⮚ EXCEPT can be used with filter statement in single values as well as filter table.

2
6
New Features of OPEN SQL

▪ The separator between the columns is comma(,).

▪ ABAP data objects used in open SQL statements are called as host variables and they are

prefixed with @.

▪ We can use the conditional statements like CASE in the select list.

▪ We can use the literals in the select list.

▪ We can use the aggregate functions like SUM, COUNT, MAX, MIN, AVG.

▪ We can use the arithmetic expressions like + , - , * , DIV, MOD, ABS, FLOOR, CEIL.
2
7
Table Expressions as Replacement of READ TABLE

▪ We use READ TABLE statement to read the first matching record from the internal table.

▪ We read a record from the internal table based upon key or index.

▪ In SAP ABAP new syntax, instead of READ TABLE, we can use the table expressions.

▪ We need to use the square bracket[ ].

▪ In the square bracket, we need to specify the key or index.

2
8
Table Expressions as Replacement of READ TABLE(Contd.)

▪ While using table expression, If the table entry does not exist, system throws the

exception CX_SY_ITAB_LINE_NOT_FOUND.

▪ Use line_exists statement to check the existence of a record.

2
9
JOIN Improvement - Use of symbol *

▪ Previously, if we want to fetch the data of all columns of a table, we can not use * for

that particular table in the join.

▪ In SAP ABAP new syntax, we can use * to fetch the data of all columns of a particular

table in the join.

3
0
Thank You

3
1

You might also like