0% found this document useful (0 votes)
18 views11 pages

Internal Table

Internal tables are temporary data structures used in ABAP for runtime data manipulation and calculations. They can be categorized into indexed (standard and sorted) and non-indexed (hashed) types, each with specific performance characteristics and usage scenarios. Key operations include reading, writing, and transferring data between internal tables, as well as using specific statements like MOVE, COLLECT, and READ to manage data effectively.

Uploaded by

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

Internal Table

Internal tables are temporary data structures used in ABAP for runtime data manipulation and calculations. They can be categorized into indexed (standard and sorted) and non-indexed (hashed) types, each with specific performance characteristics and usage scenarios. Key operations include reading, writing, and transferring data between internal tables, as well as using specific statements like MOVE, COLLECT, and READ to manage data effectively.

Uploaded by

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

Internal Table

What are internal tables?


Internal tables are a standard data type object which exists only during the runtime of the program. They are used to
perform table calculations on subsets of database tables and for re-organizing the contents of database tables according
to users need.

When an internal table is created, what are the setting criteria for the value of occur?
The objective of setting the value of an occurrence for an internal table is a question of optimization. The following facts
should be taken into account when making such decision:
1) The complete data area of a program is 64000 bytes.
2) The initial size declared is kept in roll area (quicker access to program)
3) Data entered that exceeds the initial size stores in the roll file (Slower access to program)
You should also analyze the expected volume and access rates before making the decision.

How do you get the number of lines in an internal table?


Using SY-DBCNT.

How to find the return code of a statement in ABAP programs?


Using SY-SUBRC.

What is the initial size of an internal table?


The size of the internal tables is set using the 'occurs n' clause. Here n refers to an integer number that specifies the size.
Usually it’s given as 'occurs 0' which creates an internal table with the memory space of 8kb.

How to use a specific number OCCURS statement?


The number of memory allocations the system need to allocate for the next record population.

What is Work Area?


Work area is nothing but a structure for a table with the same definition as Internal table which holds one record in run
time after that we need to append in to internal table one by one. It’s an explicit area where all the operations on
internal table can be performed. It gets destroyed when program terminates. It has two different parts. Header Line
(optional) & Body (Compulsory). Any value that comes to or goes from internal table, that travels through header line.
Of course without work area, one can perform operations through header line.

What is the main difference between work area and header line?
The functionality of Work area or Header line is same. I.e. they let us to work with the body of internal table. The default
work area for internal table is Header Line. The difference is, Header line is created by default when we create the
Internal table using "begin of" or explicitly “with header line". Work area should have the same structure as that of
internal table. It should be created by us, where as the header line is created automatically by any one of the above
statements. Note: when you create an internal table using the following statement:
Begin of IT_vbak occurs 10 without header line.
This will not create Header line.

What is the difference between this two following statements?


1. Select * from database table into itab
2. Select * from database table into table itab
First statement collects data into the header area of the internal table itab. Second statement collects the data into the
body area of the internal table itab directly.

What is the difference between Internal table with header line and with out header line?
Internal table with header line doesn’t need an explicit work area. Without header line, table needs an explicit work
area.

What should be declared explicitly in the corresponding ABAP/4 Statements to access internal tables without header
lines & why?
Work Area. This is required as the Work Area is the interface for transferring data to and from the table.

What’s an effective way of using an internal table record?


Create internal table without Header. Perform all the internal table operations by creating Work area. Clear Work area
whenever it is required. This would be the effective way of coding.

Explain Line type and Row type concept.


Line type refers to the structure of an internal table. It defines one field of internal table which can hold only one type of
data element, whereas row type defines the header or work area of the internal table where we can hold a record of
multiple data type and it refers to the table body. Creating internal table using line type and row type concept is for
reusability purpose. Line type and Row type are defined at DDIC LEVEL.

What does the TABLES statement do?


The TABLES statement:
 Identifies the table to the ABAP program.
 Creates a work area in memory to store records retrieved from the database (the work area only holds one record at
a time).

