SlideShare a Scribd company logo
Lecture 12 Advanced Internal Tables BCO5647 Applications Programming Techniques (ABAP)
Readings & Objectives Readings Keller & Keller   Chapter 4 Section 4.7.1 & 4.7.3    Objectives This lecture will Revise the structure of internal tables Review the attributes of internal tables Describe the three internal table kinds: standard, sorted, hashed Examine the features and application of STANDARD internal tables Examine the features and application of SORTED internal tables Examine the features and application of HASHED internal tables Distinguish between the use of work areas Vs header lines when processing internal tables
Internal Tables as Dynamic Data Objects Internal tables are data objects that allow you to store datasets with a fixed structure in memory. The data is stored row by row in memory. Each row has the same structure. You can also refer to each component in a row as a column in the internal table. You refer to each row in the internal table as a table row or table entry. Internal tables are dynamic data objects that can hold any number of rows of a fixed type. The number of rows in an internal table is limited only by the capacity of the specific system with which you are working.
Attributes of an Internal Table The data type of an internal table is fully specified by its: Row type The row type defines the attributes of the individual columns. You normally enter a structure type, but any data type is possible. Key definition The key columns and their sequence determine the criteria by which the system identifies table rows. You can define the key as either UNIQUE or NON-UNIQUE. The uniqueness of the key must be compatible with the access type you have chosen for the table. If the key is unique, there can be no duplicate entries in the table. Access type Key access – like database tables – works via field contents. Index access, unlike for database tables, the system assigns row numbers to certain kinds of internal tables. This means that you can sometimes use the index to access rows in the table.
Internal Table Kinds Internal Tables can be divided into three table kinds, depending on the possible access type required: Standard Tables  – the row number is maintained internally. Both index and key access are possible. Sorted Tables  – Data records are sorted by the key and stored in these tables. Their index is also maintained internally. Both index and key access are possible. Hashed Tables  – The runtime-optimized data records are maintained here. This requires a unique key. Hashed tables only allow for key access.
Defining Internal Tables - Standard Example 1 : Example 2 : DATA:  itab TYPE STANDARD TABLE OF scarr   WITH UNIQUE KEY carrid. Example 3 : DATA:  itab TYPE TABLE OF scarr.
Defining Internal Tables: Sorted & Hashed
Work Area or Header Line You can define internal tables either with (addition WITH HEADER LINE) or without header lines. An internal table with a header line consists of a work area (header line) and the actual table body. You address both objects using the  same name . Reading an Internal Table using LOOP. LOOP at itab INTO wa. LOOP at itab.   WRITE wa-carrid.     WRITE itab-carrid. ENDLOOP. ENDLOOP.
Hashed Internal Table Access to a hashed table is implemented using a hash algorithm. This means that the data records are distributed randomly but evenly over a particular memory area. Their addresses are stored in a separate table,  the hash table . The hash function uses the key data to calculate the address where the hashed table entry is located. If a  single record  is accessed using a  fully  specified key, the hash function can use the key immediately to determine the address of the hashed table entry. That is where the address of the actual data record is stored. Using a hash technique means that the access time no longer depends on the total number of entries in the table. The access time is therefore very short.  Hashed tables are therefore particularly useful for large tables with which you predominantly use read access.
Internal Table – single-record access Whenever you want to read individual table rows by declaring a complete key, use READ TABLE ... WITH  TABLE  KEY. This achieves the fastest single-record access with a key.  If the table is a standard table the SAP system performs a sequential search. If the table is a sorted table the SAP system performs a binary search. If the table is a hashed table the SAP system applies the hashed algorithm.
Internal Table Kinds - Summary Standard table Standard tables are best when you access data using an index, that is, the  order  of the data records is important but the sorting and the uniqueness are not crucial. If you decide you need to sort the table or access it using the key or a binary search, you can always program these functions by hand. Sorted table When you choose to use a sorted table, it will normally be because you want to define a  unique key . If you decide you need to sort the table or use a binary search, you can always program these functions by hand. A sorted table also defines a unique key, but unlike a standard table, the data is sorted and then inserted. Also, the initial data is built up faster. Thus, if you have a table with few entries but lots of accesses that  change  the contents, a sorted table may be more efficient than a standard  table in terms of runtime. A typical use is the preparation and execution of  database changes by mass processing . The most efficient way of doing this is to create a local copy of the data in the program, make the changes to the copy, and then write all of its data records back to the database table. When you are dealing with large amounts of data, this method both saves runtime and reduces the load on the database server. Consequently, when you access the internal table, you should already use the unique key to ensure that the data record is unique. Automatic sorting can also bring further advantages.
Internal Table Kinds - Summary Hashed table The hash algorithm calculates the address of an entry based on the key. This means that, with larger tables, the access time is reduced significantly in comparison with a binary search. But when you use a loop with a hashed table, the whole table has to be scanned. Because the data records are usually totally unsorted, a sorted table may be more useful if you have a loop over the beginning of a key. Alternatively, you could also sort the hashed table.  Hashed table is only beneficial if you want to keep  large amounts of data  locally in the program and you mostly access it  only to read  it. You must ensure that you design your hashed table so that it is possible to specify the full key when you access it from your program. Typical use for hashed tables is for buffering or bundling large amounts of data from several database tables when an  ABAP Dictionary  view or a nested SELECT statement is not possible.
Ad

