New Syntax in SAP ABAP 7.4 & 7.5: READ, APPEND & MODIFY

SAP ABAP New Syntax 7.4 & 7.5: What You Need to Know
Master the advanced SAP ABAP 7.4 & 7.5 new syntax. READ TABLE, CONCATENATE, MODIFY, COLLECT, SORT, APPEND — and a full array of new ways of writing code. This is your go-to resource as an SAP developer.
Introduction: The Revolution in ABAP Syntax
If you have had the opportunity to use ABAP syntax over the years, you will know how incredibly frustratingly verbose the older versions of the syntax would be. It would be several lines of code, just to read data from an internal table or to join two text strings together.
The latest syntax in SAP ABAP has introduced a plethora of new code constructs such as: inline declarations, functional method calls, table expressions, string templates, and a rich collection of shorthand notations. This new syntax has made ABAP code concise, legible and maintainable. Practicing with the new syntax is especially important for anyone working on an S/4HANA project, or anyone preparing for an ABAP certification.
This guide has included all of the major transformations for ABAP statements in an opposing fashion, with the older syntax statements versus the newer syntax statements. Use it, reference it, share it, and return to use it frequently!
1. Inline Declarations: The ABAP 7.4 Syntax Essential Building Block
Inline declarations may be the most revolutionary addition with SAP ABAP 7.4, and are certainly the most important to understand before addressing the other newer statements in the language.
Old Syntax
DATA lv_name TYPE string.
lv_name = 'Best Online Career'.
ABAP 7.4
DATA(lv_name) = 'Best Online Career'.
This uses the DATA operator to assign the variable and declare it at the same time. The system infers the type of lv_name. This will become a common theme in the SAP ABAP 7.4 syntax updates.
2. Internal Table Syntax in ABAP: Declare, Fill and Work Smarter
ABAP 7.4 greatly improved the way internal tables are declared. Prior to 7.4, separate declarations for types, data, and work areas were required. All of that has been simplified in the new syntax.
Old Syntax
TYPES: BEGIN OF ty_employee,
empid TYPE i,
name TYPE string,
END OF ty_employee.
DATA: lt_employees TYPE TABLE OF ty_employee,
ls_employee TYPE ty_employee.
New Syntax (ABAP 7.4+)
DATA(lt_employees) = VALUE ty_emp_tab(
( empid = 1 name = 'Rahul Sharma' )
( empid = 2 name = 'Priya Mehta' )
).
Again, the VALUE operator is allowing the internal table to be populated at the time of its declaration. This can be very handy for unit tests and quick prototypes.
3. READ TABLE Syntax in ABAP: Table Expressions
READ TABLE syntax in ABAP used to be the most common line written in any ABAP program. The new table expression syntax has made it a lot shorter.
Old Syntax
READ TABLE lt_employees INTO ls_employee WITH KEY empid = 1.
IF sy-subrc = 0.
WRITE ls_employee-name.
ENDIF.
New Syntax (ABAP 7.4)
DATA(ls_employee) = lt_employees[ empid = 1 ].
WRITE ls_employee-name.
Using the VALUE syntax with DEFAULT lets you read an element from a potentially empty internal table without throwing the CX_SY_ITAB_LINE_NOT_FOUND exception. The following reads the element from the internal table LT_EMPLOYEES (using the key EMPID = 99) and constructs the employee record with the name 'Unknown' if the employee does not exist:
DATA(ls_employee) = VALUE #( lt_employees[ empid = 99 ] DEFAULT VALUE #( name = 'Unknown' ) ).
This example uses a single line of code compared to the traditional READ TABLE syntax with the SY-SUBRC check, which consumes many lines of code.
4. APPEND Syntax in SAP ABAP
ABAP now has new syntax for the APPEND statement and inline declarations.
Standard APPEND
The following uses the old syntax to append a record to an internal table.
Old Syntax
ls_employee-empid = 3.
ls_employee-name = 'Ankit Joshi'.
APPEND ls_employee TO lt_employees.
New Syntax (ABAP 7.4)
APPEND VALUE #( empid = 3 name = 'Ankit Joshi' ) TO lt_employees.
APPEND LINES OF
This statement also conveniently allows you to copy all the lines in an internal table to another one without any looping.
Old Syntax
LOOP AT lt_source INTO ls_employee.
APPEND ls_employee TO lt_target.
ENDLOOP.
New Syntax
APPEND LINES OF lt_source TO lt_target.
And you may append a specific range:
APPEND LINES OF lt_source FROM 1 TO 5 TO lt_target.
5. SORT Syntax in SAP ABAP
The syntax for SORT has not changed much, but when used with all the new features for inline table declarations and the new functional operators, the scope of the SORT command has greatly expanded.
Old Syntax
SORT lt_employees BY name ASCENDING.
New Syntax
SORT lt_employees BY empid DESCENDING name ASCENDING.
In SAP ABAP 7.5 new syntax, after constructing a table with VALUE or CORRESPONDING, you can sort immediately, enabling one-liner pipeline patterns within method chains.
6. COLLECT Syntax in SAP ABAP
COLLECT syntax in SAP ABAP is used for summarizing all numeric fields for the same key entries. Although the statement is structurally the same, the way you can now prepare the data is a lot clearer.
Old Approach
ls_summary-department = 'IT'.
ls_summary-salary = 50000.
COLLECT ls_summary INTO lt_summary.
New Approach Using VALUE Inline
COLLECT VALUE ty_summary( department = 'IT' salary = 50000 ) INTO lt_summary.
COLLECT comes in handy for payroll summaries, budget rollups, and any times where you need data aggregated at the row level and don't want to write out a GROUP BY clause.
7. MODIFY Syntax in SAP ABAP: Update Table Rows in Place
MODIFY syntax in SAP ABAP is used to update one or more rows of an internal table using a key or index.
Old Syntax
READ TABLE lt_employees INTO ls_employee WITH KEY empid = 1.
IF sy-subrc = 0.
ls_employee-name = 'Rahul Kumar'.
MODIFY lt_employees FROM ls_employee INDEX sy-tabix.
ENDIF.
New Syntax (ABAP 7.4 Table Expression + MODIFY)
MODIFY TABLE lt_employees FROM VALUE #( empid = 1 name = 'Rahul Kumar' ).
For index-based modification using a loop with ASSIGNING:
LOOP AT lt_employees ASSIGNING FIELD-SYMBOL(<ls_emp>).
IF <ls_emp>-empid = 1.
<ls_emp>-name = 'Rahul Kumar'.
ENDIF.
ENDLOOP.
Symbols assigned with ASSIGNING reference the table memory, so there's no need for a separate MODIFY statement. The content is altered in-place.
8. DELETE Syntax in SAP ABAP
The delete syntax in SAP ABAP now uses inline conditions to integrate the powerful WHERE clause without needing a loop.
Old Syntax (Loop + Delete)
LOOP AT lt_employees INTO ls_employee.
IF ls_employee-empid = 2.
DELETE lt_employees INDEX sy-tabix.
ENDIF.
ENDLOOP.
New Syntax
DELETE lt_employees WHERE empid = 2.
Multiple conditions:
DELETE lt_employees WHERE empid > 5 AND name = 'Test'.
DELETE WHERE has simplified classic ABAP loop-delete patterns that are most likely to generate errors.
9. CONCATENATE Syntax in SAP ABAP: String Templates
As a result of the new string templates, both the classic CONCATENATE syntax in SAP ABAP and the new method are valid. However, the new method is immensely cleaner.
Old CONCATENATE Syntax in SAP ABAP
CONCATENATE lv_first lv_last INTO lv_full SEPARATED BY ' '.
New CONCATENATE Syntax in SAP ABAP — String Templates
DATA(lv_full) = |{ lv_first } { lv_last }|.
Pipe delimiters with string templates support formatting choices inline:
DATA(lv_message) = |Employee { ls_emp-empid } — { ls_emp-name } joined on { sy-datum DATE = ISO }|.
The SAP ABAP 7.5 string templates offer even further enhancements with the ALPHA, CASE, WIDTH, ALIGN, and PAD formatting options. These enhancements allow string templates to fully replace the use of WRITE TO, CONCATENATE, and many CONDENSE use cases for formatting outputs.
10. CONDENSE Syntax in SAP ABAP
The CONDENSE syntax in SAP ABAP removes leading, trailing and redundant internal spaces from a string.
Classic Usage
CONDENSE lv_name. " Removes leading/trailing spaces
CONDENSE lv_name NO-GAPS. " Removes ALL spaces
In today's world, string templates cover the majority of formatting requirements. Still, CONDENSE is useful for processing strings from external sources, as they often have unpredictable whitespace.
11. CASE Syntax in SAP ABAP: SWITCH and COND Operators
The CASE syntax in SAP ABAP has a functional equivalent starting from 7.4: the SWITCH and COND operators.
Classic CASE
CASE lv_grade.
WHEN 'A'. lv_result = 'Excellent'.
WHEN 'B'. lv_result = 'Good'.
WHEN OTHERS. lv_result = 'Average'.
ENDCASE.
New SWITCH Operator
DATA(lv_result) = SWITCH #( lv_grade
WHEN 'A' THEN 'Excellent'
WHEN 'B' THEN 'Good'
ELSE 'Average' ).
COND Operator (for conditional expressions)
DATA(lv_status) = COND #(
WHEN lv_score >= 90 THEN 'Distinction'
WHEN lv_score >= 60 THEN 'Pass'
ELSE 'Fail' ).
Both SWITCH and COND can be used inline inside method calls, VALUE constructors, WRITE statements, etc., eliminating the need for intermediate variables.
12. FOR ALL ENTRIES in SAP ABAP Syntax
The structure of for all entries in SAP ABAP syntax remains consistent, but their application in S/4HANA and ABAP 7.5 has clarified best practices.
Standard Usage
IF lt_employees IS NOT INITIAL.
SELECT empid, name, department
FROM zhr_master
INTO TABLE @DATA(lt_hr_data)
FOR ALL ENTRIES IN @lt_employees
WHERE empid = @lt_employees-empid.
ENDIF.
Key rule: an IS NOT INITIAL check must precede the use of FOR ALL ENTRIES — if the driver table is empty, the SELECT statement will retrieve all rows from the database table, which negatively impacts performance.
In SAP ABAP new syntax 7.5, the @ escape character must be used before host variables in Open SQL, and INTO TABLE @DATA(...) allows fully inline declarations of the result table.
13. EXPORT Syntax in SAP ABAP
The export syntax in SAP ABAP is used with ABAP memory or shared objects to transfer data between programs or between screens.
Classic Usage
EXPORT lv_empid = lv_empid TO MEMORY ID 'EMP_DATA'.
Import Counterpart
IMPORT lv_empid = lv_empid FROM MEMORY ID 'EMP_DATA'.
Though EXPORT/IMPORT to memory continues to be used in screen-based programs, increasingly modern ABAP development relies on interfaces and methods for data transfer between programs.
14. CALL TRANSACTION Syntax in SAP ABAP
The call transaction syntax in SAP ABAP allows the invocation of other SAP transactions within an ABAP program, with or without a BDC (Batch Data Communication) session.
Basic Call
CALL TRANSACTION 'MM03'.
With BDC and Options
CALL TRANSACTION 'MM01'
USING lt_bdcdata
MODE 'N'
UPDATE 'S'
MESSAGES INTO lt_messages.
MODE 'N' means the transaction will run in the background and no screen is displayed. MODE 'A' will display all screens. MODE 'E' will display only error screens, which is the pattern used in most of the mass data entry automation.
15. CALL SUBSCREEN Syntax in SAP ABAP
The CALL SUBSCREEN syntax used in SAP ABAP is a method of including a subscreen area within a main screen, also known as a module pool screen.
In the Screen Painter layout, introduce a subscreen area and name it AREA1.
In the PBO Module
CALL SUBSCREEN area1
INCLUDING sy-repid '0200'.
The main screen will include subscreen number 0200 of the current program. Subscreen areas facilitate the development of tab dialogs, as well as flexible and reusable screen components within the framework of classical Dynpro.
16. CHECKBOX Syntax in SAP ABAP
The CHECKBOX syntax in SAP ABAP is used in selection screens as well as classical Dynpro screens, and provides means for a binary choice of user input.
Checkbox in a Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
PARAMETERS: p_active AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK b1.
Since p_active is a CHECKBOX, if it is selected, the value will be X. If it is not selected, the value will be a space (or blank). In a typical report logic, the CHECKBOX is evaluated as follows:
IF p_active = abap_true.
" Execute only when checkbox is selected
ENDIF.
Using abap_true, that is 'X', is preferred as it is cleaner and more self-documenting than a hard-coded character literal.
Quick Reference: Old vs New SAP ABAP Syntax
| Operation | Old Syntax | New Syntax (7.4/7.5) |
|---|---|---|
| Variable declaration | DATA lv_x TYPE i. |
DATA(lv_x) = 5. |
| Read table row | READ TABLE lt INTO ls WITH KEY ... |
DATA(ls) = lt[ key = val ]. |
| Append row | APPEND ls TO lt. |
APPEND VALUE #(...) TO lt. |
| Append all rows | Loop + APPEND | APPEND LINES OF lt_src TO lt_tgt. |
| Delete rows | Loop + DELETE INDEX | DELETE lt WHERE condition. |
| CASE expression | CASE / WHEN / ENDCASE | SWITCH #( ... ) or COND #( ... ) |
| String join | CONCATENATE a b INTO c SEP ' '. |
DATA(c) = |{ a } { b }|. |
| Open SQL result | INTO TABLE lt_result |
INTO TABLE @DATA(lt_result) |
Why Learning New SAP ABAP Syntax is Beneficial for Your Career
SAP S/4HANA runs on ABAP 7.5+. If you work for a company migrating from SAP ECC to SAP S/4HANA, they expect you to know 7.5+ ABAP. They won't be maintaining ABAP coding standards from the 1990s. They will be expecting you to know how to code in a performant and modern way. ABAP 7.4/7.5 is so relevant right now that job descriptions will be specifically recruiting for it and SAP certification exams have changed to include questions on these new ABAP versions and coding syntax.
Here at Best Online Career, the breadth of our SAP ABAP courses includes comprehensive training from the traditional foundations right through to new syntaxes, CDS Views, BTP integration, and S/4HANA development cycles. No matter if you are just starting your career, or you are a skilled consultant wanting to advance your career, we help you get job ready faster with our well-defined learning framework.
Conclusion
The new syntax in SAP ABAP incorporated in 7.4 and 7.5 is not simply a case of syntactic sugar. The new inline declarations, table expressions, and string templates among other new structures introduced aid the developer by making the code more concise and less verbose.
Developers that are keen to learn all the ways SAP ABAP iterations have modified syntax — such as from read table to append lines, from modify to condense syntax — will gain the advantage of being a developer that is modern and ready for SAP S/4HANA.
Do you want to learn more? Sign up and implement your skills with our SAP ABAP Course at Best Online Career. To learn more about our courses, fees, and to book a demo class, head to Best Online Career or contact our team directly.
Related SAP Training Courses
Tags
Share this article
Help others discover this valuable SAP content


