Video Lesson 7.1: ABAP Subroutines and procedures

Learn ABAP

Video Lesson 7.1: ABAP Subroutines and procedures

In this lesson you will learn why subroutines make sense and how you can use them in your ABAP programs. Furthermore, you will learn how the interface of a subroutine is used to pass parameters and how the different transfer types are used. This is only a brief introduction to the tools.

Using Subroutines

  • A subroutine is a modularization unit within the program where a function is encapsulated in the form of source code.
  • You page out a part of a program to a subroutine to get a better overview of the main program and to use the corresponding sequence of statements several times.
  • Using subroutines makes your program more function-oriented: it splits the program's task into subfunctions, so that each subroutine is responsible for one subfunction.
  • Using subroutines also means that your program becomes easier to maintain as changes to functions often only have to be implemented in the subroutine.->

 




Video Lesson 6.2: SAP Code Inspector

Learn ABAP

Video Lesson 6.2: SAP Code Inspector

In this lesson, you will learn about the basic functions and the purpose of the program analysis tool Code Inspector.

The Code Inspector offers you the option of analyzing your programs with regard to performance, security, and typical semantic errors.

Are SELECT statements embedded in loops?

  • Security
    Is data read from a client other than the login client?

Is the database table or the WHERE clause dynamically specified in the SELECT statement?

  • Typical semantic errors
    Is the sy-subrc field checked after each AUTHORITY-CHECK statement?

Is a client actually specified for CLIENT SPECIFIED?

Are several messages of type E (E messages) sent in direct succession?

  • As the result of an inspection you receive a list of error and warning messages.
  • The i button that belongs to the message shows a detailed error description as well as improvement suggestions.
  • Double-click on the error text to branch to the corresponding program statement.->




Video Lesson 6.1 : SAP Runtime Analysis Tool

Learn ABAP

Video Lesson 6.1 : SAP Runtime Analysis Tool

In this lesson you will learn about the basic functions and the purpose of the program analysis tool Runtime Analysis. This is a brief introduction of the tool.

  • The runtime analysis tool makes it possible to take detailed measurements of the runtime requirements of your programs.
  • You can use it to localize low performance source code blocks in your programs and tune them if necessary.
  • However, always note that the measurement results depend on the current system and network load as well as the current table buffer and dataset.
  • You can measure not only programs, but also transactions and function modules with regard to their runtime.
  • Hint: It is advisable to create your own measurement variant with the setting “Aggregation: None” and to use this for the measurement since a detailed analysis of the measurement results is only possible with this.
  • Execute is used to start the runtime analysis.
  • The generated measurement results are stored in a measurement-related file.




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.