More Related Content

What's hot (20)

Abap dictionary 1
Abap dictionary 1Abap dictionary 1
Abap dictionary 1
venkata karthik
 
Hash pre
Hash preHash pre
Hash pre
Waed Shagareen
 
Index Tuning
Index TuningIndex Tuning
Index Tuning
sqlserver.co.il
 
Lecture03 abap on line
Lecture03 abap on lineLecture03 abap on line
Lecture03 abap on line
Milind Patil
 
oracle tables
oracle tablesoracle tables
oracle tables
Asanka Dilruk
 
Database Indexes
Database IndexesDatabase Indexes
Database Indexes
Sperasoft
 
Data storage and indexing
Data storage and indexingData storage and indexing
Data storage and indexing
pradeepa velmurugan
 
File organization 1
File organization 1File organization 1
File organization 1
Rupali Rana
 
Indexing structure for files
Indexing structure for filesIndexing structure for files
Indexing structure for files
Zainab Almugbel
 
Sql server ___________session_17(indexes)
Sql server  ___________session_17(indexes)Sql server  ___________session_17(indexes)
Sql server ___________session_17(indexes)
Ehtisham Ali
 
Ardbms
ArdbmsArdbms
Ardbms
guestcc2d29
 
SAS Programming Notes
SAS Programming NotesSAS Programming Notes
SAS Programming Notes
Gnana Murthy A
 
Introduction of sql server indexing
Introduction of sql server indexingIntroduction of sql server indexing
Introduction of sql server indexing
Mahabubur Rahaman
 
Advance Sqlite3
Advance Sqlite3Advance Sqlite3
Advance Sqlite3
Raghu nath
 
B tree
B treeB tree
B tree
Padma Kannan
 
Database - R.D.Sivakumar
Database - R.D.SivakumarDatabase - R.D.Sivakumar
Database - R.D.Sivakumar
Sivakumar R D .
 
Ppt Lesson 13
Ppt Lesson 13Ppt Lesson 13
Ppt Lesson 13
ayetalviola
 
Optimized cluster index generation
Optimized cluster index generationOptimized cluster index generation
Optimized cluster index generation
Rutvik Pensionwar
 
Database tables
Database tablesDatabase tables
Database tables
HasanUYANIK2
 
Database index by Reema Gajjar
Database index by Reema GajjarDatabase index by Reema Gajjar
Database index by Reema Gajjar
Reema Gajjar
 

Similar to Lecture12 abap on line (20)

Indexing techniques
Indexing techniquesIndexing techniques
Indexing techniques
Huda Alameen
 
DMBS Indexes.pptx
DMBS Indexes.pptxDMBS Indexes.pptx
DMBS Indexes.pptx
husainsadikarvy
 
