Monday 22 July 2013

SAP/ABAP - ARCHITECTURE



                                                   SAP R/3 ARCHITECTURE

Basic Terms

Server 

Common definition  
      A Person or thing  that provides service or commodity is called a  Server.
Technical definition 
 A server is a a software program, or the computer , that provides a specific kind of service to client software running on the same computer or other computers on a network.
 (OR)
A server is a computer designed to process requests and deliver data to other (client) computers over a local network or the Internet.
Types of Servers
 
a)      Web servers    b)   proxy servers  c)  FTP servers   d)  online game servers

Client-Server Architecture 

        In a Client/server architecture individual computers (known as clients) are connected to a central computer which is known as  server.
Example
 
Lets take an example of a file server to understand the core process of a client/server network, the file server acts as a storage space on the network for the files, spreadsheets, databases, etc. Instead of storing these records on every individual computer, the file server allows the clients to store their files on one central computer and make them sharable.
The client-server architecture is beneficial in reducing the multiple iterations of a single file and allowing the organization to have one centralized point for every computer to access the same file.
Real Time Example
The interaction between a lamp and an electrical socket can be considered as a interaction between client and server is just like. In the example the electrical socket is just like a server and the lamp works like a client

SAP Client Server Architecture 
SAP R/1:  is 1-tier architecture.  In which all 3 layers [Presentation + Application + Database] are installed in one systems/server.
( Server One -  Presentation + Application + Database )
 SAP R/2:  is 2-tier architecture.  In which all 3 layers [Presentation + Application + Database] are installed in two separate  systems/server.
( Server One - Presentation , Server Two - Application +Database) 
SAP R/3:  is 3-tier architecture.  In which all 3 layers [Presentation + Application + Database] are installed in three separate systems/server.
(server One -Presentation, server Two - Application, Server Three - Database)
SAP R/3 –INTRODUCTION



SAP R/3 is a 3 Tier Real time data processing system developed by SAP AG a German software company in 1992.

The R/3 system,which is also known as ERP(Enterprise Resource Planning) System is the integrated software solution designed by SAP.

Its purpose is to provides a suite of tightly integrated business applications designed to handle the entire data processing for many different types and sizes of organizations.

This version is compatible with various platforms and Operating systems such as Unix,Windows etc.

SAP R/3 is arranged into distinct functional modules covering every aspect of business

They are
  •  Financial Accounting
  •   Production Planning
  •   Materials Management
  •   Sales and Distribution
  •  Controlling
  •   Assets management
  •   Human Resources
  •   Project System
  •   Industry Solutions
  •   Plant Maintenance
  •   Quality Management
  •  Workflow
Within R/3,there is a run time environment and a set of application programs written in
ABAP/4 programming language,which are highly scalable and customizable.

SAP R/3 Architecture

SAP R/3 was based on 3 tier Client-Server Architecture.In which all 3 layers are installed in three separate systems/server.
Its three layers are given by
  • 1.     Presentation Layer.
  • 2.     Application Layer
  • 3.     Database Layer.
                                                      Diagrammatic Representation:


Simple Pictorial Representation


Presentation Layer


                        This is the software component for graphic al user  interface.  It is called SAP GUI and is the interface between an SAP system and the user. 

The interface accepts input from the user in the form of  mouse-clicks, and function keys, and sends these requests to the application server to be processed. The application server sends the results back to the SAP GUI which then formats the output for display to the user.
Application layer
                                      Application Layer is a platform where all SAP programs run.It  executes the application logic in the SAP R/3 architecture.

This layer consists of one or more Application servers and Message servers.                          

Function of Application Server
           
                      Application servers are used to send user requests from the Presentation server to the Database server and retrieve information from the Database server as a response to these requests.
            Application servers are connected to Database servers with the help of the local area network. An Application server provides a set of services, such as processing the flow logic of screens and updating data in the database of the SAP R/3 system.

            However, a single Application server cannot handle the entire workload of the business logic on its own. Therefore, the workload is distributed among multiple Application servers. 
Message Server
The Message server component of the Application layer (shown in Figure 1.2) is responsible for communicating between the Application servers. This component also contains information about Application servers and the distribution of load among these servers.
 It uses this information to select an appropriate server when a user sends a request for processing. 

