Thursday 21 March 2013

ABAP Runtime Environment



Before reading this I suggest you to first go through the Working @ Application Server to have a better understanding.

 

A brief Introduction to SAP Basis

Basis is a middleware between the ABAP programs and the operating system. The ABAP language environment is a part of SAP Basis. All the functionalities like Syntax checking, code generation, loading, interpreting and buffering ABAP programs I/p & O/p and the ABAP runtime environment are a part of SAP Basis. Basis converts your ABAP programs into OS understandable code.
 Basis provides a layer of abstraction between, the operating system, the business applications (ABAP Programs) and the database. This ensures that applications do not depend directly upon a specific server or database platform and can easily be ported from one platform to another. That means the ABAP applications are platform and database independent, i.e. even if you change your database (RDBMS) you don’t need to make any changes in your program. Same is with your OS. Basis enables you to run your business application in any OS without making any OS specific changes.

 

ABAP Runtime Environment

Unlike the programming languages like java, C/C++, DOT NET in which the programs are stored as separate files; ABAP programs are stored in SAP DB.  The ABAP code is stored in two forms: - Source Code and Generated code. Source code is the one which we can edit and view through the ABAP workbench and generated code is the binary representation of the Source code.  Once you have created a program and then when you activate the changes, both the generated code and source code are stored in DB.
When a program is run from the frontend, it first checks the program buffer to see whether it is there.  If not, then it makes a db call to retrieve the program and store it in the program buffer.  (You should aim for > 90% hit rate on the program buffer for performance reasons.)  . The processing of ABAP statements, response to the event (Keystrokes press, user clicks etc), controlling the flow logic of program is carried out by the runtime system which is provided by SAP Kernel.  A key component of the ABAP runtime system is the Database Interface, which turns database-independent ABAP statements ("Open SQL") into statements understood by the underlying DBMS ("Native SQL"). The database interface handles all the communication with the relational database on behalf of ABAP programs; it also contains extra features such as buffering of tables and frequently accessed data in the local memory of the application server.


Why are ABAP programs Stored in Database?

SAP programs are OS and DB independent with a layer between the SAP environment and the OS/DB - basically the kernel.  Plus each program can and does call many other standard functions (code).  Also each program is considered as an object to DB which usually refers to other objects stored in DB. Accessing the 100,000 plus programs from the OS would also be slow and inefficient.  Putting this in the db helps here.  Plus programs are only compiled when if required or requested through SGEN transaction, so potentially saving db space.

How an ABAP program runs?


  • The user starts a sample program where a Customer ID can be entered on the initial selection screen. This program subsequently uses the information input on the selection screen to retrieve the 'Bill Date' and the 'Total Billed Amount' from the database and display them for the user on a screen.
  • When the user starts the program, the program context is loaded on the application server. The program context contains memory areas for variables and complex data objects, information on the screens for user dialogs and ABAP processing blocks. The run-time system gets the program information from the Repository, which is a special part of the database. Here,the sample program contains three processing blocks, a selection screen as the user dialog to get the input from user, a variable to hold the user input and two structures as data objects to hold the values retrieved from database, and a screen to display the output result.
  • Since the program contains a selection screen, the ABAP runtime system sends it to the presentation server at the beginning of program processing. The presentation server displays the selection screen to the user and controls the program flow for as long as the user fills in the required input fields.
  • As soon as the user has finished entering data on the selection screen, he or she can trigger further processing by choosing 'Execute' or by pressing enter key. All data input on the selection screen is then automatically placed in its corresponding data object in the program and the ABAP runtime system resumes control of processing. The runtime system then triggers sequential processing of the ABAP processing block that comes after the selection screen.
  • The ABAP processing block contains a read access to the database that has been programmed into it.The program also passes the database information about which database table to access and which line in the table to read.
  • The database returns the requested data record to the program and the runtime system ensures that this data is stored in the appropriate data objects. Normally a structure is the target field when a single record is accessed. The structure contains variables for all fields requested from the database.
  • The ABAP processing block now triggers screen processing. This is often expressed simply by saying 'The program calls the screen'. However, in reality, each screen possesses its own processing block that is sequentially processed before the runtime system sends the screen to the presentation server (Process Before Output). This allows screens to be used in a very flexible manner.
  • After the screen's processing block has been processed, the ABAP runtime system sends the screen to the presentation server. During this process, data is transported into the screen's fields from a structure that serves as an interface for the screen.
  • Once the user performs a user action (choosing Enter, a function key, a menu function or a pushbutton, for example), control is handed over to the runtime system on the application server again. The screen fields are transported into the structure that serves as the screen's interface and a special processing block belonging to the screen is triggered. This processing block is always processed immediately following a user action (Process After Input).
  • After the 'Process After Input' processing block has been processed, the sample program continues processing the ABAP processing block that called the screen in the first place.


1 comment: