SAP ABAP Performance Tuning
Tips & Tricks
Introduction
Need for performance tuning
In this world of SAP programming, ABAP is the universal language. In most of the projects, the focus is on getting a team of ABAP programmers as soon as possible, handing over the technical specifications to them and asking them to churn out the ABAP programs within the “given deadlines”.
Often due to this pressure of schedules and deliveries, the main focus of making a efficient program takes a back seat. An efficient ABAP program is one which delivers the required output to the user in a finite time as per the complexity of the program, rather than hearing the comment “I put the program to run, have my lunch and come back to check the results”.
Leaving aside the hyperbole, a performance optimized ABAP program saves the time of the end user, thus increasing the productivity of the user, and in turn keeping the user and the management happy.
This tutorial focuses on presenting various performance tuning tips and tricks to make the ABAP programs efficient in doing their work. This tutorial also assumes that the reader is well versed in all the concepts and syntax of ABAP programming.
NOTE: Performance of a program is also often limited due to hardware restrictions, which is out of the scope of this article.
Using Selection Criteria
Use of selection criteria
Instead of selecting all the data and doing the processing during the selection, it is advisable to restrict the data to the selection criteria itself, rather than filtering it out using the ABAP code.
Not recommended
Select * from zflight.
Check : zflight-airln = ‘LF’ and zflight-fligh = ‘BW222’.
Endselect.
Recommended
Select * from zflight where airln = ‘LF’ and fligh = ‘222’.
Endselect.
One more point to be noted here is of the select *. Often this is a lazy coding practice. When a programmer gives select * even if one or two fields are to be selected, this can significantly slow the program and put unnecessary load on the entire system. When the application server sends this request to the database server, and the database server has to pass on the entire structure for each row back to the application server. This consumes both CPU and networking resources, especially for large structures.
Thus it is advisable to select only those fields that are needed, so that the database server passes only a small amount of data back.
Also it is advisable to avoid selecting the data fields into local variables as this also puts unnecessary load on the server. Instead attempt must be made to select the fields into an internal table.
============================================================================
Using Aggregate Functions
Use of aggregate functions
Use the already provided aggregate functions, instead of finding out the minimum/maximum values using ABAP code.
Not recommended
Maxnu = 0.
Select * from zflight where airln = ‘LF’ and cntry = ‘IN’.
Check zflight-fligh > maxnu.
Maxnu = zflight-fligh.
Endselect.
Recommended
Select max( fligh ) from zflight into maxnu where airln = ‘LF’ and cntry = ‘IN’.
The other aggregate functions that can be used are min (to find the minimum value), avg (to find the average of a Data interval), sum (to add up a data interval) and count (counting the lines in a data selection).
============================================================================
Using Views instead of Base Tables
Use of Views instead of base tables
Many times ABAP programmers deal with base tables and nested selects. Instead it is always advisable to see whether there is any view provided by SAP on those base tables, so that the data can be filtered out directly, rather than specially coding for it.
Not recommended
Select * from zcntry where cntry like ‘IN%’.
Select single * from zflight where cntry = zcntry-cntry and airln = ‘LF’.
Endselect.
Recommended
Select * from zcnfl where cntry like ‘IN%’ and airln = ‘LF’.
Endselect.
============================================================================
Using the Into Table Clause
Use of the into table clause of select statement
Instead of appending one record at a time into an internal table, it is advisable to select all the records in a single shot.
Not recommended
Refresh: int_fligh.
Select * from zflight into int_fligh.
Append int_fligh. Clear int_fligh.
Endselect.
Recommended
Refresh: int_fligh.
Select * from zflight into table int_fligh.
============================================================================
Modifying a Group of Lines
Modifying a group of lines of an internal table
Use the variations of the modify command to speed up this kind of processing.
Not recommended
Loop at int_fligh.
If int_fligh-flag is initial.
Int_fligh-flag = ‘X’.
Endif.
Modify int_fligh.
Endloop.
Recommended
Int_fligh-flag = ‘X’.
Modify int_fligh transporting flag where flag is initial.
============================================================================
Use of Binary Search Option
Use of binary search option
When a programmer uses the read command, the table is sequentially searched. This slows down the processing. Instead of this, use the binary search addition. The binary search algorithm helps faster search of a value in an internal table. It is advisable to sort the internal table before doing a binary search. Binary search repeatedly divides the search interval in half. If the value to be searched is less than the item in the middle of the interval, the search is narrowed to the lower half, otherwise the search is narrowed to the upper half.
Not Recommended
Read table int_fligh with key airln = ‘LF’.
Recommended
Read table int_fligh with key airln = ‘LF’ binary search.
============================================================================
Appending Internal Tables
Appending 2 internal tables
Instead of using the normal loop-endloop approach for this kind of programming, use the variation of the append command. Care should be taken that the definition of both the internal tables should be identical.
Not Recommended
Loop at int_fligh1.
Append int_fligh1 to int_fligh2.
Endloop.
Recommended
Append lines of int_fligh1 to int_fligh2.
============================================================================
Using Table Buffering
Using table buffering
Use of buffered tables is recommended to improve the performance considerably. The buffer is bypassed while using the following statements
1. Select distinct
2. Select … for update
3. Order by, group by, having clause
4. Joins
Use the Bypass buffer addition to the select clause in order to explicitly bypass the buffer while selecting the data.
============================================================================
Use of FOR ALL Entries
Use of FOR ALL Entries
Outer join can be created using this addition to the where clause in a select statement. It speeds up the performance tremendously, but the cons of using this variation are listed below
1. Duplicates are automatically removed from the resulting data set. Hence care should be taken that the unique key of the detail line items should be given in the select statement.
2. If the table on which the For All Entries IN clause is based is empty, all rows are selected into the destination table. Hence it is advisable to check before-hand that the first table is not empty.
3. If the table on which the For All Entries IN clause is based is very large, the performance will go down instead of improving. Hence attempt should be made to keep the table size to a moderate level.
Not Recommended
Loop at int_cntry.
Select single * from zfligh into int_fligh
where cntry = int_cntry-cntry.
Append int_fligh.
Endloop.
Recommended
Select * from zfligh appending table int_fligh
For all entries in int_cntry
Where cntry = int_cntry-cntry.
============================================================================
Proper Structure of the WHERE Clause
Proper structure of Where Clause
When a base table has multiple indices, the where clause should be in the order of the index, either a primary or a secondary index.
To choose an index, the optimizer checks the field names specified in the where clause and then uses an index that has the same order of the fields. One more tip is that if a table begins with MANDT, while an index does not, there is a high possibility that the optimizer might not use that index.
In certain scenarios, it is advisable to check whether a new index can speed up the performance of a program. This will come handy in programs that access data from the finance tables.
============================================================================
Proper Use of Move Statement
Proper use of Move statement
Instead of using the move-corresponding clause it is advisable to use the move statement instead. Attempt should be made to move entire internal table headers in a single shot, rather than moving the fields one by one.
============================================================================
Proper use of INNER JOIN Statement
Proper use of Inner Join
When multiple SAP tables are logically joined, it is always advisable to use inner join to read the data from them. This certainly reduces the load on the network.
Let us take an example of 2 tables, zairln and zflight. The table zairln has the field airln, which is the airline code and the field lnnam, which is the name of the airline. The table zflight has the field airln, the airline code and other fields which hold the details of the flights that an airline operates.
Since these 2 tables a re logically joined by the airln field, it is advisable to use the inner join.
Select a~airln a~lnnam b~fligh b~cntry into table int_airdet
From zairln as a inner join zflight as b on a~airln = b~airln.
In order to restrict the data as per the selection criteria, a where clause can be added to the above inner join.
============================================================================
Use ABAP SORT instead or ORDER BY
Use of ABAP Sort instead of Order By
The order by clause is executed on the database server, while the sort statement is executed on the application server. Thus instead of giving the order by in the select clause statement, it is better to collect the records in an internal table and then use the sort command to sort the resulting data set.
============================================================================
Performance Analysis Tools
Tools provided for Performance Analysis
Following are the different tools provided by SAP for performance analysis of an ABAP object
1. Run time analysis transaction SE30
This transaction gives all the analysis of an ABAP program with respect to the database and the non-database processing.
2. SQL Trace transaction ST05
The trace list has many lines that are not related to the SELECT statement in the ABAP program. This is because the execution of any ABAP program requires additional administrative SQL calls. To restrict the list output, use the filter introducing the trace list.
The trace list contains different SQL statements simultaneously related to the one SELECT statement in the ABAP program. This is because the R/3 Database Interface - a sophisticated component of the R/3 Application Server - maps every Open SQL statement to one or a series of physical database calls and brings it to execution. This mapping, crucial to R/3s performance, depends on the particular call and database system. For example, the SELECT-ENDSELECT loop on the SPFLI table in our test program is mapped to a sequence PREPARE-OPEN-FETCH of physical calls in an Oracle environment.
The WHERE clause in the trace list's SQL statement is different from the WHERE clause in the ABAP statement. This is because in an R/3 system, a client is a self-contained unit with separate master records and its own set of table data (in commercial, organizational, and technical terms). With ABAP, every Open SQL statement automatically executes within the correct client environment. For this reason, a condition with the actual client code is added to every WHERE clause if a client field is a component of the searched table.
To see a statement's execution plan, just position the cursor on the PREPARE statement and choose Explain SQL. A detailed explanation of the execution plan depends on the database system in use.
============================================================================
Wednesday, November 19, 2008
List of ABAP keywords
Key word Short text
, [, ], {, } Syntax conventions, Syntax notation
*, " Comments
** Arithm. Operator: Exponentiation (COMPUTE)
+, -, *, / Arithmetical operators (COMPUTE)
->, =>, ->>, ~, ?= Operators in ABAP Objects
ABS Mathematical function: Absolute amount COMPUTE)
ACOS Mathematical function: Cosine arc (COMPUTE)
ADD Add
ADD-CORRESPONDING Field string addition
ADJACENT DUPLICATES Delete duplicates from internal table (DELETE)
AND Comparison operator: and
ANY TABLE Generic table type for internal tables
APPEND Append line to internal table
ASIN Mathematical function: Sine arc (COMPUTE)
ASSIGN Assign field symbol
AT Event, control break, field group determination
ATAN Mathematical function: Tangent arc
AUTHORITY-CHECK Check authorization
AVG Aggregate expression: Average (SELECT)
BACK Positioning in list
BETWEEN Relational operator: Between
BINARY SEARCH Binary read of internal table (READ TABLE)
BIT-NOT Bit calculation operator: NOT (COMPUTE)
BIT-AND Bit calculation operator: AND (COMPUTE)
BIT-OR Bit calculation operator: OR (COMPUTE)
BIT-XOR Bit calculation operator: AND/OR (COMPUTE)
SET BIT Set bit of an X field
GET BIT Read bit of an X field
BLANK LINES Switch on blank lines in list
BREAK-POINT Stop processing in debug mode
C Data type for fixed-length character string
CA Relational operator for string comparison:
CALL Call external component
CASE Begin case distinction
CATCH Exception handling (catch runtime errors)
CEIL Mathematical function: Smallest whole value
(COMPUTE)
CENTERED Output format: Centered (WRITE)
CHECK Check condition
CHECKBOX Display as checkbox
PARAMETERS ... AS CHECKBOX
WRITE ... AS CHECKBOX in a list
CLASS Definition of a class
CLASS-DATA Static attributes in classes
CLASS-METHODS Static methods in classes
CLASS-EVENTS Static events in classes
CLASS-POOL Introduction for type K programs
CLEAR Initialize data object
CLIENT Client handling when
DELETE ... CLIENT SPECIFIED
EXPORT ... TO DATABASE ... CLIENT
IMPORT ... FROM DATABASE ... CLIENT
EXPORT ... TO SHARED BUFFER ... CLIENT
IMPORT ... FROM SHARED BUFFER ... CLIENT
INSERT ... CLIENT SPECIFIED
MODIFY ... CLIENT SPECIFIED
SELECT ... CLIENT SPECIFIED
UPDATE ... CLIENT SPECIFIED
CLOSE Close file/cursor
CN Relational operator for character comparison:
CNT Field groups: Number of different values
CO Relational operator for character comparison:
CODE PAGE Character set
TRANSLATE ... FROM/TO CODE PAGE
COLLECT Internal table: Add entries
COLOR Output format: Color (FORMAT)
COMMENT Comment on selection screen
SELECTION-SCREEN COMMENT
COMMIT Close processing unit
COMMUNICATION Data exchange
COMPUTE Perform calculations
CONCATENATE Concatenate character fields
CONDENSE Condense character fields
CONSTANTS Defing constants
CONTEXTS Communicate contexts
CONTINUE Exit current loop pass
CONTROLS Define controls for visualization
CONVERT Convert fields
COS Mathematical function: Cosine (COMPUTE)
COSH Mathematical function: Hyperbola cosine (COMPUTE)
COUNT Aggregate expression: Count (SELECT)
COUNTRY Set country ID (SET)
CP Relational operator for character comparison:
Contains Pattern
CREATE Generate an object or data object
CS Relational operator for character comparison:
Contains character
CURRENCY Output format: Correct format for currency (WRITE)
CURSOR Cursor
CLOSE Close database cursor
FETCH NEXT CURSOR Read lines with a database cursor
GET CURSOR FIELD Get field name
OPEN CURSOR Open database cursor
SET CURSOR Position cursor
CUSTOMER-FUNCTION Call customer enhancement
DATA Define data
DATABASE Data cluster
DELETE FROM DATABASE Delete from a database table
EXPORT ... TO DATABASE Store in a database table
IMPORT ... FROM DATABASE
DATASET Sequential file
CLOSE DATASET Close file
DELETE DATASET Delete file
EXPORT ... TO DATASET Store data cluster in file
IMPORT ... FROM DATASET Read data cluster from file
OPEN DATASET Open file
READ DATASET Read from a file
TRANSFER Output to a file
DECIMALS Output format: Places after the decimal point
(WRITE)
DEFINE Define macro
DELETE Delete from tables or from objects
DEMAND Request information from a context
DESCRIBE Determine attributes of data objects
DIALOG Call a dialog module (CALL)
DISTINCT Duplicates
SELECT DISTINCT Selection set without duplicates
AVG( DISTINCT ... ) Average without duplicates (SELECT)
COUNT( DISTINCT ... ) Number without duplicates (SELECT)
MAX( DISTINCT ... ) Maximum without duplicates (SELECT)
MIN( DISTINCT ... ) Minimum without duplicates (SELECT)
SUM( DISTINCT ... ) Sum without duplicates (SELECT)
DIV Arithmetic operator: Whole number division
(COMPUTE)
DIVIDE Divide
DIVIDE-CORRESPONDING Field string division
DO Loop
DYNPRO Screen
DELETE DYNPRO Delete
EXPORT DYNPRO Export
GENERATE DYNPRO Generate
IMPORT DYNPRO Import
SYNTAX-CHECK FOR DYNPRO Check
EDITOR-CALL Call editor
ELSE Query
ELSEIF Query
END-OF-DEFINITION End of a macro definition
END-OF-PAGE Event: End of page handling in lists
END-OF-SELECTION Event: After processing of all records in a LDB
ENDAT End of an event introduced by AT
ENDCASE End of case distinction
ENDCATCH End of exception handling
ENDDO End of a DO loop
ENDEXEC End of a Native SQL statement
ENDFORM End of a subroutine
ENDFUNCTION End of a function module
ENDIF End of a query
ENDINTERFACE End of an interface definition
ENDLOOP End of a LOOP
ENDMODULE End of a module definition
ENDON End of a conditional statement
ENDPROVIDE End of a PROVIDE loop
ENDSELECT End of a SELECT loop
ENDWHILE End of a WHILE loop
EQ Relational operator: Equals
EXEC SQL Native SQL statement
EXIT Exit loop or terminate processing
EXP Mathematical function: Exponential function
(COMPUTE)
EXPONENT Output format: Exponent display (WRITE)
EXPORT Export data
EXTENDED CHECK Switch extended syntax check on/off (SET)
EXTRACT Generate extract dataset
FETCH Read line from a database table
FIELD-GROUPS Define field groups
FIELD-SYMBOLS Define field symbols
FLOOR Mathematical function: Largest whole value
(COMPUTE)
FORM Define subroutine
FORMAT Output format for lists
FOR UPDATE Read database table with lock (SELECT)
FRAC Mathematical function: Fraction (COMPUTE)
FREE Release resources no longer needed
FUNCTION Define function module
CALL FUNCTION Call function module
FUNCTION-POOL Introduction for type F programs
GE Relational operator: Greater than or equal
GENERATE Generate a program or screen
GET Event, read settings
GT Relational operator: Greater than
HASHED TABLE Table type for internal hashed tables
HEADER LINE Define an internal table with header line (DATA)
HELP-ID Help ID for F1 help
DESCRIBE FIELD ... HELP-ID
HELP-REQUEST Self-programmed help (F1)
PARAMETERS ... HELP-REQUEST for parameters
SELECT-OPTIONS ... HELP-REQUEST for selection options
HIDE Store line information
HOTSPOT Output format: Hotspot, interaction by simple
mouse click (FORMAT)
ICON Icons in lists
IF Query
IMPORT Import data or a screen
IN Relational operator: Selection criterion
INCLUDE Include program components
INDEX Line index in an internal table
INDEX TABLE Generic table type for internal tables
DELETE ... INDEX Delete line
INSERT ... INDEX Insert line
MODIFY ... INDEX Modify line
READ TABLE ... INDEX
INFOTYPES Declare HR info type
INITIAL Relational operator: Initial value
INITIAL SIZE Define an internal table type (TYPES)
INITIALIZATION Event: Before display of the selection screen
INPUT Output format: Ready for input (FORMAT)
INSERT Insert into tables or objects
INTENSIFIED Output format: Intensified (FORMAT)
INTERFACE Definition of an interface
INTERFACES Class component interface
INTERFACE-POOL Introduction fortype J programs
INVERSE Output format: Inverse (FORMAT)
IS Relational operator
IS ASSIGNED Relational operator: Is the field symbol assigned?
IS INITIAL Relational operator: Initial value
IS REQUESTED Relational operator: Existence of a formal
parameter
JOIN Join (SELECT)
LANGUAGE Set language for text elements (SET)
LE Relational operator: Less than or equal
LEAVE Leave processing
LEFT-JUSTIFIED Output format: Left-justified (WRITE)
LIKE Use an existing field as a reference
TYPES ... LIKE Create a type
DATA ... LIKE Create a field
LINE Line in a list
MODIFY LINE Modify line
READ LINE Read line
LINE-COUNT Number of lines per page (NEW-PAGE)
LINE-SIZE Line size (NEW-PAGE)
LIST-PROCESSING List processing (LEAVE)
LOAD Load program components in internal table
LOAD-OF-PROGRAM Execution at load time
LOCAL Rescue actual parameters of a subroutine
LOCAL COPY Assign local copy to a field symbol
LOCALE Set text environment (SET)
SET LOCALE Set text environment
GET LOCALE Determine text environment
LOG Mathematical function: Natural logarithm (COMPUTE)
Logical condition
SELECT ... WHERE when reading database tables
UPDATE ... WHERE when changing database tables
DELETE ... WHERE when deleting from database tables
SELECT ... FROM ... ON when reading using a join
LOG10 Mathematical function: Base 10 logarithm (COMPUTE)
LOOP Loop
LT Relational operator: Less than
M Relational operator: Byte contains zeros and ones
MARGIN List output: Distance from edge (SET)
MATCHCODE Matchcode handling
PARAMETERS ... MATCHCODE for parameters
SELECT-OPTIONS ... MATCHCODE for selection options
MAX Aggregate expression: Maximum (SELECT)
MEMORY ABAP/4 memory
EXPORT ... TO MEMORY Roll out data to memory
IMPORT ... FROM MEMORY
MESSAGE Output message
MESSAGE-ID Specify message class (REPORT)
METHOD Definition of a method
METHODS Class component method
MIN Aggregate expression: Minimum (SELECT)
MOD Arithmetic operator: Remainder after division
(COMPUTE)
MODIFY Modify tables or objects
MODULE Flow logic: Module
MOVE Assignment
MOVE-CORRESPONDING Component-by-component assignment
MULTIPLY Multiply
MULTIPLY-CORRESPONDING Field string multiplication
NA Relational operator for character comparison:
Contains not any characters
NE Relational operator: Not equal
NEW-LINE List processing: New line
NEW-PAGE List processing: New page
NODES Interface work area for logical databases
NO-GAP Output format: Leave no gaps (WRITE)
NO-HEADING Display no column headers (NEW-PAGE)
NO-SCROLLING Do not scroll line (NEW-LINE)
NO-SIGN Output format: No preceding signs (WRITE)
NO-TITLE Do not display standard page header (NEW-PAGE)
NO-ZERO Output format: No leading zeros (WRITE)
NON-UNIQUE Defines an
TYPES internal table type
DATA internal table object
NP Relational operator for character comparison:
Does not contain pattern
NS Relational operator for character comparison:
Does not contain character
O Relational operator: Byte positions occupied by 1
OBJECT External object
CREATE OBJECT Generate
FREE OBJECT Release
OCCURS Defines an
TYPES internal table type
DATA internal table object
ON CHANGE Control break
OPEN Open file/cursor
OR Relational operator: OR
ORDER BY Sort table rows (SELECT)
OVERLAY Overlay character fields
PACK Conversion
PARAMETER Parameter in global SAP memory
GET Read parameter
SET Set parameter
PARAMETERS Define report parameters
PERFORM Execute subroutine
PF-STATUS Set GUI status
POSITION List processing: Define output position
PRINT Print formatting (NEW-PAGE)
PRINT-CONTROL Define print format
PRIVATE Class area not visible from outside
PROGRAM Introduction for type M and S programs
LEAVE PROGRAM Leave program
PROPERTY Object property
GET PROPERTY Get property
SET PROPERTY Set property
PROVIDE Internal tables: Interval-related processing
PUT Trigger event
RADIOBUTTON Radio button (PARAMETERS)
RAISE Raise exceptions and events
RAISING Raise error message in function module
RANGES Define internal table for selection criterion
READ Read tables or objects
RECEIVE Receive results (RFC)
REFRESH Delete internal table
REFRESH CONTROL Initialize control
REJECT Do not process current database line further
REPLACE Replace characters
REPORT Introduction for type 1 programs
DELETE REPORT Delete program
EDITOR-CALL FOR REPORT Call ABAP program editor
INSERT REPORT Insert program in library
READ REPORT Read program
RESERVE List processing: Conditional new page
RESET Output format: Reset all formats (FORMAT)
RIGHT-JUSTIFIED Output format: Right justified (WRITE)
ROLLBACK Roll back database changes
ROUND Output format: Scaled (WRITE)
RTTI Runtime type identification
RUN TIME ANALYZER Activate/Deactivate runtime analysis (SET)
SCAN Analyze ABAP/4 source code
SCREEN Screen
CALL SCREEN Call screen
SET SCREEN Set next screen
LEAVE SCREEN Leave screen
LEAVE TO SCREEN Branch to a screen
LOOP AT SCREEN Loop through screen fields
MODIFY SCREEN Modify screen fields
SCROLL List processing: Scroll
SCROLL-BOUNDARY List processing: Fix lead columns (SET)
SEARCH Find character
SELECT Read database table
SELECT-OPTIONS Define selection criterion
SELECTION-SCREEN Design selection screen
AT SELECTION-SCREEN Event: After editing of selection screen
SHARED BUFFER Cross-transaction application buffer
DELETE FROM SHARED BUFFER delete from application buffer
EXPORT ... TO SHARED BUFFER Store data in application buffer
IMPORT ... FROM SHARED BUFFER
SELECTION-TABLE Selection table (SUBMIT)
SET Set different processing parameters
SHIFT Move character
SIGN Mathematical function: Sign (COMPUTE)
SIN Mathematical function: Sine (COMPUTE)
SINGLE Select single record (SELECT)
SINH Mathematical function: Hyperbola sine (COMPUTE)
SKIP List processing: Output blank line
SORT Sort internal table or extract dataset
SORTED TABLE Table type for internal tables that are always kept
sorted
SPLIT Split character fields
SQRT Mathematical function: Square root (COMPUTE)
STANDARD TABLE Table type for standard internal tables
START-OF-SELECTION Event: Before first access to LDB
STATICS Define static data
STOP Stop data selection (LDB)
STRING Data type for variable-length character sequence
STRLEN Character function: Current length (COMPUTE)
STRUCTURE Data structure
INCLUDE STRUCTURE Use structure
SUBMIT Program call
SUBTRACT Subtract
SUBTRACT-CORRESPONDING Field string subtraction
SUM Calculate control total
SELECT ... SUM Aggregate expression: Total
SUPPLY Supply context key fields
SUPPRESS DIALOG Suppress dialog
SYMBOL Output as symbol (WRITE)
SYNTAX-CHECK Syntax check for programs and screens
SYNTAX-TRACE Syntax check log
SYSTEM-CALL Call to various system services
SYSTEM-EXCEPTIONS Catch runtime errors (CATCH)
TABLE LINE Unstructured lines in internal tables
TABLE_LINE Unstructured lines in internal tables
TABLES Declare database table
TABLE Set or array operations for database tables
DELETE ... FROM TABLE
INSERT ... FROM TABLE
MODIFY ... FROM TABLE
UPDATE ... FROM TABLE
SELECT ... INTO TABLE
TAN Mathematical function: Tangent (COMPUTE)
TANH Mathematical function: Hyperbola tangent (COMPUTE)
TEXT Locale-specific
CONVERT TEXT Set format
SORT itab AS TEXT Sort an internal table
SORT AS TEXT Sort an extract dataset
TEXTPOOL Text elements
DELETE TEXTPOOL Delete
INSERT TEXTPOOL Insert
READ TEXTPOOL Read
TIME Time measurement
GET RUN TIME Get runtime
GET TIME Get time
SET RUN TIME ANALYZER
TIME STAMP Time stamp ------------
GET TIME STAMP ------------ Get time stamp
CONVERT TIME STAMP ------------
------------
Convert time stamps to date/time ------------
WRITE f TIME ZONE ------------ Output of time stamps to lists
TITLEBAR ------------ Set screen title (SET)
TOP-OF-PAGE ------------ Event: Top of page handling in lists
TRANSACTION SAP transaction ------------
CALL TRANSACTION Call ------------
LEAVE TO TRANSACTION Leave to ------------
TRANSFER ------------ Output to file
TRANSLATE ------------ Character conversion in character fields
TRANSPORTING Selective field transport ------------
MODIFY ... TRANSPORTING ------------
READ ... TRANSPORTING ------------
LOOP ... TRANSPORTING ------------
TRUNC ------------ Mathematical function: Whole number part (COMPUTE)
TYPE Define a type ------------
TYPES ... TYPE ------------ Define a type
DATA ... TYPE ------------ Define a field
TYPE-POOL ------------ Introduction for type T programs
TYPE-POOLS ------------ Include type group
TYPES ------------ Define types
ULINE ------------ List processing: Underscore
UNDER ------------ Output format: One under the other (WRITE)
UNIQUE Define an ------------
TYPES ------------ internal table type
DATA internal table object ------------
UNIT ------------ Output format: Unit (WRITE)
UNPACK ------------ Conversion
UPDATE ------------ Update database table
USER-COMMAND ------------ List processing: Execute command immediately (SET)
USING Use parameter or format ------------
USING Parameter of a subroutine ------------
USING EDIT MASK ------------ Output format: Use template (WRITE)
VALUE-REQUEST Self-programmed value help (F4) ------------
PARAMETERS ... VALUE-REQUEST for parameters ------------
SELECT-OPTIONS ... VALUE-REQUEST for selection options ------------
WHEN ------------ Case distinction
SELECT ... WHERE when reading from database tables ------------
UPDATE ... WHERE when changing database tables ------------
DELETE ... WHERE when deleting database tables ------------
LOOP AT ... WHERE ------------ when looping at internal tables
DELETE ... WHERE when deleting from internal tables ------------
WHILE ------------ Loop
WINDOW ------------ List processing: Output in window
WITH-TITLE ------------ Output standard page header (NEW-PAGE)
WORK Processing unit ------------
COMMIT WORK ------------ Close unit
ROLLBACK WORK ------------ Close unit, but undo changes
WRITE ------------ List processing: Output
WRITE TO ------------ Correct type output in a variable
X ------------ Data type for fixed-length byte sequence
XSTRING ------------ Data type for variable-length byte sequence
Z ------------ Relational bit operator: Bit positions occupied by
, [, ], {, } Syntax conventions, Syntax notation
*, " Comments
** Arithm. Operator: Exponentiation (COMPUTE)
+, -, *, / Arithmetical operators (COMPUTE)
->, =>, ->>, ~, ?= Operators in ABAP Objects
ABS Mathematical function: Absolute amount COMPUTE)
ACOS Mathematical function: Cosine arc (COMPUTE)
ADD Add
ADD-CORRESPONDING Field string addition
ADJACENT DUPLICATES Delete duplicates from internal table (DELETE)
AND Comparison operator: and
ANY TABLE Generic table type for internal tables
APPEND Append line to internal table
ASIN Mathematical function: Sine arc (COMPUTE)
ASSIGN Assign field symbol
AT Event, control break, field group determination
ATAN Mathematical function: Tangent arc
AUTHORITY-CHECK Check authorization
AVG Aggregate expression: Average (SELECT)
BACK Positioning in list
BETWEEN Relational operator: Between
BINARY SEARCH Binary read of internal table (READ TABLE)
BIT-NOT Bit calculation operator: NOT (COMPUTE)
BIT-AND Bit calculation operator: AND (COMPUTE)
BIT-OR Bit calculation operator: OR (COMPUTE)
BIT-XOR Bit calculation operator: AND/OR (COMPUTE)
SET BIT Set bit of an X field
GET BIT Read bit of an X field
BLANK LINES Switch on blank lines in list
BREAK-POINT Stop processing in debug mode
C Data type for fixed-length character string
CA Relational operator for string comparison:
CALL Call external component
CASE Begin case distinction
CATCH Exception handling (catch runtime errors)
CEIL Mathematical function: Smallest whole value
(COMPUTE)
CENTERED Output format: Centered (WRITE)
CHECK Check condition
CHECKBOX Display as checkbox
PARAMETERS ... AS CHECKBOX
WRITE ... AS CHECKBOX in a list
CLASS Definition of a class
CLASS-DATA Static attributes in classes
CLASS-METHODS Static methods in classes
CLASS-EVENTS Static events in classes
CLASS-POOL Introduction for type K programs
CLEAR Initialize data object
CLIENT Client handling when
DELETE ... CLIENT SPECIFIED
EXPORT ... TO DATABASE ... CLIENT
IMPORT ... FROM DATABASE ... CLIENT
EXPORT ... TO SHARED BUFFER ... CLIENT
IMPORT ... FROM SHARED BUFFER ... CLIENT
INSERT ... CLIENT SPECIFIED
MODIFY ... CLIENT SPECIFIED
SELECT ... CLIENT SPECIFIED
UPDATE ... CLIENT SPECIFIED
CLOSE Close file/cursor
CN Relational operator for character comparison:
CNT Field groups: Number of different values
CO Relational operator for character comparison:
CODE PAGE Character set
TRANSLATE ... FROM/TO CODE PAGE
COLLECT Internal table: Add entries
COLOR Output format: Color (FORMAT)
COMMENT Comment on selection screen
SELECTION-SCREEN COMMENT
COMMIT Close processing unit
COMMUNICATION Data exchange
COMPUTE Perform calculations
CONCATENATE Concatenate character fields
CONDENSE Condense character fields
CONSTANTS Defing constants
CONTEXTS Communicate contexts
CONTINUE Exit current loop pass
CONTROLS Define controls for visualization
CONVERT Convert fields
COS Mathematical function: Cosine (COMPUTE)
COSH Mathematical function: Hyperbola cosine (COMPUTE)
COUNT Aggregate expression: Count (SELECT)
COUNTRY Set country ID (SET)
CP Relational operator for character comparison:
Contains Pattern
CREATE Generate an object or data object
CS Relational operator for character comparison:
Contains character
CURRENCY Output format: Correct format for currency (WRITE)
CURSOR Cursor
CLOSE Close database cursor
FETCH NEXT CURSOR Read lines with a database cursor
GET CURSOR FIELD Get field name
OPEN CURSOR Open database cursor
SET CURSOR Position cursor
CUSTOMER-FUNCTION Call customer enhancement
DATA Define data
DATABASE Data cluster
DELETE FROM DATABASE Delete from a database table
EXPORT ... TO DATABASE Store in a database table
IMPORT ... FROM DATABASE
DATASET Sequential file
CLOSE DATASET Close file
DELETE DATASET Delete file
EXPORT ... TO DATASET Store data cluster in file
IMPORT ... FROM DATASET Read data cluster from file
OPEN DATASET Open file
READ DATASET Read from a file
TRANSFER Output to a file
DECIMALS Output format: Places after the decimal point
(WRITE)
DEFINE Define macro
DELETE Delete from tables or from objects
DEMAND Request information from a context
DESCRIBE Determine attributes of data objects
DIALOG Call a dialog module (CALL)
DISTINCT Duplicates
SELECT DISTINCT Selection set without duplicates
AVG( DISTINCT ... ) Average without duplicates (SELECT)
COUNT( DISTINCT ... ) Number without duplicates (SELECT)
MAX( DISTINCT ... ) Maximum without duplicates (SELECT)
MIN( DISTINCT ... ) Minimum without duplicates (SELECT)
SUM( DISTINCT ... ) Sum without duplicates (SELECT)
DIV Arithmetic operator: Whole number division
(COMPUTE)
DIVIDE Divide
DIVIDE-CORRESPONDING Field string division
DO Loop
DYNPRO Screen
DELETE DYNPRO Delete
EXPORT DYNPRO Export
GENERATE DYNPRO Generate
IMPORT DYNPRO Import
SYNTAX-CHECK FOR DYNPRO Check
EDITOR-CALL Call editor
ELSE Query
ELSEIF Query
END-OF-DEFINITION End of a macro definition
END-OF-PAGE Event: End of page handling in lists
END-OF-SELECTION Event: After processing of all records in a LDB
ENDAT End of an event introduced by AT
ENDCASE End of case distinction
ENDCATCH End of exception handling
ENDDO End of a DO loop
ENDEXEC End of a Native SQL statement
ENDFORM End of a subroutine
ENDFUNCTION End of a function module
ENDIF End of a query
ENDINTERFACE End of an interface definition
ENDLOOP End of a LOOP
ENDMODULE End of a module definition
ENDON End of a conditional statement
ENDPROVIDE End of a PROVIDE loop
ENDSELECT End of a SELECT loop
ENDWHILE End of a WHILE loop
EQ Relational operator: Equals
EXEC SQL Native SQL statement
EXIT Exit loop or terminate processing
EXP Mathematical function: Exponential function
(COMPUTE)
EXPONENT Output format: Exponent display (WRITE)
EXPORT Export data
EXTENDED CHECK Switch extended syntax check on/off (SET)
EXTRACT Generate extract dataset
FETCH Read line from a database table
FIELD-GROUPS Define field groups
FIELD-SYMBOLS Define field symbols
FLOOR Mathematical function: Largest whole value
(COMPUTE)
FORM Define subroutine
FORMAT Output format for lists
FOR UPDATE Read database table with lock (SELECT)
FRAC Mathematical function: Fraction (COMPUTE)
FREE Release resources no longer needed
FUNCTION Define function module
CALL FUNCTION Call function module
FUNCTION-POOL Introduction for type F programs
GE Relational operator: Greater than or equal
GENERATE Generate a program or screen
GET Event, read settings
GT Relational operator: Greater than
HASHED TABLE Table type for internal hashed tables
HEADER LINE Define an internal table with header line (DATA)
HELP-ID Help ID for F1 help
DESCRIBE FIELD ... HELP-ID
HELP-REQUEST Self-programmed help (F1)
PARAMETERS ... HELP-REQUEST for parameters
SELECT-OPTIONS ... HELP-REQUEST for selection options
HIDE Store line information
HOTSPOT Output format: Hotspot, interaction by simple
mouse click (FORMAT)
ICON Icons in lists
IF Query
IMPORT Import data or a screen
IN Relational operator: Selection criterion
INCLUDE Include program components
INDEX Line index in an internal table
INDEX TABLE Generic table type for internal tables
DELETE ... INDEX Delete line
INSERT ... INDEX Insert line
MODIFY ... INDEX Modify line
READ TABLE ... INDEX
INFOTYPES Declare HR info type
INITIAL Relational operator: Initial value
INITIAL SIZE Define an internal table type (TYPES)
INITIALIZATION Event: Before display of the selection screen
INPUT Output format: Ready for input (FORMAT)
INSERT Insert into tables or objects
INTENSIFIED Output format: Intensified (FORMAT)
INTERFACE Definition of an interface
INTERFACES Class component interface
INTERFACE-POOL Introduction fortype J programs
INVERSE Output format: Inverse (FORMAT)
IS Relational operator
IS ASSIGNED Relational operator: Is the field symbol assigned?
IS INITIAL Relational operator: Initial value
IS REQUESTED Relational operator: Existence of a formal
parameter
JOIN Join (SELECT)
LANGUAGE Set language for text elements (SET)
LE Relational operator: Less than or equal
LEAVE Leave processing
LEFT-JUSTIFIED Output format: Left-justified (WRITE)
LIKE Use an existing field as a reference
TYPES ... LIKE Create a type
DATA ... LIKE Create a field
LINE Line in a list
MODIFY LINE Modify line
READ LINE Read line
LINE-COUNT Number of lines per page (NEW-PAGE)
LINE-SIZE Line size (NEW-PAGE)
LIST-PROCESSING List processing (LEAVE)
LOAD Load program components in internal table
LOAD-OF-PROGRAM Execution at load time
LOCAL Rescue actual parameters of a subroutine
LOCAL COPY Assign local copy to a field symbol
LOCALE Set text environment (SET)
SET LOCALE Set text environment
GET LOCALE Determine text environment
LOG Mathematical function: Natural logarithm (COMPUTE)
Logical condition
SELECT ... WHERE when reading database tables
UPDATE ... WHERE when changing database tables
DELETE ... WHERE when deleting from database tables
SELECT ... FROM ... ON when reading using a join
LOG10 Mathematical function: Base 10 logarithm (COMPUTE)
LOOP Loop
LT Relational operator: Less than
M Relational operator: Byte contains zeros and ones
MARGIN List output: Distance from edge (SET)
MATCHCODE Matchcode handling
PARAMETERS ... MATCHCODE for parameters
SELECT-OPTIONS ... MATCHCODE for selection options
MAX Aggregate expression: Maximum (SELECT)
MEMORY ABAP/4 memory
EXPORT ... TO MEMORY Roll out data to memory
IMPORT ... FROM MEMORY
MESSAGE Output message
MESSAGE-ID Specify message class (REPORT)
METHOD Definition of a method
METHODS Class component method
MIN Aggregate expression: Minimum (SELECT)
MOD Arithmetic operator: Remainder after division
(COMPUTE)
MODIFY Modify tables or objects
MODULE Flow logic: Module
MOVE Assignment
MOVE-CORRESPONDING Component-by-component assignment
MULTIPLY Multiply
MULTIPLY-CORRESPONDING Field string multiplication
NA Relational operator for character comparison:
Contains not any characters
NE Relational operator: Not equal
NEW-LINE List processing: New line
NEW-PAGE List processing: New page
NODES Interface work area for logical databases
NO-GAP Output format: Leave no gaps (WRITE)
NO-HEADING Display no column headers (NEW-PAGE)
NO-SCROLLING Do not scroll line (NEW-LINE)
NO-SIGN Output format: No preceding signs (WRITE)
NO-TITLE Do not display standard page header (NEW-PAGE)
NO-ZERO Output format: No leading zeros (WRITE)
NON-UNIQUE Defines an
TYPES internal table type
DATA internal table object
NP Relational operator for character comparison:
Does not contain pattern
NS Relational operator for character comparison:
Does not contain character
O Relational operator: Byte positions occupied by 1
OBJECT External object
CREATE OBJECT Generate
FREE OBJECT Release
OCCURS Defines an
TYPES internal table type
DATA internal table object
ON CHANGE Control break
OPEN Open file/cursor
OR Relational operator: OR
ORDER BY Sort table rows (SELECT)
OVERLAY Overlay character fields
PACK Conversion
PARAMETER Parameter in global SAP memory
GET Read parameter
SET Set parameter
PARAMETERS Define report parameters
PERFORM Execute subroutine
PF-STATUS Set GUI status
POSITION List processing: Define output position
PRINT Print formatting (NEW-PAGE)
PRINT-CONTROL Define print format
PRIVATE Class area not visible from outside
PROGRAM Introduction for type M and S programs
LEAVE PROGRAM Leave program
PROPERTY Object property
GET PROPERTY Get property
SET PROPERTY Set property
PROVIDE Internal tables: Interval-related processing
PUT Trigger event
RADIOBUTTON Radio button (PARAMETERS)
RAISE Raise exceptions and events
RAISING Raise error message in function module
RANGES Define internal table for selection criterion
READ Read tables or objects
RECEIVE Receive results (RFC)
REFRESH Delete internal table
REFRESH CONTROL Initialize control
REJECT Do not process current database line further
REPLACE Replace characters
REPORT Introduction for type 1 programs
DELETE REPORT Delete program
EDITOR-CALL FOR REPORT Call ABAP program editor
INSERT REPORT Insert program in library
READ REPORT Read program
RESERVE List processing: Conditional new page
RESET Output format: Reset all formats (FORMAT)
RIGHT-JUSTIFIED Output format: Right justified (WRITE)
ROLLBACK Roll back database changes
ROUND Output format: Scaled (WRITE)
RTTI Runtime type identification
RUN TIME ANALYZER Activate/Deactivate runtime analysis (SET)
SCAN Analyze ABAP/4 source code
SCREEN Screen
CALL SCREEN Call screen
SET SCREEN Set next screen
LEAVE SCREEN Leave screen
LEAVE TO SCREEN Branch to a screen
LOOP AT SCREEN Loop through screen fields
MODIFY SCREEN Modify screen fields
SCROLL List processing: Scroll
SCROLL-BOUNDARY List processing: Fix lead columns (SET)
SEARCH Find character
SELECT Read database table
SELECT-OPTIONS Define selection criterion
SELECTION-SCREEN Design selection screen
AT SELECTION-SCREEN Event: After editing of selection screen
SHARED BUFFER Cross-transaction application buffer
DELETE FROM SHARED BUFFER delete from application buffer
EXPORT ... TO SHARED BUFFER Store data in application buffer
IMPORT ... FROM SHARED BUFFER
SELECTION-TABLE Selection table (SUBMIT)
SET Set different processing parameters
SHIFT Move character
SIGN Mathematical function: Sign (COMPUTE)
SIN Mathematical function: Sine (COMPUTE)
SINGLE Select single record (SELECT)
SINH Mathematical function: Hyperbola sine (COMPUTE)
SKIP List processing: Output blank line
SORT Sort internal table or extract dataset
SORTED TABLE Table type for internal tables that are always kept
sorted
SPLIT Split character fields
SQRT Mathematical function: Square root (COMPUTE)
STANDARD TABLE Table type for standard internal tables
START-OF-SELECTION Event: Before first access to LDB
STATICS Define static data
STOP Stop data selection (LDB)
STRING Data type for variable-length character sequence
STRLEN Character function: Current length (COMPUTE)
STRUCTURE Data structure
INCLUDE STRUCTURE Use structure
SUBMIT Program call
SUBTRACT Subtract
SUBTRACT-CORRESPONDING Field string subtraction
SUM Calculate control total
SELECT ... SUM Aggregate expression: Total
SUPPLY Supply context key fields
SUPPRESS DIALOG Suppress dialog
SYMBOL Output as symbol (WRITE)
SYNTAX-CHECK Syntax check for programs and screens
SYNTAX-TRACE Syntax check log
SYSTEM-CALL Call to various system services
SYSTEM-EXCEPTIONS Catch runtime errors (CATCH)
TABLE LINE Unstructured lines in internal tables
TABLE_LINE Unstructured lines in internal tables
TABLES Declare database table
TABLE Set or array operations for database tables
DELETE ... FROM TABLE
INSERT ... FROM TABLE
MODIFY ... FROM TABLE
UPDATE ... FROM TABLE
SELECT ... INTO TABLE
TAN Mathematical function: Tangent (COMPUTE)
TANH Mathematical function: Hyperbola tangent (COMPUTE)
TEXT Locale-specific
CONVERT TEXT Set format
SORT itab AS TEXT Sort an internal table
SORT AS TEXT Sort an extract dataset
TEXTPOOL Text elements
DELETE TEXTPOOL Delete
INSERT TEXTPOOL Insert
READ TEXTPOOL Read
TIME Time measurement
GET RUN TIME Get runtime
GET TIME Get time
SET RUN TIME ANALYZER
TIME STAMP Time stamp ------------
GET TIME STAMP ------------ Get time stamp
CONVERT TIME STAMP ------------
------------
Convert time stamps to date/time ------------
WRITE f TIME ZONE ------------ Output of time stamps to lists
TITLEBAR ------------ Set screen title (SET)
TOP-OF-PAGE ------------ Event: Top of page handling in lists
TRANSACTION SAP transaction ------------
CALL TRANSACTION Call ------------
LEAVE TO TRANSACTION Leave to ------------
TRANSFER ------------ Output to file
TRANSLATE ------------ Character conversion in character fields
TRANSPORTING Selective field transport ------------
MODIFY ... TRANSPORTING ------------
READ ... TRANSPORTING ------------
LOOP ... TRANSPORTING ------------
TRUNC ------------ Mathematical function: Whole number part (COMPUTE)
TYPE Define a type ------------
TYPES ... TYPE ------------ Define a type
DATA ... TYPE ------------ Define a field
TYPE-POOL ------------ Introduction for type T programs
TYPE-POOLS ------------ Include type group
TYPES ------------ Define types
ULINE ------------ List processing: Underscore
UNDER ------------ Output format: One under the other (WRITE)
UNIQUE Define an ------------
TYPES ------------ internal table type
DATA internal table object ------------
UNIT ------------ Output format: Unit (WRITE)
UNPACK ------------ Conversion
UPDATE ------------ Update database table
USER-COMMAND ------------ List processing: Execute command immediately (SET)
USING Use parameter or format ------------
USING Parameter of a subroutine ------------
USING EDIT MASK ------------ Output format: Use template (WRITE)
VALUE-REQUEST Self-programmed value help (F4) ------------
PARAMETERS ... VALUE-REQUEST for parameters ------------
SELECT-OPTIONS ... VALUE-REQUEST for selection options ------------
WHEN ------------ Case distinction
SELECT ... WHERE when reading from database tables ------------
UPDATE ... WHERE when changing database tables ------------
DELETE ... WHERE when deleting database tables ------------
LOOP AT ... WHERE ------------ when looping at internal tables
DELETE ... WHERE when deleting from internal tables ------------
WHILE ------------ Loop
WINDOW ------------ List processing: Output in window
WITH-TITLE ------------ Output standard page header (NEW-PAGE)
WORK Processing unit ------------
COMMIT WORK ------------ Close unit
ROLLBACK WORK ------------ Close unit, but undo changes
WRITE ------------ List processing: Output
WRITE TO ------------ Correct type output in a variable
X ------------ Data type for fixed-length byte sequence
XSTRING ------------ Data type for variable-length byte sequence
Z ------------ Relational bit operator: Bit positions occupied by
Tuesday, November 18, 2008
Saving, Reading, Data Objects & Deleting Data Clusters in Memory,
Saving Data Objects in Memory
To read data objects from an ABAP program into ABAP memory, use the following statement:
Syntax
EXPORT [FROM ] [FROM ] ... TO MEMORY ID .
This statement stores the data objects specified in the list as a cluster in memory. If you do not use the option FROM, the data object is saved under its own name. If you use the FROM option, the data objet is saved under the name . The name identifies the cluster in memory. It may be up to 32 characters long.
The EXPORT statement always completely overwrites the contents of any existing data cluster with the same name.
If you are using internal tables with header lines, you can only store the table itself, not the header line. In the EXPORT statement, the table name is interpreted as the table. This is an exception to the general rule, under which statements normally interpret the table name as a table work area (see Choosing a Table Type).
PROGRAM SAPMZTS1.
DATA TEXT1(10) VALUE 'Exporting'.
DATA ITAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.
DO 5 TIMES.
ITAB-BOOKID = 100 + SY-INDEX.
APPEND ITAB.
ENDDO.
EXPORT TEXT1
TEXT2 FROM 'Literal'
TO MEMORY ID 'text'.
EXPORT ITAB
TO MEMORY ID 'table'.
In this example, the text fields TEXT1 and TEXT2 are stored in the ABAP memory of program SAPMZTS1 under the name "text". The internal table ITAB is stored under the name "table".
Reading Data Objects from Memory
To read data objects from ABAP memory into an ABAP program, use the following statement:
Syntax
IMPORT [TO ] [TO ] ... FROM MEMORY ID .
This statement reads the data objects specified in the list from a cluster in memory. If you do not use the TO option, the data object in memory is assigned to the data object in the program with the same name. If you do use the option, the data object is read from memory into the field . The name identifies the cluster in memory. It may be up to 32 characters long.
You do not have to read all of the objects stored under a particular name. You can restrict the number of objects by specifying their names. If the memory does not contain any objects under the name , SY-SUBRC is set to 4. If, on the other hand, there is a data cluster in memory with the name , SY-SUBRC is always 0, regardless of whether it contained the data object . If the cluster does not contain the data object , the target field remains unchanged.
In this statement, the system does not check whether the structure of the object in memory is compatible with the structure into which you are reading it. The data is transported bit by bit. If the structures are incompatible, the data in the target field may be incorrect.
PROGRAM SAPMZTS1.
DATA TEXT1(10) VALUE 'Exporting'.
DATA ITAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.
DO 5 TIMES.
ITAB-BOOKID = 100 + SY-INDEX.
APPEND ITAB.
ENDDO.
EXPORT TEXT1
TEXT2 FROM 'Literal'
TO MEMORY ID 'text'.
EXPORT ITAB
TO MEMORY ID 'table'.
SUBMIT SAPMZTS2 AND RETURN.
SUBMIT SAPMZTS3.
The first part of this program is the same as the example in the section Saving Data Objects in Memory. In the example, the programs SAPMZTS1 and SAPMZTS2 are called using SUBMIT. You can create and maintain the programs called using the SUBMIT statement by double-clicking their names in the statement. For further information about the SUBMIT statement, refer to Calling Executable Programs (Reports)
Example for SAPMZTS2:
PROGRAM SAPMZTS2.
DATA: TEXT1(10),
TEXT3 LIKE TEXT1 VALUE 'Initial'.
IMPORT TEXT3 FROM MEMORY ID 'text'.
WRITE: / SY-SUBRC, TEXT3.
IMPORT TEXT2 TO TEXT1 FROM MEMORY ID 'text'.
WRITE: / SY-SUBRC, TEXT1.
Example for SAPMZTS3:
PROGRAM SAPMZTS3.
DATA JTAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.
IMPORT ITAB TO JTAB FROM MEMORY ID 'table'.
LOOP AT JTAB.
WRITE / JTAB-BOOKID.
ENDLOOP.
The output is displayed on two successive screens. It looks like this:
The program SAPMZTS2 attempts to read a data object TEXT3 from the data cluster "text", which does not exist. TEXT3 therefore remains unchanged. The existing data object TEXT2 is placed in TEXT1. In both cases, SY-SUBRC is 0, since the cluster "text" contains data.
The program SAPMZTS3 reads the internal table ITAB from the cluster "table" into the internal table JTAB. Both tables have the same structure, namely that of the ABAP Dictionary table SBOOK.
Deleting Data Clusters from Memory
To delete data objects from ABAP memory, use the following statement:
Syntax
FREE MEMORY [ID].
If you omit the addition ID, the system deletes the entire memory, that is, all of the data clusters previously stored in ABAP memory using EXPORT. If you use the addition ID , this statement only deletes the data cluster with the name .
Only use the FREE MEMORY statement with the ID addition, since deleting the entire memory can also delete the memory contents of system routines.
PROGRAM SAPMZTST.
DATA: TEXT(10) VALUE '0123456789',
IDEN(3) VALUE 'XYZ'.
EXPORT TEXT TO MEMORY ID IDEN.
TEXT = 'xxxxxxxxxx'.
IMPORT TEXT FROM MEMORY ID IDEN.
WRITE: / SY-SUBRC, TEXT.
FREE MEMORY.
TEXT = 'xxxxxxxxxx'.
IMPORT TEXT FROM MEMORY ID IDEN.
WRITE: / SY-SUBRC, TEXT.
This produces the following output:
0 0123456789
4 xxxxxxxxxx
The FREE MEMORY statement deletes the data cluster "XYZ". Consequently, SY-SUBRC is 4 after the following IMPORT statement, and the target field remains unchanged.
To read data objects from an ABAP program into ABAP memory, use the following statement:
Syntax
EXPORT
This statement stores the data objects specified in the list as a cluster in memory. If you do not use the option FROM
The EXPORT statement always completely overwrites the contents of any existing data cluster with the same name
If you are using internal tables with header lines, you can only store the table itself, not the header line. In the EXPORT statement, the table name is interpreted as the table. This is an exception to the general rule, under which statements normally interpret the table name as a table work area (see Choosing a Table Type).
PROGRAM SAPMZTS1.
DATA TEXT1(10) VALUE 'Exporting'.
DATA ITAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.
DO 5 TIMES.
ITAB-BOOKID = 100 + SY-INDEX.
APPEND ITAB.
ENDDO.
EXPORT TEXT1
TEXT2 FROM 'Literal'
TO MEMORY ID 'text'.
EXPORT ITAB
TO MEMORY ID 'table'.
In this example, the text fields TEXT1 and TEXT2 are stored in the ABAP memory of program SAPMZTS1 under the name "text". The internal table ITAB is stored under the name "table".
Reading Data Objects from Memory
To read data objects from ABAP memory into an ABAP program, use the following statement:
Syntax
IMPORT
This statement reads the data objects specified in the list from a cluster in memory. If you do not use the TO
You do not have to read all of the objects stored under a particular name
In this statement, the system does not check whether the structure of the object in memory is compatible with the structure into which you are reading it. The data is transported bit by bit. If the structures are incompatible, the data in the target field may be incorrect.
PROGRAM SAPMZTS1.
DATA TEXT1(10) VALUE 'Exporting'.
DATA ITAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.
DO 5 TIMES.
ITAB-BOOKID = 100 + SY-INDEX.
APPEND ITAB.
ENDDO.
EXPORT TEXT1
TEXT2 FROM 'Literal'
TO MEMORY ID 'text'.
EXPORT ITAB
TO MEMORY ID 'table'.
SUBMIT SAPMZTS2 AND RETURN.
SUBMIT SAPMZTS3.
The first part of this program is the same as the example in the section Saving Data Objects in Memory. In the example, the programs SAPMZTS1 and SAPMZTS2 are called using SUBMIT. You can create and maintain the programs called using the SUBMIT statement by double-clicking their names in the statement. For further information about the SUBMIT statement, refer to Calling Executable Programs (Reports)
Example for SAPMZTS2:
PROGRAM SAPMZTS2.
DATA: TEXT1(10),
TEXT3 LIKE TEXT1 VALUE 'Initial'.
IMPORT TEXT3 FROM MEMORY ID 'text'.
WRITE: / SY-SUBRC, TEXT3.
IMPORT TEXT2 TO TEXT1 FROM MEMORY ID 'text'.
WRITE: / SY-SUBRC, TEXT1.
Example for SAPMZTS3:
PROGRAM SAPMZTS3.
DATA JTAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.
IMPORT ITAB TO JTAB FROM MEMORY ID 'table'.
LOOP AT JTAB.
WRITE / JTAB-BOOKID.
ENDLOOP.
The output is displayed on two successive screens. It looks like this:
The program SAPMZTS2 attempts to read a data object TEXT3 from the data cluster "text", which does not exist. TEXT3 therefore remains unchanged. The existing data object TEXT2 is placed in TEXT1. In both cases, SY-SUBRC is 0, since the cluster "text" contains data.
The program SAPMZTS3 reads the internal table ITAB from the cluster "table" into the internal table JTAB. Both tables have the same structure, namely that of the ABAP Dictionary table SBOOK.
Deleting Data Clusters from Memory
To delete data objects from ABAP memory, use the following statement:
Syntax
FREE MEMORY [ID
If you omit the addition ID
Only use the FREE MEMORY statement with the ID addition, since deleting the entire memory can also delete the memory contents of system routines.
PROGRAM SAPMZTST.
DATA: TEXT(10) VALUE '0123456789',
IDEN(3) VALUE 'XYZ'.
EXPORT TEXT TO MEMORY ID IDEN.
TEXT = 'xxxxxxxxxx'.
IMPORT TEXT FROM MEMORY ID IDEN.
WRITE: / SY-SUBRC, TEXT.
FREE MEMORY.
TEXT = 'xxxxxxxxxx'.
IMPORT TEXT FROM MEMORY ID IDEN.
WRITE: / SY-SUBRC, TEXT.
This produces the following output:
0 0123456789
4 xxxxxxxxxx
The FREE MEMORY statement deletes the data cluster "XYZ". Consequently, SY-SUBRC is 4 after the following IMPORT statement, and the target field remains unchanged.
Examples of Data Types and Objects
This example shows how to declare elementary data objects with reference to predefined ABAP types.
PROGRAM demo_elementary_data_objects.
DATA text1(20) TYPE c.
DATA text2 TYPE string.
DATA number TYPE i.
text1 = 'The number'.
number = 100.
text2 = 'is an integer.'.
WRITE: text1, number, text2.
This program produces the following output on the screen:
The number 100 is an integer.
In this example, the data objects TEXT1, TEXT2, and NUMBER are declared with the DATA statement. The technical attributes are determined by referring to the predefined ABAP types C, STRING, and I. Values from unnamed literals are assigned to the data objects. The contents of the named data objects are displayed on the list.
This example shows how to declare local elementary data types within a program.
REPORT demo_types_statement.
TYPES mytext(10) TYPE c.
TYPES myamount TYPE p DECIMALS 2.
DATA text TYPE mytext.
DATA amount TYPE myamount.
text = ' 4 / 3 = '.
amount = 4 / 3 .
WRITE: text, amount.
This program produces the following output on the screen:
4 / 3 = 1.33
The program uses the TYPES statement to create the local data types MYTEXT and MYAMOUNT. The technical attributes are defined with reference to predefined ABAP types. Then, the data objects TEXT and AMOUNT are declared with the DATA statement. Their data types are defined with reference to MYTEXT and MYAMOUNT. Values are assigned to the data objects and the contents of the data objects are displayed on the screen.
This example shows how to declare structures.
REPORT demo_structure.
TYPES: BEGIN OF name,
title(5) TYPE c,
first_name(10) TYPE c,
last_name(10) TYPE c,
END OF name.
TYPES: BEGIN OF mylist,
client TYPE name,
number TYPE i,
END OF mylist.
DATA list TYPE mylist.
list-client-title = 'Lord'.
list-client-first_name = 'Howard'.
list-client-last_name = 'Mac Duff'.
list-number = 1.
WRITE list-client-title.
WRITE list-client-first_name.
WRITE list-client-last_name.
WRITE / 'Number'.
WRITE list-number.
This program produces the following output on the screen:
Lord Howard Mac Duff
Number 1
The local data types NAME and MYLIST are defined as structures using the TYPES statement. The structure NAME contains the three components TITLE, FIRST_NAME and LAST_NAME, which refer to the predefined ABAP type C. The structure MYLIST contains the components CLIENT and NUMBER. CLIENT is a substructure that refers to the structure NAME. NUMBER is an elementary field with the predefined type I. A data object LIST is defined with reference to the data type MYLIST. Values are assigned to the components and their contents are then displayed on the screen.
This example shows how to define an internal table.
PROGRAM demo_internal_table.
TYPES: BEGIN OF mytext,
number TYPE i,
name(10) TYPE c,
END OF mytext.
TYPES mytab TYPE STANDARD TABLE OF mytext WITH DEFAULT KEY.
DATA text TYPE mytext.
DATA itab TYPE mytab.
text-number = 1. text-name = 'John'.
APPEND text TO itab.
text-number = 2. text-name = 'Paul'.
APPEND text TO itab.
text-number = 3. text-name = 'Ringo'.
APPEND text TO itab.
text-number = 4. text-name = 'George'.
APPEND text TO itab.
LOOP AT itab INTO text.
WRITE: / text-number,text-name.
ENDLOOP.
This program produces the following output on the screen:
1 John
2 Paul
3 Ringo
4 George
In this example, first a data type MYTEX is defined as a structure. Then, a data type MYTAB is defined as an internal table with the line type MYTEXT. The data objects TEXT and ITAB are declared with reference to the internal data types MYTEXT and MYTAB. This lines of the internal table ITAB are generated dynamically with the APPEND statement. The contents of the internal table ITAB are written to the list using the structure TEXT. See also: Internal Tables
PROGRAM demo_elementary_data_objects.
DATA text1(20) TYPE c.
DATA text2 TYPE string.
DATA number TYPE i.
text1 = 'The number'.
number = 100.
text2 = 'is an integer.'.
WRITE: text1, number, text2.
This program produces the following output on the screen:
The number 100 is an integer.
In this example, the data objects TEXT1, TEXT2, and NUMBER are declared with the DATA statement. The technical attributes are determined by referring to the predefined ABAP types C, STRING, and I. Values from unnamed literals are assigned to the data objects. The contents of the named data objects are displayed on the list.
This example shows how to declare local elementary data types within a program.
REPORT demo_types_statement.
TYPES mytext(10) TYPE c.
TYPES myamount TYPE p DECIMALS 2.
DATA text TYPE mytext.
DATA amount TYPE myamount.
text = ' 4 / 3 = '.
amount = 4 / 3 .
WRITE: text, amount.
This program produces the following output on the screen:
4 / 3 = 1.33
The program uses the TYPES statement to create the local data types MYTEXT and MYAMOUNT. The technical attributes are defined with reference to predefined ABAP types. Then, the data objects TEXT and AMOUNT are declared with the DATA statement. Their data types are defined with reference to MYTEXT and MYAMOUNT. Values are assigned to the data objects and the contents of the data objects are displayed on the screen.
This example shows how to declare structures.
REPORT demo_structure.
TYPES: BEGIN OF name,
title(5) TYPE c,
first_name(10) TYPE c,
last_name(10) TYPE c,
END OF name.
TYPES: BEGIN OF mylist,
client TYPE name,
number TYPE i,
END OF mylist.
DATA list TYPE mylist.
list-client-title = 'Lord'.
list-client-first_name = 'Howard'.
list-client-last_name = 'Mac Duff'.
list-number = 1.
WRITE list-client-title.
WRITE list-client-first_name.
WRITE list-client-last_name.
WRITE / 'Number'.
WRITE list-number.
This program produces the following output on the screen:
Lord Howard Mac Duff
Number 1
The local data types NAME and MYLIST are defined as structures using the TYPES statement. The structure NAME contains the three components TITLE, FIRST_NAME and LAST_NAME, which refer to the predefined ABAP type C. The structure MYLIST contains the components CLIENT and NUMBER. CLIENT is a substructure that refers to the structure NAME. NUMBER is an elementary field with the predefined type I. A data object LIST is defined with reference to the data type MYLIST. Values are assigned to the components and their contents are then displayed on the screen.
This example shows how to define an internal table.
PROGRAM demo_internal_table.
TYPES: BEGIN OF mytext,
number TYPE i,
name(10) TYPE c,
END OF mytext.
TYPES mytab TYPE STANDARD TABLE OF mytext WITH DEFAULT KEY.
DATA text TYPE mytext.
DATA itab TYPE mytab.
text-number = 1. text-name = 'John'.
APPEND text TO itab.
text-number = 2. text-name = 'Paul'.
APPEND text TO itab.
text-number = 3. text-name = 'Ringo'.
APPEND text TO itab.
text-number = 4. text-name = 'George'.
APPEND text TO itab.
LOOP AT itab INTO text.
WRITE: / text-number,text-name.
ENDLOOP.
This program produces the following output on the screen:
1 John
2 Paul
3 Ringo
4 George
In this example, first a data type MYTEX is defined as a structure. Then, a data type MYTAB is defined as an internal table with the line type MYTEXT. The data objects TEXT and ITAB are declared with reference to the internal data types MYTEXT and MYTAB. This lines of the internal table ITAB are generated dynamically with the APPEND statement. The contents of the internal table ITAB are written to the list using the structure TEXT. See also: Internal Tables
ABAP Syntax
The syntax of the ABAP programming language consists of the following elements:
Statements
An ABAP program consists of individual ABAP statements. Each statement begins with a keyword and ends with a period.
PROGRAM FIRST_PROGRAM.
WRITE 'My First Program'.
This example contains two statements, one on each line. The keywords are PROGRAM and WRITE. The program displays a list on the screen. In this case, the list consists of the line "My First Program".
The keyword determines the category of the statement. For an overview of the different categories, refer to ABAP Statements.
Formatting ABAP Statements
ABAP has no format restrictions. You can enter statements in any format, so a statement can be indented, you can write several statements on one line, or spread a single statement over several lines.
You must separate words within a statement with at least one space. The system also interprets the end of line marker as a space.
The program fragment
PROGRAM TEST.
WRITE 'This is a statement'.
could also be written as follows:
PROGRAM TEST. WRITE 'This is a statement'.
or as follows:
PROGRAM
TEST.
WRITE
'This is a statement'.
Use this free formatting to make your programs easier to understand.
Special Case: Text Literals
Text literals are sequences of alphanumeric characters in the program code that are enclosed in quotation marks. If a text literal in an ABAP statement extends across more than one line, the following difficulties can occur:
All spaces between the quotation marks are interpreted as belonging to the text literal.
Letters in text literals in a line that is not concluded with quotation marks are interpreted by the editor as uppercase.
If you want to enter text literals that do not fit into a single line, you can use the ‘&’ character to combine a succession of text literals into a single one.
The program fragment
PROGRAM TEST.
WRITE 'This
is
a statement'.
inserts all spaces between the quotation marks into the literal, and converts the letters to uppercase.
This program fragment
PROGRAM TEST.
WRITE 'This' &
' is ' &
'a statement'.
combines three text literals into one.
Chained Statements
The ABAP programming language allows you to concatenate consecutive statements with an identical first part into a chain statement.
To concatenate a sequence of separate statements, write the identical part only once and place a colon (:) after it. After the colon, write the remaining parts of the individual statements, separating them with commas. Ensure that you place a period (.) after the last part to inform the system where the chain ends.
Statement sequence:
WRITE SPFLI-CITYFROM.
WRITE SPFLI-CITYTO.
WRITE SPFLI-AIRPTO.
Chain statement:
WRITE: SPFLI-CITYFROM, SPFLI-CITYTO, SPFLI-AIRPTO.
In the chain, a colon separates the beginning of the statement from the variable parts. After the colon or commas, you can insert any number of spaces.
You could, for example, write the same statement like this:
WRITE: SPFLI-CITYFROM,
SPFLI-CITYTO,
SPFLI-AIRPTO.
In a chain statement, the first part (before the colon) is not limited to the keyword of the statements.
Statement sequence:
SUM = SUM + 1.
SUM = SUM + 2.
SUM = SUM + 3.
SUM = SUM + 4.
Chain statement:
SUM = SUM + : 1, 2, 3, 4.
Comments
Comments are texts that you can write between the statements of your ABAP program to explain their purpose to a reader. Comments are distinguished by the preceding signs * (at the beginning of a line) and " (at any position in a line). If you want the entire line to be a comment, enter an asterisk (*) at the beginning of the line. The system then ignores the entire line when it generates the program. If you want part of a line to be a comment, enter a double quotation mark (") before the comment. The system interprets comments indicated by double quotation marks as spaces.
************************************************
* PROGRAM SAPMTEST *
* WRITTEN BY KARL BYTE, 06/27/1995 *
* LAST CHANGED BY RITA DIGIT, 10/01/1995 *
* TASK: DEMONSTRATION *
************************************************
PROGRAM SAPMTEST.
************************************************
* DECLARATIONS *
************************************************
DATA: FLAG " GLOBAL FLAG
NUMBER TYPE I " COUNTER
......
************************************************
* PROCESSING BLOCKS *
************************************************
......
Statements
An ABAP program consists of individual ABAP statements. Each statement begins with a keyword and ends with a period.
PROGRAM FIRST_PROGRAM.
WRITE 'My First Program'.
This example contains two statements, one on each line. The keywords are PROGRAM and WRITE. The program displays a list on the screen. In this case, the list consists of the line "My First Program".
The keyword determines the category of the statement. For an overview of the different categories, refer to ABAP Statements.
Formatting ABAP Statements
ABAP has no format restrictions. You can enter statements in any format, so a statement can be indented, you can write several statements on one line, or spread a single statement over several lines.
You must separate words within a statement with at least one space. The system also interprets the end of line marker as a space.
The program fragment
PROGRAM TEST.
WRITE 'This is a statement'.
could also be written as follows:
PROGRAM TEST. WRITE 'This is a statement'.
or as follows:
PROGRAM
TEST.
WRITE
'This is a statement'.
Use this free formatting to make your programs easier to understand.
Special Case: Text Literals
Text literals are sequences of alphanumeric characters in the program code that are enclosed in quotation marks. If a text literal in an ABAP statement extends across more than one line, the following difficulties can occur:
All spaces between the quotation marks are interpreted as belonging to the text literal.
Letters in text literals in a line that is not concluded with quotation marks are interpreted by the editor as uppercase.
If you want to enter text literals that do not fit into a single line, you can use the ‘&’ character to combine a succession of text literals into a single one.
The program fragment
PROGRAM TEST.
WRITE 'This
is
a statement'.
inserts all spaces between the quotation marks into the literal, and converts the letters to uppercase.
This program fragment
PROGRAM TEST.
WRITE 'This' &
' is ' &
'a statement'.
combines three text literals into one.
Chained Statements
The ABAP programming language allows you to concatenate consecutive statements with an identical first part into a chain statement.
To concatenate a sequence of separate statements, write the identical part only once and place a colon (:) after it. After the colon, write the remaining parts of the individual statements, separating them with commas. Ensure that you place a period (.) after the last part to inform the system where the chain ends.
Statement sequence:
WRITE SPFLI-CITYFROM.
WRITE SPFLI-CITYTO.
WRITE SPFLI-AIRPTO.
Chain statement:
WRITE: SPFLI-CITYFROM, SPFLI-CITYTO, SPFLI-AIRPTO.
In the chain, a colon separates the beginning of the statement from the variable parts. After the colon or commas, you can insert any number of spaces.
You could, for example, write the same statement like this:
WRITE: SPFLI-CITYFROM,
SPFLI-CITYTO,
SPFLI-AIRPTO.
In a chain statement, the first part (before the colon) is not limited to the keyword of the statements.
Statement sequence:
SUM = SUM + 1.
SUM = SUM + 2.
SUM = SUM + 3.
SUM = SUM + 4.
Chain statement:
SUM = SUM + : 1, 2, 3, 4.
Comments
Comments are texts that you can write between the statements of your ABAP program to explain their purpose to a reader. Comments are distinguished by the preceding signs * (at the beginning of a line) and " (at any position in a line). If you want the entire line to be a comment, enter an asterisk (*) at the beginning of the line. The system then ignores the entire line when it generates the program. If you want part of a line to be a comment, enter a double quotation mark (") before the comment. The system interprets comments indicated by double quotation marks as spaces.
************************************************
* PROGRAM SAPMTEST *
* WRITTEN BY KARL BYTE, 06/27/1995 *
* LAST CHANGED BY RITA DIGIT, 10/01/1995 *
* TASK: DEMONSTRATION *
************************************************
PROGRAM SAPMTEST.
************************************************
* DECLARATIONS *
************************************************
DATA: FLAG " GLOBAL FLAG
NUMBER TYPE I " COUNTER
......
************************************************
* PROCESSING BLOCKS *
************************************************
......
Inner Join
SELECT t685~kschl t682z~kozgf t682i~kotabnr t682z~kvewe t682z~kappl t682z~kolnr zaehk zifna
FROM t685
INNER JOIN t682i
ON t685~kvewe eq t682i~kvewe and
t685~kappl eq t682i~kappl and
t685~kozgf eq t682i~kozgf
INNER JOIN t682z
ON t682i~kvewe eq t682z~kvewe and
t682i~kappl eq t682z~kappl and
t682i~kozgf eq t682z~kozgf and
t682i~kolnr eq t682z~kolnr
INTO TABLE gt_t682
WHERE t685~kvewe = 'A' AND " 'A' - Pricing
t685~kappl = 'V' AND " 'V' - Sales/Distribution
t685~kschl IN gr_kschl AND
t682z~qustr NE ''.
FROM t685
INNER JOIN t682i
ON t685~kvewe eq t682i~kvewe and
t685~kappl eq t682i~kappl and
t685~kozgf eq t682i~kozgf
INNER JOIN t682z
ON t682i~kvewe eq t682z~kvewe and
t682i~kappl eq t682z~kappl and
t682i~kozgf eq t682z~kozgf and
t682i~kolnr eq t682z~kolnr
INTO TABLE gt_t682
WHERE t685~kvewe = 'A' AND " 'A' - Pricing
t685~kappl = 'V' AND " 'V' - Sales/Distribution
t685~kschl IN gr_kschl AND
t682z~qustr NE ''.
Working with internal tables
1. Looping over an internal table
Se also Loop at with where clause - Do and dont's
Internal table with header line
Loop at itab.
itab-qty = 0.
modify itab.
endloop.
Internal table without header line
Note: You must create a workarea with same line type as the table
loop at itab into wa_itab.
wa_itab-qty = 0.
modify itab from wa_itab.
endloop.
2. Delete duplicate entries in internal table after sort
To delete all duplicate entries from a sorted internal table (e.g. just after SORT), you can use the
DELETE ADJACENT DUPLICATES FROM itab
You can use the COMPARING to limit the fields that are used to test for duplicate entries e.g.
SORT i_tab by matnr werks logort.
DELETE ADJACENT DUPLICATES FROM itab COMPARING matnr werks.
All duplicates with same combination of matnr and werks will be deleted.
3. Appending an internal table to another
Note that the two tables must have the same structure
The area the source table that will be appended can be restricted by using FROM index1 TO index2
APPEND LINES OF itab FROM index1 TO index2 TO table2.
4. Copy an internal table to another internal table
Note: The tables must have exactly the structure
itab2[] = itab2[]
5. Check if there are any entries in an internal table
If you don't need to know the number of entries in the table, but only wants to know if there are any entries at all use:
if itab[] is initial.........
Instead of using describe table.
6. Summarize dats into an internal table
Syntax: COLLECT [wa INTO] itab.
Note: You can only use COLLECT if all of the tables non-key fields are numeric (Type I, P, F)
The collect command summarizes all numerical fields (Type I, P, F) that are not part of the key into an internal table. The level of summarization is determined by the table key which can be both numerical and non numerical. After using the COLLECT command you will have a table with unique keys.
Example of collect
7. Modify, Insert, and Delete entries in an internal table
Modifying a single line
read table itab
with key name = 'My name'
into wa_itab.
wa_itab-age = 25.
modify itab from wa_itab transporting age.
Note: If you want to modify the whole table line, you can commit TRANSPORTING.
Modifying a set of lines
loop at itab into wa_itab where ........
wa_itab-name = 'My name'.
wa_itab-age = 40.
modify itab from wa_itab.
endloop.
If a subset of entries in the table should have the same values, it is better to use:
wa_itab-name = 'My name'.
wa_itab-age = 40.
modify itab from wa_itab transporting name age where .............
Notes: If you commit the where clause, a runtime error occurs.
If the table has the type SORTED TABLE or HASHED TABLE, the TRANSPORTING list may not contain key fields.
Deleting a single line
read table itab
with key name = 'My name'
into wa_itab.
if sy-subrc = 0.
delete itab.
endif.
Deleting all lines
refresh itab.
If you also want to free the memory taken up by the table, use FREE instead of REFRESH
Deleting a subset
This can be done in a loop, but it is better to do it this way:
Delete itab where name = 'My name'.
Remember that you can also use wildcards. E.g. if you want to delete all names starting with 'A':
Delete itab where name = 'A*'.
Reading database tables into internal tables
Performance tips:
• Only read the fields that you need. If you don't need all the fields avoid using SELECT *
• Avoid nested select for large numbers of entries
• Use a WHERE clause instead of CHECK
• Use as meny keyfields as possible in the WHERE clause
• If you only want to evaluate the selected data once, you should read it into a work area. Reading it into an internal table would incur additional costs for the handling of internal tables and also use more memory space.
• If you want to read the data into an internal table, it is better to do this in a single operation than to read it line-by-line in a SELECT loop and then use APPEND to append it to an internal table.
• You should only use the variant ... INTO CORRESPONDING FIELDS ... with large volumes of data because otherwise the time required to compare the field names in the name table is too high.
Efficient Method:
select carrid connid fldate
from sflight
into itab
where carrid = 'LH'.
If you use INTO clause, the fields in the field list must have the same order as in table itab. If not use:
select carrid connid fldate
from sflight
INTO CORRESPONDING FIELDS OF TABLE itab
where carrid = 'LH'.
If you want to append entries to a table which allready has entries use
select carrid connid fldate
from sflight
APPENDING CORRESPONDING FIELDS OF TABLE itab
where carrid = 'LH'.
or
select carrid connid fldate
from sflight
APPENDING itab
where carrid = 'LH'.
Se also Loop at with where clause - Do and dont's
Internal table with header line
Loop at itab.
itab-qty = 0.
modify itab.
endloop.
Internal table without header line
Note: You must create a workarea with same line type as the table
loop at itab into wa_itab.
wa_itab-qty = 0.
modify itab from wa_itab.
endloop.
2. Delete duplicate entries in internal table after sort
To delete all duplicate entries from a sorted internal table (e.g. just after SORT), you can use the
DELETE ADJACENT DUPLICATES FROM itab
You can use the COMPARING to limit the fields that are used to test for duplicate entries e.g.
SORT i_tab by matnr werks logort.
DELETE ADJACENT DUPLICATES FROM itab COMPARING matnr werks.
All duplicates with same combination of matnr and werks will be deleted.
3. Appending an internal table to another
Note that the two tables must have the same structure
The area the source table that will be appended can be restricted by using FROM index1 TO index2
APPEND LINES OF itab FROM index1 TO index2 TO table2.
4. Copy an internal table to another internal table
Note: The tables must have exactly the structure
itab2[] = itab2[]
5. Check if there are any entries in an internal table
If you don't need to know the number of entries in the table, but only wants to know if there are any entries at all use:
if itab[] is initial.........
Instead of using describe table.
6. Summarize dats into an internal table
Syntax: COLLECT [wa INTO] itab.
Note: You can only use COLLECT if all of the tables non-key fields are numeric (Type I, P, F)
The collect command summarizes all numerical fields (Type I, P, F) that are not part of the key into an internal table. The level of summarization is determined by the table key which can be both numerical and non numerical. After using the COLLECT command you will have a table with unique keys.
Example of collect
7. Modify, Insert, and Delete entries in an internal table
Modifying a single line
read table itab
with key name = 'My name'
into wa_itab.
wa_itab-age = 25.
modify itab from wa_itab transporting age.
Note: If you want to modify the whole table line, you can commit TRANSPORTING.
Modifying a set of lines
loop at itab into wa_itab where ........
wa_itab-name = 'My name'.
wa_itab-age = 40.
modify itab from wa_itab.
endloop.
If a subset of entries in the table should have the same values, it is better to use:
wa_itab-name = 'My name'.
wa_itab-age = 40.
modify itab from wa_itab transporting name age where .............
Notes: If you commit the where clause, a runtime error occurs.
If the table has the type SORTED TABLE or HASHED TABLE, the TRANSPORTING list may not contain key fields.
Deleting a single line
read table itab
with key name = 'My name'
into wa_itab.
if sy-subrc = 0.
delete itab.
endif.
Deleting all lines
refresh itab.
If you also want to free the memory taken up by the table, use FREE instead of REFRESH
Deleting a subset
This can be done in a loop, but it is better to do it this way:
Delete itab where name = 'My name'.
Remember that you can also use wildcards. E.g. if you want to delete all names starting with 'A':
Delete itab where name = 'A*'.
Reading database tables into internal tables
Performance tips:
• Only read the fields that you need. If you don't need all the fields avoid using SELECT *
• Avoid nested select for large numbers of entries
• Use a WHERE clause instead of CHECK
• Use as meny keyfields as possible in the WHERE clause
• If you only want to evaluate the selected data once, you should read it into a work area. Reading it into an internal table would incur additional costs for the handling of internal tables and also use more memory space.
• If you want to read the data into an internal table, it is better to do this in a single operation than to read it line-by-line in a SELECT loop and then use APPEND to append it to an internal table.
• You should only use the variant ... INTO CORRESPONDING FIELDS ... with large volumes of data because otherwise the time required to compare the field names in the name table is too high.
Efficient Method:
select carrid connid fldate
from sflight
into itab
where carrid = 'LH'.
If you use INTO
select carrid connid fldate
from sflight
INTO CORRESPONDING FIELDS OF TABLE itab
where carrid = 'LH'.
If you want to append entries to a table which allready has entries use
select carrid connid fldate
from sflight
APPENDING CORRESPONDING FIELDS OF TABLE itab
where carrid = 'LH'.
or
select carrid connid fldate
from sflight
APPENDING itab
where carrid = 'LH'.
Defining and Reading Internal Tables
Data types Type Description Byte
C Text (character) 1
N Numeric text 1
D Date (YYYYMMDD) 8
T Time (HHMMSS) 6
X Hexadecimal 1
I Integer 4
P Packed number 8
F Floating point no. 8
Defining and Reading Internal Tables
1. Types of internal tables
STANDARD table
Key access to a standard table uses a linear search. This means that the time required for a search is in linear relation to the number of table entries. You should use index operations to access standard tables.
SORTED table
Defines the table as one that is always saved correctly sorted. Key access to a sorted table uses a binary key. If the key is not unique, the system takes the entry with the lowest index. The runtime required for key access is logarithmically related to the number of table entries.
HASHED table
Defines the table as one that is managed with an internal hash procedure. You can only access a hashed table using the generic key operations or other generic operations ( SORT, LOOP, and so on). Explicit or implicit index operations (such as LOOP ... FROM oe INSERT itab within a LOOP) are not allowed.
INDEX table
A table that can be accessed using an index. Index table is only used to specify the type of generic parameters in a FORM or FUNCTION. That means that you can't create a table of type INDEX. Standard tables and sorted tables are index tables.
ANY table
Any table is only used to specify the type of generic parameters in a FORM or FUNCTION. That means that you can't create a table of type ANY. Standard, sorted and hashed tables belongs to ANY tables.
2. Defining an internal table
DATA itab TYPE table type of line type [WITH UNIQUE/NON-UNIQUE KEY] [Iinitial size n] [WITH HEADER LINE]
Note: There are also other ways to define an internal table. Please refer to the documentation.
The KEY option
KEY key1,,keyn :
key1..keyn are fields in the table. The sequence in which you specify the key is significant.
DEFAULT KEY :
The key fields are the standard keys. Note that you can only specify an empty key for tables with access type STANDARD TABLE. The standard key basically comprises all tables fields with character-like types (type ( C, STRING, D, T, N, X, XSTRING). In particular, components with a numeric type (also refer to ABAP numeric types) and table components usually do not belong to the standard key.
3. Reading internal tables
READ TABLE itab WITH TABLE KEY k1 = v1 k2 = v2 [additions]
Note: In case of more than one match, it is the first match that is selected.
• STANDARD TABLE: The system searches from the start of the table. The response time is in linear relation to the number of table entries.
• SORTED TABLE: The response time is in logarithmic relation to the number of table entries.
• HASHED TABLE: The response time is constant
READ TABLE itab WITH KEY k1 = v1 k2 = v2 [BINARY SEARCH] [additions]
Note: In case of more than one match, it is the first match that is selected.
• STANDARD TABLE: If you use the ... BINARY SEARCH addition, the system uses a binary search. Otherwise, the search is sequential. This assumes that the internal table is sorted in ascending order in the sequence of the specified key fields.
• SORTED TABLE: If the specified key fields form a left-justified extract of the table key, the search is binary, otherwise sequential.
• HASHED TABLE: Sequential search.
READ TABLE itab INDEX i [additions]
Accessing the table entry with the index i.
Additions:
• INTO wa - wa is used as output area
• ASSIGNING - The field symbol is assigned to the entry. This saves the cost of copying the contents in comparison to the first addition. However, this addition does involve table administration costs, and it is therefore only worthwile for lines longer than around 300 bytes.
• COMPARING f1...fn - If the system find an entry, the system compares the subfields f1, f2, ... with the corresponding fields of the work area before they are transported into it.
• COMPARING ALL FIELDS
• TRANSPORTING f1 f2 - If the system finds an entry, it does not transfer all of the subfields (default) into the work area, but only the specified fields f1 f2 ...; the other subfields remain unchanged.
• TRANSPORTING NO FIELDS
C Text (character) 1
N Numeric text 1
D Date (YYYYMMDD) 8
T Time (HHMMSS) 6
X Hexadecimal 1
I Integer 4
P Packed number 8
F Floating point no. 8
Defining and Reading Internal Tables
1. Types of internal tables
STANDARD table
Key access to a standard table uses a linear search. This means that the time required for a search is in linear relation to the number of table entries. You should use index operations to access standard tables.
SORTED table
Defines the table as one that is always saved correctly sorted. Key access to a sorted table uses a binary key. If the key is not unique, the system takes the entry with the lowest index. The runtime required for key access is logarithmically related to the number of table entries.
HASHED table
Defines the table as one that is managed with an internal hash procedure. You can only access a hashed table using the generic key operations or other generic operations ( SORT, LOOP, and so on). Explicit or implicit index operations (such as LOOP ... FROM oe INSERT itab within a LOOP) are not allowed.
INDEX table
A table that can be accessed using an index. Index table is only used to specify the type of generic parameters in a FORM or FUNCTION. That means that you can't create a table of type INDEX. Standard tables and sorted tables are index tables.
ANY table
Any table is only used to specify the type of generic parameters in a FORM or FUNCTION. That means that you can't create a table of type ANY. Standard, sorted and hashed tables belongs to ANY tables.
2. Defining an internal table
DATA itab TYPE table type of line type [WITH UNIQUE/NON-UNIQUE KEY
Note: There are also other ways to define an internal table. Please refer to the documentation.
The KEY option
KEY key1,,keyn :
key1..keyn are fields in the table. The sequence in which you specify the key is significant.
DEFAULT KEY :
The key fields are the standard keys. Note that you can only specify an empty key for tables with access type STANDARD TABLE. The standard key basically comprises all tables fields with character-like types (type ( C, STRING, D, T, N, X, XSTRING). In particular, components with a numeric type (also refer to ABAP numeric types) and table components usually do not belong to the standard key.
3. Reading internal tables
READ TABLE itab WITH TABLE KEY k1 = v1 k2 = v2 [additions]
Note: In case of more than one match, it is the first match that is selected.
• STANDARD TABLE: The system searches from the start of the table. The response time is in linear relation to the number of table entries.
• SORTED TABLE: The response time is in logarithmic relation to the number of table entries.
• HASHED TABLE: The response time is constant
READ TABLE itab WITH KEY k1 = v1 k2 = v2 [BINARY SEARCH] [additions]
Note: In case of more than one match, it is the first match that is selected.
• STANDARD TABLE: If you use the ... BINARY SEARCH addition, the system uses a binary search. Otherwise, the search is sequential. This assumes that the internal table is sorted in ascending order in the sequence of the specified key fields.
• SORTED TABLE: If the specified key fields form a left-justified extract of the table key, the search is binary, otherwise sequential.
• HASHED TABLE: Sequential search.
READ TABLE itab INDEX i [additions]
Accessing the table entry with the index i.
Additions:
• INTO wa - wa is used as output area
• ASSIGNING
• COMPARING f1...fn - If the system find an entry, the system compares the subfields f1, f2, ... with the corresponding fields of the work area before they are transported into it.
• COMPARING ALL FIELDS
• TRANSPORTING f1 f2 - If the system finds an entry, it does not transfer all of the subfields (default) into the work area, but only the specified fields f1 f2 ...; the other subfields remain unchanged.
• TRANSPORTING NO FIELDS
ABAP Vs JAVA
History
ABAP is much older than Java. While Java was released by Sun Microsystems in 1995, ABAP was created by SAP in the 1980s as the report language for its business application SAP R/2. Until today, ABAP is mainly used inside SAP as well as by SAP customers and consultants, to develop, modify, and extend SAP applications, like SAP R/3 or SAP ERP. SAP's newest platform solution NetWeaver supports both ABAP and Java. Java, on the other hand, was never intended to be used inside a certain company or for a certain product only, but focused on a broader market from the beginning. It is now widely used in many different programming areas such as network computing, web applications, or business software. All the concepts that ABAP supported since the first release are still supported and all the keywords are still valid, which is one reason why ABAP has many more keywords than Java.
Comparison
This is a comparison of the ABAP with the Java programming language. As two modern object oriented, garbage-collected programming languages, there are many conceptual similarities. However, the two languages with completely different histories also have many differences. This page documents the strong general similarities of the languages and points out those areas where the languages differ. Both languages were designed carefully, and if one language has a feature another lacks it is the result of a conscious design decision. Thus, the reader is advised to avoid the temptation to 'keep score,' and instead think about why the designers made each decision.
Language
Syntax
While Java's syntax is based on C and C++, the syntax of ABAP is not based entirely on a previous language, but has some syntax elements in common with COBOL). For example, each statement ends with a semicolon (;) in Java, while ABAP uses a dot (.). Character strings are surrounded by double quotes in Java (") and single quotes (') in ABAP. Comments are indicated by // or /* in Java and by * or " in ABAP. Whitespace is usually ignored in Java, while it can make a difference in ABAP.
Parameters in method calls are given the specified order in Java, while the parameter names usually have to be given in ABAP (Named parameters). Java supports one or no returning parameters of a method, and any number of importing parameters, while ABAP supports also several exporting or changing parameters.
Both languages do not support operator overloading as well. For many of the operators in Java (+, -, =), ABAP offers built-in functional keywords (ADD, SUBTRACT, MOVE).
Furthermore, both ABAP and Java do not allow pointer arithmetic, by which certain addresses in memory can be explicitly be accessed in languages like C, which are considered unsafe by some language designers.
Example ("Hello World")
ABAP
PROGRAM TEST.
WRITE 'Hello World'.
Java
// Hello.java
public class Hello{
public static void main(String [] args){
System.out.println("Hello World");
}
}
Platform independence
Java Code can run independently on a client or centrally on a server. Java code is not compiled into machine code, like many other languages including ABAP, but into byte code. This code is interpreted by the platform-specific Java Virtual Machine (JVM), which translates the byte code into the machine code of the platform. Thus, Java can run on any platform for which such a JVM is available.
ABAP code usually does not run directly on a client, but on an application server. Clients usually connect to the server via SAPgui or a web browser (BSP, WebDynpro). Therefore, ABAP applications can be used on any client for which a SAPGui client or a web browser is available.
ABAP is much older than Java. While Java was released by Sun Microsystems in 1995, ABAP was created by SAP in the 1980s as the report language for its business application SAP R/2. Until today, ABAP is mainly used inside SAP as well as by SAP customers and consultants, to develop, modify, and extend SAP applications, like SAP R/3 or SAP ERP. SAP's newest platform solution NetWeaver supports both ABAP and Java. Java, on the other hand, was never intended to be used inside a certain company or for a certain product only, but focused on a broader market from the beginning. It is now widely used in many different programming areas such as network computing, web applications, or business software. All the concepts that ABAP supported since the first release are still supported and all the keywords are still valid, which is one reason why ABAP has many more keywords than Java.
Comparison
This is a comparison of the ABAP with the Java programming language. As two modern object oriented, garbage-collected programming languages, there are many conceptual similarities. However, the two languages with completely different histories also have many differences. This page documents the strong general similarities of the languages and points out those areas where the languages differ. Both languages were designed carefully, and if one language has a feature another lacks it is the result of a conscious design decision. Thus, the reader is advised to avoid the temptation to 'keep score,' and instead think about why the designers made each decision.
Language
Syntax
While Java's syntax is based on C and C++, the syntax of ABAP is not based entirely on a previous language, but has some syntax elements in common with COBOL). For example, each statement ends with a semicolon (;) in Java, while ABAP uses a dot (.). Character strings are surrounded by double quotes in Java (") and single quotes (') in ABAP. Comments are indicated by // or /* in Java and by * or " in ABAP. Whitespace is usually ignored in Java, while it can make a difference in ABAP.
Parameters in method calls are given the specified order in Java, while the parameter names usually have to be given in ABAP (Named parameters). Java supports one or no returning parameters of a method, and any number of importing parameters, while ABAP supports also several exporting or changing parameters.
Both languages do not support operator overloading as well. For many of the operators in Java (+, -, =), ABAP offers built-in functional keywords (ADD, SUBTRACT, MOVE).
Furthermore, both ABAP and Java do not allow pointer arithmetic, by which certain addresses in memory can be explicitly be accessed in languages like C, which are considered unsafe by some language designers.
Example ("Hello World")
ABAP
PROGRAM TEST.
WRITE 'Hello World'.
Java
// Hello.java
public class Hello{
public static void main(String [] args){
System.out.println("Hello World");
}
}
Platform independence
Java Code can run independently on a client or centrally on a server. Java code is not compiled into machine code, like many other languages including ABAP, but into byte code. This code is interpreted by the platform-specific Java Virtual Machine (JVM), which translates the byte code into the machine code of the platform. Thus, Java can run on any platform for which such a JVM is available.
ABAP code usually does not run directly on a client, but on an application server. Clients usually connect to the server via SAPgui or a web browser (BSP, WebDynpro). Therefore, ABAP applications can be used on any client for which a SAPGui client or a web browser is available.
Labels:
ABAP,
java,
languages,
Platform independence,
syntax
ABAP - INTRO
Introduction
ABAP is one of the many application-specific fourth-generation languages (4GLs) first developed in the 1980s. It was originally the report language for SAP R/2, a platform that enabled large corporations to build mainframe business applications for materials management and financial and management accounting.
ABAP used to be an abbreviation of Allgemeiner Berichtsaufbereitungsprozessor, the German meaning of "generic report preparation processor", but was later renamed to Advanced Business Application Programming. ABAP was one of the first languages to include the concept of Logical Databases (LDBs), which provides a high level of abstraction from the basic database level.
The ABAP programming language was originally used by developers to develop the SAP R/3 platform. It was also intended to be used by SAP customers to enhance SAP applications – customers can develop custom reports and interfaces with ABAP programming. The language is fairly easy to learn for programmers but it is not a tool for direct use by non-programmers. Good programming skills, including knowledge of relational database design and preferably also of object-oriented concepts, are required to create ABAP programs.
ABAP remains the language for creating programs for the client-server R/3 system, which SAP first released in 1992. As computer hardware evolved through the 1990s, more and more of SAP's applications and systems were written in ABAP. By 2001, all but the most basic functions were written in ABAP. In 1999, SAP released an object-oriented extension to ABAP called ABAP Objects, along with R/3 release 4.6.
SAP's most recent development platform, NetWeaver, supports both ABAP and Java.
Where does the ABAP program run?
All ABAP programs reside inside the SAP database. They are not stored in separate external files like Java or C++ programs. In the database all ABAP code exists in two forms: source code, which can be viewed and edited with the ABAP Workbench tools, and generated code, a binary representation somewhat comparable with Java bytecode. ABAP programs execute under the control of the runtime system, which is part of the SAP kernel. The runtime system is responsible for processing ABAP statements, controlling the flow logic of screens and responding to events (such as a user clicking on a screen button). A key component of the ABAP runtime system is the Database Interface, which turns database-independent ABAP statements ("Open SQL") into statements understood by the underlying DBMS ("Native SQL"). The database interface handles all the communication with the relational database on behalf of ABAP programs; it also contains extra features such as buffering of frequently accessed data in the local memory of the application server.
SAP has three different layers as presentation layer (GUI), application layer (programs run on this) and data base layer where all data is stored and retrieved from user driven conditions, commands given by end user programmer through presentation layer.
SAP Basis
The ABAP language environment, including the syntax checking, code generation and runtime system, is part of the SAP Basis component. SAP Basis is the technological platform that supports the entire range of SAP applications, now typically implemented in the framework of the SAP Web Application Server. In that sense SAP Basis can be seen as the "operating system" on which SAP applications run. Like any operating system, SAP Basis contains both low-level services (for example memory management, database communication or servicing Web requests) and high-level tools for end users and administrators. These tools can be executables ("SAP kernel") running directly on the underlying operating system, transactions developed in ABAP, or Web-based interfaces...
SAP Basis also provides a layer of abstraction between the business applications and the operating system and database. This ensures that applications do not depend directly upon a specific server or database platform and can easily be ported from one platform to another.
SAP Basis currently runs on UNIX (AIX, HP-UX, Solaris, Linux), Microsoft Windows, i5/OS on IBM System i (formerly iSeries, AS/400) and z/OS on IBM System z (formerly zSeries, S/390). Supported databases are DB2, Informix, MaxDB, Oracle and Microsoft SQL Server (support for Informix was discontinued in SAP Basis release 7.00).
SAP systems and landscapes
All SAP data exists and all SAP software runs in the context of an SAP system. A system consists of a central relational database and one or more application servers ("instances") accessing the data and programs in this database. An SAP system contains at least one instance but may contain more, mostly for reasons of sizing and performance. In a system with multiple instances, load balancing mechanisms ensure that the load is spread evenly over the available application servers.
Installations of the Web Application Server (landscapes) typically consist of three systems: one for development, one for testing and quality assurance, and one for production. The landscape may contain more systems, e.g. separate systems for unit testing and pre-production testing, or it may contain fewer, e.g. only development and production, without separate QA; nevertheless three is the most common configuration. ABAP programs are created and undergo first testing in the development system. Afterwards they are distributed to the other systems in the landscape. These actions take place under control of the Change and Transport System (CTS), which is responsible for concurrency control (e.g. preventing two developers from changing the same code at the same time), version management and deployment of programs on the QA and production systems.
The Web Application Server consists of three layers: the database layer, the application layer and the presentation layer. These layers may run on the same or on different physical machines. The database layer contains the relational database and the database software. The application layer contains the instance or instances of the system. All application processes, including the business transactions and the ABAP development, run on the application layer. The presentation layer handles the interaction with users of the system. Online access to ABAP application servers can go via a proprietary graphical interface, the SAPGUI, or via a Web browser.
ABAP is one of the many application-specific fourth-generation languages (4GLs) first developed in the 1980s. It was originally the report language for SAP R/2, a platform that enabled large corporations to build mainframe business applications for materials management and financial and management accounting.
ABAP used to be an abbreviation of Allgemeiner Berichtsaufbereitungsprozessor, the German meaning of "generic report preparation processor", but was later renamed to Advanced Business Application Programming. ABAP was one of the first languages to include the concept of Logical Databases (LDBs), which provides a high level of abstraction from the basic database level.
The ABAP programming language was originally used by developers to develop the SAP R/3 platform. It was also intended to be used by SAP customers to enhance SAP applications – customers can develop custom reports and interfaces with ABAP programming. The language is fairly easy to learn for programmers but it is not a tool for direct use by non-programmers. Good programming skills, including knowledge of relational database design and preferably also of object-oriented concepts, are required to create ABAP programs.
ABAP remains the language for creating programs for the client-server R/3 system, which SAP first released in 1992. As computer hardware evolved through the 1990s, more and more of SAP's applications and systems were written in ABAP. By 2001, all but the most basic functions were written in ABAP. In 1999, SAP released an object-oriented extension to ABAP called ABAP Objects, along with R/3 release 4.6.
SAP's most recent development platform, NetWeaver, supports both ABAP and Java.
Where does the ABAP program run?
All ABAP programs reside inside the SAP database. They are not stored in separate external files like Java or C++ programs. In the database all ABAP code exists in two forms: source code, which can be viewed and edited with the ABAP Workbench tools, and generated code, a binary representation somewhat comparable with Java bytecode. ABAP programs execute under the control of the runtime system, which is part of the SAP kernel. The runtime system is responsible for processing ABAP statements, controlling the flow logic of screens and responding to events (such as a user clicking on a screen button). A key component of the ABAP runtime system is the Database Interface, which turns database-independent ABAP statements ("Open SQL") into statements understood by the underlying DBMS ("Native SQL"). The database interface handles all the communication with the relational database on behalf of ABAP programs; it also contains extra features such as buffering of frequently accessed data in the local memory of the application server.
SAP has three different layers as presentation layer (GUI), application layer (programs run on this) and data base layer where all data is stored and retrieved from user driven conditions, commands given by end user programmer through presentation layer.
SAP Basis
The ABAP language environment, including the syntax checking, code generation and runtime system, is part of the SAP Basis component. SAP Basis is the technological platform that supports the entire range of SAP applications, now typically implemented in the framework of the SAP Web Application Server. In that sense SAP Basis can be seen as the "operating system" on which SAP applications run. Like any operating system, SAP Basis contains both low-level services (for example memory management, database communication or servicing Web requests) and high-level tools for end users and administrators. These tools can be executables ("SAP kernel") running directly on the underlying operating system, transactions developed in ABAP, or Web-based interfaces...
SAP Basis also provides a layer of abstraction between the business applications and the operating system and database. This ensures that applications do not depend directly upon a specific server or database platform and can easily be ported from one platform to another.
SAP Basis currently runs on UNIX (AIX, HP-UX, Solaris, Linux), Microsoft Windows, i5/OS on IBM System i (formerly iSeries, AS/400) and z/OS on IBM System z (formerly zSeries, S/390). Supported databases are DB2, Informix, MaxDB, Oracle and Microsoft SQL Server (support for Informix was discontinued in SAP Basis release 7.00).
SAP systems and landscapes
All SAP data exists and all SAP software runs in the context of an SAP system. A system consists of a central relational database and one or more application servers ("instances") accessing the data and programs in this database. An SAP system contains at least one instance but may contain more, mostly for reasons of sizing and performance. In a system with multiple instances, load balancing mechanisms ensure that the load is spread evenly over the available application servers.
Installations of the Web Application Server (landscapes) typically consist of three systems: one for development, one for testing and quality assurance, and one for production. The landscape may contain more systems, e.g. separate systems for unit testing and pre-production testing, or it may contain fewer, e.g. only development and production, without separate QA; nevertheless three is the most common configuration. ABAP programs are created and undergo first testing in the development system. Afterwards they are distributed to the other systems in the landscape. These actions take place under control of the Change and Transport System (CTS), which is responsible for concurrency control (e.g. preventing two developers from changing the same code at the same time), version management and deployment of programs on the QA and production systems.
The Web Application Server consists of three layers: the database layer, the application layer and the presentation layer. These layers may run on the same or on different physical machines. The database layer contains the relational database and the database software. The application layer contains the instance or instances of the system. All application processes, including the business transactions and the ABAP development, run on the application layer. The presentation layer handles the interaction with users of the system. Online access to ABAP application servers can go via a proprietary graphical interface, the SAPGUI, or via a Web browser.
Monday, November 17, 2008
SAP History
From Start-Up Software Vendor to Global Market Leader
Over the course of three decades, SAP has evolved from a small, regional enterprise into a world-class international company. Today, SAP is the global market leader in collaborative, inter-enterprise business solutions. The company now employs more than 51,800 people, whose commitment and innovative spirit pace our future success.
The 1970s: A Real-Time Vision
In 1972, five former IBM employees – Dietmar Hopp, Hans-Werner Hector, Hasso Plattner, Klaus Tschira, and Claus Wellenreuther – launch a company called Systems Applications and Products in Data Processing in Mannheim, Germany. Their vision: to develop standard application software for real-time business processing.
One year later, the first financial accounting software is complete, forming the basis for the continuous development of other software components in what later came to be known as the "R/1 system." "R" stands for real-time data processing.
By the end of the decade, intensive examination of SAP's IBM database and dialog control system leads to the birth of SAP R/2.
The 1980s: Rapid Growth
SAP moves into the company's first building on Max-Planck-Strasse in an industrial park in Walldorf, near Heidelberg. Our software development area and its 50 terminals are all now under one roof. Fifty of the 100 largest German industrial firms are already SAP customers.
The SAP R/2 system attains the high level of stability of the previous generation of programs. Keeping in mind its multinational customers, SAP designs SAP R/2 to handle different languages and currencies. With this and other innovations in SAP R/2, SAP sees rapid growth.
By the middle of the decade, SAP founds its first sales organization outside Germany, in Austria. The company makes its first appearance at the CeBIT computer fair in Hanover, Germany. Revenues reach DM 100 million (around $52 million), earlier than expected.
In August 1988, SAP GmbH becomes SAP AG. Starting on November 4, 1.2 million shares are listed on the Frankfurt and Stuttgart stock exchanges.
Germany's renowned business journal, manager magazine, names SAP its Company of the Year – a distinction we would receive twice more in the next few years.
With the founding of subsidiaries in Denmark, Sweden, Italy, and the United States, SAP's international expansion takes a leap forward.
The 1990s: A New Approach to Software and Solutions
SAP R/3 is unleashed on the market. The client-server concept, uniform appearance of graphical interfaces, consistent use of relational databases, and the ability to run on computers from different vendors meets with overwhelming approval. With SAP R/3, SAP ushers in a new generation of enterprise software – from mainframe computing to the three-tier architecture of database, application, and user interface. To this day, the client-server architecture is the standard in business software.
A growing number of subsidiaries are managed out of Walldorf. The new Sales and Development Center in Walldorf officially opens it doors. It symbolizes the global success of the company. In our twentieth year, our business outside Germany exceeds 50 percent of total sales for the first time.
By 1996, the company has earned 1,089 new SAP R/3 customers. At the end of the year, SAP R/3 has been installed in more than 9,000 systems worldwide.
SAP celebrates its twenty-fifth anniversary in 1997 and now employs approximately 12,900 people. We continue to strengthen our industry focus and build more and more industry-specific solutions. Henning Kagermann becomes Co-Chairman and CEO of SAP AG with Hasso Plattner. On August 3, 1998, the letters S-A-P appear for the first time on the Big Board at the New York Stock Exchange (NYSE), the largest stock exchange in the world.
As the decade draws to a close, Hasso Plattner, Co-Founder, Co-Chairman, and CEO announces the mySAP.com strategy, heralding the beginning of a new direction for the company and our product portfolio. mySAP.com links e-commerce solutions to existing ERP applications, using state-of-the-art Web technology.
The 2000s: Innovation for the New Millennium
With the Internet, the user becomes the focus of software applications. SAP develops SAP Workplace and paves the way for the idea of an enterprise portal and role-specific access to information.
Currently, more than 12 million users work each day with SAP solutions. There are now 121,000 installations worldwide, more than 1,500 SAP partners, over 25 industry-specific business solutions, and more than 75,000 customers in 120 countries. SAP is the world's third-largest independent software vendor.
With service-oriented architecture and the underlying integration and application platform SAP NetWeaver, SAP is providing our customers with solutions for end-to-end business processes. With SAP NetWeaver, your company can integrate people, information, and processes within the company and beyond.
To further demonstrate our commitment for ongoing innovation, growth, and market leadership, SAP acquired Business Objects in 2008. Together, SAP and Business Objects, an SAP company, offers the industry's most comprehensive portfolio of business performance and optimization solutions for companies of all sizes.
Source - http://www.sap.com
Over the course of three decades, SAP has evolved from a small, regional enterprise into a world-class international company. Today, SAP is the global market leader in collaborative, inter-enterprise business solutions. The company now employs more than 51,800 people, whose commitment and innovative spirit pace our future success.
The 1970s: A Real-Time Vision
In 1972, five former IBM employees – Dietmar Hopp, Hans-Werner Hector, Hasso Plattner, Klaus Tschira, and Claus Wellenreuther – launch a company called Systems Applications and Products in Data Processing in Mannheim, Germany. Their vision: to develop standard application software for real-time business processing.
One year later, the first financial accounting software is complete, forming the basis for the continuous development of other software components in what later came to be known as the "R/1 system." "R" stands for real-time data processing.
By the end of the decade, intensive examination of SAP's IBM database and dialog control system leads to the birth of SAP R/2.
The 1980s: Rapid Growth
SAP moves into the company's first building on Max-Planck-Strasse in an industrial park in Walldorf, near Heidelberg. Our software development area and its 50 terminals are all now under one roof. Fifty of the 100 largest German industrial firms are already SAP customers.
The SAP R/2 system attains the high level of stability of the previous generation of programs. Keeping in mind its multinational customers, SAP designs SAP R/2 to handle different languages and currencies. With this and other innovations in SAP R/2, SAP sees rapid growth.
By the middle of the decade, SAP founds its first sales organization outside Germany, in Austria. The company makes its first appearance at the CeBIT computer fair in Hanover, Germany. Revenues reach DM 100 million (around $52 million), earlier than expected.
In August 1988, SAP GmbH becomes SAP AG. Starting on November 4, 1.2 million shares are listed on the Frankfurt and Stuttgart stock exchanges.
Germany's renowned business journal, manager magazine, names SAP its Company of the Year – a distinction we would receive twice more in the next few years.
With the founding of subsidiaries in Denmark, Sweden, Italy, and the United States, SAP's international expansion takes a leap forward.
The 1990s: A New Approach to Software and Solutions
SAP R/3 is unleashed on the market. The client-server concept, uniform appearance of graphical interfaces, consistent use of relational databases, and the ability to run on computers from different vendors meets with overwhelming approval. With SAP R/3, SAP ushers in a new generation of enterprise software – from mainframe computing to the three-tier architecture of database, application, and user interface. To this day, the client-server architecture is the standard in business software.
A growing number of subsidiaries are managed out of Walldorf. The new Sales and Development Center in Walldorf officially opens it doors. It symbolizes the global success of the company. In our twentieth year, our business outside Germany exceeds 50 percent of total sales for the first time.
By 1996, the company has earned 1,089 new SAP R/3 customers. At the end of the year, SAP R/3 has been installed in more than 9,000 systems worldwide.
SAP celebrates its twenty-fifth anniversary in 1997 and now employs approximately 12,900 people. We continue to strengthen our industry focus and build more and more industry-specific solutions. Henning Kagermann becomes Co-Chairman and CEO of SAP AG with Hasso Plattner. On August 3, 1998, the letters S-A-P appear for the first time on the Big Board at the New York Stock Exchange (NYSE), the largest stock exchange in the world.
As the decade draws to a close, Hasso Plattner, Co-Founder, Co-Chairman, and CEO announces the mySAP.com strategy, heralding the beginning of a new direction for the company and our product portfolio. mySAP.com links e-commerce solutions to existing ERP applications, using state-of-the-art Web technology.
The 2000s: Innovation for the New Millennium
With the Internet, the user becomes the focus of software applications. SAP develops SAP Workplace and paves the way for the idea of an enterprise portal and role-specific access to information.
Currently, more than 12 million users work each day with SAP solutions. There are now 121,000 installations worldwide, more than 1,500 SAP partners, over 25 industry-specific business solutions, and more than 75,000 customers in 120 countries. SAP is the world's third-largest independent software vendor.
With service-oriented architecture and the underlying integration and application platform SAP NetWeaver, SAP is providing our customers with solutions for end-to-end business processes. With SAP NetWeaver, your company can integrate people, information, and processes within the company and beyond.
To further demonstrate our commitment for ongoing innovation, growth, and market leadership, SAP acquired Business Objects in 2008. Together, SAP and Business Objects, an SAP company, offers the industry's most comprehensive portfolio of business performance and optimization solutions for companies of all sizes.
Source - http://www.sap.com
Subscribe to:
Posts (Atom)