Database Layer

                 The database layer consists of the database system - the database and DBMS (Data Base Management System).  The database in the SAP R/3 system stores the entire information of the system except the master and transaction data.

Apart from this , all ABAP workbench development objects  such as  Dictionary objects (tables, data elements, domains), and also all ABAP programs, menus and screens, are stored in a special section of the database, known as Repository, also known as Repository Objects.

Function Of Database Layer
              The database server accept database requests from the application server. These requests are passed on to the RDBMS (Relation Database Management System). The RDBMS sends the data back to the database server, which then passes the information back to the application server. The application server in turn passes that information to your ABAP/4 program.

SAP R/3 Landscape
Landscape is architecture of servers.There are three different landscapes for SAP. They are
  •       Development
  •       Quality
  •      Production
Development 
In Development server,a technical/functional person creates the programs or configure the system as per the company’s requirement and sends it to the quality server.
Quality
In this server, team members test the development/configuration with various parameters and then send it to the production server.
Production
Through this server the software is finally distributed to the clients.



The components of Application server are given by 
  •    Dispatcher
  •    Work processes
  •   Gateway
  •   Share Memory
Dispatcher
                    All requests that come from presentation servers are directed first to the Dispatcher.
The Dispatcher writes them first to the dispatcher queue.The Dispatcher pulls the requests from the queue on a  first-in, first-out basis. Each request is then allocated to the first available work processes.
It serves as a link between Work processes and the user logged in. It distributes requests to the work processes.

Work Processes

                     This is the area in which actual work is done. It executes the individual dialog steps of an application program.

Dialog Step 

                A dialog step is the processing used to navigate from one screen to another screen.
 It includes the processing that takes place after the user issues a request. It also involves the processing needed to display the next screen. 


Example on One Dialog Step               


There are two software processors and a database interface in every work process. The 
structure of a work process includes the following:
  •   Task Handler
  •  Screen processor
  •   ABAP processor / ABAP/4 Interpreter
  •  Database interface
Task Handler
The activities within a work process are coordinated by the task handler.
The task handler takes care of the following:
1. The loading and unloading of the user session context at the beginning and end of each dialog step.
 2. Communicates with the dispatcher and activates the Dynpro interpreter or the ABAP processor as required to perform its tasks.
Screen Processor
                        Screen flow logic is executed by the screen processor through the dispatcher. The dispatcher makes communication possible between the SAP GUI calling modules and work processes. Thus field contents are transferred from the screen to the flow logic. The screen processor passes the screen flow logic module to be processed by the ABAP processor.
ABAP processor
                          The ABAP processor helps in the execution of the processing logic of an application program and establishes communication with the database interface. It receives the module of screen flow logic from the screen processor that is to be processed.
Database interface
                  This interface is used to establish and terminate the connection between the work process and the database. It is also used to access the ABAP dictionary, programs, screens, and database tables. It handles the commit and rollback transactions as well.

Types of Work Processes
The various type of work processes are as follows
1.Dialog work process
                 This process deals with active user requests for executing dialog steps.
These processes deal with only one request at a time. minimum of 2 dialog work processes required per dispatcher that need to be configured per instance. 
2.Update work process
              This process helps in executing database update requests. Minimum 1 update process is required , and more than 1 process per dispatcher is allowed. 
These requests are part of a logical unit of work (LUW).
Detail Explanation
There are two types of update processes.

1. V1 Update process- This process handles the most critical updates.
2. V2 update process-  this process handles the non-critical updates.

This distinction allows the system to process critical database changes before less critical changes.
  • V1 modules describe critical or primary changes; these affect objects that have a controlling function in the SAP System, for example order creation or changes to material stock.
  • V2 modules describe less critical secondary changes. These are pure statistical updates, for example, such as result calculations.
The V1 modules are processed consecutively in a single update work process on the same application server. This means that they belong to the same database LUW and can be reversed. Furthermore, V1 updates are carried out under the SAP locks of the transaction that creates the update This ensures that the data remains consistent; simultaneous changes to the objects to be updated are not possible.

All V2 updates are carried out in a separate LUW and not under the locks of the transaction that creates them. If your SAP System contains a work process for V2 updates, these are only carried out in this work process. If this is not the case, the V2 components are processed by a V1 update process.