What do you get when you refer to a client-specific transparent table in the Dictionary if you have a data definition
with TABLES? (TRUE/FALSE)
 A structured work area (line). T
 A field. F
 An internal table. F

What is the difference between TYPE and LIKE keyword?


 Type refers the existing data type. Like refers the existing data object.
 Like is a keyword which is used to copy the existing properties of already existing data object. With like we create
work area for the data type.

An internal table type is defined using the ____________ statement whereas an internal table object is created using
the _____________ statement.
TYPES, DATA.

How is the read/write operation done on an internal table with header line?
When filling an internal table with a header line, you place the data in the header line. Using the corresponding
statements, the contents of the header line is transferred to the table. When reading the internal table, the ABAP/4
runtime system places the contents of the read table line in the header line.

What are Internal Tables types?


The internal tables could be categorized into two:
Indexed: Standard and Sorted tables.
Non-indexed: Hashed tables.
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.
Syntax: DATA itab TYPE table type of line type [WITH UNIQUE/NON-UNIQUE KEY]
[Initial size n] [WITH HEADER LINE]
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. It is the one we
use generally. In this the data is not sorted and the only thing we can do is just process the data with out any restriction
on it.
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. It works in two different manners:
 First one is similar to standard table but the only difference is the data will be filled in a particular manner
either ascending or descending.
 Second one you can also fill the table keeping any field as primary key. Now the data will be filled based on that
particular key.
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 or INSERT itab within a LOOP) are not allowed. You can use this when you want to
fill your internal table avoiding the duplication of data. It never permits the duplicate record to be stored in an internal
table.

In STANDARD TABLE the data are Non-Unique?


Yes.

In SORTED TABLE the data can be both ___________.


Unique & Non-Unique

If we Insert or Modify data in SORTED TABLE, it is done by index. (TRUE/FALSE)


True.

What is the difference between standard and sorted internal tables? (In performance wise)
Sorted table improve the performance in case of a huge table which has large number of records.

What the differences are between hashed & sorted internal tables?
Sorted internal table works on Binary Search and Hashed internal tables works on hashed algorithm.

In STANDARD table, we do searching in __________


Linear Search

In SORTED table, we do searching in __________


Binary Search

What is a binary search?


Binary Search is used in internal table for searching the records. In binary search, the total records are divided in
to two parts. It will search the particular record in first half and then in second half.

Which statements are allowed if you are working with an internal table of the type SORTED? (TRUE/FALSE)
 SORT. F
 APPEND. F
 MODIFY. F
 COLLECT. T
 READ. T
 INSERT. T

In case of internal tables, where user-defined key is used to differentiate between unique and non-unique keys?
Additional records with the same key would be permitted in case of the non-unique keys.
What is the difference between Select Single * from <table name> & select Upto n rows?
The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause and puts
it in to the work area of the internal table. If this results in multiple records then only the first one will be returned and
therefore may not be unique. The 'SELECT .... UP TO n ROWS' (where n stands for an integer number) statement is subtly
different. The database selects all of the relevant records that are defined by the WHERE clause or lack of, applies any
aggregate, ordering or grouping functions to them, but writes only the specified number of rows specified by the n into
the internal table. If it is given as up to 1 rows then only 1 row is written in to the internal table.

What is the difference between MOVE & ASSIGN statement?


Move: - To assign the value of a data object <f1> to a variable <f2>, use the following statement:
MOVE <f1> TO <f2>.
Or the equivalent statement
<f2> = <f1>.
The contents of <f1> remain unchanged. <f1> does not have to be a variable - it can also be a literal, a text symbol, or a
constant. You must always specify decimal points with a period (.), regardless of the user’s personal settings. For
Example:
DATA: NUMBER TYPE I, FIVE TYPE I.
MOVE 5 TO FIVE.
MOVE FIVE TO NUMBER.
The fields NUMBER and FIVE now both have the value 5. Multiple value assignments in the form is also possible.
<f4> = <f3> = <f2> = <f1>.
Assign: - When a data object is assigned, the field symbol inherits its technical attributes. The data type of the
assigned data object becomes the actual data type of the field symbol.
ASSIGN <f> TO <FS>.
When you assign the data object, the system checks whether the technical attributes of the data object <f>
correspond to any type specifications for the field symbol <FS>. The field symbol adopts any generic attributes of
<f> that are not contained in its own type specification. Following the assignment, it points to <f> in memory.

