SlideShare ist ein Scribd-Unternehmen logo
1 von 17
ABAP Course

                Chapter 4 – Database accesses



Lecturer: André Bögelsack, UCC Technische Universität München
Author: Valentin Nicolescu, André Bögelsack
                  ABAP Course                     André Bögelsack, Valentin Nicolescu   1
Copyright 2008 UCC TU München
                              All rights reserved
   Weitergabe und Vervielfältigung dieser Publikation oder von Teilen daraus sind, zu welchem Zweck und in welcher Form auch immer, ohne
    die ausdrückliche schriftliche Genehmigung durch HCC TU München nicht gestattet. In dieser Publikation enthaltene Informationen können
    ohne vorherige Ankündigung geändert werden.
   Microsoft®, WINDOWS®, NT®, EXCEL®, Word®, PowerPoint® und SQL Server® sind eingetragene Marken der Microsoft Corporation.
   IBM®, DB2®, OS/2®, DB2/6000®, Parallel Sysplex®, MVS/ESA®, RS/6000®, AIX®, S/390®, AS/400®, OS/390® und OS/400® sind eingetragene
    Marken der IBM Corporation.
   ORACLE® ist eine eingetragene Marke der ORACLE Corporation.
   INFORMIX®-OnLine for SAP und Informix® Dynamic ServerTM sind eingetragene Marken der Informix Software Incorporated.
   UNIX®, X/Open®, OSF/1® und Motif® sind eingetragene Marken der Open Group.
   Citrix®, das Citrix-Logo, ICA®, Program Neighborhood®, MetaFrame®, WinFrame®, VideoFrame®, MultiWin® und andere hier erwähnte
    Namen von Citrix-Produkten sind Marken von Citrix Systems, Inc.
   HTML, DHTML, XML, XHTML sind Marken oder eingetragene Marken des W3C®, World Wide Web Consortium, Massachusetts Institute of
    Technology.
   JAVA® ist eine eingetragene Marke der Sun Microsystems, Inc.
   JAVASCRIPT® ist eine eingetragene Marke der Sun Microsystems, Inc., verwendet unter der Lizenz der von Netscape entwickelten und
    implementierten Technologie.
   SAP, SAP Logo, R/2, RIVA, R/3, SAP ArchiveLink, SAP Business Workflow, WebFlow, SAP EarlyWatch, BAPI, SAPPHIRE, Management Cockpit,
    mySAP, mySAP.com und weitere im Text erwähnte SAP-Produkte und -Dienstleistungen sowie die entsprechenden Logos sind Marken oder
    eingetragene Marken der SAP AG in Deutschland und anderen Ländern weltweit. MarketSet und Enterprise Buyer sind gemeinsame
    Marken von SAP Markets und Commerce One.
   Alle anderen Namen von Produkten und Dienstleistungen sind Marken der jeweiligen Firmen.
   Die Verwendung der Screenshots wurde mit dem jeweiligen Eigner abgesprochen.




                               ABAP Course                                           André Bögelsack, Valentin Nicolescu               2
Agenda

1.   Data dictionary
2.   SAP flight example
3.   Database operations in SAP
4.   SAP OpenSQL
5.   Types of database changes
6.   Types of entry help




               ABAP Course            André Bögelsack, Valentin Nicolescu   3
Data dictionary

•   Data dictionary = global directory for data types
•   Assignment of help texts and explanations for data types in
    different languages
•   ERM can be shown as a figure automatically
•   Most important objects: structure, table, data element and
    domain




               ABAP Course                 André Bögelsack, Valentin Nicolescu   4
Data dictionary
Domain             ZY_ID                                      INT4             Data type


Data element       ZY_ID         ZZ_ID



Field              ZY_ID         ZZ_ID




Structure       Field

Table           Field
                Field


               ABAP Course               André Bögelsack, Valentin Nicolescu        5
Data dictionary

•   Menu path: Tools • ABAP Workbench • Development •
    Dictionary
•   TA SE11
•   View, edit, delete, create tables, data types, domains definitions
    etc.
•   Tables and views from the ABAP dictionary represent tables and
    views from the database
•   User interface are generated automatically when changing views,
    tables etc.
•   Table may be changed after they are created without losing data
•   SAP tables may be extended by APPEND structures



               ABAP Course                  André Bögelsack, Valentin Nicolescu   6