All V1 modules of an update must be processed before the V2 modules.

3.Background work process
         Used for processing background jobs.  Background work processes help in processing programs that can be executed without the involvement of a user.
At least two background work processes for each SAP system are required.
4.ENQUEUE work process
                  This process deals with the lock mechanism 
          Only 1 enqueue process exists in each SAP system. This process ensures that updates are serialized with the help of a lock table.
              An appropriate lock mechanism must be provided to prevent the applications from interfering with each other when accessing data.  In a distributed R/3 System, an enqueue server assumes this task. The enqueue server uses a lock table to manage the locks( enqueues) . When a lock request is made, the system makes sure  the requested enqueues do not collide with existing entries in the lock table.

5.Spool work process
                 These work processes send dataset to a printer in regular sessions. Online or background processing is also generated by spool work processes. There is only one spool request for each spool work process.
 Minimum 1 spool process is required and more than 1 process per dispatcher is allowed
Gateway
           Enables communication between SAP systems(through TCP-IP)  as well as with external applications(through CPI-C protocol) 
    Acts as an interface for R/3 communication protocols,such as a Remote Function Call(RFC).
RFC is the standard SAP interface used to communicate between SAP systems.
Shared Memory
                                Represents the common memory area in an Application server.All Work processes running in an application server use shared memory. This memory is used to save the contexts(data related to the current state of a running program) or buffer data.Shared memory is also used to store various types of resources that a work process uses such as programs and table content.
User Context And Roll Area
                          To perform any processing for a user's request, a work process needs to address two special memory areas: the user context and the program roll area. The user context is a memory area that contains information about the user, and the roll area is a memory area that contains information about the programs execution.
User Context
A user context is defined as a temporary memory area that contains information about the user.
When a user logs on, a user context is allocated for that log-on. When the user logs off, the memory area assigned to that individual is released.
The user context contains the following information about the user:
  •         Current settings of the user
  •        User's authorizations
  •      Names of the programs the user is currently running
Roll Area
A roll area is a memory area that is allocated by work processes for program instances.
Each time a user starts a program, a roll area is created for that instance of the program. If two users run the same program at the same time, then two roll areas will be created, one for each user. The memory in the roll area becomes free when the program ends its execution. It contains the following information about the program's execution:
  •         Dynamic memory allocations
  •         Variables' values
  •         Current pointer of the program
Roll in And Roll out
An ABAP/4 program only occupies a work process for one dialog step.
At the beginning of the dialog step, the roll area and user context are rolled in to the work process. At the end of the dialog step, they are rolled out.
  •       Roll-in :Copies user context from the roll buffer (in shared memory) to the roll local memory
  •       Roll-out—Copies user context from the roll local memory to the roll buffer

Roll-in and Roll-out Scenario

When a user login to a system the user context data has been  collected from the data base to Roll Buffer, Roll File.

When user execute any transaction the user data are loaded  to the work process roll memory from the roll buffer/file. this is known as Roll-in. and 

After the completion of one dialog LUW the roll data
  rolled out to the roll buffer. this is known Roll-out.

This method is used for the dialog multiplexing, means the
 dialog WP make free to accept any other dialog request. 

SAP memory Vs ABAP memory
SAP Memory
SAP memory is a memory area to which all main sessions within a SAP gui have access. You can use SAP memory either to pass data from one program to another within a session, or to pass data from one session to another.

GET PARAMETER in ABAP programming is used for reading the data objects in SAP memory. Before accessing, the objects should be created in SAP memory using SET PARAMETER. These data objects in SAP memory is known as SPA/GPA parameters ( also known as SET/GET parameters) .

Example 

1   SET PARAMETER ID <pid> FIELD <f>.
2  GET PARAMETER ID <pid> FIELD <f>.
ABAP Memory
ABAP memory is a memory area that all ABAP programs within the same internal session can access using the EXPORT and IMPORT statements. Data within this area remains intact during a whole sequence of program calls.

EXPORT statement is used for writing the data objects in ABAP memory from our ABAP programs.
IMPORT statement is used for reading the data objects stored in ABAP memory from our ABAP program.

Example

