Updated ABAP Material Document

download Updated ABAP Material Document

of 213

Transcript of Updated ABAP Material Document

  • 7/30/2019 Updated ABAP Material Document

    1/213

    SAP ABAP

    MATERIAL

    Bangalore 1

  • 7/30/2019 Updated ABAP Material Document

    2/213

    Introduction to ERP (Enterprise resource planning)

    There are many different systems in a large company's including planning,manufacturing, distribution, shipping, and accounting.

    Enterprise resource planning (ERP) is a system that integrates all of these functions into a

    single system, designed to serve the needs of each different department within the

    enterprise. ERP is more of a methodology than a piece of software, although it doesincorporate several software applications, brought together under a single, integrated

    interface.

    Enterprise resource planning (ERP) systems integrate primary business applications; all

    the applications in an ERP suite share a common set of data that is stored in a centraldatabase. A typical ERP system provides applications for accounting and controlling,

    production and materials management, quality management, plant maintenance, sales and

    distribution, human resources, and project management.

    Why should you be interested? Because, basically, a well-implemented and appropriateERP system can create significant efficiencies across your business, resulting in timely

    business information, better customer relationships, a more cost-effective supply chain,

    improved internal process and, ultimately, increased profitability.

    The ERP system goes far beyond being just a simple piece of software. Each

    implementation is unique and is designed to correspond to the implementer's variousbusiness processes. Regardless of how a company approaches it, ERP is sure to bring

    significant changes to how a company does business. An ERP implementation can costmillions of dollars to create, and may take several years to complete.

    Once implemented however, the ERP system brings tremendous advantages. Because all

    systems are joined together, all departments can more easily share information. The

    workflow that takes place between departments can become much more automated, and

    Bangalore 2

  • 7/30/2019 Updated ABAP Material Document

    3/213

    ultimately, customers are better served because the individual using the customer-facing

    applications will have access to every bit of information regarding each relevant process.For example, someone in sales would easily be able to log into a single system to

    determine the status of a customer order that is still in manufacturing. All this comes at acost though; training costs are high because employees must not only learn how to use

    new software, they must also learn new processes.

    ERP Improves Productivity

    Before ERP systems, each department in an organization would most likely have theirown computer system, data and database. Unfortunately, many of these systems would

    not be able to communicate with one another or need to store or rewrite data to make itpossible for cross computer system communication. For instance, the financials of acompany were on a separate computer system than the HR system, making it more

    intensive and complicated to process certain functions.

    Once an ERP system is in place, usually all aspects of an organization can work in

    harmony instead of every single system needing to be compatible with each other. Forlarge organizations, increased productivity and less types of software are a result.

    Implementing Enterprise Resource Planning

    ERP software is complex and expensive. Companies must devote significant humanresources to ERP projects and often hire consultants or systems integrators to helpimplement the systems. As a result, the company can spend millions of dollars and

    several years on ERP projects. This report outlines the challenges companies should

    expect for ERP implementation and outlines the six main steps of an ERP project:

    Vendor Selection Business Strategy Formation

    Application Configuration

    Testing and End-user Acceptance Training

    Rollout

    Benefits of implementing ERP systems:

    Inventory Reduction Improved Cash Management Increased Revenue and Profits

    Reduced Transportation and Logistics Costs

    Bangalore 3

  • 7/30/2019 Updated ABAP Material Document

    4/213

    Reduced Information Technology (IT) Costs

    Intangible benefits include unanticipated cost reductions, improved responsiveness to

    customers, more flexibility, and more effective management of the supply chain.

    Advantages of ERP Systems

    There are many advantages of implementing an EPR system; here are a few of them:

    A totally integrated system

    The ability to streamline different processes and workflows

    The ability to easily share data across various departments in an organization Improved efficiency and productivity levels

    Better tracking and forecasting

    Lower costs Improved customer service

    Disadvantages of ERP Systems

    While advantages usually outweigh disadvantages for most organizations implementing

    an ERP system, here are some of the most common obstacles experienced:

    Usually many obstacles can be prevented if adequate investment is made and adequatetraining is involved, however, success does depend on skills and the experience of the

    workforce to quickly adapt to the new system.

    Customization in many situations is limited

    The need to reengineer business processes ERP systems can be cost prohibitive to install and run

    Technical support can be shoddy

    ERP's may be too rigid for specific organizations that are either new or want tomove in a new direction in the near future.

    ERP software packages Available in the Market

    Baan from Infor Global Solutions: The Baan Corporation provides the financial and

    administrative consulting services.

    JD Edwards Enterprise One & JD Edwards World from Oracle: JD Edward is intoaccounting business software development and an ERP system JDE comprises 3 basic

    areas of expertise, functional-business, and programmer-developer and technical-CNC-

    system administration.

    Bangalore 4

    http://en.wikipedia.org/wiki/Baanhttp://en.wikipedia.org/wiki/Infor_Global_Solutionshttp://en.wikipedia.org/wiki/JD_Edwards_EnterpriseOnehttp://en.wikipedia.org/wiki/Oracle_Corporationhttp://en.wikipedia.org/wiki/Baanhttp://en.wikipedia.org/wiki/Infor_Global_Solutionshttp://en.wikipedia.org/wiki/JD_Edwards_EnterpriseOnehttp://en.wikipedia.org/wiki/Oracle_Corporation
  • 7/30/2019 Updated ABAP Material Document

    5/213

    Oracle e-Business Suite from Oracle : Oracle is into finance applications and Oracle

    relational database management systemtechnology

    PeopleSoft from Oracle: PeopleSoft is into Human resource management systems(HRMS) applications

    SAP R/3 from SAP: The most widely used modules in this ERP are Financials and

    Controlling (FICO), Human Resources (HR), Materials Management (MM), Sales &

    Distribution (SD), and Production Planning (PP) and its an integration around 25modules. Its the biggest ERP package in the Market.

    Many more ERP packages are available in the market.

    Enterprise:-Organization or Business oriented company.

    Resource: - Man, Money, Machines and materials etc.

    Planning:-Plans to maximum utilization of resources with cost minimization.

    The ultimate aim of using ERP is planning with the available resources of an enterprise to

    get the maximum output with cost minimization.

    What is SAP

    SAP was founded in 1972 by five former IBM engineers in Mannheim, Germany(Dietmar Hopp, Hasso Plattner, Klaus Tschira, Claus Wellenreuther and Hans-Werner

    Hector) and its headquarters in Walldorf German and since the 2005 annual general

    meeting the companys official name is just SAP AG.

    The acronym of SAP is Systems, Applications and Products in Data Processing" SAP is

    the largest software company in Europe and the third largest in the world. It ranks afterMicrosoft and IBM in terms of market capitalization. SAP is also the largest business

    application and Enterprise Resource Planning (ERP) solution and software provider in

    terms of revenue.

    Products

    SAP's products focus on Enterprise resource planning (ERP), which it helped to pioneer.The company's main product is mySAP ERP. The name of its predecessor, SAP R/3

    gives a clue to its functionality: the "R" stands for realtime data processing and the

    number 3 relates to a 3-tier architecture: database, application server and client (SAPgui).R/2, which ran on Mainframe architecture, was the first SAP version.

    Other major product offerings include Advanced Planner and Optimizer (APO), BusinessInformation Warehouse (BW), Customer Relationship Management (CRM), Supply

    Chain Management (SCM), Supplier Relationship Management (SRM), Human Resource

    Bangalore 5

    http://en.wikipedia.org/wiki/Oracle_e-Business_Suitehttp://en.wikipedia.org/wiki/Oracle_Corporationhttp://en.wikipedia.org/wiki/Oracle_Corporationhttp://en.wikipedia.org/wiki/Oracle_RDBMShttp://en.wikipedia.org/wiki/Oracle_RDBMShttp://en.wikipedia.org/wiki/Oracle_RDBMShttp://en.wikipedia.org/wiki/PeopleSofthttp://en.wikipedia.org/wiki/Oracle_Corporationhttp://en.wikipedia.org/wiki/Human_resource_management_systemshttp://en.wikipedia.org/wiki/SAP_R/3http://en.wikipedia.org/wiki/SAP_AGhttp://en.wikipedia.org/wiki/SAP_Human_Resource_Management_Systemshttp://en.wikipedia.org/wiki/SAP_MMhttp://en.wikipedia.org/wiki/SAP_MMhttp://en.wikipedia.org/wiki/Oracle_e-Business_Suitehttp://en.wikipedia.org/wiki/Oracle_Corporationhttp://en.wikipedia.org/wiki/Oracle_RDBMShttp://en.wikipedia.org/wiki/Oracle_RDBMShttp://en.wikipedia.org/wiki/PeopleSofthttp://en.wikipedia.org/wiki/Oracle_Corporationhttp://en.wikipedia.org/wiki/Human_resource_management_systemshttp://en.wikipedia.org/wiki/SAP_R/3http://en.wikipedia.org/wiki/SAP_AGhttp://en.wikipedia.org/wiki/SAP_Human_Resource_Management_Systemshttp://en.wikipedia.org/wiki/SAP_MM
  • 7/30/2019 Updated ABAP Material Document

    6/213

    Management Systems (HRMS), Product Lifecycle Management (PLM), Exchange

    Infrastructure (XI), Enterprise Portal (EP) and SAP Knowledge Warehouse (KW).TheAPO name has been retired and rolled into SCM. The BW name (Business Warehouse)

    has now been rolled into the SAP NetWeaver BI (Business Intelligence) suite andfunctions as the reporting modules.

    The company also offers a new technology platform, named SAP NetWeaver. While its

    original products are typically used by Fortune 500 companies, SAP is now also actively

    targeting small and medium sized enterprises (SME) with its SAP Business One and SAPAll-in-One.According to SAP AG there are over 100,800 SAP installations serving more

    than 38,000 companies. SAP products are used by over 12 million people in more than

    120 countries.

    1. The name SAP is acronym for Systems, Applications and Products in Data Processing.

    SAP is an extremely complicated system where no one individual can understand all of it.

    2. SAP runs on a fourth generation programming language language called Advance

    Business Application Programming (ABAP). It have many of the features of other

    modern programming languages such as the familiar C, Visual Basic, and Power Builder.Your programs name conventions begins with a letter yxxx or zxxx.

    3. SAP graphical user interfaces (SAPGUI) runs on Windows / NT / Unix / AS400.

    4. SAP is an enterprise resource planning (ERP) software product capable of integrating

    multiple business applications, with each application representing a specific businessarea. These applications update and process transactions in real time mode. It has the

    ability to be configured to meets the needs of the business.

    SAP R/3 is a client/server based application, utilizing a 3-tiered model. Apresentation

    layer, or client, interfaces with the user. The application layer houses all the business-specific logic, and the database layer records and stores all the information about the

    system, including transactional and configuration data.

    SAP R/3 functionality is structured using its own proprietary language called ABAP

    (Advanced Business Application Programming). ABAP, or ABAP/4 is a fourthgeneration language (4GL), geared towards the creation of simple, yet powerful

    programs. R/3 also offers a complete development environment where developers can

    either modify existing SAP code to modify existing functionality or develop their ownfunctions, whether reports or complete transactional systems within the SAP framework.

    ABAP's main interaction with the database system is via Open SQL statements. These

    statements allow a developer to query, update, or delete information from the database.

    Advanced topics include GUIdevelopment and advanced integration with other systems.With the introduction of ABAP Objects, ABAP provides the opportunity to develop

    applications with object-oriented programming.

    Bangalore 6

    http://en.wikipedia.org/wiki/Three-tier_(computing)http://en.wikipedia.org/wiki/User_interfacehttp://en.wikipedia.org/wiki/User_interfacehttp://en.wikipedia.org/wiki/User_interfacehttp://en.wikipedia.org/wiki/Business_logichttp://en.wikipedia.org/wiki/Databasehttp://en.wikipedia.org/wiki/ABAPhttp://en.wikipedia.org/wiki/Fourth-generation_programming_languagehttp://en.wikipedia.org/wiki/Fourth-generation_programming_languagehttp://en.wikipedia.org/wiki/SQLhttp://en.wikipedia.org/wiki/Graphical_user_interfacehttp://en.wikipedia.org/wiki/Graphical_user_interfacehttp://en.wikipedia.org/w/index.php?title=ABAP_Objects&action=edit&redlink=1http://en.wikipedia.org/wiki/Object-oriented_programminghttp://en.wikipedia.org/wiki/Object-oriented_programminghttp://en.wikipedia.org/wiki/Three-tier_(computing)http://en.wikipedia.org/wiki/User_interfacehttp://en.wikipedia.org/wiki/User_interfacehttp://en.wikipedia.org/wiki/Business_logichttp://en.wikipedia.org/wiki/Databasehttp://en.wikipedia.org/wiki/ABAPhttp://en.wikipedia.org/wiki/Fourth-generation_programming_languagehttp://en.wikipedia.org/wiki/Fourth-generation_programming_languagehttp://en.wikipedia.org/wiki/SQLhttp://en.wikipedia.org/wiki/Graphical_user_interfacehttp://en.wikipedia.org/w/index.php?title=ABAP_Objects&action=edit&redlink=1http://en.wikipedia.org/wiki/Object-oriented_programming
  • 7/30/2019 Updated ABAP Material Document

    7/213

    The most difficult part of SAP R/3 is its implementation, since SAP R/3 is never used the

    same way in any two places. For instance, Atlas Copco can have a differentimplementationof SAP R/3 from Procter & Gamble. Some companies may run multiple

    productive clients/systems or even multiple instances of SAP R/3. This is seen, forexample, when a company running R/3 acquires a new business already running R/3.

    They may elect to keep both systems separate, migrate one into the other, or migrate bothonto a completely new instance.

    The system landscape is ultimately the customer's decision. There are definite pros and

    cons on the continuum from single global instance / productive client (master data,impact of configuration changes on multiple business units) to separate instances per

    business unit (hardware costs and communication between instances/clients)

    Two primary issues are the root of the complexity and of the differences:

    Customization configuration - Within R/3, there are tens of thousands of database

    tables that may be used to control how the application behaves. For instance, eachcompany will have its own accounting "Chart of Accounts" which reflects how its

    transactions flow together to represent its activity. That will be specific to a given

    company. In general, the behavior (and appearance) of virtually every screen andtransaction is controlled by configuration tables. This gives the implementer great

    power to make the application behave differently for different environments. With

    that power comes considerable complexity. Extensions, Bolt-Ons - In any company, there will be a need to develop interface

    programs to communicate with other corporate information systems. This

    generally involves developing ABAP/4 code, and considerable "systems

    integration" effort to either determine what data is to be drawn out of R/3 or tointerface into R/3 to load data into the system.

    Due to the complexity of implementation, these companies recruit highly skilled SAP

    consultants to do the job. The implementation must consider the company's needs and

    resources. Some companies implement only a few modules of SAP while others maywant numerous modules.

    SAP has several layers. The Basis System (BC) includes the ABAP programming

    language, and is the heart (i.e. the base) of operations and should not be visible to higherlevel or managerial users. Other customizing and implementation tools exist also.

    Implementation Tools

    There are multiple tools available to assist in the management of ERP implementation

    projects. SAP R/3, for example, provides an Implementation Roadmap that is broken up

    into five phases. Each phase includes documentation and planning tools to help the phasemove towards completion. The five phases and their respective tasks include:

    Bangalore 7

    http://en.wikipedia.org/wiki/SAP_Implementationhttp://en.wikipedia.org/wiki/Atlas_Copcohttp://en.wikipedia.org/wiki/SAP_Implementationhttp://en.wikipedia.org/wiki/SAP_Implementationhttp://en.wikipedia.org/wiki/Procter_%26_Gamblehttp://en.wikipedia.org/wiki/SAP_Implementationhttp://en.wikipedia.org/wiki/SAP_Implementationhttp://en.wikipedia.org/wiki/SAP_Implementationhttp://en.wikipedia.org/wiki/Atlas_Copcohttp://en.wikipedia.org/wiki/SAP_Implementationhttp://en.wikipedia.org/wiki/Procter_%26_Gamblehttp://en.wikipedia.org/wiki/SAP_Implementationhttp://en.wikipedia.org/wiki/SAP_Implementation
  • 7/30/2019 Updated ABAP Material Document

    8/213

    Project Preparation

    o Building of the project team.

    o Designing the system (This includes network, hardware, and software

    requirements).o Selecting ERP vendors.

    o Defining the projects scope.

    Business Blueprint

    o In this phase project team members decide and document how the

    business and business processes will function with the implementation ofthe ERP system. These decisions will guide the configuration of the ERP.

    o Determination of methods to transfer or integrate legacy system

    information into the ERP system will also occur in this phase.

    Realization

    o Configuration of the ERP system occurs in this phase. Configuration

    guidelines are based on documentation from the Business Blueprint phase.

    o Legacy system connections are developed in this phase.

    Final Preparation

    o Testing of the new ERP system.

    o Development of the Help Desk and Help Desk Procedures.

    o Migration of existing data.

    o User training.

    o Schedule a Roll-Out date.

    Roll-Outo ERP system becomes part of everyday activities.

    o Help Desk fields questions about ERP system.

    o Monitoring of the ERP system starts in this phase.

    o Monitoring of the ERP system starts in this phase.

    The time required for each one of these phases differs from project to project based on

    the size of the implementation, dedication to the projectetc. Oftentimes the finishedprojects scope differs from the original scopes documentation causing projects to go

    overtime and over budget. When this happens, it is usually testing and training that get

    cut short which jeopardize the overall success of the project.

    Why SAP

    1. SAP is a platform independent; it can support various databases like Oracle, SQL

    Server.

    2. SAP also supports various operating systems.3. The integrity between its various modules makes SAP more users friendly.

    Bangalore 8

  • 7/30/2019 Updated ABAP Material Document

    9/213

    Areas of SAPThere are three areas in SAP.1. Functional Area

    There are more than 25 functional modules in SAP.Those who work on functional areas are called Functional Consultants.Ex: - PP Production planning

    MM- material management

    SD- Sales and Distribution

    FI- Financial AccountingCO- Controlling

    HR- human Resources

    PM- Plant Maintenance. Etc.

    2. Technical Area

    Here the technical consultants i.e. ABAPers are working.Technical Consultants will implant the ideas of functional Consultants.

    3. Basis Area

    Here the basis people will work.

    The following works are generally done hereCreation users, Authorization, Dispatcher and Role Allocation

    R/3 System Architecture

    R/3 is an integrated group of applications designed to handle the data processing for large

    corporations. The purpose of an R/3 system is to provide tightly integrated large scalebusiness applications.

    The below figure shows the structure of R/3 Architecture. The architecture contains four

    layers as Presentation Servers, Application Servers, Database Servers and Database.

    Bangalore 9

  • 7/30/2019 Updated ABAP Material Document

    10/213

    PS: - Presentation Servers

    AS: - Application Servers

    DBS: - Database Server

    DB: - Database

    Presentation Servers - The Presentation server is actually a SAPGUI or the user

    interface. The interface accepts input from the user in the form of keystrokes, mouse

    clicks and function keys, sends these requests to the application server to be processed.The application server sends the results back to the SAPGUI which then formats the

    output display to the user.

    Application Server The application server is a set of executables that collectively

    interpret the ABAP/4 programs and manage the input and output for them. When anapplication server is started, these executables all start at the same time. When an

    application server is stopped, they all shut down together.

    Each application server has a profile that specifies its characteristics when it starts up and

    while it is running. For example, an application severs profile specifies:

    Number of processes and their types Amount of memory each process may use

    Length of time a user is inactive before being automatically logged off

    The application server exists to interpret ABAP/4 programs, and they only run there-the

    programs do not run on the presentation server. If your ABAP/4 program requests

    Bangalore

    PS PS

    AS AS

    DBS

    DB

    10

  • 7/30/2019 Updated ABAP Material Document

    11/213

    information from the database, the application server will format the request and send it

    to the database server.

    Database Server - The database server is a set of executables that accept databaserequests from the application server. These requests are passed on to the RDBMS(Relation Database Management System). The RDBMS sends the data back to thedatabase server, which then passes the information back to the application server. The

    application server in turn passes that information to your ABAP/4 program and then you

    will get the required output on your presentation server.

    Database Database is nothing but a collection of data arranged for ease and speed of

    search and retrieval OR A database is a structured collection of records or data that is

    stored in a computer system.

    Application Server Architecture

    DispatcherQueue

    WP WPWPWP

    Roll Area

    (Extended Memory)

    Application Server From Presentation Servers

    To Database Server

    WorkProcesses

    Buffers

    All requests that come in 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 process. A work process handles one request at a time.

    Bangalore 11

    http://en.wikipedia.org/wiki/Datahttp://en.wikipedia.org/wiki/Computer_systemhttp://en.wikipedia.org/wiki/Datahttp://en.wikipedia.org/wiki/Computer_system
  • 7/30/2019 Updated ABAP Material Document

    12/213

    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 amemory 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 contains information about the user like about user name, login id and

    which program is running currently.

    Roll Area.

    Its a memory allocated by the work process for an instance of a program It contains

    information about the recent program which is executing currently

    Value of variables, Dynamic Memory Allocation and Pointers to work Process.

    Instance: - The term instance means application serverThe term central instance means database server

    In general the term instance means server.

    Roll In: - When a job is assigned to a work process it creates pointers to the user context

    and roll area this process is called Roll In.

    Roll Out: - After the execution of the job the pointers assigned to both user context and

    roll area are deleted this process is called Roll Out.

    Dialog Steps: - This is the time taken by the systems to show the next screen fromexisting screen is called as dialog step.

    Work process

    This is the area in which actual work is done. There are seven types of work process each

    handles a specific type request.

    1. Dialog or Online Process- for Dialog request.

    2. Update Process- Request to update data in database.

    3. Background Process- Background jobs.4. Spool Process- print spool request.

    5. Enque Process Logical lock requests

    6. Message Process- Routes messages between application server with in an R/3system

    7. Gateway Process- Funnels Messages into and out of the R/3 system.

    Components of Work Process

    Bangalore 12

  • 7/30/2019 Updated ABAP Material Document

    13/213

    Each Work Process is composed of the following1. A task handler

    2. An ABAP/4 Interpreter3. A screen Interpreter.

    4. A Database Interface

    All requests pass through the task handler, which then funnels the request to the

    appropriate part of the work process and the Interpreters Interpret the ABAP/4 code.

    Messages (6 types)

    1. S (Success): Green color status bar.

    2. E (Error): Red color status bar.

    3. W (Warning): Yellow color status bar.4. I (Information): In a pop-up box.

    5. A (Abort): In a pop-up box.

    6. X (Exit): Comes out of the program

    Three tier architecture of R/3

    Database Server

    Application Server

    Presentation Server

    (Unlike normal Client/server architecture where you have only two layers i.e., client and

    server.) Communication among the 3 tiers is accomplished by standard protocol services

    like TCP/IP or CPIC (Common Programming Interface Communication).

    Bangalore 13

    Database

    Application Application Application

    Presentation Presentation Presentation Presentation Presentation Presentation

  • 7/30/2019 Updated ABAP Material Document

    14/213

    In above case database server stores the data centrally. Basically contains database

    engine and associated processes. The database layers contain the database system used

    by all servers.

    Application server contains software components to run the program. It contains a SAP

    kernel, which can run ABAP/4 program.

    The presentation server is your client through which you send your request to application

    server. It is also called as SAP graphical user interfaces known as SAPGUI and is

    available in windows 3.1, Windows NT, Windows 95, and Macintosh. They all look

    similar whatever underlying system they are running on.

    The SAPGUI includes all graphical capabilities of window interface with menu bars, toolbars, focus property, and the entire mouse clicking operations.

    The R/3 system is open system in the sense that it can run on any operating system or any

    database and any communication technology. It means that:

    R/3 system can run on any operating system platform such as UNIX, NT, 95, AS/400.

    It supports various RDBMS such as SQL server, Oracle, Informix, DB2.

    Standard GUIs supported by R/3 are Windows 95, NT, Windows 3.1, and Macintosh.

    SAP can use standard communication protocols TCP/IP, CPIC, OSF/DCE/DME for

    network.

    Using SAPs Open SQL

    ABAP/4 code is portable between databases. To access the database in an ABAP/4

    program you will code SAPs open SQL. Open SQL is a subset and variation of ANSI

    SQL. The ABAP/4 Interpreter passes all open SQL statements to the database interfacepart of the work process. There they are converted to SQL i.e. native to the installed

    RDBMS. For example if you were running an Oracle database your ABAP/4 Open SQL

    would be converted by the database interface to Oracle SQL statements.

    If you use Open SQL, your SQL statements will be passed to the database interface.

    Using Open SQL has three advantages. All of these advantages are implemented viadatabase interface.

    Advantages using Open SQL

    1. Buffering Data on the Application Server.

    Bangalore 14

  • 7/30/2019 Updated ABAP Material Document

    15/213

    The database interface buffers information from the database on the application

    server, when data is read from the database, it can be stored in buffers on the applicationserver. If a request is then made to access the same records, they would already be on the

    application server and the request is satisfied from the buffer without having to go thedatabase. This buffering technique reduces the load on the database server and on the

    network link between the database and application servers and can speed up databaseaccess time by a factor of 10 to 100 times.

    2. Portability: - The SQL statements will be portable between databases. Forexample, if for some reason your company wanted to switch from an Oracle to an

    Informix database, it could change the database and your ABAP/4 code would

    continue to run without modification.

    3. Automatic client handling:-With Open SQL the client field is automatically

    populated by the database interface. This gives your development and testingteams may advantages. Such as the ability to perform multiple simultaneous

    testing and training on a single database without interface from each other

    WORKING WITH R/3 system

    The SAP R/3 presentation interface behaves very similarly to any other typical window

    application and is also known as SAPGUI. The first screen that you come across in R/3

    system is SAP logon screen.

    SAP R/3 logon Screen

    This is the first screen that appears when you use SAP logon utility. It has four fields: the

    client, the user, the password and the language.

    Bangalore 15

  • 7/30/2019 Updated ABAP Material Document

    16/213

    Client: Here you enter the client number. The client is group of users who has

    similar rights. It can be group of users in a business entity or a whole business entity

    or a whole company.

    User: The name of the SAP user identification. Users of the SAP system are client-

    specific, which means that user belonging to one client is valid to only the particular

    client.

    Password: It is the password that has been assigned by the system administrator.

    Language: SAP R/3 system supports multinational language on the same system atthe same time, which is very useful for multinational companies with different

    branches in several countries and possibly using different languages.

    After entering all the fields press ENTER key and system will take you to MAIN MENU

    screen.

    User might get different screens when he logs on, depending upon default settings of the

    user master record i.e., if user is DEVELOPER then the screen which he often works on

    is editor screen and he can go directly to this screen, if system administrator sets this

    screen for the user.

    Main features of any R/3 window are as follows:

    R/3 standard window elements behave exactly the same, as any other standard

    window application would, like minimizing a screen, setting the active window etc.

    From TOP to BOTTOM, R/3 window can contain typical elements such as check

    boxes, push buttons, input fields and following elements:

    Bangalore 16

  • 7/30/2019 Updated ABAP Material Document

    17/213

    Menu bar is the first element of the every R/3 window. It contains the menu item

    corresponding to the particular R/3 application. The two menu options SYSTEM and

    HELP are always present in every R/3 window. SYSTEM menu option contains all

    utilities and functions, and is available to user at all the times. The HELP menu

    contains all the available options for the different types and methods of obtaining

    online help in the system.

    Standard tool bar. The second R/3 window element is present in every R/3

    window. It is nothing but a collection of icons, which perform common functions

    like saving the object, exit etc. The various icons on std. Tool bar are as follows

    (from left to right):

    Application tool bar: The next part of the screen contains icons most commonly

    used in that particular task or transaction.

    Status bar is the bottom line of the screen and usually shows errors or informationmessages to the user. It also includes other information such as system id, session

    number, client, server name and the response time.

    Logging Off

    User can log off the R/3 system from any screen. There are three ways

    of logging off the R/3 system, which are as follows:

    From the Menu bar choose SYSTEM LOG OFF. In this case, you get the log off

    dialog box, which informs the user that any data not saved will be lost if continuing

    with the log off procedure. Use/NEX transaction code in the command field. This is dangerous, since it does not

    ask if you want to save the data.

    Clicking on the EXIT button on the R/3 initial screen.

    Bangalore 17

  • 7/30/2019 Updated ABAP Material Document

    18/213

    Getting help in the R/3 system

    R/3 includes many possibilities to get online help for almost every

    element of the system, users can get help for entire application, for

    specific function, for definitions of various terms used in SAP, i.e.,Glossary, messages, screens, fields etc.

    You obtain HELP by using any of the following options:

    Help function from the R/3 window, which is compulsory menu item of every R/3

    window.

    ? Icon of standard tool bar.

    F1 function key.

    The SAP system provides help on most fields that appear on the R/3

    system. To get help on particular field, position the cursor over it and

    press help button or F1 function key.

    Bangalore 18

  • 7/30/2019 Updated ABAP Material Document

    19/213

    Another way in which R/3 system provides help is when system displays error messages

    in the status bar. Double clicking on the status bar shows additional information about

    the message.

    ABAP/4 Development Workbench

    The development environment of SAP R/3 system is fully integrated set of various

    development tools, data dictionary, and programming language. Full integration of all

    components means that changes in any part have a direct and immediate effect on all

    application using those components.

    The screen of ABAP/4 development workbench looks like

    Tools of ABAP/4 workbench

    For programming:

    Bangalore 19

  • 7/30/2019 Updated ABAP Material Document

    20/213

    ABAP/4 dictionary Defining, maintaining and storing the data dictionary of the SAP

    R/3 system stores all the dictionary objects including tables relationship and Help

    information. Transaction code for this is SE11.

    ABAP/4 editor Creating and maintaining the ABAP/4 program, editing function

    modules, logical database, and screens. Transaction code is SE38.

    Function library Defining and maintaining the ABAP/4 function modules.

    Transaction code is SE37.

    Screen painter Designing and maintaining the screens in transaction. Transaction

    Code is SE51.

    Menu painter Designing and maintaining the means for graphical user interface.

    Transaction code SE41.

    For Navigating:

    Object browser Managing and organizing the development object in a hierarchical

    form. Transaction code is SE80.

    ABAP/4 repository information Navigating and searching for the dictionary Objects,

    development objects and relationship objects. Transaction code SE84.

    Data browser Navigating in the data tables of the database. Transaction code is SE

    16.

    For Debugging:

    SOL trace tracking the database calls from the system transaction and programs.

    Transaction code is ST05.

    Debugger Stopping the program and analyzing the results of the execution of every

    program statement.

    Runtime Analysis Analyzing the performance the system calls Transaction code is

    SE30

    For Organizing:

    Workbench organizer controlling and keeping track of development work and team

    related development projects and managing versions of development objects.

    Transaction code is SE09.

    Transport system performing and managing the transport of development object

    across different system. Transaction code is SE01

    Bangalore 20

  • 7/30/2019 Updated ABAP Material Document

    21/213

    What is ABAP/4 ?

    ABAP (Advanced Business Application Programming) is a programming language for

    developing applications for the SAP R/3 system. ABAP is one of many application-specific fourth-generation languages (4GLs) first developed in the 1980s. The most basic

    functions were written in ABAP. ABAP/4 is the language created by SAP AG for

    implementation and customization of their R/3 system.

    The ABAP programming language was originally used by developers to develop the SAP

    R/3 platform. ABAP was one of the first languages to include the concept of LogicalDatabases (LDBs), which provides a high level of abstraction from the basic database

    level.

    It was also intended to be used by SAP customers to enhance SAP applications customers can develop custom reports and interfaces with ABAP programming. The

    language is fairly easy to learn for programmers but it is not a tool for direct use by non-

    programmers. Good programming skills, including knowledge of relational database

    design and preferably also of object-oriented concepts are required to create ABAPprograms.

    The ABAP/4 Development Workbench contains all tools you need to create and maintain

    ABAP/4 programs. ABAP/4 programs are not complied but generated. During

    generation, the system creates a so-called runtime object from the source code and the

    program attributes. When you start the program, the system executes the runtime object.

    ABAP/4, a fourth generation language, contains all usual control structures and

    modularizing concepts for structured programming.

    Characteristics of the ABAP/4 programming languages

    Declarative elements for declaring data of different type and structures.

    Operational elements for manipulating data.

    Control elements to control processing flow.

    Bangalore 21

    http://en.wikipedia.org/wiki/SAP_R/3http://en.wikipedia.org/wiki/SAP_R/3http://en.wikipedia.org/wiki/SAP_R/3http://en.wikipedia.org/wiki/SAP_R/3
  • 7/30/2019 Updated ABAP Material Document

    22/213

    ABAP/4 is multi-lingual. Text elements such as titles, headings, and text body are

    stored separately, independent of the program codes. Thus, you can change, translate,

    and maintain text elements without having no adapt the coding.

    ABAP/4 supports business-related data types and operations. You can execute

    calculations using special data and time fields. The system automatically executes all

    necessary type conversions.

    ABAP/4 provides a number of functions for processing character strings.

    ABAP/4 allows you to define and call subroutines. You can even call subroutines of

    other programs. There are different ways of how to pass parameters to and from the

    Subroutines.

    ABAP/4 contains a special type of subroutine, called function module. Function

    modules are stored and maintained in a central library. They have clearly defined

    data interfaces to the calling program. You can test function modules in a stand-alonemode independent of the calling program.

    ABAP/4 contains an SQL subset called OPEN SQL. OPEN SQL allows you to read

    and change database tables independent of the underlying database system.

    ABAP/4 allows you to define and process internal tables that exist only for the

    execution period of the program. Internal tables efficiently support the usage of

    database tables and allow you to implement complex data structures in a program.

    ABAP/4 allows you to store data not only in databases but also as sequential files on

    application and presentation servers.

    ABAP language Contains below mentioned topics

    1. Data Dictionary ObjectsData Base Tables

    Views

    StructuresData Elements

    Domains

    Search helpsLock objects

    Primary Key and Foreign KeyTable Maintenance Generator

    2. Internal Tables

    Internal Tables IntroductionDeclaring Internal Table

    Populating Internal Table

    Bangalore 22

  • 7/30/2019 Updated ABAP Material Document

    23/213

    Processing Internal Table

    Initializing Internal Tables

    3. Moduralization TechniquesMacrosSub-routines

    Function Module

    4. REPORTS

    Classical

    Interactive

    Abap list viewer (ALV)

    5. BDC - Batch Data CommunicationSession method

    Call Transaction Method

    LSMW

    6. Module pool Programming

    Screen painter

    Menu painter

    7. Forms

    Scripts

    Smart forms

    8. Cross-Aplications

    ALE & IDOCS

    BAPI'sBADIs

    User Exists

    9. Miscellaneous Topics

    Correction & Transport request (CTS)

    Transport OrganizerWork Bench Request

    Task CreationRelease Objects

    SAP Memory & ABAP MemorySD Flow

    MM Flow

    Bangalore 23

  • 7/30/2019 Updated ABAP Material Document

    24/213

    Data Dictionary

    Data dictionary is the centralized and structured source of information about a database

    table. Its a logical layer situated over the database.

    Data Dictionary does not contains the data like Emp name, Addresses etc but rather a

    type of data whose function is to define the properties of data such as type, length andrelationship.

    Advantages of data dictionary.

    Advantage of using data dictionary is avoiding inconsistencies when defining data typethat will later be used in different applications. This avoids redundancies.

    When a type is defined in the dictionary, it is available to any program in the application.

    A change in the definition of a type of data in the dictionary automatically affects any

    other data or program, which has this data.

    Again, data dictionary is a fast and efficient way to answer questions such as which

    entries exist in a table of the database, what the structure of table is.

    Activation of dictionary objects

    For a dictionary object to be effective at runtime, that is, for a dictionary object to be

    available for use within a program, transaction, and so on, it must be in active status. For

    objects to become active, R/3 includes the ACTIVATION function.

    Bangalore 24

  • 7/30/2019 Updated ABAP Material Document

    25/213

    When a table or aggregated object is activated, it is placed at the disposal of the system as

    a runtime object in a way that makes it available quickly for the application program to

    access relevant information of new activated objects.

    When a dictionary object is modified, that means that the object previously existed and

    activated. You need to reactivate the object after modification.

    When mass activation is performed massively, it might take a quite a long time. Then it

    should be in the background system. This type of activation is known as background

    activation.

    The ABAP/4 Data dictionary is the central component of ABAP/4 repository. A Datadictionary is centralized and structured source of information for business application.

    The ABAP/4 dictionary is the core of the R/3 development system. It is the source of

    every definition, within R/3, from the very basic domain to the company data model. It is

    totally integrated with other tools of the development environment like screen painter,

    menu painter, and editor.

    Some of the main available functions in the ABAP/4 dictionary are as follows:

    Add, delete, modify, and manage the definition of the dictionary data.

    Preserve the data integrity.

    Be the central source of information e.g. from the dictionary you get the information

    about the defined relationship between two tables or even the directory tells whether

    table is active or empty.

    It also permits documentation of system data.

    In the R/3 system instead of working with original objects, you work with internal

    representation of objects. With this type of operation the system performance is

    enhanced and has the advantage that the development tools, screen interpreters always

    access current data.

    When any of the data dictionary objects are used in other parts of the development

    workbench for example, in program, programmer only has to enter a table name or field

    name. The system automatically knows all the properties and information of the field.

    Bangalore 25

  • 7/30/2019 Updated ABAP Material Document

    26/213

    To call ABAP/4 dictionary, from the main menu, Tools ABAP/4 workbench data

    dictionary or enter transaction SE11.

    Objects of Data Dictionary

    1. Tables

    2. views3. Data Type4. Domain

    5. Type Group

    6. Search Help

    7. Lock Objects8. Primary key and Foreign key

    9. Table Maintenance generator.

    Bangalore 26

  • 7/30/2019 Updated ABAP Material Document

    27/213

    Tables

    A table is two dimensional data matrix i.e. its the combination of rows and columns.

    The rows contain the data record and columns contain the field.

    Tables can be containing 0 or multiple records or rows.

    Ex: Employee Table.

    Types of Tables

    1. Client Dependent

    2. Client Independent

    1. Client Dependent:- If the first field of a table is MANDT and data type is CLNT

    then it is called client dependent table. The length will be always 3.

    2. Client Independent: - If the first field contains other than the MANDT then it is

    Called client independent table

    The client dependent tables are again of three types.

    1. Transparent tables.2. Pooled Tables.

    3. Clustered Table.

    1. Transparent Tables

    A transparent table in the dictionary has one to one relationship with a table in the

    database. Its structure in R/3 Data dictionary corresponding to a single database table.The database table has the same name, the same number of fields and the fields have the

    Bangalore 27

  • 7/30/2019 Updated ABAP Material Document

    28/213

    same names as the R/3 table definition. It contains application data. In below fig first

    part will shows transparent table.

    2. Table Pools and Pooled Tables

    A pooled table in R/3 has a many-to-one relationship with a table in the database. For

    one table in the database, there are many tables in the R/3 Data Dictionary. The table

    in the database has a different name than the tables in the DDIC, it has a different

    number of fields, and the fields have different names as well. Pooled tables are anSAP proprietary construct.

    In the database pooled tables are stored in a single table called a table pool table.R/3uses table pools to hold a large number (tens to thousands) of very small tables (about

    10 to 100 rows each). Table pools reduce the amount of database resources neededwhen many small tables have to be open at the same time. Pooled tables are primarilyused by SAP to hold customizing data. In the above fig second part is an example for

    pooled tables

    3. Table Clusters and Cluster Tables

    A cluster table is similar to a pooled table. It has a many to one relationship with a

    Bangalore 28

  • 7/30/2019 Updated ABAP Material Document

    29/213

    table in the database. Many cluster tables are stored in a single table in the database

    called a table cluster.

    Table clusters are used to hold data from a few (approximately 2 to 10) very largetables. They would be used when these tables have a part of their primary keys in

    common, and if the data in these tables are all accessed simultaneously. Table clusterscontain fewer tables than table pools and, unlike table pools, the primary key of each

    table within the table cluster begins with the same field or fields. In the above fig

    third part is an example for cluster tables.

    Restrictions on Pooled and Cluster Tables

    Pooled and cluster tables are usually used only by SAP and not used by customers,

    probably because of the proprietary format of these tables within the database and

    because of technical restrictions placed upon their use within ABAP/4 programs.

    1. On a pooled or cluster table, Secondary indexes cannot be created.

    2. You cannot use the ABAP/4 constructs select distinct or group by.

    3. You cannot use native SQL.4. You cannot specify field names after the order by clause. Order by primary key is

    the only permitted variation.

    Because of these restrictions on pooled and cluster tables and because of their limited

    usefulness. Normally in real time system we will not create much pooled and cluster

    tables. Only transparent tables are used or created maximum. So we will discuss only

    about transparent tables

    Other Components of the Table

    Fields: - Fields are nothing but columns.

    Domain: - Domain consists of the technical characteristics of a field such as field

    length and data type.

    Data Element: - A table is composed of fields to create a field you need a data

    element. The data element contains the field labels and documentation (F1 help) for

    the field. It contains the semantic characteristics for the field and it works like ainterface between Field and Domain.

    Domain and data elements are reusable. A domain can be used in more than one dataelement and data elements can be used in more than one field and in more than one

    table.

    Delivery Class: - Delivery class comes under attributes. The value in the delivery

    Bangalore 29

  • 7/30/2019 Updated ABAP Material Document

    30/213

    class field identifies the OWNER of the data in this table. The owner is responsible

    for maintaining the table contents. In customer tables we always enter A Here whichindicates that the table contains application data owned by the customer only.

    Ex: - A Application table (Master and Transaction data).

    Data Class: It comes under technical settings. It defines the physical address of thedatabase in which the table uses creates and logically stored or its a physical place

    where the actual data is to be stored.

    Categories of data class: APPLO Master data, transparent tables.

    Size Category: It also comes under technical settings. It defines the probable space

    requirement for a table in the database.

    Categories:

    0:- 0 to 30,000.1:- 30,000 to 1, 20,000.

    2:- 1, 20,000 to 4, 90,000.

    3:- 4, 90,000 to 1,9,00,000

    Table Maintenance allowed: Its also comes under attributes. By enabling table

    maintenance allowed user can be able to enter the data, change and display manually.

    Approaches for creating tables:- There are two approaches you can use when

    creating tables.

    Top-down-approach: In top down approach first we create the field then data

    element then domain.

    Bottom-up-approach: In the bottom-up-approach first we create the domain, thendata element and then field.

    Direct Method: Do not have data element or domain.

    Primary key: Primary key is a field or combination of fields that uniquely identify a

    row in the database table.

    Foreign Key: Foreign Key is a key which is a primary key of another table.

    Naming convention for database tables:

    1. The tables we are creating are generally called as Z-tables or customizing tables.

    2. The name of a table should be started with Y or Z that a user creates.

    3. SAP has used A to X for its own use, Z or Y in the beginning means that theprogram or table is user defined.

    So it avoids the redundancy between predefined and customizing tables.

    Bangalore 30

  • 7/30/2019 Updated ABAP Material Document

    31/213

    Steps to Create Database Tables

    To create tables, Go to transaction SE11 and select database table radio button: Give

    Database table name for example ZKA_EMP. All user-created tables must start with Yor Z.

    Eg: ZKA_EMP. Then click on the CREATEbutton.

    Eg: ZKA_EMP. Then click on the CREATEbutton and you will get the below screen.

    Bangalore 31

  • 7/30/2019 Updated ABAP Material Document

    32/213

    In the Attributes (tab) screen,Enter the short description as EMPLOYEE DETAILS.

    Delivery class: Under multiple entries, select A-Application table (Master andtransaction data).

    Check the box for the Table maintenance allowed.Now select the fields (tab), Field name EMPNO and field type ZKA_EMPNO and

    check the primary key check box. Field name EMPNO and field type ZKA_EMPNO

    and check the primary key check box and click on save button.

    When you click on save button you will get one pop-up box as shown below.

    Bangalore 32

  • 7/30/2019 Updated ABAP Material Document

    33/213

    Click on the LOCAL OBJECT button.Now double click on the field type and u will get CREATE DATA ELEMENT

    SCREEN, click on YES.

    Enter the short text EMPLOYEE NO and the domain name ZKA_EMPNO.

    Bangalore 33

  • 7/30/2019 Updated ABAP Material Document

    34/213

    Now double click on the domain name ZKA_EMPNO and enter the following details.

    Short text : EMPLOYEE NO.

    Data Type : NUMC(Click on the RIS button and select NUMC from that)

    Bangalore 34

  • 7/30/2019 Updated ABAP Material Document

    35/213

    No. of characters: As per the requirement. ( Eg. 10 ).

    Note: If the field is employee name then u need to select the data type to be CHAR andrequired no of characters.

    Now SAVE (CTRL + S) ,Click on the CHECKbutton or(CTRL + F2), and should get NO INCONSISTENSIESFOUND in the status bar.

    Then click on the ACTIVATEbutton (CTRL + F3).

    Now click on the BACKbutton and then,

    SAVE(CTRL+S), CHECK(CTRL+F2) & ACTIVATE(CTRL+F3).

    Click the BACKbutton and u will be in the main dictionary screen.

    Bangalore 35

  • 7/30/2019 Updated ABAP Material Document

    36/213

    Now click on the NEW ROWSbutton to enter as many fields u would prefer.

    Once all the fields with the data element and the domain is set up, the table need to beactivated as a whole. To activate the table the technical settings should be saved.

    Before u activate, u need to set up the technical settings by clicking on the TECHNICALSETTINGSbutton.

    Where the data class is APPL0 (Master data, Transparent tables).

    Size category is 0(0-30000).

    SAVE or(CTRL+S) the technical settings.

    Click BACK to get to the main screen and SAVE, CHECK AND ACTIVATE the table.In order to give the input values(new entries), click on Utilities->Table contents->Create

    Entries

    Bangalore 36

  • 7/30/2019 Updated ABAP Material Document

    37/213

    Enter and SAVE the values and clickRESET to give the new values.

    Once the values are saved, click the BACKbutton and click on the CONTENTS, then

    the EXECUTEbutton to see the output.

    So when we click on the EXECUTEbutton, we get the output in the table format.Thus the table is created.

    Bangalore 37

  • 7/30/2019 Updated ABAP Material Document

    38/213

    Database Views

    A view is a logical window to a table or more than one table, the data from a view is

    not actually physically stored instead being derived from one or more tables. A viewcan be used to summarize data which is distributed among several tables. It does not

    contain memory space. During runtime it contains memory after the execution the

    memory will be released

    Types of Views

    1. Projection View

    2. Database View

    3. Maintenance View4. Help View

    Projection View: This view is used to display datas from only one table i.e. view

    can draw upon only one table, this means that only the data that actually required isexchanged when the database is accessed. Selection conditions cannot be specified

    for projection view.

    Database View: This view is used to display datas from more than one table.

    Database views are implement an inner join, that is, only records of the primary table

    for which the corresponding records of the secondary tables also exist are fetched. In

    database views, the join conditions can be formulated using equality relationshipsbetween any base fields. Inconsistencies between primary and secondary table could,

    therefore, lead to reduced selection set

    Maintenance View: This view is used to for data manipulation like insert, update,

    delete, modify etc. Data from several tables can be summarized in a maintenance

    view and maintained collectively via this view. That is the data is entered via the viewand then distributed to the underlying tables by the system.

    Bangalore 38

    http://basicsofabap.blogspot.com/2009/04/database-views.htmlhttp://basicsofabap.blogspot.com/2009/04/database-views.html
  • 7/30/2019 Updated ABAP Material Document

    39/213

    Help View: This view is used to displaying possible values of field from one or morethan one table i.e. used to output additional information when the online help system

    is called or when F4 is pressed on the field.

    Steps to create Views

    DATABASE VIEW:

    View can be performed for more than one table which have the foreign relationship b/wthe tables. For Eg: If we have ZKA_EMP and ZKA_COM, We can perform view.

    Now to start with the view. Go to transaction SE11 and select View Radio button and

    enter the name as below.Eg: ZKA_DBV and click on the CREATEbutton.

    Select the database view among the options and then click on the copy button.

    Bangalore 39

  • 7/30/2019 Updated ABAP Material Document

    40/213

    Enter the short text: DATABASE VIEW.And under the tables enter both the table names ZKA_EMP,

    ZKA_COM.

    Now click on the RELATIONSHIPS button and select the referenced tables and click

    on the COPYbutton.

    Bangalore 40

  • 7/30/2019 Updated ABAP Material Document

    41/213

  • 7/30/2019 Updated ABAP Material Document

    42/213

    Now SAVE, CHECKand ACTIVATE.

    To see the output, clickCONTENTS and EXECUTE.

    Thus the database view is done with the fields in both the tables.

    PROJECTION VIEW:

    Go to SE11 and click on VIEW and enterZKA_PV. Click on the CREATEbutton.

    Bangalore 42

  • 7/30/2019 Updated ABAP Material Document

    43/213

    Select PROJECTION VIEW and click on the CONTINUEbutton.

    Now enter the short text: PROJECTION VIEW.

    Basis table: ZKA_COM (the table for which u need the projection view).

    Now click on the TABLE FIELDS button and select the fields that we need to project

    and click on the COPYbutton.

    Bangalore 43

  • 7/30/2019 Updated ABAP Material Document

    44/213

    Now SAVE, CHECKand ACTIVATE. To see the output click on the CONTENTS

    button and EXECUTE. Thus the projection view is created.

    SEARCH HELP

    Search helps are independent Repository objects that you create using the ABAP

    Dictionary. They are used to present input help for screen fields which gives list of allpossible values for either primary key or non primary keys

    The input help (F4 help) is a standard function of the R/3 System. It permits the user to

    display a list of possible values for a screen field. A value can be directly copied to aninput field by list selection.

    The fields having an input help are shown in the R/3 System by the input help key to theright of the field. This key appears as soon as the cursor is positioned on the

    corresponding screen field. The help can be started either by clicking on this screen

    element or with function key F4.

    Since the input help is a standard function, it should look and behave the same throughout

    the entire R/3 System. The development environment therefore provides tools for

    assigning a standardized input help to a screen field.

    When you define a parameter of a search help, you must also define whether it should be

    used to copy data to the input help (IMPORT parameter) or whether to return data fromthe input help (EXPORT parameter).

    Bangalore 44

  • 7/30/2019 Updated ABAP Material Document

    45/213

    Types of Search helps

    Elementary search helps:- defines a search path where we will define the table fromwhich the data has to be read and the selection criteria. Through import and export

    parameters. Used when we gets the data rom a single table.

    Collective search helps:- Combination of elementary search helps. When we need to

    fetch data based on multiple selection criteria s. More than one tables are selection frommultiple tables.

    Diff Between Elementary search helps & Collective search helps

    1) Elementary search helps describe a search path. The elementary search help must

    define where the data of the hit list should be read from (selection method), how the

    exchange of values between the screen template and selection method is implemented(interface of the search help) and how the online input help should be defined (online

    behaviour of the search help).

    2) Collective search helps combine several elementary search helps. Collective search

    help thus can offer several alternative search paths.

    3) An elementary search help defines the standard flow of an input help.

    4) A collective search help combines several elementary search helps. The user can thuschoose one of several alternative search paths with collective search help.

    5) A collective search help comprises several elementary search helps. It combines all the

    search paths that are meaningful for a field.

    6) Both elementary search helps and other search helps can be included in a collective

    search help. If other collective search helps are contained in collective search help, theyare expanded to the level of the elementary search helps when the input help is called.

    STRUCTURE

    Structure is a skeletal view of a table. It contains the definition of columns and dont

    have any contents. Structure is generally a template based on which a table is created.

    The basic difference between structure and table is that the structure does not exist at the

    underlying database system level. Structure exists as definition in the dictionary.

    Types of Structures

    Bangalore 45

  • 7/30/2019 Updated ABAP Material Document

    46/213

    Append Structure:- It will add Fields to the table from last . we can't use that structure in

    another table. An append structure is a structure assigned to just one table. When a tableis activated, all append structures for the table are found and appended to the

    table.Append structures are used to add customer fields to SAP tables and Custom tablesalso.

    Include Structure: Include structures can used by us to add fields into any ztables andSAP tables also. Because in a Ztable we can add fields where ever we want. Include

    structure can be used more than one time in a table. The same include structure can be

    included to any no of custom tables.

    Steps to create Structure.

    In the DDIC (SE11), select DATATYPE and give the structure name: ZKA_STRUCT.

    Now select STRUCTURE and click on the COPYbutton.

    Enter the short text: STRUCTURE.

    Bangalore 46

  • 7/30/2019 Updated ABAP Material Document

    47/213

    Then the components (field) corresponding to the table and select the component type

    from the existing data type.Click on SAVE, CHECKand ACTIVATE.

    Now go the table to which the structure need to be added (ZKA_EMP).Select the row

    where the structure need to be added and click on EDIT->INCLUDE->INSERT

    Enter the STRUCURE ZKA_STRUCT and clickOK.

    SAVE, CHECKand ACTIVATE.To see the output, Click on CONTENTS and EXECUTE.

    Select all the records and click on the CHANGEbutton and click on the next entry and

    fill in all the values and BACKbutton to see the output.

    Thus the Structure is created.

    Bangalore 47

  • 7/30/2019 Updated ABAP Material Document

    48/213

    Table types

    Table types are construction blueprints for internal tables that are stored in the ABAPDictionary. When you create a table type in the ABAP Dictionary, you specify the line

    type, access type, and key. The line type can be any data type from the ABAP Dictionary,

    that is, a data element, a structure, a table type, or the type of a database table. You can

    also enter a predefined Dictionary type directly as the line type, in the same way that youcan with a domain.

    In an ABAP program, you can use the TYPE addition to refer directly to a table type. Ifyou define a local data type in a program by referring to a table type as follows:

    TYPES dtype TYPE table.

    The construction blueprint of the table type is used to create a local internal table dtypein the program. The predefined Dictionary data types of the domains used by the data

    elements in the structure are converted into the corresponding ABAP types. The semanticattributes of the data elements are used for the corresponding components of the internal

    table in the program.

    Bangalore 48

  • 7/30/2019 Updated ABAP Material Document

    49/213

    Type Groups

    Type groups were based on the include technique, and allowed you to store any typedefinitions globally in the Dictionary by defining them using TYPES statements. Thedefinition of a type group is a fragment of ABAP code which you enter in the ABAP

    Editor. The first statement for the type grouppool is always: TYPE-POOL pool.

    After that, you define data types using the statement TYPES. It was also possible todefine global constants using the CONSTANTS statement. All the names of these datatypes and constants must begin with the name of the type group and an underscore:pool_

    In an ABAP program, you must declare a type group as follows before you can use it:TYPE-POOLS pool. This statement allows you to use all the data types and constants

    defined in the type grouppool in your program. You can use several type groups in thesame program.

    Let the type group HKTST be created as follows in the ABAP Dictionary:

    TYPE-POOL hktst.

    TYPES: BEGIN OF hktst_typ1,col1(10) TYPE c,

    col2 TYPE i,END OF hktst_typ1.

    TYPES hktst_typ2 TYPE p DECIMALS 2.CONSTANTS hktst_eleven TYPE i VALUE 11.

    This type group defines two data types HKTST_TYP1 and HKTST_TYP2, as well as a

    constant HKTST_ELEVEN with the value 11.

    Any ABAP program can use this definition with the TYPE-POOLS statement:

    TYPE-POOLS hktst.

    DATA: dat1 TYPE hktst_typ1,dat2 TYPE hktst_typ2 VALUE '1.23'.

    WRITE: dat2, / hktst_eleven.

    The output is: 1.

    Bangalore 49

    http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb2ff3358411d1829f0000e829fbfe/content.htmhttp://help.sap.com/saphelp_nw70/helpdata/en/fc/eb2ff3358411d1829f0000e829fbfe/content.htm
  • 7/30/2019 Updated ABAP Material Document

    50/213

    The data types defined in the type group are used to declare data objects with the

    DATAstatement and the value of the constant is, as the output shows, known in theprogram

    Example for type Group

    *&---------------------------------------------------------------------**& Report ZBASU_TYPE_GROUP **& **&---------------------------------------------------------------------**& **& **&---------------------------------------------------------------------*

    REPORT ZBASU_TYPE_GROUP .TYPE-POOLs: ZTYPE .tables: mara.

    data: itab type table of ztype_basu with header line.select-options: material for mara-matnr.

    select * from mara into corresponding fields of table itab where matnrin material.

    write:/ ztype_a.loop at itab.write:/ itab-matnr,itab-ersda,itab-ernam.endloop.

    ***************** Type Group defined DDICTYPE-POOL ZTYPE .

    constants: ZTYPE_a type i value 10.

    types: begin of ztype_basu,matnr like mara-matnr,ersda like mara-ersda,ernam like mara-ernam,end of ztype_basu.

    LOCK OBJECTS

    These types of objects are used for locking the access to database records in table. This

    mechanism is used to enforce data integrity that is two users cannot update the same data

    at the same time. With lock objects you can lock table-field or whole table.

    Bangalore 50

  • 7/30/2019 Updated ABAP Material Document

    51/213

  • 7/30/2019 Updated ABAP Material Document

    52/213

    Exclusive not cumulating (X) it is similar to exclusive lock. It allows only a single user

    access. E can be called several times from the same transaction. In contrast, a lock type X

    can be called only once during the transaction. Any other call for this lock is rejected.

    Activation of Lock Object

    When you activate the lock object, the functions are automatically generated. And these

    are ENQUEUE-EZN and DEQUEUE-EZN. EZN is name of the lock object.

    While ENQUEUE is used in program to set the code over the selected data depending

    upon the lock object arguments. DEQUEUE is used to release the lock.

    Bangalore 52

  • 7/30/2019 Updated ABAP Material Document

    53/213

    Internal TablesBy definition, internal tables are user defined structured data types. These internal

    tables can be created as a replica of data base table, using some or all fields of one table

    or more tables. These internal tables are created only during run time no memory isreserved.

    Why we need internal table

    Long life data is stored in database tables when we are directly modifying data there is

    every possibility that we may loose data by accident, which we can not afford to do so,As such we need some intermediate etc tables to do some operations upon satisfactory

    results, we can modify database tables.

    Defining Internal Tables:

    Internal table with header line: When we create internal table with header line, a

    default work area is created.

    Internal table with out header line: In this case, we need to create explicit work area to

    work with it. When we need to nest the tables with in tables, we need to use this type of

    internal table.

    Types of internal tables

    1. Standard tables: - Standard tables have an internal linear index. The system can

    access records either by using the table index or the key. The response time for keyaccess is proportional to the number of entries in the tables. The key of standard table is

    always non-unique. Standard tables can always be filled very quickly, since the system

    does not have to check whether there are already existing entries.

    Key access to a standard table uses a linear search. This means that the time required

    for a search is in linear relation to the number of table entries. You should use indexoperations to access standard tables.

    2. Sorted Tables: - Defines the tables as one that is always saved correctly sorted by key.

    The system can access records either by using the table index or the key. The responsetime for key access is logarithmically proportional to the number of table entries, since

    the system uses a binary search. The key of a sorted table can be either unique or non-

    unique.

    Bangalore 53

  • 7/30/2019 Updated ABAP Material Document

    54/213

    If the key is not unique, the system takes the entry with the lowest index. The runtimerequired for key access is logarithmically related to the number of table entries.

    3. Hashed tables: - Hashed tables have no linear index. Hashed table is accessed using

    its key. The response time is independent of the number of table entries and is constant,since the system accesses the table entries using a hash algorithm. The key of a hashed

    table must be unique.

    Defines the tables as one that is managed with an internal hash procedure. You can

    only access a hashed table using the generic key operations or other generic operations

    (sort, loop and so on) Explicit or implicit index operations (such as loop... from and insertitab with in and loop) are not allowed.

    4. Index Table: - A table that can be accessed using an index. Index table is only used tospecify the type of generic parameters in a from or function. That means that you can not

    create a table of type Index. Standard and sorted tables are index tables.

    Initializing Internal Tables

    Clear: Clears the header (Work Area) line of the internal table.Syntax: clear Itab.

    Clear []: Clears the body of the internal table without clearing the work area or header.Syntax: Clear itab [].

    Refresh : Delete all table entries, memory space remains occupied i.e. only

    removes only contents of internal table.

    Free : Delete all table entries, memory space is released i.e. de-allocates memory

    associated with internal table.

    Operations of Internal Tables

    1. Append: It will take data from work area or header into internal table body.

    Syntax: Append itab (append itab to itab)

    Append wa_itab to itab.

    2. Collect: It will work similar to append operation but it will adds the same integer

    fields otherwise it will append it.

    Syntax: Collect itab.

    3. Insert: Used to insert data at any place. For this we have to specify the index no

    Bangalore 54

  • 7/30/2019 Updated ABAP Material Document

    55/213

    otherwise its goes to dump screen.

    Syntax: insert itab index (Index number).

    4. Modify: This operation will modify the existing records.Syntax: Modify itab index (Index number).

    5. Read: Used to read a single record from itab with key or index and it will read from

    application server to the screen.

    Syntax: read itab with key (field name)

    6. Sort: Used to sort the internal tables and by default it is ascending.

    Syntax: Sort itab by (Field name).

    7. Delete: Used to delete the data from internal tables but you need to give index number

    or range and field names.Syntax: Delete itab by index (Index number)

    8. Describe: Used to describe the internal tables like how many records and what kind of

    internal table etc.Syntax: Describe table itab lines (variable name)

    Example for internal table operations

    *&---------------------------------------------------------------------**& Report ZBASU_INTERNAL_TABLE_OPERATION *

    *& **&---------------------------------------------------------------------**& **& **&---------------------------------------------------------------------*

    REPORT ZBASU_INTERNAL_TABLE_OPERATION.

    DATA: BEGIN OF ITAB OCCURS 0,F1,F2 TYPE I,F3(3),END OF ITAB.

    DATA: LIN.

    ******Append OperationITAB-F1 = 'A'.ITAB-F2 = 10.ITAB-F3 = 'BC'.APPEND ITAB.CLEAR ITAB.

    ITAB-F1 = 'B'.ITAB-F2 = 15.

    Bangalore 55

  • 7/30/2019 Updated ABAP Material Document

    56/213

    ITAB-F3 = 'BD'.APPEND ITAB.CLEAR ITAB.

    ******* Collect Operation

    ITAB-F1 = 'A'.ITAB-F2 = 20.ITAB-F3 = 'BC'.COLLECT ITAB.CLEAR ITAB.

    ITAB-F1 = 'C'.ITAB-F2 = 25.ITAB-F3 = 'BF'.APPEND ITAB.CLEAR ITAB.

    *******Insert OperationITAB-F1 = 'D'.

    ITAB-F2 = 30.ITAB-F3 = 'BG'.INSERT ITAB INDEX 2.CLEAR ITAB.

    *******Modify OperationITAB-F1 = 'F'.ITAB-F2 = 40.ITAB-F3 = 'BH'.MODIFY ITAB INDEX 2.CLEAR ITAB.

    ITAB-F1 = 'F'.MODIFY ITAB TRANSPORTING F1 WHERE F1 = 'D'.CLEAR ITAB.

    *******Sort OperationSORT ITAB.SORT ITAB BY F2.

    ******Read OperationREAD TABLE ITAB INDEX SY-TABIX INTO ITAB.READ TABLE ITAB INDEX 3 INTO ITAB.READ TABLE ITAB INTO ITAB WITH KEY F1 = 'D'.

    WRITE:/ ITAB-F1,ITAB-F2,ITAB-F3.

    ******Describe OperationDESCRIBE TABLE ITAB LINES LIN.

    ******Delete OperationDELETE ITAB INDEX 2.DELETE ITAB WHERE F1 = 'A'.

    WRITE:/ 'NO OF LINES IN MY INTERNAL TABLE', LIN.LOOP AT ITAB.WRITE:/ ITAB-F1,

    ITAB-F2,

    Bangalore 56

  • 7/30/2019 Updated ABAP Material Document

    57/213

    ITAB-F3.

    ENDLOOP.

    REPORTS

    About reports

    Reports, in the R/3 system are online programs whose function is to retrieve data from

    database and display it or print it for the user. An end user often needs some information

    to look up, depending upon which various management decisions are taken, or to just see

    business results or simply to continue work. As R/3 is collection of all business

    applications, it has provided a very powerful feature to satisfy this crucial business need

    i.e., reports are involved at each and every step of business. This type of extracting,

    collecting and formatting data that is stored in database is done by REPORT program.

    The program that is written to retrieve and display data is REPORT program and the datathat is displayed on the screen when you execute the program is called as LIST (output of

    the report).

    When you display data, you need to display the data, user needs. For example, user wants

    to see the all the employee, who has joined after 12 th December 1997. In this case user

    has to pass this information, to the system, that he needs only those employee records

    where joining data is greater than 12 th December 1997. For user, it is passing information

    to the system but for the system it is input from the user. System takes input from the user

    before it retrieves the data from the database. This is very common requirement of any

    report as the need of any business is to display data, which is required by user.

    Reports are ABAP/4 programs.

    You use reports to evaluation data from database tables. The results of such an

    evaluation can be displayed on the screen or printed form.

    Reports are stand-alone programs.

    Bangalore 57

  • 7/30/2019 Updated ABAP Material Document

    58/213

    The user can execute reports directly via the program name, for example, by choosing

    System Utilities Reporting.

    A report program contains a collection of processing blocks for different events that

    are always triggered externally. In a report, you can react on events by programming

    the corresponding processing blocks or ignore the events by not writing the

    corresponding processing blocks. A report itself never creates events.

    Reports can use logical databases or select statements defined by developer.

    For each application, SAP supplies logical databases. Or you can easily create logical

    database yourself.

    Event control of a report corresponds to a certain scheme:When a report is executed, the ABAP/4 processor creates togetherwith the logical database used (if any) a sequence of certain eventsfor which you can program processing blocks. The chronology of the

    events is (more or less)

    Steps involved in creating a Report:

    1. Processing the selection screen

    After starting a report, the selection screen allows the user to enter limits or

    control values for further report processing. The report can contain several

    processing blocks for events during selection screen processing, for example, for

    checking the input values.

    2. Reading the database

    After selection screen processing come the events for reading the database. Eitherthe report reads data from relational databases it using the corresponding ABAP/4

    statements (open SQL) or leaves this task to a logical database. In the latter case,

    the logical database creates a sequence of events to allow the report to copy the

    data.

    3. Evaluating data and creating lists

    During or after reading the database the report creates the output list. During list

    creation, several events allow you to layout the output list (for example, layout the

    page header).

    4. Outputting a list

    The last part of the processing sequence controlled by the ABAP/4 processor is

    the list output on the screen or printer. When displaying the list on the screen, user

    can trigger other reports, that are interactive and are event driven. For example, by

    clicking the mouse. By programming processing blocks for these events, you

    change a normal report to a so-called Interactive report. If a report does not

    Bangalore 58

  • 7/30/2019 Updated ABAP Material Document

    59/213

    contain event keywords, the entire coding of the report belongs to a single

    processing block, which is called by a standard event. This standard event is

    triggered directly after processing the selection screen.

    Selection criteria

    System accepts inputs from user through SELECTION CRITERIA.

    Selection criteria are nothing but input fields which allows the user to restrict information

    given to program for processing further data. If you dont specify any criteria for

    selection, your report program produces a long list of data, which might not be needed by

    the user. Basically, selection criteria are the fields where user enters some value for

    which he needs information. Through selection criteria user can enter discrete value

    or ranges. For example, user wants to see all the records of the employees, who have

    joined between 12th December 1997 and 12th May 1998. This range can be entered in

    selection criteria. As the user becomes more specific for mentioning the criteria, the list

    will be smaller and more specific.

    Syntax:

    SELECT-OPTIONS for .

    Field is the variable, which you declare for accepting input from the user.

    Table field is reference field.

    SELECT-OPTIONS: fld1 for sflight-fldate,

    carrid1 for sflight-carrid.

    Maximum length of the name Select-Options variable is 8.

    When system executes this statement, the selection screen is displayed and is like this.

    Bangalore 59

  • 7/30/2019 Updated ABAP Material Document

    60/213

    When you enter the desired information and click on execute button, rest of the program

    is executed, that is retrieval of data from database, which matches this information and

    the list is displayed.

    Behavior ofSELECT-OPTIONS

    When the Select-Options statement is executed the system creates the internal table with

    the same variable name (in this case it will be carrid1). This table is also called as

    selection table. The main purpose of selection table is to store selection criteria. The

    table has four standard fields, which are as follows:

    SIGN is a variable, which denotes the system whether the result should be included

    with those particular criteria. It can contain either I or E. I denotes Inclusion. The

    criteria are included.

    E denotes Exclusion. The criteria are excluded from the result.

    LOW the data type of LOW is the same as the field type of the database table, for

    which you are using selection criteria. This acts as lower limit of the selection.

    HIGH the data type of HIGH is the same field type of the database table, for which

    you are using the selection criteria. This acts as higher limit. If you dont enter HIGH

    value then the LOW value defines a single value selection.

    Bangalore 60

  • 7/30/2019 Updated ABAP Material Document

    61/213

    OPTION is two-character field, which contains operators like EQ, GT, LT, GE, and

    LE.

    When the user enters both the values i.e., high and low then this field acts as BT

    (between). If you dont enter high value then all other operators can be Applicable.

    For each Select-Options statement system creates internal table.

    Default values for select-options

    If you want to display default values for the selection criteria before your screen is

    displayed, give default values for the selection table fields i.e., low or high.

    SELECT-OPTIONS: CARRID1 FOR SFLIGHT-CARRID DEFAULT CARRID1-LOW= LH AND CARRID1-HIGH = SQ.

    In this case selection screen is displayed with default values LH for lower range and

    SQ for higher range. User can use same values or overwrite these values with new

    values, whichever he needs.

    Parameters

    Parameter statement is used to accept input from user. PARAMETER statement is used

    when you want user to enter data and depending upon what he enters you need to take

    action. The parameter statement declares the variable and also allows system to accept

    data into that variable.

    Syntax.

    Parameters: num type I.

    Here parameter statement declares the variable and creates the selection screen on which

    user enters the data i.e., in this case num is declared of type I and user can enter any

    number. Entered value is stored in the same variable and can be used in program.Data: m type I

    Parameters: num type I

    M = num 5

    Write: / The number is, m.

    You can define default values with parameter statement for example

    Parameter: num type I default 12.

    Bangalore 61

  • 7/30/2019 Updated ABAP Material Document

    62/213

    In this case when selection screen is displayed the default value is displayed. User can

    either use same value or overwrite the value.

    Parameter of type character and length = 1, can be displayed as Checkbox and

    Radiobutton.

    Parameter: C1 as Checkbox,

    C2 as Checkbox.

    Parameter: R1 Radiobutton group g1,

    R2 Radiobutton group g1.

    When parameter is defined as Radiobutton, it needs to be attached to one group. Only

    one Radiobutton of one group can be clicked.

    Every parameter can be associated with language dependent text that is displayed on theselection screen. This can be done with the help of text elements.

    WRITE Statement

    The basic APAB/4 statement for outputting data on the screen is WRITE.

    Syntax:

    WRITE .

    This statement outpu