Data browser

•   Menu path: Tools • ABAP Workbench • Overview • Data
    Browser
•   TA SE16
•   View table content
•   Add new entries to tables when adding is permitted for the table
•   Browse the entry help table content
•   Copy table content to transport request
•   Download table content




              ABAP Course                  André Bögelsack, Valentin Nicolescu   7
Overview about all objects
•       Database table
•       View
•       Data type
    –    Data element
    –    Structure
    –    Database table
    –    Table types
    –    Views
    –    Class / interface
•       Type group
•       Domain
•       Search help
•       Lock object


                     ABAP Course    André Bögelsack, Valentin Nicolescu   8
Visualization

•   Foreign key relationships can be visualized in data dictionary
•   Table SFLIGHT




               ABAP Course                   André Bögelsack, Valentin Nicolescu   9
SAP flight example

•   Created and maintained by SAP to demonstrate database
    operations
•   Contains exercise data for airline, flight connection number, flight
    date, airfare etc.
•   Report for data generation:
    S_FLIGHT_MODEL_DATA_GENERATION
•   SAP trainings, examples from books build refer to the flight
    example




               ABAP Course                   André Bögelsack, Valentin Nicolescu   10
SAP flight example – table structure
Connection                 Flight   Reservation                        Plane

  SPFLI              SFLIGHT         SBOOK                         SAPLANE
 MANDT                MANDT          MANDT                           MANDT
 CARRID              CARRID          CARRID                     PLANETYPE
 CONNID              CONNID          CONNID                       SEATSMAX
AIRPFROM             FLDATE          FLDATE                        TANKCAP
 AIRPTO            SEATSMAX          BOOKID                       CAP_UNIT
CITYFROM          SEATSOCC          CUSTOMID                        WEIGHT
 CITYTO                PRICE        LUGGWEIGH                      WIE_UNIT
COUNTRYFR         CURRENCY            WUNIT                       OP_SPEED
COUNTRYTO         PLANETYPE         CANCELLED                   SPEED_UNIT
   …                        …           …                                 …



             ABAP Course                      André Bögelsack, Valentin Nicolescu   11
SAP OpenSQL
•     Independent from database

Application Server                                              Database Server

    ABAP-Interpreter                DB-Interface                              SQL-Database

     Select * from      OpenSQL                    Native SQL
                       DB data                        DB data




     Exec SQL.                           Native SQL
      Select * from                                                                      Data
     End Exec.                              DB data



                      ABAP Course                               André Bögelsack, Valentin Nicolescu   12
OpenSQL instructions

•       Select:
    –      SELECT / SELECT SINGLE
    –      * / field 1 ..field n /
    –      FROM table / view
    –      INTO structure / internal table
    –      WHERE condition
•       Aggregation:
    –      MAX, MIN, AVG
    –      SUM, COUNT
•       Joins:
    –      Left outer join
    –      Inner join
    –      View



                     ABAP Course             André Bögelsack, Valentin Nicolescu   13
Procedure for database access

General:
•     Be specific to decrease the load on the database
•     Access to database takes 10,000 time longer than access to buffers
•     Avoid table scans, use indexes


Procedure:
1.     Read database data into internal tables
     •    Internal tables are tables for holding data during runtime
2.     Change data per row
     •    Use workareas to hold one row of the table and change data in the
          workarea
3.     Write changes back to database


                   ABAP Course                      André Bögelsack, Valentin Nicolescu   14
Procedure for database access
Internal tables and workareas:
        wa_spfli
                                      Workarea         • Use the workarea to modify
   LH         0400                    (one row)          one data set



         it_spfli
                                    Internal table     • Use the internal table to store
   AA         0017                (selected content)     the selected database content
                                                         temporarily
   LH         0400                                     • Internal tables are deleted
                                                         after program is finished




        Database                   Database table      • Use the database to read/write
                                   (whole content)       data
                    ABAP Course                        André Bögelsack, Valentin Nicolescu   15
Types of database changes

Modify instruction:
     MODIFY <dbtable> [CLIENT SPECIFIED] FROM <workarea>.
     MODIFY <dbtable> [CLIENT SPECIFIED] FROM TABLE
     <internaltable>
•    Modify = Update – the command updates the database table if
     the database table already contains dataset
•    Modify = Insert – the command inserts new datasets into the
     database table

