SlideShare ist ein Scribd-Unternehmen logo
1 von 9
- 1 -
Assigning Values for Complex Data Objects
MOVE also works for copying complex tables and structures. Embedded field strings
and table components are also copied.
Table Type
An internal table is a sequence of lines with the same type.
 If you want to define a table type, follow the line type declaration with
the addition OCCURS 0.
 You can also write OCCURS <n> instead of OCCURS 0, where <n> is
any integer.
Assigning Values Field by Field
 The MOVE-CORRESPONDING <rec1> to <rec2> statements transports
values field by field between field strings <rec1> and <rec2>. This only works
if the components have identical names.
 The system looks for all fields in <rec1> whose name also occurs in <rec2>
and transports field <rec1>-<field name> to <rec2>-<field name> in all cases
where it finds a match. All other fields remain unchanged.
Internal Tables
As you have already seen, internal tables (‘arrays’ or ‘matrices’ in other terminology)
are a set of lines with the same type(s).
 To define an internal table, simply use the addition OCCURS <n> when
you declare a data object with the desired line type.
 The OCCURS addition turns the data object into an internal table with
the same line type as that of the data object. It also determines the
number of lines with which the internal table is created. Unlike the array
- 2 -
concept of other programming languages, ABAP/4 can increase the
number of lines in the table dynamically at runtime.
 If you do not know how big your internal table will be, set the OCCURS
addition to 0. If you know that your internal table will be smaller than
8KB, specify the number of table lines using the OCCURS parameter.
This ensures that only this amount of memory area is occupied. This is
particularly important when you are working with nested structures. If
the memory area is insufficient, further table lines are allocated.
Working with Internal Tables
In contrast with the array concepts found in other programming languages,
ABAP/4 does NOT use direct access to table entries. Instead, operations on
table entries are carried out using a work area. This is a temporary holding area
that contains the content of the current entry for almost ALL commands dealing
with the table.
 This work space may be either a separately defined work area or a
header line that is defined when the table is defined.
ABAP/4 recognizes essentially the following operations on internal tables:
Command Effect
APPEND
Appends the contents of the work area at the end of the
internal table
COLLECT
Inserts the cumulative contents of the work area into the
internal table
INSERT
Inserts the contents of the work area into a particular table
entry
MODIFY
Overwrites a particular table entry with the content of the
work area
DELETE Deletes a specified entry from the internal table
LOOP AT
Places the entries of an internal table in a work area one at a
time
READ
TABLE
Places a single internal table entry in a work area
SORT Sorts the internal table
- 3 -
CLEAR Deletes the work area or the internal table
REFRESH Deletes the internal table
FREE Releases space in memory previously occupied by table
Internal Tables With Header Line
You access internal tables record by record. You must use a work area as an interface
for transferring data to and from the table.
When you read data from an internal table, the contents of a specified table record or
line overwrites the contents of the work area. Then, you can reference the contents of
the work area in your program. When you write data to an internal table, you must
first enter the data in the work area from with the system can transfer the data to the
internal table.
 To avoid inconsistencies, it is beneficial if the work area has the same
data type as the records or lines of the internal table. A safe procedure
for creating work areas which are compatible with internal tables is to
use the same data type for declaring both the internal table and the work
area.
 In ABAP/4, you can distinguish between two kinds of internal tables:
 Internal tables WITH header lines
 Internal tables WITHOUT header lines
 A header line is similar to a work area for a database table. A work area
is used as temporary storage for one entry of a database table. In a
similar way, a header line is used to hold one line of an internal table.
 An internal table with header line is a tuple from a work area (header
line) and the bulk of the table itself. Both are addressed using the same
name, the interpretation of the name is context-sensitive. Hence it would
- 4 -
stand for the header line in a MOVE statement, but would stand for the
bulk of the table in a SEARCH statement.
 When you create an internal table WITH a header line, a work area is
created automatically with the same data type as the rows of the internal
table. The header line and the internal table have the same name. Then,
the system uses this work area implicitly.
 In ABAP/4 statements for accessing internal tables, you can specify the
work area to be used. For internal tables with header lines, you can
leave out this specification. Then, the system uses the table work area
implicitly.
Internal Tables Without Header Line
If a table does not have a header line, you MUST provide a work area as a separate
record to hold the content of the current entry for most commands used in processing
tables.
 Internal tables WITHOUT a header line do NOT have a table work area
declared which can be used implicitly. To access internal tables
WITHOUT header lines, you must specify a work area explicitly in the
corresponding ABAP/4 statements.
 It is a matter of your preference whether you use a header line or a work
area.
 Remember that, for internal tables with header lines, the internal table