Database management system session 6
Database management system session 6Database management system session 6
Database management system session 6
Infinity Tech Solutions
 
File Organization in database management.pptx
File Organization in database management.pptxFile Organization in database management.pptx
File Organization in database management.pptx
ubaidullah75790
 
Internal tables
Internal tablesInternal tables
Internal tables
waseem27
 
dotnetMALAGA - Sql query tuning guidelines
dotnetMALAGA - Sql query tuning guidelinesdotnetMALAGA - Sql query tuning guidelines
dotnetMALAGA - Sql query tuning guidelines
Javier García Magna
 
Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…
Aaron Shilo
 
Sql performance tuning
Sql performance tuningSql performance tuning
Sql performance tuning
Leo Mark Villar
 
lecture 2 notes indexing in application of database systems.pptx
lecture 2 notes indexing in application of database systems.pptxlecture 2 notes indexing in application of database systems.pptx
lecture 2 notes indexing in application of database systems.pptx
peter1097
 
Sap abap material
Sap abap materialSap abap material
Sap abap material
Kranthi Kumar
 
asdfew.pptx
asdfew.pptxasdfew.pptx
asdfew.pptx
hunterkurosaki
 
Unit08 dbms
Unit08 dbmsUnit08 dbms
Unit08 dbms
arnold 7490
 
Advance sqlite3
Advance sqlite3Advance sqlite3
Advance sqlite3
Raghu nath
 
Sql Server Basics
Sql Server BasicsSql Server Basics
Sql Server Basics
rainynovember12
 
Overview of Storage and Indexing ...
Overview of Storage and Indexing                                             ...Overview of Storage and Indexing                                             ...
Overview of Storage and Indexing ...
Javed Khan
 
8 i index_tables
8 i index_tables8 i index_tables
8 i index_tables
Anil Pandey
 
1650607.ppt
1650607.ppt1650607.ppt
1650607.ppt
KalsoomTahir2
 
Index organized-table
Index organized-tableIndex organized-table
Index organized-table
raima sen
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
Suleman Memon
 
Hashing and Hashtable, application of hashing, advantages of hashing, disadva...
Hashing and Hashtable, application of hashing, advantages of hashing, disadva...Hashing and Hashtable, application of hashing, advantages of hashing, disadva...
Hashing and Hashtable, application of hashing, advantages of hashing, disadva...
NaveenPeter8
 
Indexing techniques
Indexing techniquesIndexing techniques
Indexing techniques
Huda Alameen
 
File Organization in database management.pptx
File Organization in database management.pptxFile Organization in database management.pptx
File Organization in database management.pptx
ubaidullah75790
 
Internal tables
Internal tablesInternal tables
Internal tables
waseem27
 
dotnetMALAGA - Sql query tuning guidelines
dotnetMALAGA - Sql query tuning guidelinesdotnetMALAGA - Sql query tuning guidelines
dotnetMALAGA - Sql query tuning guidelines
Javier García Magna
 
Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…
Aaron Shilo
 
lecture 2 notes indexing in application of database systems.pptx
lecture 2 notes indexing in application of database systems.pptxlecture 2 notes indexing in application of database systems.pptx
lecture 2 notes indexing in application of database systems.pptx
peter1097
 
Advance sqlite3
Advance sqlite3Advance sqlite3
Advance sqlite3
Raghu nath
 
Overview of Storage and Indexing ...
Overview of Storage and Indexing                                             ...Overview of Storage and Indexing                                             ...
Overview of Storage and Indexing ...
Javed Khan
 
8 i index_tables
8 i index_tables8 i index_tables
8 i index_tables
Anil Pandey
 
Index organized-table
Index organized-tableIndex organized-table
Index organized-table
raima sen
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
Suleman Memon
 
Hashing and Hashtable, application of hashing, advantages of hashing, disadva...
Hashing and Hashtable, application of hashing, advantages of hashing, disadva...Hashing and Hashtable, application of hashing, advantages of hashing, disadva...
Hashing and Hashtable, application of hashing, advantages of hashing, disadva...
NaveenPeter8
 