Delete instruction:
DELETE FROM <dbtable> WHERE [SQL statement].




                ABAP Course               André Bögelsack, Valentin Nicolescu   16
Entry help
•   Entry help uses a table in the background
•   Predefined entry help for a table




               ABAP Course                 André Bögelsack, Valentin Nicolescu   17

Weitere ähnliche Inhalte

Andere mochten auch

Lecture01 abap on line
Lecture01 abap on lineLecture01 abap on line
Lecture01 abap on lineMilind Patil
 
Sap abap ppt
Sap abap pptSap abap ppt
Sap abap pptvonline
 
Abap course chapter 7 abap objects and bsp
Abap course   chapter 7 abap objects and bspAbap course   chapter 7 abap objects and bsp
Abap course chapter 7 abap objects and bspMilind Patil
 
Modularization & Catch Statement
Modularization & Catch StatementModularization & Catch Statement
Modularization & Catch Statementsapdocs. info
 
Introduction to ABAP
Introduction to ABAPIntroduction to ABAP
Introduction to ABAPsapdocs. info
 
ABAP Event-driven Programming &Selection Screen
ABAP Event-driven Programming &Selection ScreenABAP Event-driven Programming &Selection Screen
ABAP Event-driven Programming &Selection Screensapdocs. info
 
ABAP Open SQL & Internal Table
ABAP Open SQL & Internal TableABAP Open SQL & Internal Table
ABAP Open SQL & Internal Tablesapdocs. info
 

Andere mochten auch (7)

Lecture01 abap on line
Lecture01 abap on lineLecture01 abap on line
Lecture01 abap on line
 
Sap abap ppt
Sap abap pptSap abap ppt
Sap abap ppt
 
Abap course chapter 7 abap objects and bsp
Abap course   chapter 7 abap objects and bspAbap course   chapter 7 abap objects and bsp
Abap course chapter 7 abap objects and bsp
 
Modularization & Catch Statement
Modularization & Catch StatementModularization & Catch Statement
Modularization & Catch Statement
 
Introduction to ABAP
Introduction to ABAPIntroduction to ABAP
Introduction to ABAP
 
ABAP Event-driven Programming &Selection Screen
ABAP Event-driven Programming &Selection ScreenABAP Event-driven Programming &Selection Screen
ABAP Event-driven Programming &Selection Screen
 
ABAP Open SQL & Internal Table
ABAP Open SQL & Internal TableABAP Open SQL & Internal Table
ABAP Open SQL & Internal Table
 

Ähnlich wie Abap course chapter 4 database accesses

Heterogene Daten(-strukturen) in der Oracle Datenbank
Heterogene Daten(-strukturen) in der Oracle DatenbankHeterogene Daten(-strukturen) in der Oracle Datenbank
Heterogene Daten(-strukturen) in der Oracle DatenbankUlrike Schwinn
 
20160310_ModernApplicationDevelopment_NoSQL_KPatenge
20160310_ModernApplicationDevelopment_NoSQL_KPatenge20160310_ModernApplicationDevelopment_NoSQL_KPatenge
20160310_ModernApplicationDevelopment_NoSQL_KPatengeKarin Patenge
 
Oracle hadoop doag-big-data_09_2014_gpi
Oracle hadoop doag-big-data_09_2014_gpiOracle hadoop doag-big-data_09_2014_gpi
Oracle hadoop doag-big-data_09_2014_gpiGunther Pippèrr
 
Einstieg in relationale Datenbanken mit MySQL (Handout)
Einstieg in relationale Datenbanken mit MySQL (Handout)Einstieg in relationale Datenbanken mit MySQL (Handout)
Einstieg in relationale Datenbanken mit MySQL (Handout)Kerstin Puschke
 
Tune up your APEX
Tune up your APEXTune up your APEX
Tune up your APEXMT AG
 
Analytics meets Big Data – R/Python auf der Hadoop/Spark-Plattform
Analytics meets Big Data – R/Python auf der Hadoop/Spark-PlattformAnalytics meets Big Data – R/Python auf der Hadoop/Spark-Plattform
Analytics meets Big Data – R/Python auf der Hadoop/Spark-PlattformRising Media Ltd.
 
Webinar - ABAP Development Tools
Webinar - ABAP Development ToolsWebinar - ABAP Development Tools
Webinar - ABAP Development ToolsCadaxo GmbH
 