itself and the table work areas have the same name. If you use the name
in a statement, the system interprets it as the name of the table work area
and NOT as the table itself. In some statement, however, you can enter
square brackets after the name to address the internal table instead of the
table work area as follows: <name> [ ].
Declaring Internal Tables with Header Line
You define an internal table with a header line using the addition WITH HEADER
LINE.
 A HEADER line is a work area where the currently active, individual
record in the table resides.
Filling Internal Tables
- 5 -
The SELECT command, which you first encountered in Lesson 1, places one entry
from a database table into the table work area of the same name in each loop pass. If
you want to be able to address all table entries during the program runtime, each table
entry must be saved in the internal table.
 You use the APPEND statement to fill the internal table: APPEND <wa> TO
<itab> adds the contents of work area <wa> to the end of the internal table
<itab>. If you are working with an internal table with header line, the syntax is
shortened to APPEND <itab>.
Array Fetch
You can fill an internal table with entries from a database table using a single
SELECT statement.
 The database system reads the entries in bundles, not singly. Once read,
the bundle is inserted en masse into the internal table. This method has
performance advantages over reading in records individually via a loop.
 Since this is not a loop, there is no ENDSELECT.
 In the basic form (... INTO TABLE ...) the internal table is filled with the
database entries found and existing entries are overwritten.
 In the variant ... APPENDING TABLE... the entries are appended to the
existing entries in the internal table.
Filling Internal Tables with Cumulative Values
You use the COLLECT statement to add the work area or header line to an existing
entry of the same type or (if no such entry exists) to add it to the table as a new entry.
 To do this, COLLECT searches in the internal table for an entry, all of
whose alphanumeric fields are identical with those of the entry in the
work area or header line.
 If such an entry is found, COLLECT adds all numeric fields from the
work area or header line to the corresponding fields in the table entry.
 Otherwise, the COLLECT statement appends the contents of the work
area or header line to the end of the table.
Sorting an Internal Table
You can sort an internal table using the SORT statement.
- 6 -
 If you do NOT specify any sort criteria, the table is sorted by ALLl
fields except those with data type P, I and F. The fields are sorted
ascending in the order in which they occur.
 You can use the additions BY <field name> and ASCENDING or
DESCENDING to limit the sort to certain fields and determine the sort
sequence and hierarchy.
 You should use the BY addition to narrow down the sort criteria for
performance reasons.
 As of Release 3.0D you can perform a language-specific alphabetical
sort of text fields using the TEXT addition.
Using Loops with an Internal Table
You can process an internal table using the loop statement LOOP AT ... ENDLOOP.
With each loop pass the system places the next table entry in the work area <wa> or
the header line of the internal table <itab>.
 You can restrict the entries which are read using the WHERE addition in
the same way as you do when using the SELECT command.
 At the beginning of each loop pass, SY-TABIX is set to the value of the
current table entry. When the system leaves the LOOP, SY-TABIX has
the same value as it had before the loop started.
Reading an Entry from an Internal Table
You use the READ TABLE <itab> statement to read a single table entry. When the
entry has been read, it is in the work area <wa> or the header line of <itab>.
 If the entry is successfully read, the value of SY-SUBRC is zero,
otherwise it is not equal to zero. SY-TABIX takes the value of the table
entry read.
 READ TABLE <itab> INDEX <n>. The nth table entry is read.
 If you wish to specify individual fields as a search argument you can use
the following syntax: READ TABLE <itab> WITH KEY <ki> = <v1>
<k2> = <v2>...<kn> = <vn>. In this case, the first entry from <itab> is
read which corresponds with the components specified in <k1>...<kn>.
 If the internal table is sorted by the search argument, you can use the
BINARY SEARCH addition. The system then carries out a more
performance-efficient binary search for the specified entry.
 The online documentation for the READ statement contains details of
further additions.
- 7 -
Changing an Internal Table I
 The MODIFY <itab> INDEX <i> [FROM <wa>] statement overwrites table
entry ‘i’ with the contents of the work area or the header line. Entry ‘i’ must
already exist.
 The INSERT [<wa> INTO] <itab> INDEX <i> statement creates a new table
entry before entry ‘i’ containing the contents of the work area or the header
line. If the table has ‘i’-1 entries, the contents of the work area or header line
are appended to the internal table.
 The DELETE <tab> INDEX <i> statement deletes table entry ‘i’.
Changing an Internal Table II
You can make changes to an internal table from within a LOOP. The changes always
apply to the current table entry (SY-TABIX).
INSERT A new record is inserted before the current entry containing the
contents of the work area or header line.
MODIFY The current entry is overwritten with the contents of the work area
or header line.
DELETE The current record is deleted.
The following additions can be used with the DELETE statement (cf. corresponding
additions with the LOOP statement):
 ...WHERE <condition>. The DELETE command applies to all table
