Video Lesson 5.9: ABAP Exercise – SFO Airport Flight Schedule

Learn ABAP

You will be creating a program that schedules flights to San Francisco Airport.

  • The San Francisco Airport implemented SAP and hired you to build a program to display the flight schedule of the airport. The program is going to be used by the different airlines working at the airport. They are not allowed to see other airlines flight schedule. You are ask to start with the AA airline. The front-desk workers will enter an airline and a flight number into the system, and the system will have to display all flight dates available with the available number of seats in first and business class.
  • The information is stored in the SFLIGHT, SPFLI and SCARR database tables.

Solution




Video Lesson 5.8: Authorization Check

Learn ABAP

Video Lesson 5.8: Authorization Check

This lesson explains what are authorization checks in SAP and how they can be used to create different roles and profiles for users.

  • You will learn why an authorization check is useful and how to include it in your programs.
  • You will learn to create authorization objects and assign them to roles.

Authorization Checks

  • Critical data and parts of the functional scope of the SAP System must be protected from unauthorized access.
  • You have to implement authorization checks in your program so that the user may only access areas for which he or she is authorized.
  • Authorization objects can be defined within object classes.
  • You create an actual authorization by subsequently assigning values to these fields.
  • This authorization can be integrated into the required user master records by means of an authorization profile.
  • At runtime, you can use the AUTHORITY-CHECK statement to check whether the actual user has the authorization required for executing the function in his or her user master record.




Video Lesson 5.7: For All Entries in ABAP

Learn ABAP

Video Lesson 5.7: For All Entries in ABAP

This lesson will teach you about the FOR ALL ENTRIES ABAP statement that is used to extract information from one table using the information of another table.

1. Duplicate rows are automatically removed

2. If the internal table used in the clause is empty , all the rows in
the source table will be selected . In that case, always check if it is not empty before executing the statement.

3. The fields use in the FOR ALL ENTRIES must match the types of the fields of the database tables.

Video Lesson 5.6: Create a VIEW in ABAP

Learn ABAP

Video Lesson 5.6: Create a VIEW in ABAP

This lesson will show you how to create a VIEW in the ABAP dictionary. VIEWS are used to join 2 or more tables and store that JOIN in the ABAP dictionary to use in other programs without having to perform JOIN through code.

Database View

Database views are implement an inner join, that is, only records of the primary table (selected via the join operation) for which the corresponding records of the secondary tables also exist are fetched. Inconsistencies between primary and secondary table could, therefore, lead to a reduced selection set.

In database views, the join conditions can be formulated using equality relationships between any base fields. In the other types of view, they must be taken from existing foreign keys. That is, tables can only be collected in a maintenance or help view if they are linked to one another via foreign keys.




Video Lesson 5.5: Open SQL ABAP JOIN Statement

Learn ABAP

Video Lesson 5.5: Open SQL ABAP JOIN Statement

Reading Data from Different Tables (JOIN)

There is often a requirement to read data from different tables and display it.

There are four types of reuse components that select data:

  • Logical databases (= data retrieval programs that read data from tables that belong together hierarchically)
  • Function modules (= subroutines stored in the function library of the SAP system with encapsulated functions, such as reading from hierarchically related tables)
  • BAPIs (= Methods of Business Objects with read function, for example)
  • Methods of global classes

 

  • If there are no useable reuse components available for your data selection, you have to implement the read access yourself. using a table join.
  • Let's read and output SPFLI records as an example
  • for each record, the long name of the respective airline, which is stored in SCARR, is to be output as well.
  • you can select all the required data using the SELECT statement.


Video Lesson 5.4: Create an Index in SAP

Learn ABAP

Video Lesson 5.4: Create an Index in SAP

This lesson will show you how to create an index for your database tables. Indexes speed up performance.

Speed up Access: Create an Index

  • If a database table is frequently accessed using a certain selection, you should define a secondary index for the fields contained in the selection in order to speed up corresponding accesses.
  • This happens in the display mode of the relevant transparent table in the ABAP Dictionary using the Indexes pushbutton.
  • When you activate the index, a secondary index is created in the database.
  • After an index has been created and activated, the Database Optimizer automatically uses this index when the program is executed if the index can contribute to speeding up the respective selection.
  • You do not have to specify the index manually in the SELECT statement.
  • The primary index consists of all key fields of the database table and is created automatically. ->

 




Video Lesson 5.3: ABAP Internal Tables And Work Areas

Learn ABAP

Video Lesson 5.3: ABAP Internal Tables And Work Areas

This lesson will teach you about ABAP internal tables and work areas. Internal tables can be represented as arrays of information with a determined structure.

  • Internal table is a temporary two dimensional memory structure similar to database table.
  • The data is stored line by line in memory, and each line has the same structure.
  • In ABAP, internal tables fulfill the function of arrays.
  • Since they are dynamic data objects, they save the programmer the task of dynamic memory management in his or her programs.
  • A particularly important use for internal tables is for storing and formatting data from a database table within a program.
  • Internal tables are dynamic variable  data objects.
  • Like all other data objects, you can declare internal tables using the LIKE or TYPE addition of the DATA statement.
  • DATA itab TYPE TABLE OF type|LIKE TABLE OF obj
  • Here, the LIKE addition refers to an existing table object in the same program.


Video Lesson 5.2: SAP Data Retrieval Using A Select Loop

Learn ABAP

Video Lesson 5.2: SAP Data Retrieval Using A Select Loop

This lesson shows how to use the ABAP statement SELECT-ENDSELECT to create a loop and retrieve multiple entries from a transparent table.

  • You can use the SELECT loop to read several rows of a database table into the program in succession.
  • The database delivers the data to the database interface of the application server in packages.
  • The specified processing block then copies the records to the target area row-by-row for processing.
  • The return value should be queried after the SELECT loop (that is, after the ENDSELECT statement).
  • You can use the INTO TABLE addition to copy the selected part of the database into an internal table directly instead of doing so row-by-row.
  • This technique is called an array fetch.
  • Since an Array Fetch is not a type of loop processing, no ENDSELECT statement is required or allowed.
  • The Array Fetch must be structured left-justified just like the field list.
  • If an internal table does not meet this prerequisite, you have to use the INTO CORRESPONDING FIELDS OF TABLE addition instead of INTO TABLE.
  • With the array fetch, the content that might be in the internal table is overwritten.
  • If you want to append rows instead, you can use the APPENDING TABLE addition.




Video Lesson 5.1: Read SAP Database Tables

Learn ABAP

Video Lesson 5.1: Read SAP Database Tables

In this lesson you will learn how to retrieve information on database tables and how to read data from them. An overview of techniques that allow you to access multiple database tables will also be covered.

  • SQL is the abbreviation of Structured Query Language, a language that enables define, change, and read access to database tables.
  • Every relational database system has a native SQL, which is unfortunately database-specific.
  • In contrast Open SQL is an SAP-defined, database-independent SQL standard for the ABAP language.

You use the Open SQL statement SELECT to program database read access.

The SELECT statement contains a series of clauses, each of which has a different task:

  • Amongst other things, the SELECT clause describes which fields of the table are to be read.
  • The FROM clause names the source (database table or view) from which the data is to be selected.
  • The INTO clause determines the target variable into which the selected data is to be placed.
  • The WHERE clause specifies the columns of the table that are to be selected.

For information about other clauses, refer to the keyword documentation for the SELECT statement.