Ad

More from Milind Patil (20)

Abap slide class4 unicode-plusfiles
Abap slide class4 unicode-plusfilesAbap slide class4 unicode-plusfiles
Abap slide class4 unicode-plusfiles
Milind Patil
 
Step by step abap_input help or lov
Step by step abap_input help or lovStep by step abap_input help or lov
Step by step abap_input help or lov
Milind Patil
 
Step bystep abap_fieldhelpordocumentation
Step bystep abap_fieldhelpordocumentationStep bystep abap_fieldhelpordocumentation
Step bystep abap_fieldhelpordocumentation
Milind Patil
 
Step bystep abap_field help or documentation
Step bystep abap_field help or documentationStep bystep abap_field help or documentation
Step bystep abap_field help or documentation
Milind Patil
 
Abap slides user defined data types and data
Abap slides user defined data types and dataAbap slides user defined data types and data
Abap slides user defined data types and data
Milind Patil
 
Abap slides set1
Abap slides set1Abap slides set1
Abap slides set1
Milind Patil
 
Abap slide class3
Abap slide class3Abap slide class3
Abap slide class3
Milind Patil
 
Abap slide lock Enqueue data clusters auth checks
Abap slide lock Enqueue data clusters auth checksAbap slide lock Enqueue data clusters auth checks
Abap slide lock Enqueue data clusters auth checks
Milind Patil
 
Step bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecordStep bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecord
Milind Patil
 
Abap slide lockenqueuedataclustersauthchecks
Abap slide lockenqueuedataclustersauthchecksAbap slide lockenqueuedataclustersauthchecks
Abap slide lockenqueuedataclustersauthchecks
Milind Patil
 
Abap slide exceptionshandling
Abap slide exceptionshandlingAbap slide exceptionshandling
Abap slide exceptionshandling
Milind Patil
 
Step bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecordStep bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecord
Milind Patil
 
Lecture16 abap on line
Lecture16 abap on lineLecture16 abap on line
Lecture16 abap on line
Milind Patil
 
Lecture14 abap on line
Lecture14 abap on lineLecture14 abap on line
Lecture14 abap on line
Milind Patil
 
Lecture13 abap on line
Lecture13 abap on lineLecture13 abap on line
Lecture13 abap on line
Milind Patil
 
Lecture11 abap on line
Lecture11 abap on lineLecture11 abap on line
Lecture11 abap on line
Milind Patil
 
Lecture10 abap on line
Lecture10 abap on lineLecture10 abap on line
Lecture10 abap on line
Milind Patil
 
Lecture09 abap on line
Lecture09 abap on lineLecture09 abap on line
Lecture09 abap on line
Milind Patil
 
Lecture08 abap on line
Lecture08 abap on lineLecture08 abap on line
Lecture08 abap on line
Milind Patil
 
Abap slide class4 unicode-plusfiles
Abap slide class4 unicode-plusfilesAbap slide class4 unicode-plusfiles
Abap slide class4 unicode-plusfiles
Milind Patil
 
Step by step abap_input help or lov
Step by step abap_input help or lovStep by step abap_input help or lov
Step by step abap_input help or lov
Milind Patil
 
Step bystep abap_fieldhelpordocumentation
Step bystep abap_fieldhelpordocumentationStep bystep abap_fieldhelpordocumentation
Step bystep abap_fieldhelpordocumentation
Milind Patil
 
Step bystep abap_field help or documentation
Step bystep abap_field help or documentationStep bystep abap_field help or documentation
Step bystep abap_field help or documentation
Milind Patil
 
Abap slides user defined data types and data
Abap slides user defined data types and dataAbap slides user defined data types and data
Abap slides user defined data types and data
Milind Patil
 
Abap slide lock Enqueue data clusters auth checks
Abap slide lock Enqueue data clusters auth checksAbap slide lock Enqueue data clusters auth checks
Abap slide lock Enqueue data clusters auth checks
Milind Patil
 
