Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Internal Tables
WORK AREA
Without Header line - Internal tables without header line do not have a work area. - Work area to be explicitly defined to access such internal tables.
Internal table itab is created with the same structure as internal table data type line.
Syntax Data <f> <type> [with header line]. <type> refers to a table data type or table data objects using type or like. Here internal table <f> is created of the type <type>.
Data : Begin of <f> occurs <n>, <component declaration>, , End of <f>. Work area is created by default.
Example: Data : Begin of itab occurs 10, column1 type I, column2(4) type C, column3 like mara-ernam, End of itab.
1
2 3
APPEND works even if a line with same standard key already exists.
10 5
Note: New entry has index <idx> and following line has index <idx>+1. If less than <idx>-1 entries then cannot insert line and sy-subrc = 4.
Note: New line containing values is inserted before second line. Initialized line is inserted before the first line.
Syntax DELETE <itab> [FROM <n1>] [TO <n2>] [ WHERE <condition>]. CAUTION: If no WHERE condition is given, all lines between <n1> and <n2> are deleted.
Syntax
REFRESH <itab>.
If no header line in internal table then use CLEAR <itab>. In case of table with header line CLEAR <itab> clears only the <wa>. So use CLEAR <itab>[].
Sub Totals
at first - endat Processed at the beginning of the table . Executes the relevant series of statements just once at new f - endat Processed when f changes or one of the preceding fields has just changed. at end of f endat at last - endat Processed at the end of the table Executes the relevant series of statements just once
SUM.
When processing an internal table in a block starting with LOOP and concluded by ENDLOOP , SUM calculates the control totals of all fields of type I , F and P (see also ABAP/4 number types ) and places them in the LOOP output area (header line of the internal table or an explicitly specified work area).
Types of SQLs
Native SQL Open SQL
UPDATE
MODIFY DELETE OPEN CURSOR, FETCH, CLOSE CURSOR
SELECT - syntax
SELECT <result> INTO <target> FROM <source> [WHERE <condition>] [GROUP BY <fields>] [HAVING <cond.>] [ORDER BY <fields>].
SELECT statements
Reading Single Entries e.g. Select single * from customers
FROM variants
... FROM <dbtabname> ... FROM <tabref1> [INNER] JOIN <tabref2> ON <cond> ... FROM <tabref1> LEFT [OUTER] JOIN <tabref2> ON <cond>
Native SQL
EXEC SQL [PERFORMING <form>]. <Native SQL statements> ENDEXEC.
Example: DATA: BEGIN OF WA, CONNID TYPE SPFLI-CONNID, CITYFROM TYPE SPFLI-CITYFROM, CITYTO TYPE SPFLI-CITYTO, END OF WA. DATA C1 TYPE SPFLI-CARRID VALUE 'LH'. EXEC SQL PERFORMING LOOP_OUTPUT. SELECT CONNID, CITYFROM, CITYTO INTO :WA FROM SPFLI WHERE CARRID = :C1 ENDEXEC. FORM LOOP_OUTPUT. WRITE: / WA-CONNID, WA-CITYFROM, WA-CITYTO. ENDFORM.
Restrict no of columns Use aggregate functions Minimize the Number of Data Transfers Avoid nested select loops
An alternative option is to use the SELECT .. FOR ALL ENTRIES statement. This statement can often be a lot more efficient than performing a large number of SELECT or SELECT SINGLE statements during a LOOP of an internal table.
Reduce the Database Load Buffering Logical databases Avoid repeated database access Using Internal Tables to Buffer Records To avoid executing the same SELECT multiple times (and therefore have duplicate selects), an internal table of type HASHED can be used to improve performance.
Dynamic Selections
Used when the table name or the precise condition of the WHERE clause is not known.
Using Select-Options e.g. select-options sname for customers-name. select * from customers into table all_customers where name in sname.
Dynamic Table Naming e.g . Data: tablename(10) . move customers to tablename. Select * from tablename.
ABAP Memory
Using Temporary Storage e.g. export all_customers all_bookings to memory id CUSTBOOK. import all_customers all_bookings from memory id CUSTBOOK.
Using Clustered Tables e.g. export all_customers all_bookings to database zflight(zz) id CUSTBOOK.
SAP Memory
SET PARAMETER ID <pid> FIELD <f>.
Writes the contents of the field f to the global SAP memory under the key pid . If the key already contains a value, it is overwritten.
Match Codes
Devices for users to find values stored in SAP database system based on defined criteria. For retrieving data based on non-key fields. It is a keyword used to call the Search help for the Selection Screen
element.
Demo
Its demo time Over to R/3
Thank You.
Do send feedback, queries and suggestions