1     EXPORT LV_BANFN FROM MEMORY ID 'MEM1'.
2     IMPORT LV_BANFN FROM MEMORY ID 'MEM1'.

Difference between Internal and External Session

External session: - when user logs on to R/3 system, the system Creates a new terminal session called external session. E.g. System Session.

Internal session: - created by calling a transaction (with CALL TRANSACTION), a dialog module (with CALL DIALOG) or a report (with SUBMIT or RETURN). 

In general each user can open up to six R/3 windows in a single SAP GUI session. Each of these windows corresponds to a session on the application server with its own area of shared memory.

                                                ABAP Workbench
The ABAP Workbench is the central part of SAP ERP system business applications.
It is a graphical programming environment in the SAP R/3 system to develop different applications by using the ABAP language.
It provide a set of tools and libraries to design,implement,test and maintain the transactions and reports written in the ABAP language.
ABAP Workbench Tools
The main tools and utilities used to perform development-related tasks are as follows:
·        ABAP Editor: writes and maintains ABAP programs, edit screens, functional modules, and screens
·        ABAP Dictionary: records and processes all objects, such as tables, their definitions, and relationships among them
·        Screen Painter: designs and maintains the GUI screen for a client-server environment
·        Class Builder: displays and processes ABAP object classes
·        Menu Painter: designs the user interface elements, such as the menu bar, standard toolbar, application toolbar, and function key assignment
·        Function Builder: defines, maintains, and processes the ABAP functional modules
Internet Transaction Server(ITS)
ITS stands for Internet Transaction Server. ITS is the essential link between the SAP R/3 system and the Internet. It enables Internet (and Intranet) users to communicate directly between R/3 systems.
It changes the data on the screen of the SAP ERP system into HTML format, and vice-verse. It is very helpful for developing and testing full-fledged web transactions. All components of the transaction can be stored in the SAP ERP system, including those used at run time.
 ITS supports automatic processing of language and converts it into an HTML-dependent language at run time. As of ERP 6.0, the ITS instances are integrated in the SAP ERP basis system.
Logical Unit of Work(LUW)
LUW Concept means a group of related data either updated entirely or not at all. LUW's help to guarantee database integrity.
 When an LUW has been successfully concluded, the database is once again in a correct state. If, however, an error occurs within an LUW, all database changes made since the beginning of the LUW are canceled and the database is then in the same state as before the LUW started. 
There are two types of LUW.They are
1.Database LUW
 
A database LUW is the mechanism used by the database to ensure that its data is always consistent. The database LUW is either fully executed by the database system or not at all.
Once a database LUW has been successfully executed, the database will be in a consistent state. If an error occurs within a database LUW, all of the database changes since the beginning of the database LUW are reversed. This leaves the database in the state it had before the transaction started.

2. SAP LUW

A logical unit consisting of dialog steps, whose changes are written to the database in a single database LUW is called an SAP LUW. Unlike a database LUW, an SAP LUW can span several dialog steps, and be executed using a series of different work processes



Step 1) Once user click on the SAP system from GUI , User request is forwarded to Dispatcher .

Step 2) Request is stored in Request queues first. Dispatcher follows First in First out rule .It will find free work process and if available will be assigned.

Step 3) As per user request , particular work process is assigned to user.For example , when user login to the system then Dialog work process is assigned to the user.If user runs a report in background then background work process is assigned to the user.When some modifications are done at database level then update work process is assigned.So as per user’s action work process is assigned.

Step 4) Once user is assigned the dialog work process then user authorizations, user’s current setting are rolled in to work-process in shared memory to access user’s data.Once dialog step is executed then user’s data is rolled out from work process. Thus shared memory will be cleaned and other user’s data can be saved in shared memory area. Dialog step means the screen movements. In a transaction, when a users jumps from one screen to other the process is called a dialog step.

Step 5) First work process will find the data in the buffer. If it finds data in buffer then there is no need to retrieve data from database. Thus response time is improved and this process is called hit.If it does not find the data in buffer then it will find the data in database and this process is called miss. Hit ratio should be always higher than miss ratio. It improves the performance of system .

Step 6) Other requested data is queried from the database and once the process is complete,the result is sent back to GUI via dispatcher.

Step 7) At the end user’s data is removed from shared memory so the memory will be available to other users.This process is called roll-out.