Step bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecordStep bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecord
Milind Patil
 
Abap slide lockenqueuedataclustersauthchecks
Abap slide lockenqueuedataclustersauthchecksAbap slide lockenqueuedataclustersauthchecks
Abap slide lockenqueuedataclustersauthchecks
Milind Patil
 
Abap slide exceptionshandling
Abap slide exceptionshandlingAbap slide exceptionshandling
Abap slide exceptionshandling
Milind Patil
 
Step bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecordStep bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecord
Milind Patil
 
Lecture16 abap on line
Lecture16 abap on lineLecture16 abap on line
Lecture16 abap on line
Milind Patil
 
Lecture14 abap on line
Lecture14 abap on lineLecture14 abap on line
Lecture14 abap on line
Milind Patil
 
Lecture13 abap on line
Lecture13 abap on lineLecture13 abap on line
Lecture13 abap on line
Milind Patil
 
Lecture11 abap on line
Lecture11 abap on lineLecture11 abap on line
Lecture11 abap on line
Milind Patil
 
Lecture10 abap on line
Lecture10 abap on lineLecture10 abap on line
Lecture10 abap on line
Milind Patil
 
Lecture09 abap on line
Lecture09 abap on lineLecture09 abap on line
Lecture09 abap on line
Milind Patil
 
Lecture08 abap on line
Lecture08 abap on lineLecture08 abap on line
Lecture08 abap on line
Milind Patil
 
Ad

Recently uploaded (20)

machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
João Esperancinha
 
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
CSUC - Consorci de Serveis Universitaris de Catalunya
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Top-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptxTop-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptx
BR Softech
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
Build With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdfBuild With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdf
Google Developer Group - Harare
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
Agentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community MeetupAgentic Automation - Delhi UiPath Community Meetup
Agentic Automation - Delhi UiPath Community Meetup
Manoj Batra (1600 + Connections)
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
João Esperancinha
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Top-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptxTop-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptx
BR Softech
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 