20190604_DOAGDatabase2019_OracleNoSQLDB_for_DBAs
20190604_DOAGDatabase2019_OracleNoSQLDB_for_DBAs20190604_DOAGDatabase2019_OracleNoSQLDB_for_DBAs
20190604_DOAGDatabase2019_OracleNoSQLDB_for_DBAsKarin Patenge
 
Bessere Data Warehouses durch Table Functions - DOAG Konferenz 2011 - OPITZ C...
Bessere Data Warehouses durch Table Functions - DOAG Konferenz 2011 - OPITZ C...Bessere Data Warehouses durch Table Functions - DOAG Konferenz 2011 - OPITZ C...
Bessere Data Warehouses durch Table Functions - DOAG Konferenz 2011 - OPITZ C...OPITZ CONSULTING Deutschland
 
20171121_DOAGKonferenz_JSON_OracleNoSQL_KPatenge
20171121_DOAGKonferenz_JSON_OracleNoSQL_KPatenge20171121_DOAGKonferenz_JSON_OracleNoSQL_KPatenge
20171121_DOAGKonferenz_JSON_OracleNoSQL_KPatengeKarin Patenge
 
Das ende von owb was nun migrationspfade fuer owb_projekte-dani schnider-stan...
Das ende von owb was nun migrationspfade fuer owb_projekte-dani schnider-stan...Das ende von owb was nun migrationspfade fuer owb_projekte-dani schnider-stan...
Das ende von owb was nun migrationspfade fuer owb_projekte-dani schnider-stan...Trivadis
 
Big Data Community Webinar vom 16. Mai 2019: Oracle NoSQL DB im Überblick
Big Data Community Webinar vom 16. Mai 2019: Oracle NoSQL DB im ÜberblickBig Data Community Webinar vom 16. Mai 2019: Oracle NoSQL DB im Überblick
Big Data Community Webinar vom 16. Mai 2019: Oracle NoSQL DB im ÜberblickKarin Patenge
 
Komprimierung in der Oracle Datenbank (Stand 11gR2, 12c)
Komprimierung in der Oracle Datenbank (Stand 11gR2, 12c)Komprimierung in der Oracle Datenbank (Stand 11gR2, 12c)
Komprimierung in der Oracle Datenbank (Stand 11gR2, 12c)Ulrike Schwinn
 
Analyse von Applikationslogs und Querylogs: Datenbanken, Hadoop oder Splunk?
Analyse von Applikationslogs und Querylogs: Datenbanken, Hadoop oder Splunk?Analyse von Applikationslogs und Querylogs: Datenbanken, Hadoop oder Splunk?
Analyse von Applikationslogs und Querylogs: Datenbanken, Hadoop oder Splunk?KurtStockinger
 
Uwe Ricken – IT-Tage 2015 – Workshop: MS SQL Server Optimierung
Uwe Ricken – IT-Tage 2015 – Workshop: MS SQL Server OptimierungUwe Ricken – IT-Tage 2015 – Workshop: MS SQL Server Optimierung
Uwe Ricken – IT-Tage 2015 – Workshop: MS SQL Server OptimierungInformatik Aktuell
 
Datenbank-Selbstverwaltung - Das Oracle-Data-Dictionary
Datenbank-Selbstverwaltung - Das Oracle-Data-DictionaryDatenbank-Selbstverwaltung - Das Oracle-Data-Dictionary
Datenbank-Selbstverwaltung - Das Oracle-Data-DictionaryMarkus Flechtner
 
Oracle Database 12c Release 2
Oracle Database 12c Release 2 Oracle Database 12c Release 2
Oracle Database 12c Release 2 oraclebudb
 
Überblick zu Oracle Database 12c Release 2
Überblick zu Oracle Database 12c Release 2Überblick zu Oracle Database 12c Release 2
Überblick zu Oracle Database 12c Release 2Ulrike Schwinn
 
Azure Data Factory – Data Management für die Cloud
Azure Data Factory – Data Management für die CloudAzure Data Factory – Data Management für die Cloud
Azure Data Factory – Data Management für die Cloudinovex GmbH
 

Ähnlich wie Abap course chapter 4 database accesses (20)

Heterogene Daten(-strukturen) in der Oracle Datenbank
Heterogene Daten(-strukturen) in der Oracle DatenbankHeterogene Daten(-strukturen) in der Oracle Datenbank
Heterogene Daten(-strukturen) in der Oracle Datenbank
 