What is MOVE-CORRESPONDING Statement?


To perform a move from one field string to another where the data types and/or length do not match, MOVE-
CORRESPONDING Statement is used. It generates individual MOVE Statements for components with matching names.
Components in the receiving field string that do not have a matching name in the sending field string are not changed.
Syntax: MOVE-CORRESPONDING <f1> TO <f2>.
<f1> is Sending field string and <f2> is receiving field string.

Among MOVE and MOVE-CORRESPONDING which is efficient one?


MOVE-CORRESPONDING.

What is the command to be used to transfer the data from one internal table to another internal?
Take there is two internal tables - itab1 and itab2.
 Move-corresponding itab1 to itab2.
 Move itab1 to itab2.
 itab2 = itab1

What is a COLLECT statement?


COLLECT allows you to create unique or summarized datasets. The Collect statement includes the header line of an
internal table in the table as a new entry or adds it to an existing entry of the same type. ABAP/4 scans the table for an
entry which corresponds to the header line in all the fields which are not of type P, I, F. If such an entry is found, the
system adds all P, I and F fields from the header line to the corresponding fields in the table entry. If no match is found,
it is appended to the table by creating a new entry instead. The way in which the system finds the entries depends on
the type of the internal table:
 STANDARD TABLE: The system creates a temporary hash administration for the table to find the entries. This means
that the runtime required to find them does not depend on the number of table entries. The administration is
temporary, since it is invalidated by operations like DELETE, INSERT, MODIFY, SORT. A subsequent COLLECT is then
no longer independent of the table size, because the system has to use a linear search to find entries. For this
reason, you should only use COLLECT to fill standard tables.
 SORTED TABLE: The system uses a binary search to find the entries. There is a logarithmic relationship between the
number of table entries and the search time.

How COLLECT statement is it different from the APPEND statement?


When COLLECT Statement is executed, the system forms a key from the default key fields in the work area. The default
key fields are character fields (type c, n, d, t, and x). Therefore the keys are composed of the values from all field types c,
n, d, t, and x. It doesn’t matter if they are besides one another or sequential from each other by other fields.
The system then searches the body of the internal table for a row that has the same key as the key in the work area. If it
doesn’t find one, the row is appended to the end of the table. If it does find one, the numeric fields (types i, p, and f) in
the work area are added to the corresponding fields in the found row.

If an internal table is created using the initial size addition then what problem is faced while using the statement
APPEND <internal table> SORTED BY <field>?
Number of entries in the table exceeding the initial size clause is deleted.

Differentiate between the CLEAR, REFRESH and FREE internal table statements.
 CLEAR Statement initializes all fields in the header line.
 REFRESH Statement deletes all table lines but the storage space is not released and header line remains unchanged.
 FREE Statement releases the storage space for the table and the header line remains unchanged.

The CLEAR <field> statement sets a field back to its default value. (True/False)
False.

CLEAR statement clears the fields. (True/False)


False.

Name the ABAP/4 key word, which is used to clear the Header line of an Internal Table.
CLEAR <itab>.

Name the ABAP/4 key words to initialize an Internal Table with and without header line.
REFRESH <itab>.

In an ABAP/4 program how do you access data that exists on a presentation server vs. on an application server?
For presentation server use UPLOAD or WS_UPLOAD function modules.
For application server use OPEN DATASET, READ DATASET and CLOSE DATASET commands.

What is the difference between ‘Upload’, ‘Ws_uplaod’ and ‘Gui_upload’ function module?
Upload Ws_upload Gui_upload
 Uploading file from  Uploading file from  Uploading file from presentation