entries which satisfy the condition.
 ...FROM <n1> TO <n2>. All entries from <n1> to <n2> inclusive are
deleted. If only the FROM addition is specified, all entries from <n1> to
the end of the table are deleted. If only the TO addition is specified, all
entries from the beginning of the table to <n2> are deleted.
Internal Table Index
The index is the sequential number of a table line. It is NOT a table field, but is
created and managed automatically by the system.
You can use the index with the DELETE, INSERT, MODIFY, LOOP, and READ
statements. In these statements, you can specify the index either as a literal or as a
variable.
- 8 -
After processing a particular line of an internal table, the system field SY-TABIX
generally contains the index of that line.
Deleting an Internal Table
If you are using an internal table without a header line, CLEAR <itab> deletes the
body of the table.
If your internal table has a header line, CLEAR <itab> deletes the header line.
If you only want to address the body of an internal table with a header line, you use
the form <itab>[].
 Example 1: ITAB_WITHOUT and ITAB_WITH are two internal tables
without and with header lines respectively. The command
ITAB_WITHOUT = ITAB_WITH[] assigns the body of ITAB_WITH
to ITAB_WITHOUT.
 Example 2: CLEAR ITAB_WITH[] deletes only the body of the internal
table ITAB_WITH.
REFRESH <itab> deletes the body of the table.
Information about Internal Tables
You can get information about an internal table using the DESCRIBE TABLE
statement:
 The LINES addition returns the number of entries currently in the table.
 The OCCURS addition returns the number of OCCURS in the table
definition.
You can display information about any data object using the DESCRIBE FIELD
statement (see the online documentation for the DESCRIBE statement).
- 9 -

Weitere ähnliche Inhalte

Was ist angesagt?

Intro to Excel Basics: Part II
Intro to Excel Basics: Part IIIntro to Excel Basics: Part II
Intro to Excel Basics: Part IISi Krishan
 
ABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.infoABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.infosapdocs. info
 
Best SAP ABAP Training Institute with Placement in Pune | Aspire
Best SAP ABAP Training Institute with Placement in Pune | AspireBest SAP ABAP Training Institute with Placement in Pune | Aspire
Best SAP ABAP Training Institute with Placement in Pune | AspireAspire Techsoft Academy
 
X rec extened reconciliation using excel vba
X rec   extened reconciliation using excel vbaX rec   extened reconciliation using excel vba
X rec extened reconciliation using excel vbasenthilsundaresan
 
Sap internal
Sap   internalSap   internal
Sap internalkyashpal
 
John Noll Portfolio
John Noll PortfolioJohn Noll Portfolio
John Noll PortfolioJohnNoll
 
Reading Fixed And Varying Data
Reading Fixed And Varying DataReading Fixed And Varying Data
Reading Fixed And Varying Dataguest2160992
 
Abap report
Abap reportAbap report
Abap reportDucat
 
15 wordprocessing ml subject - fields and hyperlinks
15   wordprocessing ml subject - fields and hyperlinks15   wordprocessing ml subject - fields and hyperlinks
15 wordprocessing ml subject - fields and hyperlinksShawn Villaron
 
Compar x r (row based comparison tool)
Compar x r (row based comparison tool)Compar x r (row based comparison tool)
Compar x r (row based comparison tool)senthilsundaresan
 
Maximizing SAP ABAP Performance
Maximizing SAP ABAP PerformanceMaximizing SAP ABAP Performance
Maximizing SAP ABAP PerformancePeterHBrown
 
Understanding sas data step processing.
Understanding sas data step processing.Understanding sas data step processing.
Understanding sas data step processing.Ravi Mandal, MBA
 
Base SAS Statistics Procedures
Base SAS Statistics ProceduresBase SAS Statistics Procedures
Base SAS Statistics Proceduresguest2160992
 
HALL OF FAME INDUCTIONS
HALL OF FAME INDUCTIONSHALL OF FAME INDUCTIONS
HALL OF FAME INDUCTIONSTalia Strnad
 

Was ist angesagt? (19)

Intro to Excel Basics: Part II
Intro to Excel Basics: Part IIIntro to Excel Basics: Part II
Intro to Excel Basics: Part II
 
ABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.infoABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.info
 
BAPI - Criação de Ordem de Manutenção
BAPI - Criação de Ordem de ManutençãoBAPI - Criação de Ordem de Manutenção
BAPI - Criação de Ordem de Manutenção
 