20160310_ModernApplicationDevelopment_NoSQL_KPatenge
20160310_ModernApplicationDevelopment_NoSQL_KPatenge20160310_ModernApplicationDevelopment_NoSQL_KPatenge
20160310_ModernApplicationDevelopment_NoSQL_KPatenge
 
Oracle hadoop doag-big-data_09_2014_gpi
Oracle hadoop doag-big-data_09_2014_gpiOracle hadoop doag-big-data_09_2014_gpi
Oracle hadoop doag-big-data_09_2014_gpi
 
Einstieg in relationale Datenbanken mit MySQL (Handout)
Einstieg in relationale Datenbanken mit MySQL (Handout)Einstieg in relationale Datenbanken mit MySQL (Handout)
Einstieg in relationale Datenbanken mit MySQL (Handout)
 
Tune up your APEX
Tune up your APEXTune up your APEX
Tune up your APEX
 
Analytics meets Big Data – R/Python auf der Hadoop/Spark-Plattform
Analytics meets Big Data – R/Python auf der Hadoop/Spark-PlattformAnalytics meets Big Data – R/Python auf der Hadoop/Spark-Plattform
Analytics meets Big Data – R/Python auf der Hadoop/Spark-Plattform
 
Webinar - ABAP Development Tools
Webinar - ABAP Development ToolsWebinar - ABAP Development Tools
Webinar - ABAP Development Tools
 
20190604_DOAGDatabase2019_OracleNoSQLDB_for_DBAs
20190604_DOAGDatabase2019_OracleNoSQLDB_for_DBAs20190604_DOAGDatabase2019_OracleNoSQLDB_for_DBAs
20190604_DOAGDatabase2019_OracleNoSQLDB_for_DBAs
 
Bessere Data Warehouses durch Table Functions - DOAG Konferenz 2011 - OPITZ C...
Bessere Data Warehouses durch Table Functions - DOAG Konferenz 2011 - OPITZ C...Bessere Data Warehouses durch Table Functions - DOAG Konferenz 2011 - OPITZ C...
Bessere Data Warehouses durch Table Functions - DOAG Konferenz 2011 - OPITZ C...
 
20171121_DOAGKonferenz_JSON_OracleNoSQL_KPatenge
20171121_DOAGKonferenz_JSON_OracleNoSQL_KPatenge20171121_DOAGKonferenz_JSON_OracleNoSQL_KPatenge
20171121_DOAGKonferenz_JSON_OracleNoSQL_KPatenge
 
Das ende von owb was nun migrationspfade fuer owb_projekte-dani schnider-stan...
Das ende von owb was nun migrationspfade fuer owb_projekte-dani schnider-stan...Das ende von owb was nun migrationspfade fuer owb_projekte-dani schnider-stan...
Das ende von owb was nun migrationspfade fuer owb_projekte-dani schnider-stan...
 
Big Data Community Webinar vom 16. Mai 2019: Oracle NoSQL DB im Überblick
Big Data Community Webinar vom 16. Mai 2019: Oracle NoSQL DB im ÜberblickBig Data Community Webinar vom 16. Mai 2019: Oracle NoSQL DB im Überblick
Big Data Community Webinar vom 16. Mai 2019: Oracle NoSQL DB im Überblick
 
Komprimierung in der Oracle Datenbank (Stand 11gR2, 12c)
Komprimierung in der Oracle Datenbank (Stand 11gR2, 12c)Komprimierung in der Oracle Datenbank (Stand 11gR2, 12c)
Komprimierung in der Oracle Datenbank (Stand 11gR2, 12c)
 
Analyse von Applikationslogs und Querylogs: Datenbanken, Hadoop oder Splunk?
Analyse von Applikationslogs und Querylogs: Datenbanken, Hadoop oder Splunk?Analyse von Applikationslogs und Querylogs: Datenbanken, Hadoop oder Splunk?
Analyse von Applikationslogs und Querylogs: Datenbanken, Hadoop oder Splunk?
 
Uwe Ricken – IT-Tage 2015 – Workshop: MS SQL Server Optimierung
Uwe Ricken – IT-Tage 2015 – Workshop: MS SQL Server OptimierungUwe Ricken – IT-Tage 2015 – Workshop: MS SQL Server Optimierung
Uwe Ricken – IT-Tage 2015 – Workshop: MS SQL Server Optimierung
 