presentation server to internal presentation server to internal server to internal table without the
table with use of dialog. table without the use of dialog. use of dialog.
 The only required parameter is  The required parameters are  The required parameters are
‘DATA_TAB’ parameter. ‘FILENAME’, ‘FILETYPE’ & ‘FILENAME’ & ‘DATA_TAB’
‘DATA_TAB’ parameter. parameter.

 No “HAS_FIELD_SEPARATOR”  No “HAS_FIELD_SEPARATOR”  To read a local file with fields


parameter. parameter. separated by Tab,
“HAS_FIELD_SEPARATOR” parameter
should contain value ‘X’. Default is
space.

Name the function modules to write data from an Internal Table to the Presentation Server.
DOWNLOAD and WS_DOWNLOAD.

Name the function modules to read data from Presentation Server into an Internal Table.
UPLOAD and WS_UPLOAD.

Name the function module that can be used to give information about files on Presentation Server and about its
Operating System.
WS_QUERY.

How to determine the attributes of an internal table?


DESCRIBE TABLE <itab> [LINES <lin>] [OCCURS <occ>].

What is the main purpose of READ keyword?


Read statement is used to retrieve only one record from internal table. While using Read statement, the internal table
should have all primary keys. Otherwise SY-SUBRC will be returned as failed.

Write the different variants of the READ TABLE clause.


 read table <internal table>.
 read table <internal table> with key <key>.
 read table <internal table> with key <key> binary search.
 read table <internal table> index <i>.

How do you read selected lines of database table into an internal table in packages of predefined size?
SELECT * FROM <SPFLI> INTO TABLE <ITAB> PACKAGE SIZE <N>.
Where 'N' is variable.

Name the WILDCARD characters which are used for comparisons with character strings & numeric strings.
'%' and '_'.

Is SELECT a loop?
Yes.

How we format the data before write statement in report? What are control break statements?
We can format the reports output by using the loop events, which are called control break statements. These are used
to execute a set of code within the Loop and Endloop. These statements are:
 AT FIRST…..ENDAT: Used for Main Heading.
 AT LAST…..ENDAT: Used for Grand Total.
 AT NEW <Field> …..ENDAT: Used for Sub Heading.
 AT END OF <Field> …..ENDAT: Used for Sub-total.
 ON CHANGE OF <Field>…..ENDAT: Used for separating table on change of value for specified <field>.

What is difference between ON CHANGE OF <Field> & AT NEW <Field>?


 In case if you want to calculate sub-totals for same values in a field you can use the AT NEW statement. For example
in a table sflight there are two fields - carrid (airline id) and seatsmax (seat available). In case if you want to calculate
the total number of seats available for each carrid you have to sort the table first and using the AT NEW statement,
you can calculate the total seats for each carrid. AT NEW statement will be triggered whenever there is a change in
the carrid and the total seats will be returned for each carrid. In the same scenario if you use ON CHANGE OF <Field>
Statement it will not return the total seats for each carrid, instead it will return the total seat count for the entire
table, i.e. for all the carrid in the table.
 AT NEW statement can be used only between Loop…..Endloop whereas ON CHANGE OF Statement can also be used
in select….endselect, do…..enddo, etc.
 Another difference is that while using AT NEW, if you code any write statements between AT NEW and ENDAT the
value for the numeric fields will be returned as 0 and no numeric fields will be returned as *(asterisk). But in ON
CHANGE OF Statement the original values will be returned.

What is the main point while using control break in internal table?
For calculations purpose like sub-total, grand total. When you are using control break commands, internal table must be
sorted with key field and control-break commands must be used in between the LOOP and ENDLOOP only.

If we use control break statement in between SELECT and ENDSELECT, will it execute?
No.

SELECT * FROM tabname WHERE sales = ‘2000’.


...........................
ENDSELECT.
Suppose SY-SUBRC NE 0. Then how many times will SELECT….. ENDSELECT get executed?
Once.

What is the difference between CHECK and CONTINUE?


