ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.
com/2015/10/25/abap-740-quick-reference/
Home / Community / Blogs
ABAP 7.40 Quick Reference
October 25, 2015 | 94,990 Views |
Jeffrey Towell
more by this author
ABAP Development
SAP NetWeaver | 740 | abap | document | overveiw | reference | sap netweaver
share
0 share
18 tweet share
0
Follow
Share & Follow
Privacy Terms of Use Legal Disclosure Copyright Trademark Sitemap Newsletter
1 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
So you’re an experienced ABAP programmer wanting to leverage off the
fantastic new functionality available to you in ABAP 7.40!
However, searching for information on this topic leads you to fragmented
pages or blogs that refer to only a couple of the new features available to
you.
What you need is a quick reference guide which gives you the essentials
you need and shows you how the code you are familiar with can be
improved with ABAP 7.40.
The below document contains exactly this!
It gives examples of “classic” ABAP and its 740 equivalent. It goes into more
details on the more difficult topics normally via examples. This allows the
reader to dive in to the level they desire. While this document does not
contain everything pertaining to ABAP 740 it certainly covers the most
useful parts in the experience of the author.
The document has been compiled by drawing on existing material available
online as well as trial and error by the author. In particular the blogs by Horst
Keller have been useful and are the best reference I have found (prior to this
document ). He has a landing page of sorts for his various blogs on the topic
here:
ABAP Language News for Release 7.40
Credit also goes to Naimesh Patel for his useful explanations and examples
on ABAP 7.40. Here is his example of the “FOR iteration expression” which I
leaned on (links to his other 740 articles can be found at the bottom of the
link):
http://zevolving.com/2015/05/abap-740-for-iteration-expression/
I compiled the below document to make the transition to using ABAP 740
easier for myself and my project team. It has worked well for us and I hope it
will do the same for you.
Regards,
Jeff Towell
2 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
41 Comments
You must be Logged on to comment or reply to a post.
3 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
4 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
5 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
6 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
7 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
8 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
9 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
10 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
Same is true for “thomas” a few lines below.
Nevertheless this is the first example I found, where the advantage of meshes can be
seen.
All the best
Michael
Jeffrey Towell Post author
May 19, 2016 at 1:03 pm
Thanks for pointing that out Michael. I have corrected that.
The amazing thing is that the code is a copy and paste from a working
program I wrote and still have. I’ve noticed the “<” and “>” get stripped
off my field symbols in this document before. My theory is that when it
gets converted to HTML that the field symbols sometimes look like
HTML tags because they are between the <>. As such they are
sometimes stripped out by this conversion to HTML.
That’s my theory anyway.
Thanks again.
Michael Calekta
May 19, 2016 at 1:17 pm
Sorry to interrupt again, but it was not only the <> missing,
which you have corrected, but also the ls_ which is still
missing. I don’t think this can get lost by an html-
conversion-error. Perhaps a missing definition and value
assignment from the original coding.
I have copied the example and tried it, and it really works
fine, once I could eliminate the syntax-errors because of the
missing letters.
11 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
12 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
13 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
APPEND INITIAL LINE TO rt_config_pers_data ASSIGNING FIELD–
SYMBOL(<fs>).
MOVE-CORRESPONDING rs_config_pers_data to <fs>.
<fs>–pers_for_user = wa_touser–low.
ENDLOOP.
is it possible to do such actions in one statement ?
Jeffrey Towell Post author
August 19, 2016 at 12:07 am
Hi Konstantin,
Its possible to get it on one line by using each component of the
structure instead of the “CORRESPONDING”. In your case this would
look like:
DATA(rt_config_pers_data) =
VALUE bsp_dlct_pers( FOR wa_touser IN touser
( pers_for_user = wa_touser–low
component = rs_config_pers_data–component
viewname = rs_config_pers_data–viewname
role_key = rs_config_pers_data–role_key
component_usage = rs_config_pers_data–component_usage
object_type = rs_config_pers_data–object_type
object_sub_type = rs_config_pers_data–object_sub_type
changed_by = rs_config_pers_data–changed_by
changed_at = rs_config_pers_data–changed_at
config = rs_config_pers_data–config
14 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
15 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
16 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
17 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
18 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
[ASCENDING|DESCENDING [AS TEXT]]
[WITHOUT MEMBERS]
[{INTO group}|{ASSIGNING <group>}]
[LOOP AT GROUP group|<group>
ENDLOOP.]
ENDLOOP.
II. Explanation
The outer loop will do one iteration per key. So if 3 records match the key there
will only be one iteration for these 3 records. The structure “group” (or
“<group>” ) is unusual in that it can be looped over using the “LOOP AT
GROUP” statement. This will loop over the 3 records (members) of the group.
The
structure “group” also contains the current key as well as the size of the group
and index of the group ( if GROUP SIZE and GROUP INDEX have been
assigned a field name). This is best understood by an example.
19 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
III. Example
With 7.40
TYPES: BEGIN OF ty_employee,
name TYPE char30,
role TYPE char30,
age TYPE i,
END OF ty_employee,
ty_employee_t TYPE STANDARD TABLE OF ty_employee WITH KEY name.
DATA(gt_employee) = VALUE ty_employee_t(
( name = ‘John‘ role = ‘ABAP guru‘ age = 34 )
( name = ‘Alice‘ role = ‘FI Consultant‘ age = 42 )
( name = ‘Barry‘ role = ‘ABAP guru‘ age = 54 )
( name = ‘Mary‘ role = ‘FI Consultant‘ age = 37 )
( name = ‘Arthur‘ role = ‘ABAP guru‘ age = 34 )
( name = ‘Mandy‘ role = ‘SD Consultant‘ age = 64 ) ).
DATA: gv_tot_age TYPE i,
gv_avg_age TYPE decfloat34.
“Loop with grouping on Role
LOOP AT gt_employee INTO DATA(ls_employee)
GROUP BY ( role = ls_employee-role
size = GROUP SIZE
index = GROUP INDEX )
ASCENDING
ASSIGNING FIELD-SYMBOL(<group>).
CLEAR: gv_tot_age.
“Output info at group level
WRITE: / |Group: { <group>-index } Role: { <group>-role WIDTH = 15 }|
&| Number in this role: { <group>-size }|.
20 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
With 7.40
“Loop at members of the group
LOOP AT GROUP <group> ASSIGNING FIELD-SYMBOL(<ls_member>).
gv_tot_age = gv_tot_age + <ls_member>-age.
WRITE: /13 <ls_member>-name.
ENDLOOP.
“Average age
gv_avg_age = gv_tot_age / <group>-size.
WRITE: / |Average age: { gv_avg_age }|.
SKIP.
ENDLOOP.
IV. Output
Group: 1 Role: ABAP guru Number in this role: 3
John
Barry
Arthur
Average age: 40.66666666666666666666666666666667
Group: 2 Role: FI Consultant Number in this role: 2
Alice
Mary
Average age: 39.5
Group: 3 Role: SD Consultant Number in this role: 1
Mandy
Average age: 64
11. Classes/Methods
I. Referencing fields within returned structures
Before 7.40
DATA: ls_lfa1 TYPE lfa1,
lv_name1 TYPE lfa1–name1.
ls_lfa1 = My_Class=>get_lfa1( ).
21 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
Before 7.40
lv_name1 = ls_lfa1–name1.
With 7.40
DATA(lv_name1) = My_Class=>get_lfa1( )–name1.
II. Methods that return a type BOOLEAN
Before 7.40
IF My_Class=>return_boolean( ) = abap_true.
…
ENDIF.
With 7.40
IF My_Class=>return_boolean( ).
…
ENDIF.
NB: The type “BOOLEAN” is not a true Boolean but a char1 with allowed
values X,- and <blank>.
Using type “FLAG” or “WDY_BOOLEAN” works just as well.
III. NEW operator
This operator can be used to instantiate an object.
Before 7.40
DATA: lo_delivs TYPE REF TO zcl_sd_delivs,
lo_deliv TYPE REF TO zcl_sd_deliv.
CREATE OBJECT lo_delivs.
CREATE OBJECT lo_deliv.
lo_deliv = lo_delivs->get_deliv( lv_vbeln ).
With 7.40
DATA(lo_deliv) = new zcl_sd_delivs( )->get_deliv( lv_vbeln
12. Meshes
Allows an association to be set up between related data groups.
22 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
I. Problem
Given the following 2 internal tables:
TYPES: BEGIN OF t_manager,
name TYPE char10,
salary TYPE int4,
END OF t_manager,
tt_manager TYPE SORTED TABLE OF t_manager WITH UNIQUE KEY name.
TYPES: BEGIN OF t_developer,
name TYPE char10,
salary TYPE int4,
manager TYPE char10, “Name of manager
END OF t_developer,
tt_developer TYPE SORTED TABLE OF t_developer WITH UNIQUE KEY
name.
Populated as follows:
Row Name[C(10)] Salary[I(4)]
1 Jason 3000
2 Thomas 3200
Row Name[C(10)] Salary[I(4) Manager[C(10)]
1 Bob 2100 Jason
2 David 2000 Thomas
3 Jack 1000 Thomas
4 Jerry 1000 Jason
5 John 2100 Thomas
6 Tom 2000 Jason
Get the details of Jerry’s manager and all developers managed by Thomas.
II. Solution
With 7.40
23 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
With 7.40
TYPES: BEGIN OF MESH m_team,
managers TYPE tt_manager ASSOCIATION my_employee
ON manager = name,
developers TYPE tt_developer ASSOCIATION my_manager
ON name = manager,
END OF MESH m_team.
DATA: ls_team TYPE m_team.
ls_team–managers = lt_manager.
ls_team–developers = lt_developer.
*Get details of Jerry’s manager *
“get line of dev table
ASSIGN lt_developer[ name = ‘Jerry’ ] TO FIELD–SYMBOL(<ls_jerry>
DATA(ls_jmanager) = ls_team–developers\my_manager[ <ls_jerry> ]
WRITE: / |Jerry‘s manager: { ls_jmanager-name }|,30
|Salary: { ls_jmanager-salary }|.
“Get Thomas’ developers
SKIP.
WRITE: / |Thomas‘ developers:|.
“line of manager table
ASSIGN lt_manager[ name = ‘Thomas’ ] TO FIELD–SYMBOL(<ls_thomas>
LOOP AT ls_team–managers\my_employee[ <ls_thomas> ]
ASSIGNING FIELD–SYMBOL(<ls_emp>).
WRITE: / |Employee name: { <ls_emp>–name }|.
ENDLOOP.
III. Output
Jerry’s manager: Jason Salary: 3000
Thomas’ developers:
Employee name: David
Employee name: Jack
Employee name: John
13. Filter
24 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
Filter the records in a table based on records in another table.
I. Definition
… FILTER type( itab [EXCEPT] [IN ftab] [USING KEY keyname]
WHERE c1 op f1 [AND c2 op f2 […]] )
II. Problem
Filter an internal table of Flight Schedules (SPFLI) to only those flights
based on a filter table that contains the fields Cityfrom and CityTo.
III. Solution
With 7.40
TYPES: BEGIN OF ty_filter,
cityfrom TYPE spfli–cityfrom,
cityto TYPE spfli–cityto,
f3 TYPE i,
END OF ty_filter,
ty_filter_tab TYPE HASHED TABLE OF ty_filter
WITH UNIQUE KEY cityfrom cityto.
DATA: lt_splfi TYPE STANDARD TABLE OF spfli.
SELECT * FROM spfli APPENDING TABLE lt_splfi.
DATA(lt_filter) = VALUE ty_filter_tab( f3 = 2
( cityfrom = ‘NEW YORK’ cityto = ‘SAN FRANCISCO’
( cityfrom = ‘FRANKFURT’ cityto = ‘NEW YORK’
DATA(lt_myrecs) = FILTER #( lt_splfi IN lt_filter
WHERE cityfrom = cityfrom
AND cityto = cityto ).
“Output filtered records
LOOP AT lt_myrecs ASSIGNING FIELD–SYMBOL(<ls_rec>).
WRITE: / <ls_rec>–carrid,8 <ls_rec>–cityfrom,30
<ls_rec>–cityto,45 <ls_rec>–deptime.
ENDLOOP.
Note: using the keyword “EXCEPT” (see definition above) would have
returned the exact opposite records i.e all records EXCEPT for those those
25 of 26 08-03-2018, 16:57
ABAP 7.40 Quick Reference | SAP Blogs https://blogs.sap.com/2015/10/25/abap-740-quick-reference/
returned above.
Alert Moderator
26 of 26 08-03-2018, 16:57