Datenbank-Selbstverwaltung - Das Oracle-Data-Dictionary
Datenbank-Selbstverwaltung - Das Oracle-Data-DictionaryDatenbank-Selbstverwaltung - Das Oracle-Data-Dictionary
Datenbank-Selbstverwaltung - Das Oracle-Data-Dictionary
 
Oracle Database 12c Release 2
Oracle Database 12c Release 2 Oracle Database 12c Release 2
Oracle Database 12c Release 2
 
Überblick zu Oracle Database 12c Release 2
Überblick zu Oracle Database 12c Release 2Überblick zu Oracle Database 12c Release 2
Überblick zu Oracle Database 12c Release 2
 
DOAG 2010: ADF Faces RC Best Practice
DOAG 2010: ADF Faces RC Best PracticeDOAG 2010: ADF Faces RC Best Practice
DOAG 2010: ADF Faces RC Best Practice
 
Azure Data Factory – Data Management für die Cloud
Azure Data Factory – Data Management für die CloudAzure Data Factory – Data Management für die Cloud
Azure Data Factory – Data Management für die Cloud
 

Mehr von 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 lovMilind Patil
 
Step bystep abap_fieldhelpordocumentation
Step bystep abap_fieldhelpordocumentationStep bystep abap_fieldhelpordocumentation
Step bystep abap_fieldhelpordocumentationMilind 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 documentationMilind 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 dataMilind 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 checksMilind Patil
 
Step bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecordStep bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecordMilind Patil
 
Abap slide lockenqueuedataclustersauthchecks
Abap slide lockenqueuedataclustersauthchecksAbap slide lockenqueuedataclustersauthchecks
Abap slide lockenqueuedataclustersauthchecksMilind Patil
 
Abap slide exceptionshandling
Abap slide exceptionshandlingAbap slide exceptionshandling
Abap slide exceptionshandlingMilind Patil
 
Step bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecordStep bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecordMilind Patil
 
Lecture16 abap on line
Lecture16 abap on lineLecture16 abap on line
Lecture16 abap on lineMilind Patil
 
Lecture14 abap on line
Lecture14 abap on lineLecture14 abap on line
Lecture14 abap on lineMilind Patil
 
Lecture13 abap on line
Lecture13 abap on lineLecture13 abap on line
Lecture13 abap on lineMilind Patil
 
Lecture12 abap on line
Lecture12 abap on lineLecture12 abap on line
Lecture12 abap on lineMilind Patil
 
Lecture11 abap on line
Lecture11 abap on lineLecture11 abap on line
Lecture11 abap on lineMilind Patil
 
Lecture10 abap on line
Lecture10 abap on lineLecture10 abap on line
Lecture10 abap on lineMilind Patil
 
Lecture09 abap on line
Lecture09 abap on lineLecture09 abap on line
Lecture09 abap on lineMilind Patil
 
Lecture08 abap on line
Lecture08 abap on lineLecture08 abap on line
Lecture08 abap on lineMilind Patil
 

Mehr von Milind Patil (20)

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
 
Step bystep abap_fieldhelpordocumentation
Step bystep abap_fieldhelpordocumentationStep bystep abap_fieldhelpordocumentation
Step bystep abap_fieldhelpordocumentation
 
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
 
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
 
Abap slides set1
Abap slides set1Abap slides set1
Abap slides set1
 
Abap slide class3
Abap slide class3Abap slide class3
Abap slide class3
 
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
 
Step bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecordStep bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecord
 
Abap slide lockenqueuedataclustersauthchecks
Abap slide lockenqueuedataclustersauthchecksAbap slide lockenqueuedataclustersauthchecks
Abap slide lockenqueuedataclustersauthchecks
 
Abap slide exceptionshandling
Abap slide exceptionshandlingAbap slide exceptionshandling
Abap slide exceptionshandling
 
Step bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecordStep bystep abap_changinga_singlerecord
Step bystep abap_changinga_singlerecord
 
Abap reports
Abap reportsAbap reports
Abap reports
 
Lecture16 abap on line
Lecture16 abap on lineLecture16 abap on line
Lecture16 abap on line
 
Lecture14 abap on line
Lecture14 abap on lineLecture14 abap on line
Lecture14 abap on line
 