Check statement gives the conditional jump. It checks the condition within a loop and if it satisfies the condition, the
control moves to next statement in the loop. Otherwise, it terminates the loop.
Continue statement is an unconditional jump. It acts like go to statement. If the condition is true, it processes the
remaining statements and if the condition is false, then the control moves to the top of loop.

What is the use of 'FOR ALL ENTRIES'?


To avoid nested select statements we use SELECT FOR ALL ENTRIES statement. If there are more than 10000 records
SELECT FOR ALL ENTRIES is used. Performance wise SELECT FOR ALL ENTRIES is better to use.

What is the syntax for specifying database table name at runtime in SELECT statement?
NAME = 'SPFLI'.
SELECT * FROM (NAME).
--------------
--------------
ENDSELECT.

How to specify a client for database table processing?


TABLES SPFLI.
SELECT * FROM SPFLI CLIENT SPECIFIED
WHERE MANDT BETWEEN '001' AND '003'.
...
ENDSELECT.

Name the editor command.


 Insert
 Find
 Next
 Replace

Name the line commands.


 Insert
 Delete, Copy
 After, Before, Move
 Scroll, Split, Repeat

Line commands can be repeated maximum of _________ times.


9

ABAP is a ________ editor.


Line

How to add a single record to a database table?


Insert into <database table> values <work area>

How to insert all lines from an internal table into a database table?
Insert <database table> from table <internal table>

How delete records from an internal table?


Delete employees from table itab.

How to delete all records?


Select * from zmellemtab.
Delete zmellemtab.
Endselect.

How to eliminate duplicate entries in internal tables?


First sort the internal table and then to delete all duplicate entries from a sorted internal table use the following syntax:
SORT <internal table> BY <field name>.
DELETE ADJACENT DUPLICATES FROM <internal table> COMPARING <field name>.
You can use the COMPARING addition to limit the fields that are used to test for duplicate entries.
SORT itab by matnr.
DELETE ADJACENT DUPLICATES FROM itab COMPARING matnr.
All duplicates with same combination of matnr will be deleted.

Name the ABAP/4 key words, which are used to change the contents of database table.
UPDATE or MODIFY.

What is the Difference between INSERT, MODIFY and UPDATE?


 INSERT: Add a new record into the database table.
 MODIFY: If record is available it modifies otherwise it won’t modify.
 UPDATE: If record is available its update the record otherwise it creates a new record.

In the SELECT statement what is GROUP BY?


The use of GROUP BY has the prerequisite that SELLECT only individual columns, not all the columns, are specified using
*. If GROUP BY is used, all columns that are specified directly after SELECT and not specified as an argument of an
aggregate function must be listed there. For example:
Select count (*) from emptable group by deptno where deptno = 1.

SQL used in ABAP/4 is known as ____________.


OPEN SQL.

What is Open SQL & Native SQL?


Open SQL allows you to access all database tables known to the SAP system, regardless of the database manufacturer.
Sometimes, however, we may want to use database-specific SQL statements called Native SQL in your ABAP/4 program.
To avoid incompatibilities between different database tables and also to make ABAP/4 programs independent of the
database system in use, SAP has created a set of separate SQL statements called Open SQL. Open SQL contains a subset
of standard SQL statements as well as some enhancements which are specific to SAP.
A database interface translates SAP's Open SQL statements into SQL commands specific to the database in use. Native
SQL statements access the database directly.

What does an EXEC SQL statement do in ABAP? What is the disadvantage of using it?
To use a Native SQL statement, it must be preceded by an EXEC SQL statement and concluded by an ENDEXEC
statement.
Syntax: EXEC SQL
[Native SQL statements]
ENDEXEC.
Disadvantages are:
 An ABAP/4 program with Native SQL statements does not generally run with different databases.
 Syntax check is not done to statements written inside the EXEC SQL statements.

How do you take care of performance issues in your ABAP programs?