Lecture12 abap on line

  • 1. Lecture 12 Advanced Internal Tables BCO5647 Applications Programming Techniques (ABAP)
  • 2. Readings & Objectives Readings Keller & Keller Chapter 4 Section 4.7.1 & 4.7.3 Objectives This lecture will Revise the structure of internal tables Review the attributes of internal tables Describe the three internal table kinds: standard, sorted, hashed Examine the features and application of STANDARD internal tables Examine the features and application of SORTED internal tables Examine the features and application of HASHED internal tables Distinguish between the use of work areas Vs header lines when processing internal tables
  • 3. Internal Tables as Dynamic Data Objects Internal tables are data objects that allow you to store datasets with a fixed structure in memory. The data is stored row by row in memory. Each row has the same structure. You can also refer to each component in a row as a column in the internal table. You refer to each row in the internal table as a table row or table entry. Internal tables are dynamic data objects that can hold any number of rows of a fixed type. The number of rows in an internal table is limited only by the capacity of the specific system with which you are working.
  • 4. Attributes of an Internal Table The data type of an internal table is fully specified by its: Row type The row type defines the attributes of the individual columns. You normally enter a structure type, but any data type is possible. Key definition The key columns and their sequence determine the criteria by which the system identifies table rows. You can define the key as either UNIQUE or NON-UNIQUE. The uniqueness of the key must be compatible with the access type you have chosen for the table. If the key is unique, there can be no duplicate entries in the table. Access type Key access – like database tables – works via field contents. Index access, unlike for database tables, the system assigns row numbers to certain kinds of internal tables. This means that you can sometimes use the index to access rows in the table.
  • 5. Internal Table Kinds Internal Tables can be divided into three table kinds, depending on the possible access type required: Standard Tables – the row number is maintained internally. Both index and key access are possible. Sorted Tables – Data records are sorted by the key and stored in these tables. Their index is also maintained internally. Both index and key access are possible. Hashed Tables – The runtime-optimized data records are maintained here. This requires a unique key. Hashed tables only allow for key access.
  • 6. Defining Internal Tables - Standard Example 1 : Example 2 : DATA: itab TYPE STANDARD TABLE OF scarr WITH UNIQUE KEY carrid. Example 3 : DATA: itab TYPE TABLE OF scarr.
  • 7. Defining Internal Tables: Sorted & Hashed
  • 8. Work Area or Header Line You can define internal tables either with (addition WITH HEADER LINE) or without header lines. An internal table with a header line consists of a work area (header line) and the actual table body. You address both objects using the same name . Reading an Internal Table using LOOP. LOOP at itab INTO wa. LOOP at itab. WRITE wa-carrid. WRITE itab-carrid. ENDLOOP. ENDLOOP.
  • 9. Hashed Internal Table Access to a hashed table is implemented using a hash algorithm. This means that the data records are distributed randomly but evenly over a particular memory area. Their addresses are stored in a separate table, the hash table . The hash function uses the key data to calculate the address where the hashed table entry is located. If a single record is accessed using a fully specified key, the hash function can use the key immediately to determine the address of the hashed table entry. That is where the address of the actual data record is stored. Using a hash technique means that the access time no longer depends on the total number of entries in the table. The access time is therefore very short. Hashed tables are therefore particularly useful for large tables with which you predominantly use read access.
  • 10. Internal Table – single-record access Whenever you want to read individual table rows by declaring a complete key, use READ TABLE ... WITH TABLE KEY. This achieves the fastest single-record access with a key. If the table is a standard table the SAP system performs a sequential search. If the table is a sorted table the SAP system performs a binary search. If the table is a hashed table the SAP system applies the hashed algorithm.
  • 11. Internal Table Kinds - Summary Standard table Standard tables are best when you access data using an index, that is, the order of the data records is important but the sorting and the uniqueness are not crucial. If you decide you need to sort the table or access it using the key or a binary search, you can always program these functions by hand. Sorted table When you choose to use a sorted table, it will normally be because you want to define a unique key . If you decide you need to sort the table or use a binary search, you can always program these functions by hand. A sorted table also defines a unique key, but unlike a standard table, the data is sorted and then inserted. Also, the initial data is built up faster. Thus, if you have a table with few entries but lots of accesses that change the contents, a sorted table may be more efficient than a standard table in terms of runtime. A typical use is the preparation and execution of database changes by mass processing . The most efficient way of doing this is to create a local copy of the data in the program, make the changes to the copy, and then write all of its data records back to the database table. When you are dealing with large amounts of data, this method both saves runtime and reduces the load on the database server. Consequently, when you access the internal table, you should already use the unique key to ensure that the data record is unique. Automatic sorting can also bring further advantages.
  • 12. Internal Table Kinds - Summary Hashed table The hash algorithm calculates the address of an entry based on the key. This means that, with larger tables, the access time is reduced significantly in comparison with a binary search. But when you use a loop with a hashed table, the whole table has to be scanned. Because the data records are usually totally unsorted, a sorted table may be more useful if you have a loop over the beginning of a key. Alternatively, you could also sort the hashed table. Hashed table is only beneficial if you want to keep large amounts of data locally in the program and you mostly access it only to read it. You must ensure that you design your hashed table so that it is possible to specify the full key when you access it from your program. Typical use for hashed tables is for buffering or bundling large amounts of data from several database tables when an ABAP Dictionary view or a nested SELECT statement is not possible.