Best SAP ABAP Training Institute with Placement in Pune | Aspire
Best SAP ABAP Training Institute with Placement in Pune | AspireBest SAP ABAP Training Institute with Placement in Pune | Aspire
Best SAP ABAP Training Institute with Placement in Pune | Aspire
 
29
2929
29
 
X rec extened reconciliation using excel vba
X rec   extened reconciliation using excel vbaX rec   extened reconciliation using excel vba
X rec extened reconciliation using excel vba
 
Sap internal
Sap   internalSap   internal
Sap internal
 
John Noll Portfolio
John Noll PortfolioJohn Noll Portfolio
John Noll Portfolio
 
Chap13 scr
Chap13 scrChap13 scr
Chap13 scr
 
Reading Fixed And Varying Data
Reading Fixed And Varying DataReading Fixed And Varying Data
Reading Fixed And Varying Data
 
Abap report
Abap reportAbap report
Abap report
 
15 wordprocessing ml subject - fields and hyperlinks
15   wordprocessing ml subject - fields and hyperlinks15   wordprocessing ml subject - fields and hyperlinks
15 wordprocessing ml subject - fields and hyperlinks
 
Compar x r (row based comparison tool)
Compar x r (row based comparison tool)Compar x r (row based comparison tool)
Compar x r (row based comparison tool)
 
SAS Proc SQL
SAS Proc SQLSAS Proc SQL
SAS Proc SQL
 
Maximizing SAP ABAP Performance
Maximizing SAP ABAP PerformanceMaximizing SAP ABAP Performance
Maximizing SAP ABAP Performance
 
Understanding sas data step processing.
Understanding sas data step processing.Understanding sas data step processing.
Understanding sas data step processing.
 
Base SAS Statistics Procedures
Base SAS Statistics ProceduresBase SAS Statistics Procedures
Base SAS Statistics Procedures
 
Sql basics v2
Sql basics v2Sql basics v2
Sql basics v2
 
HALL OF FAME INDUCTIONS
HALL OF FAME INDUCTIONSHALL OF FAME INDUCTIONS
HALL OF FAME INDUCTIONS
 

Andere mochten auch

IS20G New York ToniAnne Fardette Day 2 The 3 Keys
IS20G  New York ToniAnne Fardette Day 2 The 3 KeysIS20G  New York ToniAnne Fardette Day 2 The 3 Keys
IS20G New York ToniAnne Fardette Day 2 The 3 KeysSean Bradley
 
Png atelier slides
Png atelier slidesPng atelier slides
Png atelier slidescameronyates
 
Identity Services Engine overview
Identity Services Engine overviewIdentity Services Engine overview
Identity Services Engine overviewNazim Latypayev
 
Madkour-1985-Journal_of_Chemical_Technology_and_Biotechnology._Chemical_Techn...
Madkour-1985-Journal_of_Chemical_Technology_and_Biotechnology._Chemical_Techn...Madkour-1985-Journal_of_Chemical_Technology_and_Biotechnology._Chemical_Techn...
Madkour-1985-Journal_of_Chemical_Technology_and_Biotechnology._Chemical_Techn...Al Baha University
 
Ryan Leslie: Reputation Management: Revisited
Ryan Leslie: Reputation Management: RevisitedRyan Leslie: Reputation Management: Revisited
Ryan Leslie: Reputation Management: RevisitedSean Bradley
 
презентация Dss 375
презентация Dss 375презентация Dss 375
презентация Dss 375Ellada
 
Pac1 FEM
Pac1 FEMPac1 FEM
Pac1 FEMedusv10
 
Hcm520 risk management and patient safety3
Hcm520 risk management and patient safety3Hcm520 risk management and patient safety3
Hcm520 risk management and patient safety3dvilegi
 
MARIA MONTESSORI
MARIA MONTESSORIMARIA MONTESSORI
MARIA MONTESSORIuzuxunago
 
DeWalt Powerstation presentation
DeWalt Powerstation presentationDeWalt Powerstation presentation
DeWalt Powerstation presentationdoorman24u
 
أصابع أميركية في الانتخابات الاوكرانية
أصابع أميركية في الانتخابات الاوكرانيةأصابع أميركية في الانتخابات الاوكرانية
أصابع أميركية في الانتخابات الاوكرانيةIbrahimia Church Ftriends
 
The best of SEO toturial
The best of SEO toturialThe best of SEO toturial
The best of SEO toturialboyfvn
 
Brief definition globalization
Brief definition globalizationBrief definition globalization
Brief definition globalizationfrootiishi
 
Inforgraphic: Bandit Signs, A How to Guide
Inforgraphic: Bandit Signs, A How to Guide Inforgraphic: Bandit Signs, A How to Guide
Inforgraphic: Bandit Signs, A How to Guide FortuneBuilders
 