Performance of ABAP programs can be improved by minimizing the amount of data to be transferred. The data set must
be transferred through the network to the applications, so reducing the amount of time and also reduces the network
traffic.
Some measures that can be taken are:
 Use views defined in the ABAP/4 DDIC, rather than tables (also has the advantage of better reusability).
 Use field list (SELECT clause) rather than SELECT * Statement.
 Range tables should be avoided (IN operator).
 Avoid nested SELECTS.

Which transaction code can be used to analyze the performance of ABAP Program?
AL21.

What is performance tuning?


Performance tuning for Data Selection Statement
1. ABAP/4 Optimization
 Use the GET RUN TIME commands to help evaluate performance. It's hard to know whether that optimization
technique REALLY helps unless you test it out. Using this tool can help you know what is effective, under what
kinds of conditions. The GET RUN TIME has problems under multiple CPUs, so you should use it to test small
pieces of your program, rather than the whole program.
 Avoid 'SELECT *', especially in tables that have a lot of fields. Use SELECT A B C INTO instead, so that fields are
only read if they are used. This can make a very big difference.
 Field-groups can be useful for multi-level sorting and displaying. However, they write their data to the system's
paging space, rather than to memory (internal tables use memory). For this reason, field-groups are only
appropriate for processing large lists (e.g. over 50,000 records). If you have large lists, you should work with the
systems administrator to decide the maximum amount of RAM your program should use, and from that,
calculate how much space your lists will use. Then you can decide whether to write the data to memory or swap
space. See the Field-groups ABAP example.
 Use as many table keys as possible in the WHERE part of your select statements.
 Whenever possible, design the program to access a relatively constant number of records (for instance, if you
only access the transactions for one month, then there probably will be a reasonable range, like 1200-1800, for
the number of transactions inputted within that month). Then use a SELECT A B C INTO TABLE ITAB statement.
 Get a good idea of how many records you will be accessing. Log into your productive system, and use SE80 ->
Dictionary Objects (press Edit), enter the table name you want to see, and press Display. Go To Utilities -> Table
Contents to query the table contents and see the number of records. This is extremely useful in optimizing a
program's memory allocation.
 Try to make the user interface such that the program gradually unfolds more information to the user, rather
than giving a huge list of information all at once to the user.
 Declare your internal tables using OCCURS NUM_RECS, where NUM_RECS is the number of records you expect
to be accessing. If the number of records exceeds NUM_RECS, the data will be kept in swap space (not memory).
 Use SELECT A B C INTO TABLE ITAB whenever possible. This will read all of the records into the itab in one
operation, rather than repeated operations that result from a SELECT A B C INTO ITAB... ENDSELECT statement.
Make sure that ITAB is declared with OCCURS NUM_RECS, where NUM_RECS is the number of records you
expect to access.
 Many tables contain totals fields (such as monthly expense totals). Use these avoid wasting resources by
calculating a total that has already been calculated and stored.
 Program Analysis Utility: To determine the usage of variables and subroutines within a program, you can use
the ABAP utility called ‘Program Analysis’ included in transaction SE38. To do so, execute transaction SE38, enter
your program name, then use the path Utilities -> Program Analysis.
2. ABAP Performance improvements via Data Dictionary
 INDEX CREATION SUGGESTIONS RELATED TO DATABASE PERFORMANCE: The columns at the beginning of an
index are the most “common”. The most “common” columns are those where reports are selecting columns
with no ranges - the where clause for these columns is an “equal to” expression. Rearrange columns of an index
to match the selection criteria. For example, if a select statement is written to include columns 1 and 2 with
“equal to” expressions in the where clause and column 3 and 4 are selected with value ranges, then the index
should be created with columns in the sequence of 1,2,3,4.
 Columns towards the end of the index are either infrequently used in selects or are part of reporting selects that
involve ranges of values.
 TABLE TYPE SUGGESTIONS RELATED TO DATABASE PERFORMANCE: Use VIEW tables to effectively join and
“denormalize” related tables that are taking large amounts of time to select for reporting. For example, at times
where highly accessed tables normalize description text into one table and the header data into another table, it
may make sense to create a view table that joins the relevant fields of the two associated with a poor
performing ABAP.
 For POOL tables that contain large amounts of data and are highly accessed, convert the pooled table into a