Editor's Notes

  • #5: The data type of an internal table is fully specified by its: Row type The row type defines the attributes of the individual columns. You normally enter a structure type, but any data type is possible. Key definition The key columns and their sequence determine the criteria by which the system identifies table rows. You can define the key as either UNIQUE or NON-UNIQUE. The uniqueness of the key must be compatible with the access type you have chosen for the table. If the key is unique, there can be no duplicate entries in the table. Access type Key access . like database tables . works via field contents. Example: Using the search term UA 0007 for read access to an internal table with the unique key CARRID CONNID and data as specified above will result in exactly one data record. Index access , unlike for database tables, the system assigns row numbers to certain kinds of internal tables. This means that you can sometimes use the index to access rows in the table. Example: Read-access to the data record with index 5 returns the fifth data record from the internal table.
  • #6: Standard tables are the most flexible kind. The flexibility occurs because the sort sequence of a standard table is not fixed. You can change it several times and resort the internal table’s contents accordingly. They are usually used with index access, however when used with key access, the system searches all lines sequentially for the key value. The average search time is proportional to the number of lines. Sorted tables are ideally used with unique keys and fixed sorting. When a sorted table is defined, either a unique or non-unique key must be defined. By definition, this key also determines the sorting order, it cannot be changed. When a key access is made using this key, the SAP system will automatically use a binary search technique. Sorted tables are especially useful for the loop processing of an entire internal table’s content in a fixed order. Hashed tables are not intended for loop processing. Instead, you would use it when you need to access one specific entry at a time of an internal table’s contents. In a key access to a hashed table, the SAP system calculates the position of the line from the key value using a hash function . The search time is not affected by the number of lines and always constant. Can be used for buffering or bundling large amounts of data from several DB tables. Refer to access times for 3 table kinds - Keller & Kruger Fig 4.17 Pg 177
  • #7: Example 1: The example shows the definition of a STANDARD internal table (TT_DISTANCE) using a local table kind (TT_DISTANCE_TY), which itself uses a local row type (S_DISTANCE_TY). Therefore, the defined internal standard table has the columns CARRID, CONNID, DISTANCE, and DISTID. The DEFAULT KEY means that all non-numeric fields are used to create the key. They are used in the sequence in which they occur in the row type. In this case, the keys CARRID, CONNID, and DISTID are defined. The key is non-unique. Example 2: The example shows the definition of a STANDARD internal table (itab) using a global row type (scarr). The defined internal standard table has the same columns as the DB table scarr. The KEY is defined as CARRID and is unique. Example 3: The example defaults to a STANDARD internal table WITH NON-UNIQUE DEFAULT KEY NOTE: No work area has been defined in these examples. This will be demonstrated later.
  • #8: The above example shows the definition of a sorted table and a hashed table. Both tables have the same row type as the standard table on the previous slide. Note that the contents of the tables are in a different order. For sorted tables, the sequence of the entries in the internal table is determined by the sequence of the fields in the key definition. For table kinds defined in a program, you can use the optional INITIAL SIZE addition to specify the number of rows that the runtime system should reserve when it instantiates the data object. INITIAL SIZE replaces the OCCURS statement.
  • #9: You can define internal tables either with (addition WITH HEADER LINE) or without header lines. An internal table with a header line consists of a work area (header line) and the actual table body. You address both objects using the same name . Note 1: Work area can be also defined as DATA: wa LIKE LINE OF scarr. Note 2: Reading an Internal Table using LOOP and WA
  • #10: Access to a hashed table is implemented using a hash algorithm. Simplified, this means that the data records are distributed randomly but evenly over a particular memory area. Their addresses are stored in a separate table, the hash table . The hash function uses the key data to calculate the address where the hashed table entry is located. The function is not injective, that is, there can be several data records stored at a single address. This is implemented internally as a chained list. Thus, the system may still have to search through such an area sequentially. However, the chained list can contain no more than two entries. If a new key leads to the same hashed table address for a third time, the system uses a changed hash function and rebuilds the management from scratch. The slide image illustrates the simplest case, that is, in which there is only one data record stored at each address. If a single record is accessed using a fully specified key, the hash function can use the key immediately to determine the address of the hashed table entry. That is where the address of the actual data record is stored. Using a hash technique means that the access time no longer depends on the total number of entries in the table. The access time is therefore very short. Hashed tables are therefore particularly useful for large tables with which you predominantly use read access. Data records are not inserted into the table in a sorted order. As with standard tables, you can sort hashed tables using the SORT statement - Sorting the table can be useful if you later want to use a loop to access the table.
  • #11: Demo zbmcLec009a zbmcLec009b zbmcLec009c
  • #13: Demo Workshop Exercises
  翻译: