DATA and @DATA Inline ABAP declarations available from release 7.40 to help make your code cleaner and more readable
Inline ABAP DATA declarations are a new concept introduced in release 7.4 which allows you to declare your
internal table variables or work areas within the code that uses them. This is done simply by adding the
DATA(wa_data) or @DATA(it_data) statements.
The easiest way to describe this is to show you a very simple before after ABAP code example. Pre 7.40 you would declare a work area and read data into it somthing like this
DATA: it_ekko TYPE STANDARD TABLE OF EKKO, wa_ekko TYPE EKKO. READ IT_EKKO INTO WA_EKKO.
Using the new method you would simply just using the folowing code:
READ TABLE it_ekko INDEX 1 INTO DATA(wa_ekko_new).Hopefully the above example gives you an idea of how this new functionality can streamline your ABAP code and make it more readable. Also gives you the basics so you can have a play yourself. Now onto the @DATA statement....
The @DATA statement- Service Pack 08
The @DATA statement takes this a step further, allowing you to automatically inline declare an internal table to hold values you are selecting from a database table, using the SELECT statement. The only problem with this functionality is that it doesn't come in until Service Pack 08 or SP09. I have tried SP07 and it is definitely not in that and is there by SP09.
If you had a coding example where you declare an internal table to select values into it you would have some code that looked something like this.
TYPES: BEGIN OF t_ekko, ebeln TYPE ekpo-ebeln, ebelp TYPE ekpo-ebelp, statu TYPE ekpo-statu, aedat TYPE ekpo-aedat, matnr TYPE ekpo-matnr, menge TYPE ekpo-menge, meins TYPE ekpo-meins, netpr TYPE ekpo-netpr, peinh TYPE ekpo-peinh, CELLCOLOR TYPE LVC_T_SCOL, END OF t_ekko. DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0, wa_ekko TYPE t_ekko. select ebeln ebelp statu aedat matnr menge meins netpr peinh up to 10 rows from ekpo into CORRESPONDING FIELDS OF TABLE it_ekko.Using the new @DATA statement you could essentially replace all this with the following ABAP code, which automatically create an internal table with the correct field structure and drops the selected values into it. AS well as the @DATA note the ,'s after each field in the SELECT.
select ebeln, ebelp, statu, aedat, matnr, menge, meins, netpr, peinh up to 10 rows from ekpo into TABLE @DATA(it_ekko_new).This is more like it and if you combine the two examples together you get quite a neat and efficient looking section of code. It essentially removes all the ABAP declaration lines of code without adding much at all to SELECT and READ statements.
select ebeln, ebelp, statu, aedat, matnr, menge, meins, netpr, peinh up to 10 rows from ekpo into TABLE @DATA(it_ekko_new). READ TABLE it_ekko_new INDEX 1 INTO DATA(wa_ekko_new2). WRITE:/ wa_ekko_new2.
ABAP Programming EVENTS in SAP
ABAP Function Module basics in SAP
ABAP Workbench Programming Techniques - BC402
ABAP rules to consider before creating a bespoke abap report or program
ABAP Subroutine basics in SAP
Get access to an SAP system for individual needs
SAP Base 64 encoding and decoding using ABAP code
Call web URl from ABAP report or SAP help documentation
Direct download, downloading sap objects
SAP icons and some ABAP code to display them
SAP icons list and their associated codes
Internal Program Environment diplays all internal/external objects and operations used by an SAP program
minisap installation on your local pc to allow ABAP development, your own local SE80
SAP minisap installation on your local pc to allow ABAP development for free
SAP module based information such FI, HR, MM, PM, BW etc
Need an SAP ABAP program created?
SAP repository objects - List of useful standard and bespoke SAP repository objects
Retrieve SAP objects using transport entry in SE10 to restore objects that have been deleted
SAP Help for all areas for SAP ABAP Development inc ABAP, ALV, Web dynpro, bsp, HR, BW
ABAP tutorial - Logging into an SAP system for the first time
Manage and delete SAP sessions using ABAP code
SAP module areas
Increase & Decrease size of SAP editor text
ABAP development information and code examples for producing be-spoke SAP functionality
ABAP Development Info - Example code and information on various areas of ABAP development
SAP command field entries - box in top left corner
Force new page when printing abap source code
ABAP FIELD SYMBOL - Techniques for manupulating data using the FIELD-SYMBOL statement
Hiding ABAP Source Code so that it can not be viewed by anyone
ABAP Internal table declaration - Various methods of creating internal data structures and tables
Parameter ID - ABAP code to demonstrate how to set and get a parameter ID
RANGE statement - Example ABAP code to demonstrate the RANGE command
Change SAP logo in top right hand corner of SAP client
ABAP SELECT statement within SAP - Example ABAP code to demonstrate the SELECT command
Create desktop Shortcut to SAP function
SAP Note assistant - Using transaction SNOTE to read and apply OSS note fix
VARYING command - Example ABAP code to demonstrate the VARYING command
Creating your first helloworld ABAP report in SAP