transparent table and add an index. POOLED tables are supposed to be collections of smaller tables that are
quickly accessed from the database or are completely buffered in memory. Pooled tables containing more than
a few hundred rows and are accessed many times in a report or transaction are candidates for POOL to
TRANSPARENT Conversion. For example, table A053 contains tax jurisdiction condition information and are
accessed more than ten times in the sales order create transaction. If the entire United States tax codes are
loaded into these condition tables, the time to save a sales order increases to unacceptable levels. Converting
the tax condition table to transparent and creating an index based upon the key fields, decreases processing
time from minutes to seconds.
 Do not allow the use of LIKE in an SAP SQL statement accessing a large table.
 Use internal tables in ABAPs to preselect values once and store values in memory for sorting and searching
purposes (this is an assumption stated at the beginning of this discussion).
 Avoid logical databases when not processing all row s of a table. In fact, a logical database is merely a group of
nested SAP SQL SELECT statements. In general, when processing a small number of rows in a larger table is
required, the use of internal tables and NOT using a logical database or nested selects will be much better for
performance.

Briefly describe how to improve performance of your program?


1. Avoid using SELECT...ENDSELECT construct and use SELECT ... INTO TABLE.
2. Use WHERE clause in your SELECT statement to restrict the volume of data retrieved.
3. Design your Query to use as much index fields as possible from left to right in your WHERE statement
4. Use FOR ALL ENTRIES in your SELECT statement to retrieve the matching records at one shot.
5. Avoid using nested SELECT statement, SELECT within Loops.
6. Avoid using INTO CORRESPONDING FIELDS OF TABLE. Instead use INTO TABLE.
7. Avoid using SELECT * and Select only the required fields from the table.
8. Avoid nested loops when working with large internal tables.
9. Use assign instead of into in LOOPs for table types with large work areas
10. When in doubt call transaction SE30 and use the examples and check your code
11. Whenever using READ TABLE use BINARY SEARCH addition to speed up the search. Be sure to sort the internal table
before binary search. This is a general thumb rule but typically if you are sure that the data in internal table is less
than 200 entries you need not do SORT and use BINARY SEARCH since this is an overhead in performance.
12. Use "CHECK" instead of IF/ENDIF whenever possible.
13. Use "CASE" instead of IF/ENDIF whenever possible.
14. Use "MOVE" with individual variable/field moves instead of "MOVE-CORRESPONDING", creates more coding but is
more efficient.
15. Use refresh, clear statements after the data retrieval.
16. Use ST05 transaction to trace the program, and check any select query is taking more time, and then check program
contains loops inside loops.
17. Perform sorting.

While running a report it takes long time for execution. What steps will you do to reduce the execution time? What is
runtime analysis? Have you used this?
 Open the report in SE38.
 Go to Utilities -> More Utilities -> Runtime Analysis.
 Select the ‘Program’ Radio-button and give the report name there and click the ‘execute’ button.
 It will take you to another Screen. There you can execute your report and come back.
 Click on ‘Analyze’ button, present at the bottom of the Screen.
 Then you will get one graph. If it is ‘Red’ then your report is having very poor performance and if it is ‘Green’ then it
is alright.
 There are two types of Graph: ABAP GRAPH (For Report) and DATABASE GRAPH (Retrieving data from database in a
report).

What is the role of ST05 in performance tuning?


SQL trace.

What is SQL Trace?


SQL Trace tool is provided along with ABAP workbench to analyze the SQL queries for developers. It is a performance
tuning tool, which is used to fine tune your program. At any point of time one user can use the SQL trace as it consumes
more system resource. It traces the time taken to fetch the data from the database and helps us to reduce it (E.g.
modifying SELECT statements, INNER Joining etc.)

Will join conditions in SQL queries affect performance?


Yes

Will sorted internal tables help in performance?


Yes

Will where conditions in a SQL query help improve performance? o.

You might also like