0% found this document useful (0 votes)
42 views3 pages

SAP ABAP 7.4 Syntax

The document outlines new syntax features introduced in SAP ABAP 7.4/7.5, including inline data declarations, conditional statements, and various SQL enhancements. It covers topics such as the COND statement, SWITCH statement, table expressions, and new keywords for object creation, along with examples for each. Additionally, it discusses debugging complex expressions and the use of SQL window functions.

Uploaded by

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

SAP ABAP 7.4 Syntax

The document outlines new syntax features introduced in SAP ABAP 7.4/7.5, including inline data declarations, conditional statements, and various SQL enhancements. It covers topics such as the COND statement, SWITCH statement, table expressions, and new keywords for object creation, along with examples for each. Additionally, it discusses debugging complex expressions and the use of SQL window functions.

Uploaded by

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

SAP ABAP 7.4/7.

5 New Syntax Topics with Examples

1. Inline Data Declarations

DATA(lv_sum) = 5 + 3.

2. COND Statement

DATA(lv_result) = COND string(


WHEN sy-subrc = 0 THEN 'Success'
WHEN sy-subrc = 4 THEN 'No Data'
ELSE 'Error'
).

3. SWITCH Statement

DATA(lv_status) = SWITCH string( sy-subrc


WHEN 0 THEN 'OK'
WHEN 1 THEN 'Minor Issue'
ELSE 'Fail'
).

4. Purpose of #

DATA(lv_text) = VALUE string( # 'Auto typed text' ).

5. String Expressions

DATA(lv_fullname) = |{ lv_firstname } { lv_lastname }|.

6. VALUE Expression

DATA(lt_numbers) = VALUE int4_tab( ( 1 ) ( 2 ) ( 3 ) ).

7. Use of BASE in VALUE Expression

DATA lt_base TYPE STANDARD TABLE OF i WITH EMPTY KEY.


lt_base = VALUE #( ( 1 ) ( 2 ) ).
lt_base = VALUE #( BASE lt_base ( 3 ) ( 4 ) ).

8. Corresponding Operator

DATA: ls1 TYPE ty_struct1, ls2 TYPE ty_struct2.


ls2 = CORRESPONDING #( ls1 ).

9. ALPHA Keyword with IN or OUT

DATA(lv_matnr) = |000000001234567890|.
lv_matnr = |{ lv_matnr ALPHA = OUT }|. " Removes leading zeros
SAP ABAP 7.4/7.5 New Syntax Topics with Examples

10. Table Expressions

DATA(lv_name) = lt_emp[ id = 'E01' ]-name.

11. LOOP AT GROUPS

LOOP AT GROUPS carrid_group ASSIGNING FIELD-SYMBOL(<group>)


GROUP BY spfli-carrid.
WRITE: / <group>-carrid.
ENDLOOP.

12. New Keyword for Object Creation

DATA(lo_obj) = NEW cl_demo_class( ).

13. LET Expression

DATA(lv_final) = LET sum = a + b IN sum * 2.

14. CONV Operator

DATA(lv_string) = CONV string( lv_int ).

15. REDUCE Operator

DATA(lv_sum) = REDUCE i( INIT x = 0 FOR num IN lt_tab NEXT x = x + num ).

16. FILTER

DATA(lt_filtered) = FILTER #( lt_data USING KEY key_name WHERE field = 'X' ).

17. Open SQL - Comma-Separated Columns

SELECT carrid, connid, cityfrom, cityto


FROM spfli
INTO TABLE @DATA(lt_flights).

18. Open SQL - Conditional Statements

SELECT carrid,
CASE WHEN cityfrom = 'FRANKFURT' THEN 'Yes' ELSE 'No' END AS from_frankfurt
FROM spfli
INTO TABLE @DATA(lt_flights).

19. Open SQL - Literals

SELECT * FROM scarr INTO TABLE @DATA(lt_carriers)


WHERE carrid = @'LH'.
SAP ABAP 7.4/7.5 New Syntax Topics with Examples

20. Open SQL - Aggregate Functions

SELECT COUNT(*) AS total FROM spfli INTO @DATA(lv_count).

21. Open SQL - Arithmetic Functions

SELECT carrid, connid, price * 1.12 AS price_with_tax FROM sflight INTO TABLE
@DATA(lt_result).

22. Parallel Cursor - New Syntax

LOOP AT lt_header INTO DATA(ls_header).


LOOP AT lt_item INTO DATA(ls_item) FROM sy-tabix WHERE hkey = ls_header-hkey.
" process
ENDLOOP.
ENDLOOP.

23. Debugging Complex ABAP Expressions

Use "ABAP Debugger" and press F2 or Right-Click > Display Expression.

24. SQL Window Expression

SELECT carrid, connid, RANK() OVER (PARTITION BY carrid ORDER BY price DESC) AS rank
FROM sflight
INTO TABLE @DATA(lt_ranked).

25. SQL Window Function with Frames

SELECT carrid, connid,


SUM(price) OVER (PARTITION BY carrid ORDER BY connid ROWS BETWEEN 1 PRECEDING AND
CURRENT ROW) AS sum_price
FROM sflight
INTO TABLE @DATA(lt_window).

26. SQL Window Function (Rank and Value)

SELECT carrid, connid, price,


RANK() OVER (PARTITION BY carrid ORDER BY price DESC) AS rank
FROM sflight
INTO TABLE @DATA(lt_ranked).

27. Indicator Structures

DATA indicator TYPE STRUCTURE indicator_structure.

You might also like