• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Lecture07 abap on line
 

Lecture07 abap on line

on

  • 874 views

 

Statistics

Views

Total Views
874
Views on SlideShare
874
Embed Views
0

Actions

Likes
2
Downloads
122
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Sample problem Go through example above explaining solution in terms of the relationship between the two tables.
  • Solution 1 - Nested Select Statement What if you wanted to print details of each flight (departure/destination)? >> a third select statement would be used using the carrid and connid number to look up another table storing dept & dest cities. Use of nested selects is complex and requires a good knowledge of the table structures involved as well as correct syntax involved with the “where” clause.
  • Solution 2 - Using a Logical Database Using a logical database is another method for reading data from a database table. A logical database is actually a separate program, usually written by SAP, that provides access to a group of related tables to an ABAP/4 program. The R/3 system contains about 150 logical databases covering most of the business processes (financials, purchasing, stock movements). When you run a program that calls a logical database , the program behind the logical database runs as well. The logical database issues the SELECT commands and returns the data to the calling program. Where is the logical database specified? >> In the program attributes screen. How does the program know what data to retrieve i.e. flights after 01/09/2006? >> Selection screen automatically appears. How do you know a program uses a logical database? >> If it contains the GET statement and NODE statement .
  • A logical database supplies your program with entries from tables. This means that you only need to program the data processing statements. Each logical database has a structure containing a hierarchy of those tables that can be read. You can attach exactly one logical database to each type 1 program. The logical database then supplies your program with entries from tables. This means that you only need to program the data processing statements.
  • Assigning a Logical Database All Logical Databases have a name which must be entered in the Logical database field of the attributes screen. Only one logical database can be used per program.
  • Selection screen of a Logical Database The logical database has its own selection screen with typical criteria from which the user can select. When the program is started, the system displays the selection screen defined by the logical database. Selections displayed depend on the NODES statement. The NODES statement determines how detailed the selection screen is : The selection screen that has been defined in the logical database should contain only those key information input fields that the program needs. The NODES statement allows you to ensure only information from relevant tables is available to the logical database. Once the user has input some selection criteria, the logical database can issue the appropriate SELECT command with the proper where clause to retrieve the data. What would happen if the user did not type in any input to the selection screen? >> Booking information would be displayed for all flights for all airlines.
  • Using the GET event GET isn’t a command like SELECT or WRITE. It’s an event. A code block associated with an event ends with the next event statement, such as another GET. Using events to access data in a logical database can be confusing at first, so a simple example will be used. A logical database is composed of several tables that form a hierarchy (as well as a program that accesses those tables). The logical database makes data from the hierarchy available to your ABAP program. Looking at the program from the traditional top-down approach, you would expect a list of all the rows from the spfli table followed by all the rows from the sflight table. But events don’t execute in a top-down fashion - they execute when appropriate. Each event is like a separated subroutine that’s executed when the systems detects a certain condition. REFER to NEXT Slide's NOTES
  • Using the GET event What would happen if I switched the 2 GET statements around? >> Nothing, because they are events, they would still be triggered in the order determined by the hierarchy of the tables in the logical database. What would happen if I deleted the GET spfli event? >> A list of flight dates without the corresponding flight details A simple GET statement may in fact access more than one table if the GET specifies a table at the bottom of the logical database hierarchy. The overhead of reading from all those tables isn’t obvious from looking at a single statement. A program using a SELECT statement may give you better performance.

Lecture07 abap on line Lecture07 abap on line Presentation Transcript

  • Lecture 7 Reporting – Logical Databases BCO5647 Applications Programming Techniques (ABAP)
  • Readings & Objectives
    • Readings
    • Matzke Chapter 3 Section 3.6
    • Objectives This lecture will
    • Introduce the concept of a Logical Database
    • Examine how Logical Databases can be optimally used
    • Describe how a Logical Database is incorporated into an ABAP program
    • Introduce the GET event statement and explain its use in relation to a Logical Database
    • Summarise the advantages of using Logical Databases
  • Sample Problem
    • Print a list of all customers who will depart after 01/09/2006.
    • Use the bookings table and the customer table.
  • Solution 1 - Nested Select Statement
    • report lec601.
    • tables : bookings , customer.
    • select * from bookings
    • where fldate > ‘20060901’.
    • select * from customer
    • where id = bookings-customid .
    • write: / customer-name ,
    • bookings-fldate.
    • endselect.
    • endselect.
  • Solution 2 - Using a Logical Database
    • report lec601.
    • nodes : customers, bookings.
    • get customers.
    • write: / customers-name.
    • get bookings.
    • write at /3 bookings-fldate.
  • Using a Logical Database
    • A logical database supplies your program with entries from tables. This means that you only need to program the data processing statements.
    • Each logical database has a structure containing a hierarchy of those tables that can be read.
  • What is a Logical Database?
    • Using a logical database is another method for reading data from a database table.
    • A logical database is actually a separate program , usually written by SAP, that provides access to a group of related tables .
    • The database access has been optimized using Open SQL.
    • The R/3 system contains about 150 logical databases covering most of the business processes.
    • When you run a program that uses a logical database , the program behind the logical database runs as well. The logical database displays an automatic selection screen for the user, i s sues the SELECT commands and returns the data to the calling program (your program) .
  • Assigning a Logical Database
    • The name of the logical database is an attribute of the program and must be set in the attributes screen .
  • Selection screen of a Logical Database
    • When you use a logical database in your program, a selection screen is called automatically, and the user can enter information to limit the data returned by the logical database.
    • Selections displayed depends on the nodes statement in the program.
  • Event Sequencing: Usi ng the GET event
    • An event is a keyword that defines a block of code to be executed when the system detects a certain occurrence.
    • The GET event is used in a program that uses a logical database.
    • The GET events in an ABAP program are processed in a tree like order to match the tree like order relationship of the tables in the logical database.
  • Using the GET event
    • The first data record from database table SPFLI is made available to your program. If your program has a GET spfli , the event block is processed.
    • The first data record from SFLIGHT that corresponds to the key of the current SPFLI record is made available to your program. If your program has a GET sflight , the event block is processed.
    • The next corresponding data record from database table SFLIGHT is made available to your program and the event block is processed again.
    • GET sf l ight : is called again until no further corresponding data records are found.
    • The logical database makes the next corresponding data record from SPFLI available to your program etc.
    • ...
  • Advantages of Logical Databases
    • Logical Databases simplify the creation of reports where access to data from multiple tables is required.
    • A selection screen with appropriate selection criteria is automatically created. You don’t have to define this in your program.
    • Logical Databases can be used in more than one program. Improvements to the database access methods of the logical database immediately improve the performance of all programs using it.