Andere mochten auch (20)

IS20G New York ToniAnne Fardette Day 2 The 3 Keys
IS20G  New York ToniAnne Fardette Day 2 The 3 KeysIS20G  New York ToniAnne Fardette Day 2 The 3 Keys
IS20G New York ToniAnne Fardette Day 2 The 3 Keys
 
Png atelier slides
Png atelier slidesPng atelier slides
Png atelier slides
 
Identity Services Engine overview
Identity Services Engine overviewIdentity Services Engine overview
Identity Services Engine overview
 
Madkour-1985-Journal_of_Chemical_Technology_and_Biotechnology._Chemical_Techn...
Madkour-1985-Journal_of_Chemical_Technology_and_Biotechnology._Chemical_Techn...Madkour-1985-Journal_of_Chemical_Technology_and_Biotechnology._Chemical_Techn...
Madkour-1985-Journal_of_Chemical_Technology_and_Biotechnology._Chemical_Techn...
 
Ryan Leslie: Reputation Management: Revisited
Ryan Leslie: Reputation Management: RevisitedRyan Leslie: Reputation Management: Revisited
Ryan Leslie: Reputation Management: Revisited
 
Gombi Privacy Day
Gombi Privacy DayGombi Privacy Day
Gombi Privacy Day
 
Campeonato 2012 profes
Campeonato 2012 profesCampeonato 2012 profes
Campeonato 2012 profes
 
презентация Dss 375
презентация Dss 375презентация Dss 375
презентация Dss 375
 
Pac1 FEM
Pac1 FEMPac1 FEM
Pac1 FEM
 
Hcm520 risk management and patient safety3
Hcm520 risk management and patient safety3Hcm520 risk management and patient safety3
Hcm520 risk management and patient safety3
 
MARIA MONTESSORI
MARIA MONTESSORIMARIA MONTESSORI
MARIA MONTESSORI
 
DeWalt Powerstation presentation
DeWalt Powerstation presentationDeWalt Powerstation presentation
DeWalt Powerstation presentation
 
أصابع أميركية في الانتخابات الاوكرانية
أصابع أميركية في الانتخابات الاوكرانيةأصابع أميركية في الانتخابات الاوكرانية
أصابع أميركية في الانتخابات الاوكرانية
 
The best of SEO toturial
The best of SEO toturialThe best of SEO toturial
The best of SEO toturial
 
Fts sunum
Fts sunumFts sunum
Fts sunum
 
Brief definition globalization
Brief definition globalizationBrief definition globalization
Brief definition globalization
 
Blogs
BlogsBlogs
Blogs
 
Inforgraphic: Bandit Signs, A How to Guide
Inforgraphic: Bandit Signs, A How to Guide Inforgraphic: Bandit Signs, A How to Guide
Inforgraphic: Bandit Signs, A How to Guide
 
3RdTT_Twitter_4_Business
3RdTT_Twitter_4_Business3RdTT_Twitter_4_Business
3RdTT_Twitter_4_Business
 
Amazing Fashion
Amazing FashionAmazing Fashion
Amazing Fashion
 

Ähnlich wie Internal tables

Lecture12 abap on line
Lecture12 abap on lineLecture12 abap on line
Lecture12 abap on lineMilind Patil
 
Spread sheet Ppt Amna Mukhtar 6G2 (Revised).pptx
Spread sheet Ppt Amna Mukhtar 6G2 (Revised).pptxSpread sheet Ppt Amna Mukhtar 6G2 (Revised).pptx
Spread sheet Ppt Amna Mukhtar 6G2 (Revised).pptxmajidengineer777
 
Relational Database Management System
Relational Database Management SystemRelational Database Management System
Relational Database Management Systemsweetysweety8
 
Day-2 SQL Theory_V1.pptx
Day-2 SQL Theory_V1.pptxDay-2 SQL Theory_V1.pptx
Day-2 SQL Theory_V1.pptxuzmasulthana3
 
Using vlookup in excel
Using vlookup in excelUsing vlookup in excel
Using vlookup in excelmegankilb
 
Are you an abap coder or a programmer?
Are you an abap coder or a programmer?Are you an abap coder or a programmer?
Are you an abap coder or a programmer?SAPYard
 
LECTURE 06 (SPREADSHEET).pptx
LECTURE 06 (SPREADSHEET).pptxLECTURE 06 (SPREADSHEET).pptx
LECTURE 06 (SPREADSHEET).pptxMwangaPrayGod
 
Sql server lesson6
Sql server lesson6Sql server lesson6
Sql server lesson6Ala Qunaibi
 