Lecture13 abap on line
Lecture13 abap on lineLecture13 abap on line
Lecture13 abap on line
 
Lecture12 abap on line
Lecture12 abap on lineLecture12 abap on line
Lecture12 abap on line
 
Lecture11 abap on line
Lecture11 abap on lineLecture11 abap on line
Lecture11 abap on line
 
Lecture10 abap on line
Lecture10 abap on lineLecture10 abap on line
Lecture10 abap on line
 
Lecture09 abap on line
Lecture09 abap on lineLecture09 abap on line
Lecture09 abap on line
 
Lecture08 abap on line
Lecture08 abap on lineLecture08 abap on line
Lecture08 abap on line
 

Abap course chapter 4 database accesses

  • 1. ABAP Course Chapter 4 – Database accesses Lecturer: André Bögelsack, UCC Technische Universität München Author: Valentin Nicolescu, André Bögelsack ABAP Course André Bögelsack, Valentin Nicolescu 1
  • 2. Copyright 2008 UCC TU München All rights reserved  Weitergabe und Vervielfältigung dieser Publikation oder von Teilen daraus sind, zu welchem Zweck und in welcher Form auch immer, ohne die ausdrückliche schriftliche Genehmigung durch HCC TU München nicht gestattet. In dieser Publikation enthaltene Informationen können ohne vorherige Ankündigung geändert werden.  Microsoft®, WINDOWS®, NT®, EXCEL®, Word®, PowerPoint® und SQL Server® sind eingetragene Marken der Microsoft Corporation.  IBM®, DB2®, OS/2®, DB2/6000®, Parallel Sysplex®, MVS/ESA®, RS/6000®, AIX®, S/390®, AS/400®, OS/390® und OS/400® sind eingetragene Marken der IBM Corporation.  ORACLE® ist eine eingetragene Marke der ORACLE Corporation.  INFORMIX®-OnLine for SAP und Informix® Dynamic ServerTM sind eingetragene Marken der Informix Software Incorporated.  UNIX®, X/Open®, OSF/1® und Motif® sind eingetragene Marken der Open Group.  Citrix®, das Citrix-Logo, ICA®, Program Neighborhood®, MetaFrame®, WinFrame®, VideoFrame®, MultiWin® und andere hier erwähnte Namen von Citrix-Produkten sind Marken von Citrix Systems, Inc.  HTML, DHTML, XML, XHTML sind Marken oder eingetragene Marken des W3C®, World Wide Web Consortium, Massachusetts Institute of Technology.  JAVA® ist eine eingetragene Marke der Sun Microsystems, Inc.  JAVASCRIPT® ist eine eingetragene Marke der Sun Microsystems, Inc., verwendet unter der Lizenz der von Netscape entwickelten und implementierten Technologie.  SAP, SAP Logo, R/2, RIVA, R/3, SAP ArchiveLink, SAP Business Workflow, WebFlow, SAP EarlyWatch, BAPI, SAPPHIRE, Management Cockpit, mySAP, mySAP.com und weitere im Text erwähnte SAP-Produkte und -Dienstleistungen sowie die entsprechenden Logos sind Marken oder eingetragene Marken der SAP AG in Deutschland und anderen Ländern weltweit. MarketSet und Enterprise Buyer sind gemeinsame Marken von SAP Markets und Commerce One.  Alle anderen Namen von Produkten und Dienstleistungen sind Marken der jeweiligen Firmen.  Die Verwendung der Screenshots wurde mit dem jeweiligen Eigner abgesprochen. ABAP Course André Bögelsack, Valentin Nicolescu 2
  • 3. Agenda 1. Data dictionary 2. SAP flight example 3. Database operations in SAP 4. SAP OpenSQL 5. Types of database changes 6. Types of entry help ABAP Course André Bögelsack, Valentin Nicolescu 3
  • 4. Data dictionary • Data dictionary = global directory for data types • Assignment of help texts and explanations for data types in different languages • ERM can be shown as a figure automatically • Most important objects: structure, table, data element and domain ABAP Course André Bögelsack, Valentin Nicolescu 4
  • 5. Data dictionary Domain ZY_ID INT4 Data type Data element ZY_ID ZZ_ID Field ZY_ID ZZ_ID Structure Field Table Field Field ABAP Course André Bögelsack, Valentin Nicolescu 5
  • 6. Data dictionary • Menu path: Tools • ABAP Workbench • Development • Dictionary • TA SE11 • View, edit, delete, create tables, data types, domains definitions etc. • Tables and views from the ABAP dictionary represent tables and views from the database • User interface are generated automatically when changing views, tables etc. • Table may be changed after they are created without losing data • SAP tables may be extended by APPEND structures ABAP Course André Bögelsack, Valentin Nicolescu 6
  • 7. Data browser • Menu path: Tools • ABAP Workbench • Overview • Data Browser • TA SE16 • View table content • Add new entries to tables when adding is permitted for the table • Browse the entry help table content • Copy table content to transport request • Download table content ABAP Course André Bögelsack, Valentin Nicolescu 7
  • 8. Overview about all objects • Database table • View • Data type – Data element – Structure – Database table – Table types – Views – Class / interface • Type group • Domain • Search help • Lock object ABAP Course André Bögelsack, Valentin Nicolescu 8
  • 9. Visualization • Foreign key relationships can be visualized in data dictionary • Table SFLIGHT ABAP Course André Bögelsack, Valentin Nicolescu 9
  • 10. SAP flight example • Created and maintained by SAP to demonstrate database operations • Contains exercise data for airline, flight connection number, flight date, airfare etc. • Report for data generation: S_FLIGHT_MODEL_DATA_GENERATION • SAP trainings, examples from books build refer to the flight example ABAP Course André Bögelsack, Valentin Nicolescu 10
  • 11. SAP flight example – table structure Connection Flight Reservation Plane SPFLI SFLIGHT SBOOK SAPLANE MANDT MANDT MANDT MANDT CARRID CARRID CARRID PLANETYPE CONNID CONNID CONNID SEATSMAX AIRPFROM FLDATE FLDATE TANKCAP AIRPTO SEATSMAX BOOKID CAP_UNIT CITYFROM SEATSOCC CUSTOMID WEIGHT CITYTO PRICE LUGGWEIGH WIE_UNIT COUNTRYFR CURRENCY WUNIT OP_SPEED COUNTRYTO PLANETYPE CANCELLED SPEED_UNIT … … … … ABAP Course André Bögelsack, Valentin Nicolescu 11
  • 12. SAP OpenSQL • Independent from database Application Server Database Server ABAP-Interpreter DB-Interface SQL-Database Select * from OpenSQL Native SQL DB data DB data Exec SQL. Native SQL Select * from Data End Exec. DB data ABAP Course André Bögelsack, Valentin Nicolescu 12
  • 13. OpenSQL instructions • Select: – SELECT / SELECT SINGLE – * / field 1 ..field n / – FROM table / view – INTO structure / internal table – WHERE condition • Aggregation: – MAX, MIN, AVG – SUM, COUNT • Joins: – Left outer join – Inner join – View ABAP Course André Bögelsack, Valentin Nicolescu 13
  • 14. Procedure for database access General: • Be specific to decrease the load on the database • Access to database takes 10,000 time longer than access to buffers • Avoid table scans, use indexes Procedure: 1. Read database data into internal tables • Internal tables are tables for holding data during runtime 2. Change data per row • Use workareas to hold one row of the table and change data in the workarea 3. Write changes back to database ABAP Course André Bögelsack, Valentin Nicolescu 14
  • 15. Procedure for database access Internal tables and workareas: wa_spfli Workarea • Use the workarea to modify LH 0400 (one row) one data set it_spfli Internal table • Use the internal table to store AA 0017 (selected content) the selected database content temporarily LH 0400 • Internal tables are deleted after program is finished Database Database table • Use the database to read/write (whole content) data ABAP Course André Bögelsack, Valentin Nicolescu 15
  • 16. Types of database changes Modify instruction: MODIFY <dbtable> [CLIENT SPECIFIED] FROM <workarea>. MODIFY <dbtable> [CLIENT SPECIFIED] FROM TABLE <internaltable> • Modify = Update – the command updates the database table if the database table already contains dataset • Modify = Insert – the command inserts new datasets into the database table Delete instruction: DELETE FROM <dbtable> WHERE [SQL statement]. ABAP Course André Bögelsack, Valentin Nicolescu 16
  • 17. Entry help • Entry help uses a table in the background • Predefined entry help for a table ABAP Course André Bögelsack, Valentin Nicolescu 17