MergeResult_2024_02_09_08_59_11.pptx
MergeResult_2024_02_09_08_59_11.pptxMergeResult_2024_02_09_08_59_11.pptx
MergeResult_2024_02_09_08_59_11.pptxKrishnansuSenapati
 
ExcelTipsAndTricks.pptx
ExcelTipsAndTricks.pptxExcelTipsAndTricks.pptx
ExcelTipsAndTricks.pptxJohn Donahue
 
Excel Tutorials - VLOOKUP and HLOOKUP Functions
Excel Tutorials - VLOOKUP and HLOOKUP FunctionsExcel Tutorials - VLOOKUP and HLOOKUP Functions
Excel Tutorials - VLOOKUP and HLOOKUP FunctionsMerve Nur Taş
 

Ähnlich wie Internal tables (20)

Lecture12 abap on line
Lecture12 abap on lineLecture12 abap on line
Lecture12 abap on line
 
Intermediate Excel
Intermediate Excel Intermediate Excel
Intermediate Excel
 
Sql join
Sql  joinSql  join
Sql join
 
Spread sheet Ppt Amna Mukhtar 6G2 (Revised).pptx
Spread sheet Ppt Amna Mukhtar 6G2 (Revised).pptxSpread sheet Ppt Amna Mukhtar 6G2 (Revised).pptx
Spread sheet Ppt Amna Mukhtar 6G2 (Revised).pptx
 
Join sql
Join sqlJoin sql
Join sql
 
Relational Database Management System
Relational Database Management SystemRelational Database Management System
Relational Database Management System
 
Day-2 SQL Theory_V1.pptx
Day-2 SQL Theory_V1.pptxDay-2 SQL Theory_V1.pptx
Day-2 SQL Theory_V1.pptx
 
Etl2
Etl2Etl2
Etl2
 
Using vlookup in excel
Using vlookup in excelUsing vlookup in excel
Using vlookup in excel
 
Are you an abap coder or a programmer?
Are you an abap coder or a programmer?Are you an abap coder or a programmer?
Are you an abap coder or a programmer?
 
Hive commands
Hive commandsHive commands
Hive commands
 
Sap abap material
Sap abap materialSap abap material
Sap abap material
 
LECTURE 06 (SPREADSHEET).pptx
LECTURE 06 (SPREADSHEET).pptxLECTURE 06 (SPREADSHEET).pptx
LECTURE 06 (SPREADSHEET).pptx
 
Sql server lesson6
Sql server lesson6Sql server lesson6
Sql server lesson6
 
Ijebea14 228
Ijebea14 228Ijebea14 228
Ijebea14 228
 
SQL DDL
SQL DDLSQL DDL
SQL DDL
 
MergeResult_2024_02_09_08_59_11.pptx
MergeResult_2024_02_09_08_59_11.pptxMergeResult_2024_02_09_08_59_11.pptx
MergeResult_2024_02_09_08_59_11.pptx
 
ExcelTipsAndTricks.pptx
ExcelTipsAndTricks.pptxExcelTipsAndTricks.pptx
ExcelTipsAndTricks.pptx
 
Excel
ExcelExcel
Excel
 
Excel Tutorials - VLOOKUP and HLOOKUP Functions
Excel Tutorials - VLOOKUP and HLOOKUP FunctionsExcel Tutorials - VLOOKUP and HLOOKUP Functions
Excel Tutorials - VLOOKUP and HLOOKUP Functions
 

Kürzlich hochgeladen

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 

Kürzlich hochgeladen (20)

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 

Internal tables

  • 1. - 1 - Assigning Values for Complex Data Objects MOVE also works for copying complex tables and structures. Embedded field strings and table components are also copied. Table Type An internal table is a sequence of lines with the same type.  If you want to define a table type, follow the line type declaration with the addition OCCURS 0.  You can also write OCCURS <n> instead of OCCURS 0, where <n> is any integer. Assigning Values Field by Field  The MOVE-CORRESPONDING <rec1> to <rec2> statements transports values field by field between field strings <rec1> and <rec2>. This only works if the components have identical names.  The system looks for all fields in <rec1> whose name also occurs in <rec2> and transports field <rec1>-<field name> to <rec2>-<field name> in all cases where it finds a match. All other fields remain unchanged. Internal Tables As you have already seen, internal tables (‘arrays’ or ‘matrices’ in other terminology) are a set of lines with the same type(s).  To define an internal table, simply use the addition OCCURS <n> when you declare a data object with the desired line type.  The OCCURS addition turns the data object into an internal table with the same line type as that of the data object. It also determines the number of lines with which the internal table is created. Unlike the array
  • 2. - 2 - concept of other programming languages, ABAP/4 can increase the number of lines in the table dynamically at runtime.  If you do not know how big your internal table will be, set the OCCURS addition to 0. If you know that your internal table will be smaller than 8KB, specify the number of table lines using the OCCURS parameter. This ensures that only this amount of memory area is occupied. This is particularly important when you are working with nested structures. If the memory area is insufficient, further table lines are allocated. Working with Internal Tables In contrast with the array concepts found in other programming languages, ABAP/4 does NOT use direct access to table entries. Instead, operations on table entries are carried out using a work area. This is a temporary holding area that contains the content of the current entry for almost ALL commands dealing with the table.  This work space may be either a separately defined work area or a header line that is defined when the table is defined. ABAP/4 recognizes essentially the following operations on internal tables: Command Effect APPEND Appends the contents of the work area at the end of the internal table COLLECT Inserts the cumulative contents of the work area into the internal table INSERT Inserts the contents of the work area into a particular table entry MODIFY Overwrites a particular table entry with the content of the work area DELETE Deletes a specified entry from the internal table LOOP AT Places the entries of an internal table in a work area one at a time READ TABLE Places a single internal table entry in a work area SORT Sorts the internal table
  • 3. - 3 - CLEAR Deletes the work area or the internal table REFRESH Deletes the internal table FREE Releases space in memory previously occupied by table Internal Tables With Header Line You access internal tables record by record. You must use a work area as an interface for transferring data to and from the table. When you read data from an internal table, the contents of a specified table record or line overwrites the contents of the work area. Then, you can reference the contents of the work area in your program. When you write data to an internal table, you must first enter the data in the work area from with the system can transfer the data to the internal table.  To avoid inconsistencies, it is beneficial if the work area has the same data type as the records or lines of the internal table. A safe procedure for creating work areas which are compatible with internal tables is to use the same data type for declaring both the internal table and the work area.  In ABAP/4, you can distinguish between two kinds of internal tables:  Internal tables WITH header lines  Internal tables WITHOUT header lines  A header line is similar to a work area for a database table. A work area is used as temporary storage for one entry of a database table. In a similar way, a header line is used to hold one line of an internal table.  An internal table with header line is a tuple from a work area (header line) and the bulk of the table itself. Both are addressed using the same name, the interpretation of the name is context-sensitive. Hence it would
  • 4. - 4 - stand for the header line in a MOVE statement, but would stand for the bulk of the table in a SEARCH statement.  When you create an internal table WITH a header line, a work area is created automatically with the same data type as the rows of the internal table. The header line and the internal table have the same name. Then, the system uses this work area implicitly.  In ABAP/4 statements for accessing internal tables, you can specify the work area to be used. For internal tables with header lines, you can leave out this specification. Then, the system uses the table work area implicitly. Internal Tables Without Header Line If a table does not have a header line, you MUST provide a work area as a separate record to hold the content of the current entry for most commands used in processing tables.  Internal tables WITHOUT a header line do NOT have a table work area declared which can be used implicitly. To access internal tables WITHOUT header lines, you must specify a work area explicitly in the corresponding ABAP/4 statements.  It is a matter of your preference whether you use a header line or a work area.  Remember that, for internal tables with header lines, the internal table itself and the table work areas have the same name. If you use the name in a statement, the system interprets it as the name of the table work area and NOT as the table itself. In some statement, however, you can enter square brackets after the name to address the internal table instead of the table work area as follows: <name> [ ]. Declaring Internal Tables with Header Line You define an internal table with a header line using the addition WITH HEADER LINE.  A HEADER line is a work area where the currently active, individual record in the table resides. Filling Internal Tables
  • 5. - 5 - The SELECT command, which you first encountered in Lesson 1, places one entry from a database table into the table work area of the same name in each loop pass. If you want to be able to address all table entries during the program runtime, each table entry must be saved in the internal table.  You use the APPEND statement to fill the internal table: APPEND <wa> TO <itab> adds the contents of work area <wa> to the end of the internal table <itab>. If you are working with an internal table with header line, the syntax is shortened to APPEND <itab>. Array Fetch You can fill an internal table with entries from a database table using a single SELECT statement.  The database system reads the entries in bundles, not singly. Once read, the bundle is inserted en masse into the internal table. This method has performance advantages over reading in records individually via a loop.  Since this is not a loop, there is no ENDSELECT.  In the basic form (... INTO TABLE ...) the internal table is filled with the database entries found and existing entries are overwritten.  In the variant ... APPENDING TABLE... the entries are appended to the existing entries in the internal table. Filling Internal Tables with Cumulative Values You use the COLLECT statement to add the work area or header line to an existing entry of the same type or (if no such entry exists) to add it to the table as a new entry.  To do this, COLLECT searches in the internal table for an entry, all of whose alphanumeric fields are identical with those of the entry in the work area or header line.  If such an entry is found, COLLECT adds all numeric fields from the work area or header line to the corresponding fields in the table entry.  Otherwise, the COLLECT statement appends the contents of the work area or header line to the end of the table. Sorting an Internal Table You can sort an internal table using the SORT statement.
  • 6. - 6 -  If you do NOT specify any sort criteria, the table is sorted by ALLl fields except those with data type P, I and F. The fields are sorted ascending in the order in which they occur.  You can use the additions BY <field name> and ASCENDING or DESCENDING to limit the sort to certain fields and determine the sort sequence and hierarchy.  You should use the BY addition to narrow down the sort criteria for performance reasons.  As of Release 3.0D you can perform a language-specific alphabetical sort of text fields using the TEXT addition. Using Loops with an Internal Table You can process an internal table using the loop statement LOOP AT ... ENDLOOP. With each loop pass the system places the next table entry in the work area <wa> or the header line of the internal table <itab>.  You can restrict the entries which are read using the WHERE addition in the same way as you do when using the SELECT command.  At the beginning of each loop pass, SY-TABIX is set to the value of the current table entry. When the system leaves the LOOP, SY-TABIX has the same value as it had before the loop started. Reading an Entry from an Internal Table You use the READ TABLE <itab> statement to read a single table entry. When the entry has been read, it is in the work area <wa> or the header line of <itab>.  If the entry is successfully read, the value of SY-SUBRC is zero, otherwise it is not equal to zero. SY-TABIX takes the value of the table entry read.  READ TABLE <itab> INDEX <n>. The nth table entry is read.  If you wish to specify individual fields as a search argument you can use the following syntax: READ TABLE <itab> WITH KEY <ki> = <v1> <k2> = <v2>...<kn> = <vn>. In this case, the first entry from <itab> is read which corresponds with the components specified in <k1>...<kn>.  If the internal table is sorted by the search argument, you can use the BINARY SEARCH addition. The system then carries out a more performance-efficient binary search for the specified entry.  The online documentation for the READ statement contains details of further additions.
  • 7. - 7 - Changing an Internal Table I  The MODIFY <itab> INDEX <i> [FROM <wa>] statement overwrites table entry ‘i’ with the contents of the work area or the header line. Entry ‘i’ must already exist.  The INSERT [<wa> INTO] <itab> INDEX <i> statement creates a new table entry before entry ‘i’ containing the contents of the work area or the header line. If the table has ‘i’-1 entries, the contents of the work area or header line are appended to the internal table.  The DELETE <tab> INDEX <i> statement deletes table entry ‘i’. Changing an Internal Table II You can make changes to an internal table from within a LOOP. The changes always apply to the current table entry (SY-TABIX). INSERT A new record is inserted before the current entry containing the contents of the work area or header line. MODIFY The current entry is overwritten with the contents of the work area or header line. DELETE The current record is deleted. The following additions can be used with the DELETE statement (cf. corresponding additions with the LOOP statement):  ...WHERE <condition>. The DELETE command applies to all table entries which satisfy the condition.  ...FROM <n1> TO <n2>. All entries from <n1> to <n2> inclusive are deleted. If only the FROM addition is specified, all entries from <n1> to the end of the table are deleted. If only the TO addition is specified, all entries from the beginning of the table to <n2> are deleted. Internal Table Index The index is the sequential number of a table line. It is NOT a table field, but is created and managed automatically by the system. You can use the index with the DELETE, INSERT, MODIFY, LOOP, and READ statements. In these statements, you can specify the index either as a literal or as a variable.
  • 8. - 8 - After processing a particular line of an internal table, the system field SY-TABIX generally contains the index of that line. Deleting an Internal Table If you are using an internal table without a header line, CLEAR <itab> deletes the body of the table. If your internal table has a header line, CLEAR <itab> deletes the header line. If you only want to address the body of an internal table with a header line, you use the form <itab>[].  Example 1: ITAB_WITHOUT and ITAB_WITH are two internal tables without and with header lines respectively. The command ITAB_WITHOUT = ITAB_WITH[] assigns the body of ITAB_WITH to ITAB_WITHOUT.  Example 2: CLEAR ITAB_WITH[] deletes only the body of the internal table ITAB_WITH. REFRESH <itab> deletes the body of the table. Information about Internal Tables You can get information about an internal table using the DESCRIBE TABLE statement:  The LINES addition returns the number of entries currently in the table.  The OCCURS addition returns the number of OCCURS in the table definition. You can display information about any data object using the DESCRIBE FIELD statement (see the online documentation for the DESCRIBE statement).