[go: up one dir, main page]

0% found this document useful (0 votes)
23 views216 pages

Abap 4

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 216

NIKHEEL D.

SHINDE 1
shindenikheel@gmail.com

SAP ABAP/4

1
NIKHEEL D. SHINDE 2
shindenikheel@gmail.com

SR.NO. Topic Page No.


1 ERP SAP
1.1 What is ERP 6
1.2 What is SAP
1.3 Modules in SAP 7
1.4 SAP Architecture Introduction(R/1,R/2,R/3)
1.5 CLIENT in SAP
9
1.6 SAP R/3 Logical Architecture in detail
1.7 Advantages of SAP
1.8 SAP Consultants 13
1.9 SAP Implementation phases
1.10 SAP Landscape
1.11 SAP Transport request 15
16
2 SAP ABAP
2.1 Introduction 18
2.2 ABAP Consultant Roles & Responsibilities
2.3 ABAP’er Useful T-Codes
2.4 Ticket system in support projects SAP ABAP Consultants 19
2.5 SAP & ABAP Memory 20
2.6 ABAP programming standards for Performance tuning
2.7 Data types
2.8 Operators 21
2.9 Flow control statements 23
2.10 Package creation 24
2.11 Program creation 26
2.12 String Functions 27
2.13 Message class 29
31

2
NIKHEEL D. SHINDE 3
shindenikheel@gmail.com
3 ABAP/Data Dictionary (D.Dic)
IN 3.1 Introduction
3.2 Domain
34
3.3 Data Element
35
D 3.4 Database table
 Types of table & its differentiation
 Exploring Database Tables 36
 Table creation 37
EX 3.5 Views 39
 Introduction 46
 Types of views
 Creation of different types of VIEWS
3.6 Structure
 Introduction
 Difference between tables & structure 63
 Types of structure & its differentiation
3.7 Search Help
 Introduction
 Types of Search help
74
3.8 Type Group
3.9 Lock Objects

82
83

3
NIKHEEL D. SHINDE 4
shindenikheel@gmail.com

4 Internal Table
4.1 Introduction 85
4.2 Difference between Internal table & Views
4.3 Types of Internal table & its differentiation 86
4.4 Operation in Internal table 87
5 Open SQL
5.1 Introduction 102
5.2 Types of SQL
5.3 SELECT Statements 103
5.4 Aggregate functions & Group by clause 104
5.5 Into clause
5.6 Joins(Inner & Left outer) 105
5.7 For All Entries 107
5.8 Insert, Modify, Update, Delete 108
6 Modularization Techniques
6.1 Introduction 110
6.2 Types of Modularization
7 Object Oriented ABAP
7.1 Introduction 120
7.2 Components
7.3 Events 121
7.4 Constructors 122
7.5 Interface 123
7.6 Inheritance 124
8 Reports
8.1 Introduction 126
8.2 Events 127
8.3 Types of Reports
 Classical
 Interactive 129
 ALV(Grid/List, Interactive) 130
9 Form Designing
9.1 Introduction 134
9.2 Types of Form Designing & its differentiation
9.3 SAP Script 135
 Introduction
 Components
 Function modules of SAP Script
 Driver Program
9.4 SMART-FORMS 146
 Introduction
 Components
10 Data Migration Techniques
10.1 Types of Transfer Techniques 148
10.2 Types of Data Migration
10.3 BDC(Batch Data Control) 153
 Transfer Methods
 BDCDATA Structure
 Recording procedure for BDC
 Call Transaction Program
 Session Program
4
NIKHEEL D. SHINDE 5
shindenikheel@gmail.com

10.4 LSMW(Legacy System Migration Workbench) 161


 Significance of LSMW
 Principles
 Advantages
 Functions
 Procedure
11 Module Pool Programming
11.1 Introduction of Module Pool Programming 177
12 Enhancements 180
12.1 Introduction
12.2 User Exit
12.3 Customer Exit
12.4 Difference between User Exit & Customer Exit
13 BADI 183
13.1 Introduction
13.2 Architecture
13.3 Advantages
13.4 Types of BADI
13.5 Difference between BADI & Customer Exit
14 Enhancement Framework 186
14.1 Introduction
14.2 Types of Enhancement Framework
14.3 Grouping Enhancement
14.4 Creating, Editing & Deleting Enhancement Spots
14.5 Creating, Editing & Deleting Enhancement Implementation
15 SAP CROSS Application 195
15.1 Introduction
15.2 RFC Concept
15.3 BOR Concept
15.4 BAPI Concept
15.5 COMMIT BAPI
16 ALE IDOC
16.1 Introduction 200

5
NIKHEEL D. SHINDE 6
shindenikheel@gmail.com

1. ERP SAP

6
NIKHEEL D. SHINDE 7
shindenikheel@gmail.com

1.1 What Is ERP?

ERP is an acronym for Enterprise Resource Planning, but even its full name doesn't shed much
light on what ERP is or what it does. For that, you need to take a step back and think about all of
the various processes that are essential to running a business, including inventory and order
management, accounting, human resources, customer relationship management (CRM), and
beyond. At its most basic level, ERP software integrates these various functions into one complete
system to streamline processes and information across the entire organization.

The central feature of all ERP systems is a shared database that supports multiple functions used
by different business units. In practice, this means that employees in different divisions—for
example, accounting and sales—can rely on the same information for their specific needs.

An ERP software package can help your business in many ways some of them are as follows:

 ERP helps in streamlining your Business Process and Workflows


 It helps you in better customer support and services
 You gain real time data from various departments allowing quick and powerful decision
making
 Reduce paper work, duplication of entries and Manual entries.
To summarize ERP system helps in increasing your productivity level, profits and altogether
growth of your organization.

ERP Vendors –

• SAP (more than 50% of market)


• Oracle applications
• People Soft
• JD Edwards
• BAAN
• Larson

1.2 What is SAP?


SAP Software is a ERP( Enterprise Resource Planning) solution, through which large and medium
scale companies can manage their business.SAP Software is produced by a German based company
SAP.

SAP Company: SAP Company founded in 1972 in Germany by five former employees of IBM
namely, Dietmar Hopp, Klaus Tschira, Hans-Werner Hector, Hasso Plattner, and Claus Wellenreuther
and they released standard versions called R1 and R2 in early days, and they released 3-tier
architecture R3 in 1992`s which was very successful.
7
NIKHEEL D. SHINDE 8
shindenikheel@gmail.com

In 2000 SAP released ECC (Enterprise Central Component), latest version in market is ECC 6.0 and
they are adding additions to this in the form of enhancement packs.

Why SAP?

Through SAP software a company can plan their business in different aspects like Supply Chain
Solutions, Material Management, Sales and Distribution, Finance controlling, Human Resource
planing, etc.

The total SAP Software is built using ABAP Programming Language, which is a standard
programming language developed by SAP it self, we call ABAP as 4th Generation Programming
Language (ABAP/4)

1.3 Modules in SAP


 SAP FI module: FI stands for Financial Accounting.
 SAP CO module: CO stands for Controlling.
 SAP CRM module: CRM stands for Customer Relationship Management.
 SAP HR module: HR stands for Human Resources.
 SAP MM module: MM stands for Materials Management.
 SAP PLM module: PLM stands for Product Life Cycle Management.
 SAP PM module: PM stands for Plant Maintenance.
 SAP PP module: PP stands for Production Planning.
 SAP PS module: PS stands for Project Systems.
 SAP QM module: QM stands for Quality Management.
 SAP SD module: SD stands for Sales and Distribution.
 SAP WM module: WM stands for Warehouse Management.
 SAP LO module: LO stands for Logistics General.
 SAP ABAP module: ABAP stands for Advanced Business Application Programming.
 SAP Basis module: Basis also known as Basis Admin is typically the administration of SAP.
 SAP BI module: BI stands for Business Intelligence.
 SAP XI module: SAP Exchange Infrastructure (SAP XI) enables you to implement cross-system
processes on services.
 SAP PI module: SAP Process Integration (SAP PI) is enterprise application integration
(EAI)software.

1.4 SAP Architectures


1. R/1 Architecture:

 Developed in 1972
Designed in GERMAN GUI language
Developed in C programming language
Developed for FI = Finance Module
1: 1 Tier Architecture
R: Real time system

8
NIKHEEL D. SHINDE 9
shindenikheel@gmail.com

2. R/2 Architecture:
Developed in 1980
Designed in MULTI-LAUNGUAGE & MULTI-CURRENCY
Developed in C, C++ & Semi-ABAP programming language
Developed for Basic Modules i.e. SD, MM, PP, WM, FI, CO, HR, etc.
2: 2 Tier Architecture

3. R/3 Architecture:
Developed in 1992
Developed in ABAP/4 programming language
Developed for Basic + Advance Modules i.e. CRM, SCM, HCS, SRM, MDM, PS, etc.
3: 3 Tier Architecture

9
NIKHEEL D. SHINDE 10
shindenikheel@gmail.com

1.5 What is CLIENT in SAP?


 CLIENT is the topmost hierarchy in SAP database.
 Each functional module in SAP is assigned a client.
 The objects developed by ABAP’er for each module is stored in a Package and request number
and finally saved under a client number assigned for the particular module.

1.6 SAP R/3 Logical Architecture in detail:


As name suggests SAP R/3 has three layers

 Presentation Layer
 Application Layer
 Database Layer

Presentation Layer

Presentation layer is the first layer of R/3. This is the top layer of the system. Presentation layer
presents the end user how an SAP system looks at the front end for performing transactions
(operations of end user).

This layer consists of GUI’s (Graphical User Interface), an interface which connects the system
and the end user to perform transactions. GUI’s are installed in the system to use the application.
Each and every end user system has a GUI application. If there are 100 end users in organizations,
all the end users will be accessing SAP through a GUI installed in their systems. GUI’s may be a
Window application / Java application / an HTML application. With the help of these GUI
applications, the end users operate on SAP.

10
NIKHEEL D. SHINDE 11
shindenikheel@gmail.com

Application Layer

The Application Layer is the middle layer of R/3 architecture. This layer is the heart of SAP R/3
products. This layer consists of the application. All Transactions of the end user are performed in
this layer. An application in the Application Layer consists of 5 components.

 Dispatcher
 Gateway
 Buffering
 Work Process (WP)
 Message

Component 1: Dispatcher

The Dispatcher acts as an interface between the application layer and the presentation layer. The
requests of the user from the presentation layer enter the application via dispatcher. After the
request is processed, the response to the user is given back through the dispatcher.

Component 2: Gateway

The Gateway is another type of an interface. This interface connects the application in the
application layer with the RDBMS (database) in the database layer. Here, during the process of
transaction, the request for add / delete / search / retrieval of data’s, to/ from the RDBMS flows via
the Gateway.

Component 3: Buffering

The Buffering (or a buffer) is the temporary storage area for data’s in order to perform transactions
with those data’s. Usually, data’s are stored as Tables in RDBMS. Transactions are performed in
an area called Work Process (WP). Frequently changing tables (data’s) are stored in buffer and
transactions are processed with data’s from the buffer. It does not directly process with data’s from
RDBMS. E.g., the data’s regarding Currency of nation as stored in Buffering area of the
application since the value of currency changes every day.

The transaction time for each transaction when processing via buffering is 0.2 milliseconds.
While, the transaction time for each transaction when processing directly via RDBMS is 6
milliseconds. Hence, to increase the performance, almost all transactions are processed via
buffering and not directly via RDBMS.

11
NIKHEEL D. SHINDE 12
shindenikheel@gmail.com

Component 4: Work Process (WP)

The Work Process is the actual transaction processing area in an application. Work Processes
executes the dialog steps of application programs, i.e., it actually processes the transactions. The
work process (WP) consists of 3 components.

 Dialog
 ABAP processor
 Database Interface

Dialog: Dialog is also called as Screen Processor. From a programming point of view, user
interaction is controlled by screens. A screen consists of flow logic. The screen flow logic controls
a large part of the user interaction. The R/3 Basis system contains a special language for
programming screen flow logic. The screen processor executes the screen flow logic. Via the
dispatcher, it takes over the responsibility for communication between the work process and the
GUI, calls modules in the flow logic, and ensures that the field contents are transferred from the
screen to the flow logic.

ABAP Processor: The actual processing logic of an application program is written in ABAP
SAP’s own programming language. The ABAP processor executes the processing logic of the
application program, and communicates with the database interface. The screen processor tells the
ABAP processor which module of the screen flow logic should be processed next.

Database Interface: The database interface provides the following services:

 Converts Open SQL into Native SQL of the application.


 Establishing and terminating connections between the work process and the database.
 Access to database tables.
 Access to R/3 Repository objects (ABAP programs, screens and so on).
 Access to catalog information (ABAP Dictionary).
 Controlling transactions (commit and rollback handling).
 Table buffer administration on the application server.

Open SQL statements are a subset of Standard SQL that is fully integrated in ABAP. They allow
you to access data irrespective of the database system that the R/3 installation is using. Open SQL
consists of the Data Manipulation Language (DML) part of Standard SQL; in other words, it
allows you to read (SELECT) and change (INSERT, UPDATE, DELETE) data. The tasks of the
Data Definition Language (DDL) and Data Control Language (DCL) parts of Standard SQL are
performed in the R/3 System by the ABAP Dictionary and the authorization system. These
provide a unified range of functions, irrespective of database, and also contain functions beyond
those offered by the various database systems.

12
NIKHEEL D. SHINDE 13
shindenikheel@gmail.com

Native SQL is only loosely integrated into ABAP, and allows access to all of the functions
contained in the programming interface of the respective database system. Unlike Open SQL
statements, Native SQL statements are not checked and converted, but instead are sent directly to
the database system. Programs that use Native SQL are specific to the database system for which
they were written. R/3 applications contain as little Native SQL as possible. In fact, it is only used
in a few Basis components (for example, to create or change table definitions in the ABAP
Dictionary).

Types of Work Processes

The services offered by an application server are determined by the types of its work processes.

 Dialog Work Process:

Dialog work processes deal with requests from an active user to execute dialog steps.

 Update Work Process:

Update work processes execute database update requests. Update requests are part of an SAP
LUW (Logical Unit of Work) that bundle the database operations resulting from the dialog in a
database LUW for processing in the background.

 Background Work Process:

Background work processes process programs that can be executed without user interaction
(background jobs).

 Enque Work Process:

The enque work process administers a lock table in the shared memory area. The lock table
contains the logical database locks for the R/3 System and is an important part of the SAP LUW
concept. In an R/3 System, you may only have one lock table. You may therefore also only have
one application server with enque work processes.

 Spool Work Process:

The spool work process passes sequential datasets to a printer or to optical archiving. Each
application server may contain only one spool work process. Here Spool Numbers are generated
and actions are performed according to the order of spool number.

Component 5: Message

Message is used for Internal Communication between applications in the application layer. It uses
"Idoc" to exchange information. Idoc, short for Intermediate Document, is a SAP document
format for transferring the data for a business transaction. Idoc is similar to XML in purpose, but
differs in syntax. Both serve the purpose of data exchange and automation in computer systems.

Main advantages of SAP (because of R/3 Architecture)-

• Faster between networks. Transaction time in milliseconds. Transaction failures are almost
zero.
• Transactions are very secure. Data hacking is not possible. Packet format which can be hacked
by TSR (terminate stay resident) does not exist in SAP. Uses EDI (Electronic data interface).
13
NIKHEEL D. SHINDE 14
shindenikheel@gmail.com

1.7 SAP ADVANTAGES:


• SAP can support any database at the back end.
• Platform independent.
• Supports multiple languages.
• Faster b/w networks.
• Can support any database in the backend.
• Transaction failure is very less comparing 2 other ERP packages (0.03%).
 Simultaneous processing of inputs from various users
 Automatic updating of the database
 Common Data Base
 Operational aspects, financial and management are satisfied simultaneously.
 Faster time to serve customers, external and internal.
 Easier to measure results
 Optimization of costs.

1.8 SAP Consultants


SAP is a huge software and in order to implement SAP ERP for a Organization, it needs lot of
man power, the SAP implementation is done by different type of consultants.

Functional Consultants Technical Consultants Network Administrators


Functional consultants are Technical consultants are Network Administrators are Basis
responsible for responsible for customizing SAP Consultants, they are responsible for
configuring the real world ABAP software as per customer Network management and Network
business scenarios into specifications i:e Developing related SAP configurations like server
SAP software . New SAP Business Applications, maintenance, managing network down
Ex: Configurations like Enhancing SAP Software, times, controlling network, user
Plants Configurations, Creating SAP Tables etc management etc
Business Countries
Configurations, Sales
Organizations
configuration etc

1.9 SAP Implementation Phases / ASAP Methodology


ASAP, accelerated SAP implementation methodology is a proven and successful methodology in
implementation of SAP projects.

Steps and phases involved in ASAP implementation methodology

1. Project Preparation
2. Business Blueprint
3. Realization
4. Final Preparation
5. Go Live & Support

14
NIKHEEL D. SHINDE 15
shindenikheel@gmail.com

Phase1: Project Preparation

This is the first phase on any project under ASAP methodology, this will begin building up a core
project team to go through whole implementation process.

In this phase the team goes through initial planning and preparation for SAP project
implementation, this phase includes:

 Defining project goals and objectives.


 Clarifying the scope of implementation.
 Defining project schedule, budget plan, and implementation sequence.
 Establishing the project organization and relevant committees, and assigning resources.

Phase2: Business blue print

This is the second of a project under ASAP methodology, this is the detailed formula of the
implementation of the project. The main objective of this phase is to achieve common
understanding of how the company intends to run SAP software.

The project goals and objectives will be set in this phase. This phase also involves man power,
training needs etc.

Phase3: Realization

This is the third phase in ASAP, the purpose of this phase is to implement all the business process
requirements based on blue print.

In this level, the project team should have activities as follow, unit test; integration test;
RICEF(Reports, Interfaces, Conversions, Enhancements and Forms) developments, data cleaning,
preparation, collection, validation and testing; train the trainer, such as process owner and super
users. The project should develop end user training in accordance with the end user training
strategy.

Phase4: Final Preparation

In the fourth phase in ASAP, Final Preparation, it will complete the final preparation which
include testing, end user testing, system management and cut over activities, to finalize the
readiness to go live. In addition, this step will resolve all critical open issues, on successful
completion in the live SAP system.

15
NIKHEEL D. SHINDE 16
shindenikheel@gmail.com

Phase5: Go Live & Support

The purpose of this phase is to move from a project-oriented, pre-production environment


(Development environment) to live production operation. The most important elements include
setting up production support, monitoring system transactions, and optimizing overall system
performance.

The project team will integrate new organizational chart and job profile information performance
management system. In addition, the help desk(support desk) will support end user. The important
issue after implementation is to review system processes and continuous improvement which
means the core team will design high level structure, job hierarchy, role, responsibilities and
performance metrics for post implementation support personal.

1.10 SAP Landscape


Landscape is like a server system or like a layout of the servers or some may even call it the
architecture of the servers viz. SAP is divided into three different landscape DEV, QAS and PRD.
- DEV: would have multiple clients for ex: 190- Sandbox, 100- Golden, 180 - Unit Test.
- QAS: may again have multiple clients for ex: 300- Integration Test, 700 to 710 Training.
- PRD: may have something like a 200 Production.

16
NIKHEEL D. SHINDE 17
shindenikheel@gmail.com

1.11 SAP Transport Request


 Transport Requests (TRs) – are also known as Change Requests. It is a kind of 'Container /
Collection' of changes that are made in the development system . It also records the
information regarding the type of change, purpose of transport, request category and the target
system.
 Each TR contains one or more change jobs, also known as change Tasks (minimum unit of
transportable change) . Tasks are stored inside a TR, just like multiple files are stored in some
folder. TR can be released only once all the tasks inside a TR are completed, released or
deleted.
 Change Task is actually a list of objects that are modified by a particular user. Each task can be
assigned to (and released by) only one user, however multiple users can be assigned to each
Transport Request (as it can contain multiple tasks). Tasks are not transportable by themselves,
but only as a part of TR.

Change requests are named in a standard format as: <SID>K<Number> [Not modifiable by
system administrators]

 SID – System ID


 K – Is fixed keyword/alphabet
 Number – can be anything from a range starting with 900001

Example: DEVK900030

Tasks also use the same naming convention, with 'numbers' consecutive to the number used in TR
containing them.

For Example, Tasks in the above mentioned TR Example can be named as: DEVK900031,
DEVK900032 …

17
NIKHEEL D. SHINDE 18
shindenikheel@gmail.com

2. SAP ABAP/4

18
NIKHEEL D. SHINDE 19
shindenikheel@gmail.com

2.1 Introduction
What is ABAP?

 ABAP stands for Advanced Business Programming Language, which is a standard


programming language of SAP ERP Software, entire SAP Software is built using ABAP
programming language.
 We use ABAP to customize or to enhance SAP software.
 It is High-Level programming language.
 It is appeared in 1983.
 It is combination of C, C++, SQL, JAVA, HTML, PHP, XML, .NET

2.2 SAP ABAP Consultant Roles & Responsibilities


SAP ABAP Consultants are responsible for developing SAP business applications using SAP Standard
programming language ABAP, the main roles and responsibilities of SAP ABAP Consultant are...

 SAP ABAP Consultants plays crucial role in implementation of SAP software for a
organization .
 Total SAP software is developed using ABAP, ABAP consultants are needed in every SAP
module.

Implementation Process Support Process


 Getting the business Requirement document from  Receiving tickets/issues from
functional consultant / functional analyst. business.
 Analyses the business Requirement.  Analyzing the ticket.
 Analyses the estimated time for development.  Resolving the issue in time.
 Development of Object (ABAP application).  Developer testing and
 Unit Testing by Developer. transporting.
 Releasing the object to testing environment.
 Prepare technical document of the development.

2.3 ABAP’er Useful T-Codes


 SE11: Data Dictionary.
 SE16: Data Browser.
 SE24: Global Class maintenance.
 SE37: Function Module Explorer.
 SE38: ABAP Editor and Program Development.
 SE41: Menu Painter.
 SE51: Screen Painter.
 SE71: SAPSCRIPT Layout Set.
 SE80: ABAP Development Workbench.
 SE93: Maintain Transaction Codes.
 SE21: Package Builder
 SMARTFORMS: SMARTFORM Creation
 CMOD: Create Customer Exit
 SMOD: Search Exit
 SE18: Check Exit for BADI & Enhancement Framework
 SE19: Create Exit for BADI & Enhancement Framework
19
NIKHEEL D. SHINDE 20
shindenikheel@gmail.com

2.4 Ticket system in support projects SAP ABAP Consultants


Handling tickets is called Issue Tracking system. The errors or bugs forwarded by the end user to
the support team are prioritized under three priorities High, Medium and Low. Each and every
priority as got its time limits before that we have to fix the error.

The main job of the supporting consultant is to provide assistance on line to the customer or the
organization where SAP is already implemented for which the person should be very strong in the
subject and the process which are implemented in SAP at the client side to understand, to
analyses, to actuate and to give the right solution in right time. This is the job of the support
consultant.

The issues or the tickets (problems) which are raised is taken care of on priority basis by the
support team consultants.

The work process in support projects are given below for your reference.

1. The customer or the end user logs a call through any tool or by mail (RADIX).

2. Each one of the support team is a part of support group.

3. Whenever a customer logs a call he /she have to mention to which work group (by name).

4. Once the calls came to the work group the support consultant or the team needs to send an IR
(Initial Response) to the user depending upon the priority of the calls. (Top, High, Med, Low,
None)

5. Then the error is fixed, debugged by the support consultant or the team. Then after testing
properly by generating TR (Transport Request through the basis admin)

6. Then it is informed to the end user/customer/super user about the changes which have moved to
the production server by CTS process.

These are the process. In summary, what I understand is that if any configuration or customization
is required to solve the issue, then the consultant have to work on DEV Client, then the end user
will test it in the QA client and after approval the BASIS consultant has to transport it to the
PRODUCTION client.

An example: Tickets in SD can be considered as the problems which the end user or the employee
in the company faces while working on R/3. Tickets usually occur during the implementation or
after the implementation of the project. There can be numerous problem which can occur in the
production support and a person who is working in the support has to resolve those tickets in the
limited duration, every ticket has the particular deadline alert so your responsibility is to finish it
before that deadline.

To begin with, we should give "TICKET" to you for not knowing it.

Here is an e.g. of a ticket raise:


End user is not able to
1. Create Sales order for a customer from a new plant, since shipping point determination is not
happened. (Without shipping point the document becomes INCOMPLETE and he will not be able
to proceed further like DELIVERY, BILLING).
20
NIKHEEL D. SHINDE 21
shindenikheel@gmail.com

He raises a ticket and the priority is set in one of the below:


1. Low 2. Medium 3. High.

Now you need to solve this ticket. You would analyze the problem and identify that the SP
configuration has to be done for the new plant.

You would request a transport for DEV CLIENT to BASIS. You do the change and Request one
more Transport to BASIS for QA client. The End user will test the same by creating a sales order
for the new plant and approve it.

Finally, you request a transport to move the changes to PRODUCTION. Once the change is
deployed in production the TICKET is closed. What I have given is a small example. You would
get some real issues with severity HIGH in your day-day support.

2.5 SAP & ABAP Memory


SAP Memory ABAP Memory
SAP memory is global memory, all SAP ABAP memory is local memory, all programs
GUI sessions have access. within a session can have access.
SAP memory is a memory area, which can ABAP memory is a memory area, which can be
be accessible by all SAP GUI sessions. By accessed by all ABAP programs with in internal
using SAP memory we can share data session, these data sharing can be processed by
between sessions as well as SAP programs. using EXPORT/IMPORT statements. To pass data
from a program to another program we have to fill
a memory id using EXPORT and can be imported
by using IMPORT .
The data can be exchanged by using The data can be exchanged by using
GET/SET parameters. EXPORT/IMPORT parameters.
These parameters can be set either for a The most frequent use of EXPORT/IMPORT
particular user or for a particular program parameters is to share data between programs.
using the SET PARAMETER statement.
Other ABAP programs can then retrieve the
set parameters using the GET
PARAMETER statement. The most frequent
use of SET/GET parameters is to fill screen
fields.

2.6 ABAP programming standards for Performance tuning


1. When reading data from database table, never use SELECT *, always use select with list of
fields.
2. Always specify key fields in where conditions of SELECT statements, because these will have
primary index.
3. Sometimes we may need to use non-key fields in where conditions of SELECT statements, in
that case create secondary indexes and use.
4. Never use select with corresponding in SELECT statements.
5. Always use read table with binary search and make you have sorted the internal table in
ascending order before using read table binary search.
6. Never use select joins for more than 3 tables.
7. Always use select for all entries for more than 3 tables.
21
NIKHEEL D. SHINDE 22
shindenikheel@gmail.com

8. Always check whether the parent internal table is initial or not before using for all entries.
9. Never use nested loops, instead use parallel cursor.
10. Never use select statements inside loops, instead use for all entries.

2.7 Data Types


Data types describe data objects. ABAP provides predefined data types that can be used in an
ABAP program. Apart from the predefined data types, data types can be customized either locally
in a program or globally in the SAP R/3 Repository. The following are three kinds of data types:

 Elementary types
 Complex types
 Reference types

22
NIKHEEL D. SHINDE 23
shindenikheel@gmail.com

1. Pre-defined data types: These are of two types.


A. Fixed type Data types: These are of two types
a) Numeric data types:
i. Integer i (4)
ii. Float f (8)
iii. Packed p (8)
b) Character Data types
i. Character C (1)
ii. Number Char N (1)
iii. Date D (8)
iv. Time T (6)
B. Variant type data type
a) String (character format
b) X String (Hexa Decimal Format)
2. User-defined data types:
A. Types
B. Structures
C. Data Element
3. Reference Data type:
A .Classes
B. Interface.

Data Type Initial Field Length Valid Field Initial Value Description
(in bytes) Length (in bytes)
Numeric Types
I 4 4 0 Specifies an integer
(whole number)
F 8 8 0 Represents a floating
point number
P 8 1–16 0 Specifies a
packed number
Character Types
C 1 1-65535 '..........' Denotes a text field
(alphanumeric
characters)
D 8 8 '00000000' Specifies a date field
(Format:YYYYMMDD)
N 1 1-65535 '0....0' Specifies a numeric
text field
(numeric characters)
T 6 6 '000000' Specifies a time field
(Format:HHMMSS)
Hexadecimal Types
X 1 1-65535 X'0.... 0' Specifies a hexadecimal
field

23
NIKHEEL D. SHINDE 24
shindenikheel@gmail.com

The Variable-Length Data Type

A variable-length data type is used for data objects whose length cannot be fixed, as the length
varies according to the specified data. The variable-length data type is of two types, STRING and
XSTRING

Variable Length Data Type Description


STRING Specifies a sequence of characters with variable lengths. A string
can contain any number of alphanumeric characters. The length of
the string can be calculated by multiplying the number of characters
with the length required for the internal representation of a single
character.
XSTRING Represents a string used for byte strings of a hexadecimal type. A
byte string has a variable string and can contain any number of
bytes. The length of a byte string is same as the number of bytes.

24
NIKHEEL D. SHINDE 25
shindenikheel@gmail.com

2.8Operators
Basic Arithmetic Operations

ABAP/4 supports the four basic arithmetic operations, as well as power calculation. You can
specify the following arithmetic operators in a mathematical expression:

+ Addition
- Subtraction
* Multiplication
/ Division
DIV Integer division
MOD Remainder of integer division
** Exponentiation

Comparison Operator:

Comparison Alternate True When

Forms
a1 = a2 EQ a1 equals a2
a1 <> a2 NE or >< a1 does not equal a2
a1 > a2 GT a1 is greater than a2
a1 < a2 LT a1 is less than a2
a1 > = a2 GE or => a1 is greater than or equal to a2
a1 < = a2 LE or = < a1 is less than or equal to a2
a1 between a2 and a3 N/A a1 lies between a2 and a3 (inclusive)
Not a1 between a2 and N/A a1 lies outside the range of a2 to a3 (inclusive)
a3

25
NIKHEEL D. SHINDE 26
shindenikheel@gmail.com

2.9 Flow Control Statements


Occasionally, ABAP programs use some conditions or loops to control the flow of execution of
the ABAP program. Various conditions and loops can be implemented in programs by using the
standard keywords, such as IF, CASE, DO, and WHILE.

The processing block of the ABAP program consists of several statements, some of which are:
 IF...ENDIF
 CASE...ENDCASE
 DO...ENDDO

Now, let's discuss each control statement in detail.

 The IF...ENDIF Control Statement

IF...ENDIF is a control statement used to specify one or more conditions. You can also nest the IF
control structures in an ABAP program. The following syntax is used for the IF...ENDIF
statement:
IF <condition1>.
<Statement block>.
ELSEIF <condition2>
<Statement block>.
ELSEIF <condition3>
<Statement block>.
........
ELSE.
<Statement block>.

ENDIF.

 The CASE Control Statement:

The CASE control statement is used when you need to compare two or more numbers. The syntax
of the CASE statement is:
CASE <f>.
WHEN <fij> [OR <fij> OR ....... ].
<Statement block>
WHEN <fij> [OR <fij> OR ....... ].
<Statement block>
WHEN…..
WHEN OTHERS.
<Statement block>
ENDCASE.

In the preceding syntax, the statement block following a WHEN clause is executed if the content
of the fields shown in the <f> expression is similar to one of the fields <fij>. After executing all
the conditions specified in the WHEN statement, the program continues to process the remaining
statements after the ENDCASE statement. The WHEN OTHERS clause is executed in a program
when the value of the <f> field does not match with any value specified in the <fij> fields of the
WHEN clause.
26
NIKHEEL D. SHINDE 27
shindenikheel@gmail.com

Consider the following key points while constructing the CASE... WHEN...ENDCASE statement:

If the WHEN OTHERS clause is omitted in a program and the value of the <f> field does not
match with any value specified in the <fij> fields, the program continues to process the remaining
statements after the ENDCASE statement.
No logical expressions can be used for the <f> field.

The field strings used in the CASE...WHEN...ENDCASE statement is treated as type C variables.

Note:
There is a difference between the CASE and IF...ELSE control statement. In the IF...ELSE
statement, you can use the complex expression in the <conditions> clause, but in the CASE
statement, you can only give a single value in the <f> field.

 Looping:

A statement block is executed repeatedly in a program by using loops in the program. The loops
are categorized into two types:
1. Unconditional loops by using the DO statement.
2. Conditional loops by using the WHILE statement

 Unconditional Loops Using the DO Statement:

Unconditional loops repeatedly execute several statements without specifying any condition. The
DO statement implements unconditional loops by executing a set of statements (statement block)
several times unconditionally. The syntax of the DO statement is:
DO [n TIMES] [VARYING <f> FROM <fi> NEXT <f2>].
<statement block>

ENDDO.

 Conditional Loops Using the WHILE Statement:

Conditional loops execute several statements only after certain conditions are fulfilled. This can be
accomplished with the WHILE statement. The WHILE statement allows you to execute a block of
statements so long as the condition mentioned in the WHILE statement evaluates to true. The
syntax of the WHILE statement is:
WHILE <condition> [VARY <f> FROM <f1> NEXT <f2>]
[statement_block]

ENDWHILE.

27
NIKHEEL D. SHINDE 28
shindenikheel@gmail.com

2.10 Package Creation


Package is a naming convention used from version 4.7 onwards. In earlier versions it is called
as Development class.

Tcode: -> SE21 for Package builder.

Click On CREATE button. Give any SHORT DESCRIPTION

Click On CREATE button

Click ENTER button

28
NIKHEEL D. SHINDE 29
shindenikheel@gmail.com

2.11 Program Creation


Some Rules for using ABAP Editor:

 ABAP is not case sensitive, but it is space sensitive.


 Specify program name starting with Z or Y.
 In ABAP, variables, operators & values must be specified with at least one SPACE.
 Every ABAP statement must end with a period ‘.’.
 Messages in ABAP must be enclosed with in single quotes ‘’.
 F8 is short cut to execute ABAP programs.
 * are used to comment characters or line in ABAP.
For multiple line comment use (ctrl+ <) for uncomment (ctrl+ >).
 “ are used to comment partially .
They are used to embed programmers comments in program and play a vital role in creation of
program.

Go to SE38 T-code. Give program name starts with Y/Z , then click on CREATE

29
NIKHEEL D. SHINDE 30
shindenikheel@gmail.com

Given any suitable TITLE for program, select EXECUTABLE TYPE of program & ENTER.

Give created package name & ENTER. ENTER.

Write a required code & ACTIVATE (Ctrl+F3) the program. Then Execute Program (F8)

Execute Program (F8)

30
NIKHEEL D. SHINDE 31
shindenikheel@gmail.com

2.12 String Functions

1. SPLIT - This function is used to split the given string value based an any
separator and save in separate string variables.

eg. code:

DATA STR(30) VALUE 'SAP IS AN ERP'.


DATA: S1(5), S2(5), S3(5), S4(5).
SPLIT STR AT ' ' INTO S1 S2 S3 S4.
43
WRITE :/ S1, / S2, / S3, / S4.

2. SEARCH - This string function is used to search for the specified value in a
given string.

eg. code:
DATA STR(30) VALUE 'SAP IS AN ERP'.
DATA S1(3) VALUE 'AN'.
SEARCH STR FOR S1.
WRITE :/ SY-FDPOS.

sy-fdpos is the system variable used to hold the position of an alphabet in


the string.

3. CONCATENATE - This string function is used to add the different character


type variables into one string.

eg. code:

DATA STR(30).
DATA: S1(5) VALUE 'INDIA', S2(5) VALUE 'IS', S3(5) VALUE 'GREAT'.
CONCATENATE S1 S2 S3 INTO STR SEPARATED BY ' '.
WRITE :/ STR.

31
NIKHEEL D. SHINDE 32
shindenikheel@gmail.com

4. SHIFT - This string function is used to move the string to the specified
position (LEFT, RIGHT, CIRCULAR) based on the number of places specified.

eg. code:

DATA STR(20) VALUE 'ABAP IS IN SAP'.


SHIFT STR BY 5 PLACES.
WRITE STR COLOR 5.

DATA STR(20) VALUE 'ABAP IS IN SAP'.


SHIFT STR RIGHT BY 5 PLACES.
WRITE STR COLOR 5.

DATA STR(20) VALUE 'ABAP IS IN SAP'.


SHIFT STR CIRCULAR BY 5 PLACES.
WRITE STR COLOR 5.

5. TRANSLATE - This string function is used to change the case of the given
string value.
44

eg. code:

DATA STR(10) VALUE 'CHENNAI'.


TRANSLATE STR TO LOWER CASE.
WRITE STR.

6. CONDENSE - This string function is used to remove the blank spaces in the
given string.

eg. code:

data str(30) value ' INDIA IS GREAT'.


CONDENSE STR.
WRITE STR.

7. REPLACE - This string function is used to replace the given string with
specified string value.

eg. code:

data str(30) value 'INDIA IS GREAT'.


DATA S1(10) VALUE 'WRITE'.
REPLACE 'IS' IN STR WITH S1.
WRITE STR.

8. STRLEN - This string function is used to identify the length of the given
string.

Eg. code:
32
NIKHEEL D. SHINDE 33
shindenikheel@gmail.com

data str(30) value 'INDIA IS GREAT'.


data len type i.
len = STRLEN( STR ).
write len.

2.13 Message Class


Message Classes are container of user-defined messages. We can create our own messages to be
displayed in the screen and we can create these messages in a message pool inside the message
class.
SE91 is the T-code to create a message class.
The created messages can be called from programs using the statement 'MESSAGE'.

SYNTAX:
MESSAGE <type_of_message><message id>(message_class).

TYPES OF MESSAGES:
S - Status message.
I - Information message.
E - Error message.
W - Warning message.
A - Abort message.
T - Terminate message.

You can create up to 1000 messages in a single message class. The message id ranges from 0 -
999.

Creation of Message Class:


Give MESSAGE CLASS name starts with Y/Z. Click On CREATE button

33
NIKHEEL D. SHINDE 34
shindenikheel@gmail.com

Give SHOTR TEXT, then SAVE (Ctrl+S) & Click on MESSAGE tab

Enter required message & SAVE (Ctrl+S).

34
NIKHEEL D. SHINDE 35
shindenikheel@gmail.com

3. ABAP/DATA
DICTIONARY

35
NIKHEEL D. SHINDE 36
shindenikheel@gmail.com

3.1 Data/ ABAP Dictionary


SAP Data Dictionary is a central repository for the development of Objects, SAP Data Dictionary
is used to create and maintain meta data ( data definitions ) . T-Code for Data Dictionary is SE11.

SQL Can be divided into two parts

 DML -- Data Manipulation Language


 DDL -- Data Definition Language

Where DML consists of SELECT, INSERT, UPDATE, MODIFY, DELETE etc, this will be
handled by ABAP Programs and DDL consists of commands like CREATE TABLE, DROP
TABLE, ALTER TABLE, CREATE INDEX etc, this will be handled by Data Dictionary, hence
Data Dictionary is the central repository for the development of objects.

ABAP Dictionary Description


Repository Object
Domain Describes the technical attributes of a field, such as the data type of the
field or a fixed range of values accepted by the field.
Data Type Creates user-defined data types, such as data elements, structures, and
tables.
Type Group Creates a group of data types in ABAP Dictionary.
Database Table Helps design tables. Note that the name of the table should begin with
either the letter Y or Z, and its length can be up to 16 characters,
including Y and Z.
View Retrieves data from database tables. A view acts as a virtual table
because it does not store the data physically.
Search Help Defines input help (F4 helps) for the fields of a database table. Input help
provides a set of valid values that you can enter for a field.
Lock Object Synchronizes simultaneous access of the same set of data records by
multiple users.

3.2 Domain
A domain is used to define a data type, length, and value range for a table field. The fields of a
table and the fields of a structure that uses a domain automatically get the value range as defined
in the domain. The relationship between the field and the domain is defined by the data element of
the field. If you make any changes in a domain, the attributes of the fields related to that domain
change accordingly.

36
NIKHEEL D. SHINDE 37
shindenikheel@gmail.com

3.3 Data Element


Data elements describe individual fields of a table in a database and are used to specify the types
of columns in the database. The following are the two different kinds of data elements:

Elementary types—Refer to data types that have semantic attributes, such as built-in data type,
length, and number of decimal places. These data types can be assigned to a data element in either
of the following ways:

o Assigning a predefined ABAP Dictionary type— Specifies that the data element can be
assigned with the predefined ABAP Dictionary types, such as CHAR and NUMC. Apart from this,
you can also assign the length to the selected data type.

o Assigning a domain— Specifies that the data element being created inherits the technical
characteristics related to the elementary types from a predefined domain. You can use a domain
with any number of data elements.

Reference types—Refer to single fields that contain references to global classes and interfaces
from the ABAP class library.

3.4 Database Table


In ABAP Dictionary, you can create three types of tables with different characteristics:
1. Transparent tables
2. Pooled tables
3. Cluster tables

1. Transparent Tables:
A transparent table forms a one-to-one relationship with the table definition in the database.
Transparent tables are used to hold the application data, which represents master data or
transaction data used by an application. An example of master data is the table of vendors (also
called vendor master data) or the table of customers (also called customer data). An example of
transaction data is an order placed by a customer or an order placed with a vendor.

37
NIKHEEL D. SHINDE 38
shindenikheel@gmail.com

2. Pooled Tables:
A pooled table in ABAP Dictionary forms a many-to-one relationship with the table definition in
the SAP database. It means that for a single table defined in the database, there are many tables in
ABAP Dictionary. The names of the tables in ABAP Dictionary must differ from those of the
tables stored in the database.
All pooled tables are stored in the SAP database in a single table, called a table pool, which is a
database table with a special structure that can store the data of multiple pooled tables.
The table pool definition consists of two key fields (Tabname and Varkey) and a long argument
field (Vardata).

Field Data Type Meaning


Tabname CHAR(10) Holds the name of a pooled table.
Varkey CHAR (n) Stores the entries of the key fields of a pooled table as
a string. The maximum length of the string is specified by
the n variable.
Dataln INT2(5) Stores the length of a string in Vardata.
Vardata RAW RAM(n) Holds the entries from all the data fields of a pooled table
as a string, where the maximum length of the string is determined
by the database system being used.

The length of the name of a pooled table must not exceed 10 characters. Varkey is a character
field, so all the key fields of a pooled table must have character data types, such as CHAR,
NUMC, and CLNT. The total length of all the key fields or all the data fields of pooled tables
must not exceed the length assigned to the Vardata or Varkey field.

3. Cluster Tables:
Similar to a pooled table, a cluster table also forms many-to-one relationships with table
definitions in the SAP database. Cluster tables are stored in a single table in the SAP database,
called the table cluster. Cluster tables are used when the constituent tables have a common primary
key. The data from these common primary key fields can be accessed simultaneously. The data
contained in the rows that have the common primary key can be combined into a single row in the
table cluster.

3.4.1 Difference between Transparent, Pool & Cluster table

Transparent Tables Pool Tables Cluster Tables


Contain a single table. Used to They are used to hold a large They are used to hold data from
store master data number of very small tables a few numbers of large tables.
(stores system data). (stores system data).
It has a one-to-one relationship It has a many-to-one It has a many-to-one
with a table in the database. relationship with a table in the relationship with table in the
database. database.
For each transparent table there is It is stored with other pooled Many cluster tables are stored
one associated table in the tables in a single table called in a single table in the database
database. table pool in the database. called a table cluster.
The database table has the same The database table has different The database table has different
name, same number of fields and name, different number of name, different number of
the fields have the same names. fields and fields have different fields and fields have different
names. names.
There is only a single table. Table pools contain more tables Contains fewer tables than table
than table clusters. pools.
Secondary indexes can be Secondary indexes cannot be Secondary indexes cannot be
created. created. created.
38
NIKHEEL D. SHINDE 39
shindenikheel@gmail.com

3.4.2 Exploring Database table

In ABAP Dictionary, tables can be defined independent of the database. When a table is activated
in ABAP Dictionary, similar copy (that is, definition) of its fields is created in the database as
well. In other words, the tables defined in ABAP Dictionary are translated automatically into the
format that is compatible with the database because the definition of the table depends on the
database used by the SAP system.
In ABAP Dictionary, a table definition consists of the following components:
Fields— Store information.

Foreign keys— Define the relationships between tables.

Technical settings— Specify the settings of the table, such as data class and size category.

Indexes— Helps retrieve the rows within a table.

Types of Table Fields:


A table consists of many fields, and each field contains many elements.

Elements Description
Field name Represents the name given to a field, which can contain a maximum of 16
characters. The field name may be composed of digits, letters, and
underscores; however, it must begin with a letter.
Key flag Determines whether or not a field belongs to a key field.
Field type Assigns a data type to a field.
Field length Represents the number of characters that can be entered in a field.
Decimal places Defines the number of digits permissible after the decimal point. This
element is used only for numeric data types.
Short text Explains the meaning of the corresponding field.

There are two types of table fields:

1. Currency Field:
The currency field is composed of two subfields: the currency field and the currency key
field. The field that holds the numeric amount is known as the currency field, and the one that
holds the currency type is known as the currency key field.
For instance, if you need to store the value 1000 rupees, 1000 is stored in the currency field
and rupees is stored in the currency key field. The data type of the currency field must be CURR
and must be linked to a currency key field of the CUKY data type holding a currency key, such
as USD (US dollars), CAD (Canadian dollars), or ITL (Italian lira). The currency key field acts
as the reference field for the currency field.

2. Quantity Field:
The quantity field contains a numeric value for a measurement such as length, temperature,
weight, or current. These numeric measurements are supported by the units of measure field,
such as inches, degree Celsius, kilograms, or kilovolts. The quantity fields have QUAN as the
data type and must be linked to a reference field that has a UNIT data type.

39
NIKHEEL D. SHINDE 40
shindenikheel@gmail.com

Technical Settings of a Table:


You can define technical settings for a table while declaring it.

Data Parameters Description


Data Class Defines the physical area (that is, table space) of the SAP database in
which a table must be created.
Size category Defines the size of a table based on the number of records that can be
entered in the table.
Buffering permission Defines whether or not a table can be buffered.
Buffering type Defines the buffering type for a table. It can be full, single-record, or
generic.
Logging Defines whether thDeecfihnaensgw eshemthaedre tthoetchheaenngterisem
s oafdea tabtlheeshould be
logged. entries of a table should be logged. If
If logging is switclhoegdgionng, aisnsywcihtcahnegde omna,daentyocahatanbglee mreacdoerd is recorded
in a log table. to a table record is recorded in a log
table.

Buffering Type Description


Full buffering Specifies that all the records of the table are loaded into the buffer when
one record of the table is accessed.
Generic buffering Specifies that when a record of the table is accessed, all the records having
this record in the generic key fields (part of the table key that is left-
justified, identified by specifying a number of key fields) are loaded into the
buffer.
Single-record Specifies that only the accessed records of a table are loaded into the buffer.
buffering

Database Table

 Relating Tables by Using Foreign Keys:


Foreign keys are used to establish relationships between various tables in ABAP Dictionary. You
can create value checks for input fields with the help of foreign keys. A foreign key links two
tables by assigning the foreign key fields of one table to the primary key fields of another table.

Definition: Is a Field in one Table that is connected to another table via Foreign Key relationship
and the purpose is 10 validate the data being entered in one Table (Foreign Key Table) with a
valid set of values from another table (Check Table).

Technical Requirements to create a Foreign Key:-


a) The Domain names of the field in the Foreign Key table and for the field in the Check table
should be same.
b) The field in the check table should be Primary Key.

Table Fields Creation Rules:


1. Give field name in simple character format without space. We can also use number &
underscore sign ‘_’ for indicating space Special symbols & space is not allowed.
2. Create at least 1 key field in the table, which declares initially.
3. Do not assign INT  Integer data type in the case of key field. Use NUMC  Numeric
character data type.
40
NIKHEEL D. SHINDE 41
shindenikheel@gmail.com

4. In 1 table we can create maximum 16 key fields & 233 non-key fields i.e. total 249 field in 1
table.
5. In the case of key field always create new DATA ELEMENT & DOMAIN, but not in case
of FOREIGN KEY field in another table.

3.4.2 Database table Creation

Select DATABASE TABLE option. Give table name starts with Y/Z. Click On CREATE button

Select Delivery Class: A & Data Browser/Table View Maint: X Display/Maintenance Allowed

SAVE(Ctrl+S).

41
NIKHEEL D. SHINDE 42
shindenikheel@gmail.com

Select Appropriate Package then SAVE & ENTER.

Click & Open FIELDS tab. Create number of FIELDS as per requirement, using field creation
rules.

After giving DATA ELEMENT name, double click on that given name.

ENTER 3 times for given 3 windows as below:

42
NIKHEEL D. SHINDE 43
shindenikheel@gmail.com

Give suitable name in SHORT DESCRIPTION field which became a FIELD NAME of that
TABLE.

Copy DATA ELEMENT name which starts with Y/Z & paste into DOMAIN filed or give any name
which starts with Y/Z.

Click on FIELDS LABEL tab, copy SHORT DESCRIPTION and past into all 4 fields of field label.

Click on DATA TYPE TAB, Double click on given domain name which starts with Y/Z & ENTER
3 times for below windows:

ENTER

43
NIKHEEL D. SHINDE 44
shindenikheel@gmail.com

Give any SHORT DISCRIPTION. Assign data type from given list which is suaitble for table field
(F4), with suaitble length for field in NO. CHARACTER field.

SAVE (Ctrl+S) & ACTIVATE (Ctrl+F3). ENTER, then BACK (F3).

SAVE (Ctrl+S) & ACTIVATE (Ctrl+F3) Data Element & BACK (F3) to field creation screen.

44
NIKHEEL D. SHINDE 45
shindenikheel@gmail.com

After creation of required fields click on TECHNICAL SETTING button.

Set DATA CLASS = APPL0 & SIZE CATEGORY = 0, then SAVE(Ctrl+S) & BACK(F3).

In Menu Bar click on EXTRASENHANCEMENT CATEGORYENTER.

45
NIKHEEL D. SHINDE 46
shindenikheel@gmail.com

Select 1st or 2nd option

SAVE(Ctrl+S) & ACTIVATE(Ctrl+F3) table. ENTER.

In Menu Bar click on UTILITIES(M)TABLE CONTENTSCREATE for creating


records ni table.

Feed the values in given field & SAVE(Ctrl+S). For creating new record click on RESET button &
BACK(F3).

46
NIKHEEL D. SHINDE 47
shindenikheel@gmail.com

In Menu Bar click on UTILITIES(M)TABLE CONTENTSDISPLAY for display records


oftable

Press F8 for record execution.

47
NIKHEEL D. SHINDE 48
shindenikheel@gmail.com

3.5 Views
• View is a data dictionary object.
• It exists logically inside the data dictionary.
• It is used to fetch data’s from more than one database table.
• In views, we specify the tables and SAP will automatically generate a join condition code in
the background.

Types of Views:
 Database view
 Projection view
 Maintenance view
 Help view

Database View:
• Database views are implement an inner join, that is, only records of the primary table (selected
via the join operation) for which the corresponding records of the secondary tables also exist
are fetched.
• In database views, the join conditions can be formulated using equality relationships between
any base fields.
• Data about an application object is often distributed on several database tables. A database
view provides an application-specific view on such distributed data.
• Selection with a database view is generally faster than access to individual tables.
• Since a database view is implemented in the database, a database view may only contain
transparent tables
• We can use this view in SE38 code & creation of SEARCH HELP.

Creation of Database view:

Select VIEW option give name starts with y/z click on CREATE button, then select DATABASE
VIEW option & ENTER.

48
NIKHEEL D. SHINDE 49
shindenikheel@gmail.com

Give any suitable SHORT DECRIPTION & give that TABLE NAME for which we have to create
DATABASE VIEW& also having PREIMARY KEYFOREIGN KEY relationship.

Click on RELATIONSHIP button & select required table name with suitable key field relationship
& ENTER.

Click on VIEW FIELDS tab.

49
NIKHEEL D. SHINDE 50
shindenikheel@gmail.com

Click on TABLE FIELDS button, double click on any 1 table name.

Select required fields from 1st table for DATABASE VIEW & ENTER.

Again click on TABLE FIELDS button, double click on any 2nd table name.

Select required fields from 2nd table for DATABASE VIEW & ENTER.

50
NIKHEEL D. SHINDE 51
shindenikheel@gmail.com

SAVE(Ctrl+S)& ACTIVATE(Ctrl+F3) DATABASE VIEW.

In Menu Bar click on UTILITIES(M)CONTENTS(H).

51
NIKHEEL D. SHINDE 52
shindenikheel@gmail.com

Press F8.

Projection View:
• A projection view can draw upon only one table. Selection conditions cannot be specified for
projection views. Projection views are used to suppress or mask certain fields in a table
(projection), thus minimizing the number of interfaces.
• There is no corresponding object in the database for a projection view. The R/3 System maps
the access to a projection view to the corresponding access to its base table. You can also
access pooled tables and cluster tables with a projection view.
• The maintenance status of the view controls how the data of the table can be accessed with the
projection view.
• We can use this view in SE38 code & creation of SEARCH HELP.

Creation of PROJECTION VIEW:

Select VIEW option give name starts with y/z click on CREATE button, then select PROJECTION
VIEW option & ENTER.

52
NIKHEEL D. SHINDE 53
shindenikheel@gmail.com

Give any suitable SHORT DESCRIPTION. Give that table name in BASIS TABLE field for which
we have to create PROJECTION VIEW. Click on TABLE FIELDS button for require field
selection.

Select required fields from given list for PROJECTION VIEW & ENTER.

53
NIKHEEL D. SHINDE 54
shindenikheel@gmail.com

SAVE(Ctrl+S)& ACTIVATE(Ctrl+F3) PROJECTION VIEW.

In Menu Bar click on UTILITIES(M)CONTENTS(H).

54
NIKHEEL D. SHINDE 55
shindenikheel@gmail.com

Press F8.

55
NIKHEEL D. SHINDE 56
shindenikheel@gmail.com

Maintenance Views:
• Maintenance views enable a business-oriented approach to looking at data, while at the same
time, making it possible to maintain the data involved (INSERT, UPDATE, DELETE).
• 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 view and then distributed to the
underlying tables by the system.
• All the tables in a maintenance view must be linked with foreign keys, that is the outer join
conditions for maintenance views are always derived from the foreign key cannot directly
enter the join conditions as for database views.
• A standardized table maintenance transaction is provided (SM30), permitting you to maintain
the data from the base tables of a maintenance view together.

Creation of Maintenance View:


Select VIEW option give name starts with y/z click on CREATE button, then select
MAINTENANCE VIEW option & ENTER.

Give any suitable SHORT DECRIPTION & give that TABLE NAME for which we have to create
DATABASE VIEW& also having PREIMARY KEYFOREIGN KEY relationship.

56
NIKHEEL D. SHINDE 57
shindenikheel@gmail.com

Click on RELATIONSHIP button & select required table name with suitable key field relationship
& ENTER.

Click on VIEW FIELDS tab.

Click on TABLE FIELDS button, double click on any 1 table name.

Select required fields from 1st table for DATABASE VIEW & ENTER.

57
NIKHEEL D. SHINDE 58
shindenikheel@gmail.com

Again click on TABLE FIELDS button, double click on any 2nd table name.

Select required fields from 2nd table for DATABASE VIEW & ENTER.

SAVE(Ctrl+S)& ACTIVATE(Ctrl+F3) MAINTAINANCE VIEW.

58
NIKHEEL D. SHINDE 59
shindenikheel@gmail.com

In Menu Bar click on UTILITIES(M)TABLE MAINTAINANCE GENRATOR

Set AUTHORIZATION GROUP = &NC& and in FUNCTION GROUP field give same name of
Table/View name which starts with Y/Z. Select ONE STEP or TWO STEP option. Click on FIND
SCR NUMBER(S) button, then enter & press F6(Creation of TMG).

59
NIKHEEL D. SHINDE 60
shindenikheel@gmail.com

Back to table/view main creation screen. In Menu Bar click on UTILITIES(M)CONTENTS(H)

60
NIKHEEL D. SHINDE 61
shindenikheel@gmail.com

Click on NEW ENTRIES button for new record creation through maintenance view which reflects
in table

Help Views:
• Help views are used to output additional information when the online help system is called.
• When the F4 button is pressed for a screen field, a check is first made on whether a match code
is defined for this field. If this is not the case, the help view is displayed in which the check
table of the field is the primary table. Thus, for each table no more than one help view can be
created, that is, a table can only be primary table in at most one help view.
• If you need a view with outer join for the data selection, you have to use a help view as
selection method.
• All the tables included in a help view must be linked with foreign keys. Only foreign keys that
have certain attributes can be used here. The first table to be inserted in the help view is called
the primary table of the help view. The tables added to this primary table with foreign keys are
called secondary tables.

Creation of Help View:

Select VIEW option give name starts with y/z click on CREATE button, then select Help VIEW
option & ENTER.

61
NIKHEEL D. SHINDE 62
shindenikheel@gmail.com

Give any suitable SHORT DECRIPTION & give that TABLE NAME for which we have to create
HELP VIEW& also having PREIMARY KEYFOREIGN KEY relationship.

Click on RELATIONSHIP button & select required table name with suitable key field relationship
& ENTER.

62
NIKHEEL D. SHINDE 63
shindenikheel@gmail.com

Click on VIEW FIELDS tab. Click on TABLE FIELDS button, double click on any 1 table name.

Select required fields from 1st table for HELP VIEW & ENTER.

Again click on TABLE FIELDS button, double click on any 2nd table name.

Select required fields from 2nd table for DATABASE VIEW & ENTER.

63
NIKHEEL D. SHINDE 64
shindenikheel@gmail.com

SAVE(Ctrl+S)& ACTIVATE(Ctrl+F3) DATABASE VIEW.

After successful activation of HELP VIEW, use it in help view. There is no direct display of HELP
VIEW.

64
NIKHEEL D. SHINDE 65
shindenikheel@gmail.com

3.6 Structures
• A structure is defined like a table in the ABAP Dictionary and can then be accessed from
within ABAP programs.
• Contain data temporarily during program runtime.
• The same data elements and domains can be used in structures as in tables.
• Table and structure have lot of differences in the sense of behavior and properties, the below
are the main differences between table and structure in data dictionary.

Table and Structure Difference

Table Structure
Table can store data physically and Structure cannot store data physically; it can hold
permanently. data at run time only.
Table have primary key. Structure doesn’t have any primary key.
Table have technical settings (data class, size Structure doesn’t have any technical attributes and
category etc), maintenance attributes (Display maintenance attributes.
maintenance restrictions).
Table has primary and secondary indexes. Structures don’t have primary and secondary indexes.

Types of Structure:

Sr. APPEND INCLUDE


No.
1. It define within existing SAP It define outside of table, i.e. global declaration
STANDARD table or CUSTOMIZE Which is reusable.
Table, i.e local declaration which is
not reusable.
2. In 1 table we can attach maximum 19 In 1 table we can attach maximum 9 include
Append
3. Always attach in the last of all the fields Can be attach in between any 2 fields
4. Field name have to be starts with yy/zz. In this case it’s not necessary.
5. Useful for enhancement. Not useful for enhancement.

1. Include Structure:

• In addition to listing the individual fields, you can also include the fields of another structure in
tables and structures ,Individual fields and includes can be mixed as required.
• When an include is changed, all the tables and structures that include it are automatically
adjusted.
• Only flat structures can be included. In a flat structure, every field either refers to a data
element or is directly assigned a data type, length and possibly decimal places.
• Only structures may be included in a table. Tables, structures and views may be included in a
structure.

65
NIKHEEL D. SHINDE 66
shindenikheel@gmail.com

Creation of Include structure:

Select DATA TYPE option give name starts with y/z click on CREATE button, then select
STRUCTURE option & ENTER.

Create required FIELDS with regarding DATA ELEMENT & DOMAIN as per the process in
table field creation.

In Menu Bar click on EXTRASENHANCEMENT CATEGORY Select 1st or 2nd option.

Then SAVE(Ctrl+S)& ACTIVATE(Ctrl+F3) INCLUDE STRUCTURE.

66
NIKHEEL D. SHINDE 67
shindenikheel@gmail.com

BACK(F3) to initial screen of SE11Select DATABASE TABEL option, give that table name in
which we have to attach created INCLUDE STRUCTURE & click on CHANGE button.

Put the cursor on that field where we want to attach INCLUDE STRUCTURE.

67
NIKHEEL D. SHINDE 68
shindenikheel@gmail.com

In Menu Bar click on EDITINCLUDEINSERT.

In STRUCTURE field, give created & activated INCLUDE STRUCTURE name, then ENTER.

SAVE(Ctrl+S)& ACTIVATE(Ctrl+F3) TABLE.

68
NIKHEEL D. SHINDE 69
shindenikheel@gmail.com

In Menu Bar click on UTILITIES(M)TABLE CONTENTCREATE ENTRIES.

Insert required data with newly created field using INCLUDE STRUCTURE.

In Menu Bar click on UTILITIES(M)TABLE CONTENTDISPLAY, then press F8.

69
NIKHEEL D. SHINDE 70
shindenikheel@gmail.com

To change existing data select 1 data, in menu bar TABLE ENTRYCHANGE.

Edit or change data, then SAVE(Ctrl+S).

70
NIKHEEL D. SHINDE 71
shindenikheel@gmail.com

2. Append Structure:

 Append structures are used for enhancements that are not included in the standard. This
includes special developments, country versions and adding customer fields to any tables or
structures.
 An append structure is a structure that is assigned to exactly one table or structure. There can
be more than one append structure for a table or structure.
 When a table or structure is activated, all the append structures of the table are searched and
the fields of these append structures are added to the table or structure.
 If an append structure is created or changed, the table or structure assigned to it is also adjusted
to these changes when the append structure is activated.

Creation of Append Structure:


Select DATABASE TABLE option, then give that table name (standard/customize) in which we
have to create new fields & click on DISPLAY button.

Click on APPEND STRUCTURE button, then ENTER or select CREATE button icon.

71
NIKHEEL D. SHINDE 72
shindenikheel@gmail.com

Give APPEND STRUCTURE name starts with y/z & ENTER.

Create fields as per requirement with regarding DATA ELEMENT & DOMAIN.

In Menu Bar click on EXTRASENHANCEMENT CATEGORY Select 1st or 2nd option.

Then SAVE(Ctrl+S)& ACTIVATE(Ctrl+F3) APPEND STRUCTURE.

72
NIKHEEL D. SHINDE 73
shindenikheel@gmail.com

BACK(F3) to the table field creation screen.

In Menu Bar click on UTILITIES(M)TABLE CONTENTCREATE ENTRIES.

Insert required data with newly created field using INCLUDE STRUCTURE.

73
NIKHEEL D. SHINDE 74
shindenikheel@gmail.com

In Menu Bar click on UTILITIES(M)TABLE CONTENTDISPLAY.

Press F8.

74
NIKHEEL D. SHINDE 75
shindenikheel@gmail.com

To change existing data select 1 data, in menu bar TABLE ENTRYCHANGE.

Edit or change data, then SAVE(Ctrl+S).

75
NIKHEEL D. SHINDE 76
shindenikheel@gmail.com

3.7 Search Help


Search Helps, another repository object of ABAP Dictionary, are used to display all the possible
values for a field in the form of a list. This list is also known as a hit list. You can select the values
that are to be entered in the fields from this hit list. The following are the three types of Search
Help objects provided by ABAP Dictionary:
• Elementary Search Help
• Collective Search Help

Elementary Search Help:


The elementary Search Help is used to define an input help. This input help allows you to perform
the following functions:
• Defining the source from where the data displayed in the hit list is retrieved (the selection
method)
• Defining the Search Help parameters; that is, information related to the value selection
• Defining the dialog steps to be executed in the input help

The data in a hit list can be retrieved from a single database table, multiple tables, or a client-
specific table.
The interface of Search Help defines the context data that can be used in the input help and the
data that can be returned to the input template. This interface consists of parameters that define the
fields of the selection method.

Creation of Elementary Search Help:

Select SEARCH HELP option, give name starts with y/z then click on CREATE button.

Select ENEMENTARY SEARCH HELP option & ENTER.

76
NIKHEEL D. SHINDE 77
shindenikheel@gmail.com

Give any suitable SHORT DECRIPTION & give that TABLE/VIEW


NAME(PROJECTION/DATABASE/MAINTANENCE) in SELECTION METHOD field for which
we have to create ENEMENTARY SEARCH HELP.

Put cursor on SEARCH HELP PARAMETER column then press F4 button. Select 1-by-1 required
fields from given list. Tick mark on IMP & EMP option. Give LPOS & SPOS in numeric format
as per total number of has been taken in SEARCH HELP PARAMETER COLUMN.

SAVE(Ctrl+S)& ACTIVATE(Ctrl+F3) ELEMENTARY SEARCH HELP.

77
NIKHEEL D. SHINDE 78
shindenikheel@gmail.com

Collective Search Help:

 The collective Search Help is a combination of several elementary Search Helps.


 This Search Help is used to define alternative Search Help paths.
 A collective Search Help is a collection of several elementary Search Helps; therefore, you can
transfer the values between various elementary Search Helps and the input templates by using
the collective Search Help in the input help.
 Consequently, a collective Search Help also has an interface to transfer the values of the
associated fields.

Creation of Collective Search Help:

Select SEARCH HELP option, give name starts with y/z then click on CREATE button. Select
ENEMENTARY SEARCH HELP option & ENTER.

78
NIKHEEL D. SHINDE 79
shindenikheel@gmail.com

Give any suitable SHORT DECRIPTION, then click on INCLUDED SEARCH HELPS tab. List
out all ELEMENTARY SEARCH HELP name which we created using 1 table.

Click on DEFINATION tab & list out those fields name with its regarding DATA ELEMENT
which are exist in, listed CREATED & ACTIVATED ELEMENTARY SEARCH HELP in
INCLUDE SEARCH HELP tab. Also tick mark on IMP & EXP option.

79
NIKHEEL D. SHINDE 80
shindenikheel@gmail.com

Again come to INCLUDE SEARCH HELPS tab, put the cursor on 1st ELEMENTARY SEARCH
HELP & click on PARAM. ASSIGN button.

Press ENTER/YES.

Put cursor in REFRENCE PARAMETER’S 1st field press F4 button and assign suitable field from
given list. Perform same procedure for another ELEMENTARY SEARCH HELP and assign
reference parameter suitable field.

SAVE(Ctrl+S)& ACTIVATE(Ctrl+F3) COLLECTIVE SEARCH HELP.

80
NIKHEEL D. SHINDE 81
shindenikheel@gmail.com

Applying ELEMENTARY/COLLECTIVE Search Help:

Rules:
1. If we want to attach search help on 1 or more field, those field should be exist in search help.
2. At the time of table field search help creation, tick mark on EXP option is mandatory.

Procedure:
In SE11 select DATABASE TABLE option & give that activated table name, on which fields we
have to apply search help option.

81
NIKHEEL D. SHINDE 82
shindenikheel@gmail.com

According to search help applying rule, put cursor on that field on which we have to apply search
help. Click on SEARCH HELP button.

Give created & activated SEARCH HELP NAME.

Press ENTER.

SAVE(Ctrl+S)& ACTIVATE(Ctrl+F3) table.

82
NIKHEEL D. SHINDE 83
shindenikheel@gmail.com

In Menu Bar click on UTILITIES(M)TABLE CONTENTDISPLAY.

then press F4 button on that field where we attach SEARCH HELP.

ELEMENTARY
SEARCH HELP-
SINGLE TAB

83
NIKHEEL D. SHINDE 84
shindenikheel@gmail.com

COLLECTIVE
SEARCH HELP-
MULTIPLE TAB

3.8 Type Groups:


 Type groups, another repository object of ABAP Dictionary, allow you to define data types
directly in ABAP Dictionary, instead of defining them in an ABAP program.
 The name of a type group in ABAP Dictionary must have a maximum length of five
characters.
 Every data type name defined in a type group must begin with the name of the type group
followed by an underscore sign.
 These defined data types can be used in an ABAP program with the help of the TYPE- POOLS
statement.
To create a type group, select the Type Group radio button in the initial screen of ABAP
Dictionary, enter the name of the type group, and click the Create button. Then, enter the
following code snippet in the maintenance screen of the ZTYPE type group:

TYPE-POOL ZTYPE.
TYPES: ZTYPE_NAME(30) TYPE c,
ZTYPE_AGE(3) TYPE i.

In this code snippet, two data types are created. The declared type group (that is, ZTYPE), can be
used in an ABAP program (SE38: ABAP EDITOR), as shown in the following code snippet:

84
NIKHEEL D. SHINDE 85
shindenikheel@gmail.com

REPORT ZSHIVAM.
TYPE-POOLS ZTYPE.
DATA: NAME TYPE ZTYPE_NAME,
AGE TYPE ZTYPE_AGE.

In the preceding code snippet, the ZTYPE type group is included in the ZSHIVAM program with
the TYPE-POOLS statement. Therefore, the data types in the ZTYPE type group can be used in
the ZSHIVAM program with the help of the DATA statement.

3.9 Lock Objects:

 The R/3 System synchronizes simultaneous access of several users to the same data records
with a lock mechanism.
 When interactive transactions are programmed, locks are set and released by calling function
modules and these function modules are automatically generated from the definition of lock
objects in the ABAP Dictionary.
 Structure of a Lock Object
The tables in which data records should be locked with a lock request are defined in a
lock object together with their key fields. When tables are selected, one table (the primary
table) is first selected. Further tables (secondary tables) can also be added using foreign key
relationships
 Lock Arguments
The lock argument of a table in the lock object consists of the key fields of the table.
The lock argument fields of a lock object are used as input parameters in the function modules
for setting and removing locks generated from the lock object definition.

 A lock mode can be assigned for each table in the lock object. This mode defines how other
users can access a locked record of the table.

 When the lock is set, the corresponding lock entry is stored in the lock table of the system for
each table.

 Access by more than one user can be synchronized in the following ways:

 Exclusive lock: The locked data can only be displayed or edited by a single user. A request
for another exclusive lock or for a shared lock is rejected.

 Shared lock: More than one user can access the locked data at the same time in display mode.
A request for another shared lock is accepted, even if it comes from another user. An exclusive
lock is rejected.

 Exclusive but not cumulative: Exclusive locks can be requested several times from the same
transaction and are processed successively. In contrast, exclusive but not cumulative locks can
be called only once from the same transaction. All other lock requests are rejected.

85
NIKHEEL D. SHINDE 86
shindenikheel@gmail.com

4. Internal
table

86
NIKHEEL D. SHINDE 87
shindenikheel@gmail.com

4.1 Internal Tables


An internal table is a temporary table that contains the records of an ABAP program while it is
being executed. Consequently, an internal table exists only during the runtime of an SAP program.
In addition, internal tables are used to process large volumes of data by using the ABAP language.
You must declare an internal table in an ABAP program when you need to retrieve data from
database tables.

Similar to any other table, data in an internal table is stored in rows and columns, where each row
is called a line and each column is called a field. In an internal table, all the records have the same
structure and key. The individual records of an internal table are accessed with an index or a key.
Because an internal table exists till the associated program is being executed, the records of the
internal table are discarded when the execution of the program is terminated.

4.2 Difference between INTERNAL TABLES &VIEWS:


Sr.No Internal Table Views
1. Internal tables are locally defined in a Views are globally defined in the
program. dictionary.
2. Internal tables do not hold data unless Views hold data automatically at run time
selected into by a select statement. from the corresponding base tables.
3. Reading from an internal table is faster Reading from an internal table is Slow than
than from a view. from a view.
4. Internal tables can be created from tables Views can only be created from one or
or structures. more database tables.
5. Internal tables need not be in the Views have to be in the customer (Y,Z)
customer namespace. namespace.

4.3.1 Types of Internal Tables:


Internal tables can be categorized into three types: standard tables, sorted tables, and hashed
tables. In addition, internal tables can be categorized on the basis of their definition, as a fully
specified or generic type. A fully specified table type determines how the SAP system accesses the
entries of the table based on performing key-based operations. This table type performs a linear
search in standard tables, a binary search in sorted tables, and a hash algorithm search in hashed
tables. However, in the generic table type, the tables are searched on the basis of indexes.

87
NIKHEEL D. SHINDE 88
shindenikheel@gmail.com

Standard Tables

Standard tables have a linear index, which manages the table as a treelike structure. The records of
a standard table are accessed by using a table index or key. Standard tables always have a non-
unique key. Therefore, the SAP system does not need to check the table's existing entries when
new entries are added to the table. You can use standard tables when individual table entries need
to be addressed on the basis of indexes, because this is the quickest way to access a table. A
standard table can be populated by using the APPEND statement and its entries can be read,
modified, and deleted by specifying the index number in the relevant ABAP statement.

Sorted Tables

Sorted tables also have internal indexes, similar to standard tables, and are sorted with a key. You
can access the records of a sorted table by using a table index or key. In this case, a key also is
defined as either unique or non-unique. Sorted and standard tables use indexes and are therefore
also called index tables. In sorted tables, records entered are sorted automatically. These tables are
populated by using the INSERT statement according to the sort sequence defined in the table key.
As a result, whenever a user tries to add a non sequential entry to the table, it is recognized easily.
Sorted tables are used in particular situations, such as when you want to perform partial sequential
processing of code. In case of partial sequential processing of code, the code is written in a loop
and the beginning of the table key is specified in the WHERE clause.

Hashed Tables

These tables have no linear index and are accessed only by the keys. The SAP system accesses the
entries of a hashed table by using a hash algorithm. While defining a hashed table, the key of the
hashed table must be defined as unique. Hashed tables are selected when the user wants to perform
operations based on the key and not the index. Hashed tables are useful when you want to create
and use an internal table that resembles a database table, or if you want to process large volumes
of data.

4.3.2 Difference between Types of Internal Tables:


# Standard Internal Sorted Internal Tables Hashed Internal tables
tables
1 These are default These are special type of internal These are used with logical
internal tables. tables, where data is databases i:e with all fields
already(automatically) sorted as you and all records.
insert the record
2 To read a record we use To read a record we use either key Here index operation is not
either key or index or index operation. allowed, we only use key
operation. operation.
3 To search for a record, To search for a record, we use To search for a record we
we can use either linear binary search as data is already use hashed algorithm.
search or binary sorted.
search.
4 We can use sort We don`t use sort as data is already -
operation. sorted.
5 We can use insert and We only use insert, not append. These are mainly used in
append to add records. ABAP with BI projects
88
NIKHEEL D. SHINDE 89
shindenikheel@gmail.com

4.4 Operations of Internal Tables:


Statement for Internal Tables Without Statement for Internal Tables With
Header Lines Header Lines
INSERT <work_area_itab> INTO TABLE INSERT TABLE <internal_tab>.
<internal_tab>.
COLLECT <work_area_itab> INTO COLLECT <internal_tab>.
<internal_tab>.
READ TABLE <internal_tab>... INTO READ TABLE <internal_tab>...
<work_area_itab>.
MODIFY TABLE <internal_tab> FROM MODIFY TABLE <internal_tab>...
<work_area_itab>...
MODIFY <internal tab> FROM MODIFY <internal_tab>... WHERE...
<work_area_tab>...WHERE...
DELETE TABLE <internal_tab> FROM DELETE TABLE <internal_tab>.
<work_area_itab>.
LOOP AT <internal_tab> INTO LOOP AT <internal_tab> ...
<work_area_itab> ...
APPEND <work_area_itab> TO <internal_tab>. APPEND <internal_tab>.

----------------------Example : INTERNAL TABLE WITH HEADER LINE.--------------------------

REPORT YSP_INTERNAL_HL.

WRITE : '$$$$$$$$$$$$$$$ STANDERED INTERNAL TABLE $$$$$$$$$$$$$$$$$'.


SKIP.
*DATA : BEGIN OF itab,
* name(10) TYPE c,
* salary TYPE i,
* END OF itab.
*
*DATA : ctab LIKE itab OCCURS 0 WITH HEADER LINE .

TYPES : BEGIN OF ITAB,


NAME(10) TYPE C,
SALARY TYPE I,
END OF ITAB.

DATA : CTAB TYPE TABLE OF ITAB WITH HEADER LINE.

WRITE : '******** Insert / Append ********'.


SKIP.

ctab-name = 'sid'.
ctab-salary = 5000.
append ctab.

89
NIKHEEL D. SHINDE 90
shindenikheel@gmail.com

ctab-name = 'sam'.
ctab-salary = 6000.
append ctab.

ctab-name = 'shree'.
ctab-salary = 7000.
insert TABLE ctab.

LOOP AT ctab.
WRITE : ctab-name, ctab-salary, /.
ENDLOOP.

WRITE : '******** Modify ********'.


SKIP.

ctab-name = 'sid'.
ctab-salary = 8000.
MODIFY TABLE ctab.

ctab-name = 'sam'.
ctab-salary = 6500.
MODIFY TABLE ctab.

LOOP AT ctab.
WRITE : ctab-name, ctab-salary, /.
ENDLOOP.

WRITE : '******** Delete ********'.


SKIP.

ctab-name = 'sam'.
ctab-salary = 6500.
DELETE TABLE ctab.

LOOP AT ctab.
WRITE : ctab-name, ctab-salary, /.
ENDLOOP.

WRITE : '$$$$$$$$$$$$$$$$$$ SORTED TABLE $$$$$$$$$$$$$$$$$$'.


SKIP.

DATA : BEGIN OF itab1,


id TYPE i,
name(10) TYPE c,
phno TYPE i,
90
NIKHEEL D. SHINDE 91
shindenikheel@gmail.com

salary TYPE i,
END OF itab1.

DATA : ctab1 like SORTED TABLE OF itab1 with UNIQUE KEY id WITH HEADER LINE.

WRITE : '******** Insert / Append ********'.


SKIP.
ctab1-id = 3.
ctab1-name = 'Ram'.
ctab1-phno = 965845.
ctab1-salary = 5600.
APPEND ctab1.

ctab1-id = 1.
ctab1-name = 'Sam'.
ctab1-phno = 947845.
ctab1-salary = 8600.
INSERT TABLE ctab1.

ctab1-id = 2.
ctab1-name = 'Raj'.
ctab1-phno = 965123.
ctab1-salary = 6000.
INSERT TABLE ctab1.

ctab1-id = 4.
ctab1-name = 'Shiv'.
ctab1-phno = 97896.
ctab1-salary = 5800.
INSERT TABLE ctab1.

LOOP AT ctab1.
WRITE : ctab1-id, ctab1-name, ctab1-phno, ctab1-salary, /.
ENDLOOP.

WRITE : '******** Read Single Record ********'.


SKIP.
READ TABLE ctab1 WITH KEY id = 3.
WRITE : ctab1-id, ctab1-name, ctab1-phno, ctab1-salary, /.

WRITE : '******** Modify ********'.


SKIP.
ctab1-id = 4.
91
NIKHEEL D. SHINDE 92
shindenikheel@gmail.com

ctab1-name = 'Shiva'.
ctab1-phno = 9789655.
ctab1-salary = 5800.
MODIFY TABLE ctab1.

LOOP AT ctab1.
WRITE : ctab1-id, ctab1-name, ctab1-phno, ctab1-salary, /.
ENDLOOP.

WRITE : '******** Delete ********'.


SKIP.
ctab1-id = 4.
ctab1-name = 'Shiva'.
ctab1-phno = 9789655.
ctab1-salary = 5800.
DELETE TABLE ctab1.

LOOP AT ctab1.
WRITE : ctab1-id, ctab1-name, ctab1-phno, ctab1-salary, /.
ENDLOOP.

WRITE : '$$$$$$$$$$$$$$$$$$ HASHED TABLE $$$$$$$$$$$$$$$$$$'.


SKIP.

DATA : BEGIN OF itab2,


id TYPE i,
name(10) TYPE c,
phno TYPE i,
salary TYPE i,
END OF itab2.

DATA : ctab2 like HASHED TABLE OF itab2 with UNIQUE KEY id WITH HEADER LINE.

WRITE : '******** Insert / Append ********'.


SKIP.
ctab2-id = 1.
ctab2-name = 'Om'.
ctab2-phno = 947845.
ctab2-salary = 8600.
INSERT TABLE ctab2.

ctab2-id = 2.
ctab2-name = 'Rajesh'.
ctab2-phno = 965123.
92
NIKHEEL D. SHINDE 93
shindenikheel@gmail.com

ctab2-salary = 6000.
INSERT TABLE ctab2.

ctab2-id = 3.
ctab2-name = 'Rohit'.
ctab2-phno = 965845.
ctab2-salary = 5600.
INSERT TABLE ctab2.

ctab2-id = 4.
ctab2-name = 'Sham'.
ctab2-phno = 97896.
ctab2-salary = 5800.
INSERT TABLE ctab2.

LOOP AT ctab2.
WRITE : ctab2-id, ctab2-name, ctab2-phno, ctab2-salary, /.
ENDLOOP.

WRITE : '******** Read Single Record ********'.


SKIP.
READ TABLE ctab2 WITH KEY id = 3.
WRITE : ctab2-id, ctab2-name, ctab2-phno, ctab2-salary, /.

WRITE : '******** Modify ********'.


SKIP.
ctab2-id = 4.
ctab2-name = 'Sham'.
ctab2-phno = 97896.
ctab2-salary = 5800.
MODIFY TABLE ctab2.

LOOP AT ctab2.
WRITE : ctab2-id, ctab2-name, ctab2-phno, ctab2-salary, /.
ENDLOOP.

WRITE : '******** Delete ********'.


SKIP.
ctab2-id = 4.
ctab2-name = 'Sham'.
ctab2-phno = 97896.
ctab2-salary = 5800.
93
NIKHEEL D. SHINDE 94
shindenikheel@gmail.com

DELETE TABLE ctab2.

LOOP AT ctab2.
WRITE : ctab2-id, ctab2-name, ctab2-phno, ctab2-salary, /.
ENDLOOP.

OUTPUT :

$$$$$$$$$$$$$$$$$$$$$ STANDERED INTERNAL TABLE $$$$$$$$$$$$

******** Insert / Append ********

sid 5.000

sam 6.000

shree 7.000

******** Modify ********

sid 8.000

sam 6.500

shree 7.000

******** Delete ********

sid 8.000

shree 7.000

$$$$$$$$$$$$$$$$$$ SORTED TABLE $$$$$$$$$$$$$$$$$$

******** Insert / Append ********

1 Sam 947.845 8.600

2 Raj 965.123 6.000

3 Ram 965.845 5.600

4 Shiv 97.896 5.800

******** Read Single Record ********

3 Ram 965.845 5.600

******** Modify ********

1 Sam 947.845 8.600

94
NIKHEEL D. SHINDE 95
shindenikheel@gmail.com

2 Raj 965.123 6.000

3 Ram 965.845 5.600

4 Shiva 9.789.655 5.800

******** Delete ********

1 Sam 947.845 8.600

2 Raj 965.123 6.000

3 Ram 965.845 5.600

$$$$$$$$$$$$$$$$$$ HASHED TABLE $$$$$$$$$$$$$$$$$$

******** Insert / Append ********

1 Om 947.845 8.600

2 Rajesh 965.123 6.000

3 Rohit 965.845 5.600

4 Sham 97.896 5.800

******** Read Single Record ********

3 Rohit 965.845 5.600

******** Modify ********

1 Om 947.845 8.600

2 Rajesh 965.123 6.000

3 Rohit 965.845 5.600

4 Sham 97.896 5.800

******** Delete ********

1 Om 947.845 8.600

2 Rajesh 965.123 6.000

3 Rohit 965.845 5.600

----------------------Example: INTERNAL TABLE WITH WORK AREA. ----------------------

REPORT YSP_INTERNAL_WA.

DATA : BEGIN OF itab OCCURS 0,


name(10) TYPE c,
95
NIKHEEL D. SHINDE 96
shindenikheel@gmail.com

salary TYPE i,
END OF itab.

data : it like SORTED TABLE OF itab WITH UNIQUE KEY NAME,


wa like LINE OF it.

WRITE : '**************** Insert / Append *********************'.


SKIP.
wa-name = 'sid'.
wa-salary = 4500.
INSERT wa INTO TABLE itab.

wa-name = 'sam'.
wa-salary = 5500.
INSERT wa INTO TABLE itab.

wa-name = 'shree'.
wa-salary = 8000.
APPEND wa to itab.

LOOP AT itab INTO wa.


WRITE : wa-name, wa-salary, /.
ENDLOOP.

WRITE : '**************** READ *********************'.


*wa-name = 'sam'.
*wa-salary = 5500.
READ TABLE itab INTO wa WITH KEY NAME = 'sam'.
WRITE : / wa-name, wa-salary, /.
WRITE : '**************** Modify *********************'.
SKIP.

wa-name = 'shree'.
wa-salary = 7000.
MODIFY TABLE itab FROM wa.

LOOP AT itab INTO wa.


WRITE : wa-name, wa-salary, /.
ENDLOOP.

WRITE : '**************** Delete *********************'.


SKIP.

wa-name = 'sam'.

96
NIKHEEL D. SHINDE 97
shindenikheel@gmail.com

wa-salary = 5500.
DELETE TABLE itab FROM wa.

LOOP AT itab INTO wa.


WRITE : wa-name, wa-salary, /.
ENDLOOP.

OUTPUT :

**************** Insert / Append *********************

sid 4.500

sam 5.500

shree 8.000

**************** READ *********************

sam 5.500

**************** Modify *********************

sid 4.500

sam 5.500

shree 7.000

**************** Delete *********************

sid 4.500

shree 7.000

97
NIKHEEL D. SHINDE 98
shindenikheel@gmail.com

Initializing Internal Tables

Similar to all data objects, an internal table can be initialized by using the CLEAR statement. The
syntax to initialize an internal table is:

CLEAR <internal_tab>.

This syntax restores the original state of the <internal_tab> internal table. The original state is the
state immediately after the creation of the internal table; i.e., when the internal table contains no
lines. However, the memory allocated to the internal table remains unchanged until the memory is
released manually by the user. The following syntax is used to clear the entire body of an internal
table:

CLEAR <internal_tab>[].

Refreshing Internal Tables

The REFRESH statement is used to ensure that an internal table is initialized. The following
syntax shows the use of the REFRESH statement:

REFRESH <internal_tab>.

This syntax always applies to the entire body of the internal table. Note that the memory space
being used by an internal table is not released.

Releasing the Memory of Internal Tables

The FREE statement is used to initialize an internal table and release the memory allocated to it.
The following syntax is used to release the memory allocated to an internal table:

FREE <internal_tab>.

Similar to the REFRESH statement, the FREE statement works only on the body of the table and
not on its work area. The name of an internal table can be referenced even after using the FREE
statement because even after the memory allocated to the internal table is released, the internal
table continues to occupy the memory required for its header. However, when the internal table is
populated again, the SAP system allocates new memory to the table.

Control Break statement:

Control break processing is used to execute a piece of code whenever a specific condition in the
data is detected during the processing of internal table loop.

The following control break statements are available within LOOP and ENDLOOP.

 AT FIRST / ENDAT
 AT LAST / ENDAT
 AT NEW / ENDAT
 AT END OF / ENDAT
 SUM
98
NIKHEEL D. SHINDE 99
shindenikheel@gmail.com

 ON CHANGE OF / ENDON

The code between AT NEW and ENDAT is executed only during the first loop pass. So it is used
to write the headers or some other initialization processing.

The code between AT LAST and ENDAT is executed only during the last loop pass. So it is used
to write the totals or some report footers.

*————————–* *Data Declaration *———————————–*

DATA: gwa_spfli TYPE spfli.


DATA: gt_spfli TYPE TABLE OF spfli.

*UP TO 5 ROWS addition selects only 5 rows from table SPFLI

SELECT * UP TO 5 ROWS FROM spfli INTO TABLE gt_spfli.

LOOP AT gt_spfli INTO gwa_spfli.

AT FIRST.

WRITE:/ 'Start of Loop'.


WRITE:/ 'Flight Details'.
WRITE:/ 'Airline Code' COLOR 5,14 'Connection No.' COLOR 5,
29 'Departure City' COLOR 5, 44 'Arival City' COLOR 5.
ULINE.

ENDAT.

WRITE:/ gwa_spfli-carrid,14 gwa_spfli-connid,


29 gwa_spfli-cityfrom,44 gwa_spfli-cityto.

AT LAST.

ULINE.
WRITE:/ 'End of Loop'.

ENDAT.

ENDLOOP.

Output

99
NIKHEEL D. SHINDE 10
shindenikheel@gmail.com

Between AT FIRST and ENDAT the work area will not contain any data. The default key fields
are filled with asterisks(*) and the numeric fields are filled with zeros. The ENDAT restores the
contents to the values they had prior to entering the AT FIRST. Changes to the work area within
AT FIRST and ENDAT are lost. The same applies for AT LAST and ENDAT.

*——————————–* *Data Declaration *———————————*

DATA: gwa_spfli TYPE spfli.


DATA: gt_spfli TYPE TABLE OF spfli.

*UP TO 5 ROWS addition selects only 5 rows from table SPFLI

SELECT * UP TO 5 ROWS FROM spfli INTO TABLE gt_spfli.

LOOP AT gt_spfli INTO gwa_spfli.


AT FIRST.
WRITE:/ 'Flight Details'.
WRITE:/ 'Airline Code' COLOR 5,14 'Connection No.' COLOR 5,
29 'Departure City' COLOR 5, 44 'Arival City' COLOR 5,
58 'Distance' COLOR 5.

WRITE:/ gwa_spfli-carrid,14 gwa_spfli-connid, 29 gwa_spfli-cityfrom,44 gwa_spfli-cityto, 58


gwa_spfli-distance.

ULINE.
ENDAT.
WRITE:/ gwa_spfli-carrid,14 gwa_spfli-connid,
29 gwa_spfli-cityfrom,44 gwa_spfli-cityto,
58 gwa_spfli-distance.
AT LAST.
ULINE.

WRITE:/ gwa_spfli-carrid,14 gwa_spfli-connid, 29 gwa_spfli-cityfrom,44 gwa_spfli-cityto, 58


gwa_spfli-distance.

WRITE:/ 'End of Loop'.


ENDAT.
ENDLOOP.

10
0
NIKHEEL D. SHINDE 10
shindenikheel@gmail.com

Output

AT NEW and ENDAT is used to detect a change in the value of the field between the loop passes.
The field that is specified in AT NEW is called control level. The code between AT NEW and
ENDAT will be executed during the first loop pass and every time the value of the control level
changes or any other field left to the control level changes. Between AT NEW and ENDAT all the
fields in the work area that are right to the control level are filled with zeros and asterisks.

Similarly The code between AT END OF and ENDAT will be executed during the last loop pass
and every time the value of the control level changes or any other field left to the control level
changes.

*————* *Data Declaration *————–*

DATA: gwa_spfli TYPE spfli.


DATA: gt_spfli TYPE TABLE OF spfli.

SELECT * UP TO 5 ROWS FROM spfli INTO TABLE gt_spfli.

LOOP AT gt_spfli INTO gwa_spfli.


AT FIRST.
WRITE:/ 'Flight Details'.
WRITE:/ 'Airline Code' COLOR 5,14 'Connection No.' COLOR 5,
29 'Departure City' COLOR 5, 44 'Arival City' COLOR 5,
58 'Distance' COLOR 5.
ULINE.
ENDAT.

AT NEW carrid. WRITE:/ gwa_spfli-carrid, ‘ : New Airline’. ULINE. ENDAT.

WRITE:/14 gwa_spfli-connid,
29 gwa_spfli-cityfrom,44 gwa_spfli-cityto,
58 gwa_spfli-distance.

AT END OF carrid. ULINE. WRITE:/ ‘End of Airline : ‘, gwa_spfli-carrid. ULINE. ENDAT.

AT LAST.
WRITE:/ 'End of Loop'.
ENDAT.
10
1
NIKHEEL D. SHINDE 10
shindenikheel@gmail.com

ENDLOOP.

Output

100
NIKHEEL D. SHINDE 10
shindenikheel@gmail.com

5. Open sql

101
NIKHEEL D. SHINDE 10
shindenikheel@gmail.com

5.1 OPEN SQL:


Open SQL is a set of ABAP statements that performs operations like reads, modifies or deletes
data in the SAP database. Open SQL is independent of the database system, so the syntax of the
open SQL is uniform for all the databases supported by SAP.

All open SQL statements are passed to the database interface. The DB interface converts the open
SQL to native SQL and passes it on to the database.

5.2 Different types of OPEN/SQL


DDL

Data Definition Language (DDL) statements are used to define the database structure or schema.
Some examples:

o CREATE - to create objects in the database


o ALTER - alters the structure of the database
o DROP - delete objects from the database
o TRUNCATE - remove all records from a table, including all spaces allocated for the records
are removed
o RENAME - rename an object

DML

Data Manipulation Language (DML) statements are used for managing data within schema
objects. Some examples:

o SELECT - retrieve data from the a database


o INSERT - insert data into a table
o UPDATE - updates existing data within a table
o DELETE - deletes all records from a table, the space for the records remain
o MERGE - UPSERT operation (insert or update)
o LOCK TABLE - control concurrency

DCL

Data Control Language (DCL) statements. Some examples:

o GRANT - gives user's access privileges to database


o REVOKE - withdraw access privileges given with the GRANT command
o COMMIT - save work done
o ROLLBACK - restore database to original since the last COMMIT

List of Open SQL statements


102
NIKHEEL D. SHINDE 10
shindenikheel@gmail.com

Open SQL Description


SELECT Reads data from database
INSERT Inserts lines to database
UPDATE Changes the contents of lines in database
MODIFY Inserts lines into database or changes the contents of existing lines
DELETE Deletes lines from database

5.3 Select statements & Where clause with its different functions

Condition Description
SELECT * FROM ZSTUDENT_DATA condition specified in the WHERE clause is
WHERE ADDRESS NE 'C CHOWK'. evaluated to true if the ADDRESS field does not
ENDSELECT. contain the string C CHOWK.
TABLES: ZSTUDENT_DATA. Exhibits the use of the BETWEEN range operator
SELECT * FROM ZSTUDENT_DATA with the WHERE clause. The condition specified
WHERE MONTHLYFEES in the WHERE clause is evaluated to true if the
BETWEEN 500 AND 800. field MONTHLYFEES contains numbers between
ENDSELECT. 500
and 800.
TABLES: ZSTUDENT_DATA. Demonstrates the use of the NOT BETWEEN
SELECT * FROM ZSTUDENT_DATA range operator with the WHERE clause. The
WHERE YEARLYFEES condition specified in the WHERE clause is
NOT BETWEEN 6000 AND 10000. evaluated to true
ENDSELECT. if the field YEARLYFEES contains numbers not
between 6000 and 10000.
TABLES: ZSTUDENT_DATA. Illustrates the use of the LIKE operator with the
SELECT * FROM ZSTUDENT_DATA WHERE clause. The condition specified in the
WHERE STUDENTNAME LIKE WHERE clause is evaluated to true if the field
'%SRIVASTAVA'. STUDENTNAME contains a string containing the
ENDSELECT. pattern SRIVASTAVA at the end of a student's
name.
TABLES: ZSTUDENT_DATA. Demonstrates the use of the NOT LIKE operator
SELECT * FROM ZSTUDENT_DATA with the WHERE clause. The condition specified
WHERE CITY NOT LIKE '_A%'. in the WHERE clause is evaluated to true if the
ENDSELECT. field City contains a value whose second character
is not A.
TABLES: ZSTUDENT_DATA. Shows the use of the IN operator with the WHERE
SELECT * FROM ZSTUDENT_DATA clause. The condition specified in the WHERE
WHERE CITY IN ('AGRA', 'MUMBAI', clause is evaluated to true if the column CITY
'LUCKNOW'). contains one of the values AGRA, MUMBAI, or
ENDSELECT. LUCKNOW.
TABLES: ZSTUDENT_DATA. Demonstrates the use of the NOT IN operator with
SELECT * FROM ZSTUDENT_DATA the WHERE clause. The condition specified in the
WHERE CITY NOT IN ('DELHI', 'GOA'). WHERE clause is evaluated to true if the column
ENDSELECT. CITY does not contain the values DELHI or GOA.

103
NIKHEEL D. SHINDE 10
shindenikheel@gmail.com

5.4 Aggregate Functions:


Reading Aggregate Data for Columns
The syntax to use the SELECT statement to read aggregate data of a column from a database table
is:
SELECT <database_tab_lines> <agg>([DISTINCT] <s1>)
[AS <a 1>]
<agg>([DISTINCT] <s2>) [AS <a 2>] ...
In this syntax, the <s1> <s2>...<s n > expressions stand for field labels. The <agg> expression
represents one of the following aggregate functions:
MAX—Returns the maximum value of the <s i> columns.
MIN—Returns the minimum value of the <s i> columns.
AVG—Returns the average value of the <s i> columns.
SUM—Returns the sum of the values of the <s i> columns.
COUNT—Counts the total lines of the database table.
COUNT (DISTINCT <s i>)—Returns the number of different values in the <s i> columns.
COUNT(*)—Returns the total number of lines in the result set of the SELECT statement.

The DISTINCT clause ensures that no duplicate values are used to calculate the aggregate of the
data. The aggregate functions AVG and SUM are used only with numeric fields. If you use the
MAX, MIN, and SUM functions, ensures that the data type of the corresponding columns must be
of the ABAP Dictionary type, such as I and F. When the aggregate function is AVG, the
It is to be noted that null values are not used for calculation. If all the lines in a selection contain
the null value in the corresponding fields, the result of the calculation also turns out to be null. In
ABAP, the null value is interpreted as zero (depending on the data type of the field).
The AS clause is used to define an alternative column name (also called an alias), <a i>, for each
aggregate expression. An alias column name is preferred over the actual column name because it
helps simplify the query. The field names specified in the SELECT clause for aggregate functions
are also included in the GROUP BY clause.

Examples:

SELECT <agg>( [DISTINCT] COL_2 )


INTO RESULT
FROM ITEM.

WRITE RESULT.

5.5 The INTO Clause


The INTO clause, in the SELECT statement, is used to define the target area. The target area is a
variable that contains the field names whose data type is compatible with the field names specified
in the SELECT statement. The SELECT statement uses the following specifications to determine
the data type of the target area:
The <database_tab_lines> specification—Determines the target area, such as a flat or a tabular
structure.
The <database_tab_cols> specification—Determines the structure or the line type of the target
area.

104
NIKHEEL D. SHINDE 10
shindenikheel@gmail.com

The target area is flat when a single line is selected, and it can be either tabular or flat if multiple
lines are selected. Note that if the target area is flat, it must be specified in the
SELECT...ENDSELECT loop construction.

When you specify all the columns of a database table in the SELECT statement, the target area is
either a structure type or a type that can be converted into a structure. However, if you specify the
names of columns individually in the SELECT statement, the target area can be a component of a
structure or a field. The elementary type of fields in the SELECT statement must be compatible
with the corresponding elementary components of the target area.
The following syntax of the INTO clause is used to read the data from database table and send it to
a work area:

SELECT ... INTO [CORRESPONDING FIELDS OF] <work_area> ...

In this syntax, <work_area> represents a work area. The use of the CORRESPONDING FIELDS
clause is optional after the INTO clause. The CORRESPONDING FIELDS clause is used to limit
the amount of data being read from the result set of the SELECT statement and transferred into an
ABAP program. Note that the CORRESPONDING FIELDS clause does not limit the amount of
data being read from a database table.

When an asterisk (*) symbol is used in the SELECT statement to specify all columns of a database
table, the data is transferred into the <work_area> from left to right according to the structure of
the database table. However, when individual columns or aggregate expressions are used in the
SELECT statement, the columns are transferred into the work area from left to right according to
the structure of the work area. Note that when the data is retrieved from a database table into the
<work_area>, the values of the components of <work_area> are overwritten. However, the values
of the components of <work_area> are not affected by the SELECT statement.

5.6 JOINS (INNER & LEFT OUTER):


The join syntax represents a recursively nested table join expression. A join expression consists of
a left-hand and a right- hand side, which are joined either by means of [INNER] JOIN or LEFT
[OUTER] JOIN. Depending on the type of join, a join expression can be either an inner
(INNER) or an outer (LEFT OUTER) join. Every join expression can be enclosed in round
brackets. If a join expression is used, the SELECT command circumvents SAP buffering.

On the left-hand side, either a single database table, a view dbtab_left, or a join expression join
can be specified. On the right-hand side, a single database table or a view dbtab_right as well as
join conditions join_cond can be specified after ON. In this way, a maximum of 24 join
expressions that join 25 database tables or views with each other can be specified after FROM.

AS can be used to specify an alternative table name tabalXias for each of the specified database
table names or for every view. A database table or a view can occur multiple times within a join
expression and, in this case, have various alternative names.

The syntax of the join conditions join_cond is the same as that of the sql_cond conditions after
the addition WHERE, with the following differences:

 At least one comparison must be specified after ON.


 Individual comparisons may be joined using AND only.

105
NIKHEEL D. SHINDE 10
shindenikheel@gmail.com

 All comparisons must contain a column in the database table or the view dbtab_right on the
right-hand side as an operand.
 The following additions not be used: NOT, LIKE, IN.
 No sub-queries may be used.
 For outer joins, only equality comparisons (=, EQ) are possible.
 If an outer join occurs after FROM, the join condition of every join expression must contain at
least one comparison between columns on the left-hand and the right-hand side.
 In outer joins, all comparisons that contain columns as operands in the database table or the
view dbtab_right on the right-hand side must be specified in the corresponding join condition.
In the WHERE condition of the same SELECT command, these columns are not allowed as
operands.

Resulting set for inner join

The inner join joins the columns of every selected line on the left- hand side with the columns of
all lines on the right-hand side that jointly fulfill the join_cond condition. A line in the resulting
set is created for every such line on the right-hand side. The content of the column on the left-hand
side may be duplicated in this case. If none of the lines on the right-hand side fulfils the join_cond
condition, no line is created in the resulting set.

Resulting set for outer join

The outer join basically creates the same resulting set as the inner join, with the difference that at
least one line is created in the resulting set for every selected line on the left-hand side, even if no
line on the right-hand side fulfils the join_cond condition. The columns on the right-hand side that
do not fulfil the join_cond condition are filled with null values.

Example

Join the columns carrname, connid, fldate of the database tables scarr, spfli and sflight by
means of two inner joins. A list is created of the flights from p_cityfr to p_cityto. Alternative
names are used for every table.

PARAMETERS: p_cityfr TYPE spfli-cityfrom,


p_cityto TYPE spfli-cityto.

DATA: BEGIN OF wa,


fldate TYPE sflight-fldate,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
END OF wa.

DATA itab LIKE SORTED TABLE OF wa


WITH UNIQUE KEY fldate carrname connid.

SELECT c~carrname p~connid f~fldate


INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( scarr AS c
INNER JOIN spfli AS p ON p~carrid = c~carrid
AND p~cityfrom = p_cityfr
AND p~cityto = p_cityto )
INNER JOIN sflight AS f ON f~carrid = p~carrid
AND f~connid = p~connid ).

LOOP AT itab INTO wa.


WRITE: / wa-fldate, wa-carrname, wa-connid.
ENDLOOP.

106
NIKHEEL D. SHINDE 10
shindenikheel@gmail.com

5.7 FOR ALL ENTRIES:


If the addition FOR ALL ENTRIES is specified before the language element WHERE, then the
components comp of the internal table itab can be used as operands when comparing with
relational operators.

The internal table itab must have a structured line type and the component comp must be
compatible with the column col.

The logical expression sql_cond of the WHERE condition can comprise various logical
expressions by using AND and OR. However, if FOR ALL ENTRIES is specified, there must be
at least one Comparison with a column of the internal table itab, which can be specified either
statistically or dynamically (Release 6.40 and higher). In a statement with a SELECT statement
with FOR ALL ENTRIES, the addition ORDER BY can only be used with the addition
PRIMARY KEY.

The whole logical expression sql_cond is evaluated for each individual line of the internal table
itab. The resulting set of the SELECT statement is the union of the resulting sets from the
individual evaluations. Duplicate lines are automatically removed from the resulting set. If the
internal table itab is empty, the whole WHERE statement is ignored and all lines in the database
are put in the resulting set.

Notes

 In Release 6.10 and higher, the same internal table can be specified after FOR ALL
ENTRIES and after INTO.

 The addition FOR ALL ENTRIES is only possible before WHERE conditions of the
SELECT statement.

 If the additions PACKAGE SIZE or UP TO n ROWS are specified together with FOR ALL
ENTRIES, they are not passed to the database system but are applied instead to the resulting
set once all selected rows on the application server have been imported.

 With duplicated rows in the resulting set, the addition FOR ALL ENTRIES has the same
effect as if addition DISTINCT were specified in the definition of the selection quantity.
Unlike DISTINCT, the rows are not deleted from the database system but are deleted on the
application server from the resulting set.

 Addition FOR ALL ENTRIES is only possible for WHERE conditions of the SELECT
statement.

Example

Exporting all flight data for a specified departure city. The relevant airlines and flight numbers are
first put in an internal table entry_tab, which is evaluated in the WHERE condition of the
subsequent SELECT statement.

PARAMETERS p_city TYPE spfli-cityfrom.

TYPES: BEGIN OF entry_tab_type,


carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
END OF entry_tab_type.
107
NIKHEEL D. SHINDE 10
shindenikheel@gmail.com

DATA: entry_tab TYPE TABLE OF entry_tab_type,


sflight_tab TYPE SORTED TABLE OF sflight
WITH UNIQUE KEY carrid connid fldate.

SELECT carrid connid


FROM spfli
INTO CORRESPONDING FIELDS OF TABLE entry_tab
WHERE cityfrom = p_city.

SELECT carrid connid fldate


FROM sflight
INTO CORRESPONDING FIELDS OF TABLE sflight_tab
FOR ALL ENTRIES IN entry_tab
WHERE carrid = entry_tab-carrid AND
connid = entry_tab-connid.

5.8 Insert, Modify, Update, Delete:


In the case of INSERT & MODIFY we required WORK AREA of table, but not for update & delete.

INSERT:
INSERT INTO <target_database_tab> VALUES <work_area>.

MODIFY:
MODIFY <target_database_tab> FROM <work_area>.

UPDATE:
UPDATE <target_database_tab> SET <si> ... [WHERE <cond>].

DELETE:
DELETE FROM <target_database_tab> WHERE <cond> .

108
NIKHEEL D. SHINDE 10
shindenikheel@gmail.com

.Modularization
technique

109
NIKHEEL D. SHINDE 11
shindenikheel@gmail.com

6.1 Modularization Techniques:


Modularization techniques enhance the readability and understandability of large ABAP
programs. At times, it becomes difficult to enhance and debug the source code of a lengthy ABAP
program. The ABAP language simplifies the debugging process by offering various
modularization techniques, such as subroutines, function modules, and source code modules.
Modularization techniques help to remove redundancy that occurs when an ABAP program
contains the same or similar blocks of statements or the same function is used multiple times.
Modularization techniques also improve the structure of an ABAP program and make it easy to
read, maintain, and update.

6.2 Types of modularization techniques


1. Macros:

 If you want to reuse the same set of statements more than once in a program, you can include
them in a macro.
 Define macro’s block of code within:
DEFINE <macro>.

<statements>

END-OF-DEFINITION.

 In this we can use limited arguments starts with “&1 to &9”.


 It is a non compiling code, hence it perform fast & never shows any error.

Example: Design code in SE38.

DATA RESULT TYPE I,

DEFINE OPERATION.
RESULT = &1 &2 &3.
OUTPUT &1 &2 &3 RESULT.
END-OF-DEFINITION.

DEFINE OUTPUT.
WRITE: / 'The result of &1 &2 &3 is', &4.
END-OF-DEFINITION.

OPERATION 4 + 3.
OPERATION 2 ** 7.

The produces the following output:


The result of 4 + 3 is 7
The result of 2 ** 7 is 128

110
NIKHEEL D. SHINDE 11
shindenikheel@gmail.com

2. Include programs:

 While creating a program in SE38 select program type “IINCLUDE”.


 This is non self-executable code. We have to create different code in SE38 with type
“1EXECUTABLE”.
 We cannot pass any arguments to external program.

How to create include programs?


If you create an include program yourself, you must assign it the type I in its program
attributes. You can also create or change an include program by double-clicking on the name of
the program after the INCLUDE statement in your ABAP program. If the program exists, the
ABAP Workbench navigates to it. If it does not exist, the system creates it for you.

How to use Include programs?


An include program cannot run independently, but must be built into other programs. Include
programs can contain other includes.

Example:

------------------------------Include Program (SE38 with type IINCLUDE)

***INCLUDE STARTTXT.
WRITE: / 'Program started by', SY-UNAME,
/ 'on host', SY-HOST,
'date: ' , SY-DATUM,
'time: ' , SY-UZEIT.
ULINE.

------------------------------Main Program (SE38 with type 1EXECUTABLE)

PROGRAM SAPMZTST.
INCLUDE STARTTXT. “ calling of include program

This could produce the following output:


Program started by SENTHIVEL
on host ds0025 date: 09/07/2004 time: 03:15:40

Procedures
Procedures contain a set of statements, and are called from other ABAP programs.
ABAP contains the following kinds of procedures:

3. Subroutine:

Subroutines are procedures that you can define in any ABAP program and also call from any
program. Subroutines are normally called internally, that is, they contain sections of code or
algorithms that are used frequently locally. If you want a function to be reusable throughout the
system, use a function module.

111
NIKHEEL D. SHINDE 11
shindenikheel@gmail.com

 Defining Subroutine:

A subroutine is a block of code introduced by FORM and concluded by ENDFORM.


FORM <subr> [USING ... [VALUE(]<pi>[)] [TYPE <t>|LIKE <f>]... ]
[CHANGING... [VALUE(]<pi>[)] [TYPE <t>|LIKE <f>]... ].
< Statements>
ENDFORM.
<subr> - Subroutine Name

 Calling Subroutine:

You call subroutines using the statement


PERFORM... [USING ... <pi>... ]
[CHANGING... <pi>... ].

Subroutines can call other subroutines (nested calls) and may also call themselves (recursive
calls). Once a subroutine has finished running, the calling program carries on processing after the
PERFORM statement. You can use the USING and CHANGING additions to supply values to the
parameter interface of the subroutine.

Passing data from / to Subroutines:

 Calling by Reference
FORM ..... [USING <fi1> ... <fin>] [CHANGING <fo1> ... <fon>] ...
PERFORM... [USING <ai1> ... <ain>] [CHANGING <ao1> ... <aon>] .…

Input parameters which are changed in the subroutine are also changed in the calling
program.

 Calling by Value
FORM ..... USING ...VALUE(<fii>) ..
PERFORM... USING ....... <aii> ..

Input parameter is not changed during the call.

 Calling by Value and Result


FORM ..... CHANGING ...VALUE(<fii>) ..
PERFORM... CHANGING .......<aii> ..
Changes to the formal parameters are copied to the actual parameter at the end of the
subroutine.

4. Functional modules:

 Special external subroutines stored in a central library that you can call from your ABAP/4
programs
 Can create your own function modules.
 Transaction Code SE37.
 You use the ABAP/4 Workbench to call, create, and maintain function modules.

112
NIKHEEL D. SHINDE 11
shindenikheel@gmail.com

 You can combine several function modules to form a function group in the function library.
Function groups are stored in the program library with the attribute type F.

EXPORTING option
To pass actual parameters al to the formal input parameters fl. The formal parameters must
be declared as import parameters in the function module.
IMPORTING option
To pass formal parameters fL to the actual parameters aL . The formal parameters must be
declared as export parameters in the function module.
CHANGING option
To pass actual parameters aL to the formal parameters fL and after processing the function
module, the system passes the (changed) formal parameters fL back to the actual parameters aL The
formal parameters must be declared as changing parameters in the function module.
TABLES option
To pass internal tables between the actual and formal parameters. With this option, internal
tables are always passed by reference.
EXCEPTIONS option
To catch exceptions. The exceptions are defined in the function module.

Example:

Create FUNCTION GROUP for FUNCTION MODULE STORAGE.

Enter your PACKAGE NAME in given field. Right click on your PACKAGE
NAMECREATEFUNCTION GROUP.

113
NIKHEEL D. SHINDE 11
shindenikheel@gmail.com

Give FUNCTION GROUP name starts with y/z, give SHORT TEXT & ENTER.

After creation of FUNCTION GROUP. Open FUNCTION GROUP folder, right click on created
FUNCTION GROUP nameACTIVATE.

114
NIKHEEL D. SHINDE 11
shindenikheel@gmail.com

Now go to T-CODE: SE37 for FUNCTION MODULE creation. Give FUNCTION MODULE
name starts with y/z then click on CREATE.

Now give created FUNCTION GROUP name and SHORT TEXT then click on SAVE.

115
NIKHEEL D. SHINDE 11
shindenikheel@gmail.com

TEST THE CREATED FUNC_M:

CALLING FUNC_M IN SE38:

116
NIKHEEL D. SHINDE 11
shindenikheel@gmail.com

Now go to T-CODE: SE38. Give program name starts with y/z then click on CREATE.

Give suitable TITLE, select TYPE: EXECUTABLE then SAVE.

Click on PATTEREN button.

117
NIKHEEL D. SHINDE 11
shindenikheel@gmail.com

Select CALL FUNCTION option, give created FUNCTION MODULE name & ENTER.

SAVE (Ctrl+S) & ACTIVATE(Ctrl+F3) program.

Press F8 (EXECUTE). Pass required value & again press F8 (EXECUTE).

118
NIKHEEL D. SHINDE 11
shindenikheel@gmail.com

7.Object oriented
abap/4

119
NIKHEEL D. SHINDE 12
shindenikheel@gmail.com

7.1 Object Oriented ABAP and Concepts


Introduction to Object Oriented ABAP, Concepts and principles of Object Oriented ABAP
programming

 The main feature of Object Oriented programming is representing real-time objects in the form
of class objects.
 Object Oriented ABAP focus on representing real-time objects of classes.
 SAP ABAP Object Oriented programming is available in two flavors.
 One is Global Classes and another one is local class.

Global Class

Global Class is an ABAP object which can be accessible via SAP Class Builder; T-code for SAP
Class Builder is SE24.

Local Class

Local classes are classes which are available in ABAP programs; we can access them via ABAP
editor SE38.

ABAP Classes and It`s components

What is a Class? A class is a user defined data type with attributes, methods, events, user-defined
types, interfaces etc for a particular entity or business application.

What are Objects? Objects are nothing but instances of classes, each object has a unique identity
that is memory and its own attributes.

Declaring Classes and Objects

Syntax: DATA <instance> TYPE REF TO <class name> . "Declaring global class in ABAP
program using type ref to(type reference to )
CREATE OBJECT <instance>. "Create object for the declared instance

7.2 Components of a Class


Attributes: Attributes are variables, constants declared within a class.

Methods: Methods are coding blocks which provides some functionality.

 These methods are similar to Function Modules in ABAP.


 Methods can access all attributes of its own class.
 Methods are defined in definition part and implemented in implementation part.
 We can call methods using CALL METHOD statement.

Events: Event is a mechanism through which one method of a class can raise method of other
class, without hazard of instantiating that class.

Interfaces: Interfaces are similar to classes which contain methods Without any implementation.

120
NIKHEEL D. SHINDE 12
shindenikheel@gmail.com

Interfaces are mainly used to extend the scope or functionality of the class.

Instance and Static Components

Instance components: These components exist separately in each instance (object) of the class
and are referred using instance component selector using ->

Static components: These components exist globally for a class and are referred to using static
component selector =>.

Visibility of Components of Class

Each class component has a visibility.

In ABAP Objects, the whole class definition is separated into three visibility sections:

 PUBLIC.
 PROTECTED.
 PRIVATE.

Public section: Data declared in public section can be accessed by the class itself, by its
subclasses as well as by other users outside the class.

Protected section: Data declared in the protected section can be accessed by the class itself, and
also by its subclasses but not by external users outside the class.

Private Section: Data declared in the private section can be accessed by the class only, but not by
its subclasses and by external users outside the class.

Global Class and Local Class

Classes in ABAP Objects can be declared either globally or locally.

Global Class: Global classes and interfaces are defined in the Class Builder (Transaction SE24) in
the ABAP Workbench.

All of the ABAP programs in an R/3 System can access the global classes.

Local Class: Local classes are define in an ABAP program (Transaction SE38) and can only be
used in the program in which they are defined.

7.3 Events in SAP classes


Working with events and event handler methods in SAP classes in SAP ABAP programming
model

What are events in SAP Classes?

Event is a mechanism by which method of one class can raise method of another class, without the
hazard of instantiating that class.

121
NIKHEEL D. SHINDE 12
shindenikheel@gmail.com

Follow the below steps to add a event

 Define an event.
 Define a method.
 Link event and method and convert the method into event-handler method.
 Create a triggering method which will raise the event.
 Use set handler and register event handler method to a particular instance in the program.

Use below syntax to register a event handler method for a instance

SET HANDLER <INSTANCE> <EVT-HDLER-METHOD> for <INSTANCE>. "here instance is


the object created by using create object

7.4 CONSTRUCTORS in SAP Class


What is a constructor method in SAP Classes and Uses of Constructor method in OOABAP?

What is a constructor in a class?

CONSTRUCTOR is a special type of method, it is executed automatically whenever a object is


created or instantiated.

These methods are mainly used to set default values in classes.

CONSTRUCTORS are two types in SAP classes.

1. CONSTRUCTOR (Instance Constructor).


2. CLASS CONSTRUCTOR (Static Constructor).

CONSTRUCTOR.

These methods can only have importing parameters, there will not be any exporting parameters.

The name of the CONSTRUCTOR method must be CONSTRUCTOR only.

CLASS CONSTRUCTOR (Also called as STATIC CONSTRUCTOR).

It is a type of constructor, this method will be executed automatically whenever a first call to the
class is made, the first call may be through instance or through class.

These CLASS CONSTRUCTORS are mainly used to set the default values globally i:e
irrespective of instances, these methods will not have any importing and exporting
parameters.These methods will be executed only once.

Name of the CLASS CONSTRUCTOR must be CLASS_CONSTRUCTOR.

122
NIKHEEL D. SHINDE 12
shindenikheel@gmail.com

7.5 Interface Concept in Object Oriented ABAP


Using interface concept with SAP Object Oriented ABAP programming.

Before going to interfaces, we must know about Polymorphism.

What is Polymorphism in Object Oriented Programming model?

It is a concept by which the same method names will behave differently in different classes i.e
each method will have its own implementation in different classes but with the same name.

Interface is one of the concept in Object Oriented ABAP to achieve Polymorphism.

What is an interface in Object Oriented ABAP?

 Interfaces are independent structure which is used in a class to extend the functionality of a
class.
 Interfaces contain methods without any implementation. Where as a class contains methods
with implementation.
 We need to define an interface with the required method names in SE24 TCODE.
 The interfaces can be used by no of classes to extend the functionality of the class.
 To implement an interface in a class just give the name of interface under the tab.
 All the interface methods will be automatically copied to the classes in a particular class
without affecting the other classes.
 The main use of interfaces is re-usability and maintain standard project framework.

In the above diagram, application is business application, Class A, Class B, Class C, Class D and
Class E are independent classes, all these classes are using one Interface called Interface( in
diagram).

In all the classes, the methods names are same but the implementation will be different from one
class to another class thereby achieving the concept called POLYMORPHISM. Polymorphism is
implemented in the form of interface.

123
NIKHEEL D. SHINDE 12
shindenikheel@gmail.com

7.6 Inheritance Concept in SAP Classes


What is inheritance in SAP Classes, uses of inheritance, properties of inheritance in SAP
OOABAP

Inheritance

Inheritance is the concept of passing the behavior of one class to another class.

You can use an existing class to derive a new class.

Derived class inherits the data and methods of a super class.

However they can overwrite the existing methods also add new code. Advantage of this property
is re-usability.

This means we can add additional features to an existing class without modifying it.

SUPER is the keyword used to represent the super class in oops, you can access the methods and
attributes the super class using this word super.

REDIFINATION is the keyword which is used to overwrite the parent class methods with new
definition.

NOTE: In Object Oriented ABAP we have only single inheritance. There is no multiple
inheritance.

Inheritance in general

Super Class Is a main class by using this we can derive a new class which will be called as Child
class.

Final Class is a class which cannot be used for inheritance, it is a class property (check box under
properties of class).

124
NIKHEEL D. SHINDE 12
shindenikheel@gmail.com

8.Reports

125
NIKHEEL D. SHINDE 12
shindenikheel@gmail.com

8.1 ABAP Report Programming


SAP-ABAP supports two types of Programs - Report Programs & Dialog Programs. Report
Programs are used when large amounts of data needs to be displayed

Purpose/Use of Report Programs

 They are used when data from a number of tables have to be selected and processed before
presenting
 Used when reports demand a special format
 Used when the report has to be downloaded from SAP to an Excel sheet to be distributed
across.
 Used when the report has to be mailed to a particular person.

Important Points to Note about Report Program

 Report Programs are always Executable Programs. Program Type is always 1.


 Every Report program corresponds to a particular Application Type i.e. either with Sales &
Distribution, FI - CO etc. It can also be Cross Application i.e. type '*'.
 Report Programming is an Event-driven programming.

 The first line of a report program is always Report <report-name>.


 In order to suppress the list heading or the name of the program the addition No Standard
Page Heading is used.
 The line size for a particular report can be set by using the addition line-size <size>.
 The line count for a particular page can be set by using the addition line-count n(n1). N is the
number of lines for the page and N1 is the number of lines reserved for the page footer.

Selection Screen

"Selection screen" is the screen where one specifies the input values for which the program should
run.

The selection screen is normally generated from the

1. Parameters:

Parameters helps one to do dynamic selection. They can accommodate only one value for one
cycle of execution of the program.

Syntax:

Defining parameters as a data type

Parameters p_id(30) type c.

Defining parameters like a table field.

Parameter p_id like <table name>-<field name>.

2. Select-Options:
126
NIKHEEL D. SHINDE 12
shindenikheel@gmail.com

A Select-Option is used to input a range of values or a set of values to a program

Syntax:

select-options s_vbeln for vbak-vbeln.

You can also define a select option like a variable

select-options s_vbeln for vbak-vbeln no intervals no-extension

8.2 Events in an ABAP Report Program


ABAP report programs are event driven programs. The different events in a report Program are:

 LOAD-OF-PROGRAM
First event to be called before any of the other ABAP code is processed

 INITIALIZATION
Called after the abap selection screen code has been processed (i.e. parameters, select-options
etc) but before these are displayed to the user. So you can use it to initialize input fields of the
selection screen or change the default values of these before the user gets to enter data into
them.

 AT SELECTION SCREEN OUTPUT


This is called just before the selection screen is displayed and can be used to manipulate the
actual selection screen attributes using the loop at screen functionality. This allows you to do
things like hide fields, grey them out so they are output only or make them intensified etc.

 AT SELECTION-SCREEN.
This event is triggered when the user presses enter on the report selection screen and is mainly
used to add processing related to screen validation. Within the AT SELECTION SCREEN
event you have not left the selection screen, which allows you to manipulate the values
contained within sel screen parameters or stop the program and return the user to the selection
screen by displaying an error message.

 AT SELECTION-SCREEN ON
This allows you to add processing to a selection screen field for when it is chnaged, user presses
F1 or F4 etc using the following parameters

 TOP-OF-PAGE
This is called when a new page is started with an ABAP list and is used to display a header for
the list.

 TOP-OF-PAGE During LINE_SELECTION


If you use the 'DURING LINE-SELECTION' addition this event is also triggered when creating
detailed lists.
127
NIKHEEL D. SHINDE 12
shindenikheel@gmail.com

 END-OF-PAGE
This is displayed at the end of each page if there is a line reservation in the addition LINE-
COUNT of the initiating statement for a page footer.

 START-OF-SELECTION
This event is called when . If the user executes the program either by pressing the execute
button or F8 this is the first event triggered after all screen selection processing has been
completed (AT Selection...). So pressing execute triggers both AT SELECTION and then
START-OF-SELECTION

If no other events are declared then there is no need to manually code this event as all
processing statements will be automatically assigned to an implicit START-OF-SELECTION
block. It is a good ideal to put it in though as it separates the code and makes it easier to read.
Generally you would put all you data selection ABAP code within this event.

 END-OF-SELECTION
If your report is linked to a logical database this event is called after the logical database has
completely finished its work. Otherwise this event is trigged after the START-OF-SELECTION
event so you would generally use it to processes the data retrieved in that event.

Interactive Programming

 Using Interactive Programming users can actively control the data retrieval and display of data
 Used to create a detailed list from a very basic list
 The detailed data is written on a secondary list.
 The secondary list may either completely overlay the first screen or one can display it in a new
screen
 The secondary lists can be themselves interactive.
 The first list may also call a transaction.
 There are different events associated with interactive programming.

Some commands used for interactive programming


Hotspot:
If one drags the mouse over the data displayed in the report the cursor changes to a Hand with an
Outstretched Index finger. A hotspot can be achieved using the FORMAT statement.

Syntax: Format Hotspot On (Off).

Hide:
This command helps you to store the field names based on which one will be doing further
processing to get a detailed list. It is written directly after the WRITE statement for a field. When a
row is selected the values get automatically filled in the variables for further use.

Syntax: Hide <field-name>.

128
NIKHEEL D. SHINDE 12
shindenikheel@gmail.com

Example:

************************* Classical & Interactive Report *************************

REPORT YSD_RPT.

TYPES: BEGIN OF FLS,


CARRID TYPE SFLIGHT-CARRID,
CONNID TYPE SFLIGHT-CONNID,
PRICE TYPE SFLIGHT-PRICE,
END OF FLS.

TYPES: BEGIN OF BKS,


CARRID TYPE SBOOK-CARRID,
BOOKID TYPE SBOOK-BOOKID,
LOCCURAM TYPE SBOOK-LOCCURAM,
PASSNAME TYPE SBOOK-PASSNAME,
PASSFORM TYPE SBOOK-PASSFORM,
END OF BKS.

DATA : flt TYPE TABLE OF FLS WITH HEADER LINE,


BKT TYPE TABLE OF BKS WITH HEADER LINE,
FL(50), VL(50).

SELECT CARRID
BOOKID
LOCCURAM
PASSNAME
PASSFORM
FROM SBOOK INTO TABLE BKT UP TO 100 ROWS WHERE CARRID = 'AZ'.

LOOP AT BKT.
WRITE : / BKT-CARRID ,
BKT-BOOKID ,
BKT-LOCCURAM,
BKT-PASSNAME,
BKT-PASSFORM.
ENDLOOP.

AT LINE-SELECTION.

CASE SY-LSIND.
WHEN '1'.
GET CURSOR FIELD FL VALUE VL.

SELECT CARRID
CONNID
PRICE
FROM SFLIGHT INTO TABLE FLT WHERE CARRID = VL.

LOOP AT FLT.
129
NIKHEEL D. SHINDE 13
shindenikheel@gmail.com

WRITE : / FLT-CARRID,
FLT-CONNID,
FLT-PRICE .
ENDLOOP.

ENDCASE.

******************** ABAP List Viewer Report: With All Fields *********************

DATA : FLIGHT TYPE TABLE OF SFLIGHT WITH HEADER LINE.

SELECT * FROM SFLIGHT INTO TABLE FLIGHT.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'


EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
TABLES
T_OUTTAB = FLIGHT
EXCEPTIONS
PROGRAM_ERROR =1
OTHERS =2
.

**************** ABAP List Viewer Report: With Selected Fields ********************

DATA : FLT TYPE TABLE OF ZSD_FLIGHT WITH HEADER LINE.

SELECT CARRID
CONNID
FLDATE
PRICE
SEATSMAX FROM SFLIGHT INTO TABLE FLT.

130
NIKHEEL D. SHINDE 13
shindenikheel@gmail.com

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'


EXPORTING
I_STRUCTURE_NAME = 'ZSD_FLIGHT'
TABLES
T_OUTTAB = FLT
EXCEPTIONS
PROGRAM_ERROR =1
OTHERS =2
.

************************** ALV Interactive Report *******************************

TYPE-POOLS : SLIS.
DATA : STL TYPE TABLE OF YPRSTUDENT WITH HEADER LINE,
CTL TYPE TABLE OF YPRCOURSE WITH HEADER LINE,

TEVN TYPE SLIS_T_EVENT,


WEVN TYPE SLIS_ALV_EVENT .

WEVN-NAME = 'USER_COMMAND'.
WEVN-FORM = 'DISP_COURSE'.
APPEND WEVN TO TEVN.

SELECT * FROM YPRSTUDENT INTO TABLE STL.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'


EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = '&IC1'
I_STRUCTURE_NAME = 'YPRSTUDENT'
IT_EVENTS = TEVN
TABLES
T_OUTTAB = STL.
131
NIKHEEL D. SHINDE 13
shindenikheel@gmail.com

EXCEPTIONS
PROGRAM_ERROR =1
OTHERS =2
.

FORM DISP_COURSE USING UCM TYPE SY-UCOMM


VL TYPE SLIS_SELFIELD .

CASE UCM.
WHEN '&IC1'.
IF VL-FIELDNAME = 'CID'.
SELECT * FROM YPRCOURSE INTO TABLE CTL WHERE ID = VL-VALUE.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'


EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_STRUCTURE_NAME = 'YPRCOURSE'
TABLES
T_OUTTAB = CTL
EXCEPTIONS
PROGRAM_ERROR =1
OTHERS =2
.

ENDIF.

ENDCASE.

ENDFORM.

132
NIKHEEL D. SHINDE 13
shindenikheel@gmail.com

9.Form
designing

133
NIKHEEL D. SHINDE 13
shindenikheel@gmail.com

Introduction of SAP Script & SMARTFORMS.

 A business form is used as a standard format to document various processes in a business.


Examples of business forms that companies routinely maintain to record the business processes
are invoices, credit memos, and delivery notes.
 The mySAP ERP system provides two SAP programming tools, SAP script and SAP Smart
Forms, to design, build, and print business forms.
 SAP script was the only tool in versions of SAP R/3 before release 4.6 that allowed you to use
built-in forms as templates to create the required business forms.
 SAP Smart Forms is an alternative tool used to design, build, and print business forms in an
SAP system.
 The SAP script tool cannot be used to print multiple forms simultaneously.
 To overcome this drawback, you can use the SAP Smart Forms tool, which supports mass
printing. In other words, you can design and print multiple forms simultaneously by using the
SAP Smart Forms tool.
 This tool provides the facility to print and send documents through e-mail, fax, and the
Internet, and was first shipped with SAP R/3 4.6.
 SAP script has two important components, a print program and a layout set. A print program is
a sequence of function modules such as OPEN_FORM, START_FORM, and WRITE_FORM.
 The print program is used to retrieve the data of a form and call the layout set objects, which
are called windows.
 In SAP script, an ABAP program populates the contents of a window through a function call
given by the print program.
 SAP Smart Forms, on the other hand, has three important components: a print program
manually, a layout set, and a function module.
 Unlike SAP script, where you have to activate a layout set for a form manually, the layout set
for the form is generated automatically in SAP Smart Forms.
 This automatic generation of a layout set creates a standard callable SAP function module,
which reduces the time to generate the output.
 This is because when a print program of Smart Forms calls a form, the form itself takes over
the task of generating the output (using the generated function module), without the
involvement of the print program.

9.2.1 Types of FORM DESIGNING:


1. SAP Script.
2. SMART-FORMS.

9.2.2 Difference between SAP Script & SMART-FORMS:

No. SAP Script SMART FORMS


1. No color para formatting option available. Declare color para formatting option globally
& reuse it in different FORMS.
2. No coding page available, have to create Coding page available, can be self-executable
Print/driver program. Without print/driver program.

134
NIKHEEL D. SHINDE 13
shindenikheel@gmail.com
3. No direct table format designing option Table as well Template direct format
Available, have to write BOX query for designing
each single row & column. Option available with dynamic & static data
size allocation.

135
NIKHEEL D. SHINDE 13
shindenikheel@gmail.com

4. Have to create print/driver program with Not necessary to create print/driver program.
Suitable 3 standard function modules It
(OPEN_FORM, WRITE_FORM, will auto generate STANDARD FUNCTION
CLOSE_FORM) for script execution. MODULE in background which navigate to
SE37 for execution of SMART-FORMS.
5. No TEXT MODULE option available for TEXT MODULE can create globally which is
simple para execution. reusable.
6. Cannot compile syntax & from designing. Compliable.
7. We cannot see and arrange windows on We can see & arrange also code the windows
page directly. paragraph simultaneously.
8. Cannot UPLOAD/DOWNLOAD. Can UPLOAD/DOWNLOAD.

9.3 SAP SCRIPT


9.3.1 Introduction

SAP Script is a tool which is used to printable business documents in SAP like invoice form, Sales
Order form, Delivery form, other form related to HR etc.

Scripts are older version of SAP print forms, advanced version to scripts are smartforms( we will
learn in next chapters ).

SAP Scripts are client dependent, that is if we develop a script in client 200, it will not be visible
in other clients like 300, 100.

Advanced version of scripts, smartforms are client independent, they will be visible in all clients.

Why SAP Scripts are client dependent?

If we generate a SAP Script, it will be internally stored as texts.

Texts are nothing but a data, as per SAP all data is client dependent, so SAP Scripts are client
dependent.

SE71 is the T-code for SAP scripts.

9.3.2 Components of SAP Scripts

1. Header (Administrative data and basic settings).


2. Pages.
3. Windows.
4. Page windows.
5. Paragraph format.
6. Character Format.
7. Layout.

136
NIKHEEL D. SHINDE 13
shindenikheel@gmail.com

9.3.2 Function Modules used in SAP Scripts

We use some function modules to develop SAP Scripts, explained below.

OPEN_FORM: This is used to open a form for execution by loading it into memory.

WRITE_FORM: It is used to write some information on the SAP Script form using Text
Element.

CLOSE_FORM: It is used to close the form which is opened by open form.

START_FORM: It is used to call another SAP Script into current SAP Script (Nested Scripts).

END_FORM: It is used to end the form which started by START_FORM.

9.3.4 Driver Program

A program which contains business logic statements i.e., all select statements, loops, appends etc,
is called Driver program.

In simple words, a program which is used to drive or print the script.

All the variables, work areas, internal tables which are declared in the driver program will be
automatically transferred to SAP Scripts.

If we want to display the variables or work area values we need to follow below syntax.

Example:

Go to T-CODE:SE71 for SAP Script creation, give name starts with y/z then click on CREATE.

137
NIKHEEL D. SHINDE 13
shindenikheel@gmail.com

Then press ENTER.

Give suitable meaning then SAVE (Ctrl+S). Click on PAGES button for page creation.

Give any page name & suitable meaning then SAVE (Ctrl+S). Click on WINDOWS button for page
creation.

138
NIKHEEL D. SHINDE 13
shindenikheel@gmail.com

Creation on new window click EDITCREATE ELEMENT. Give WINDOW name& MEANING
then ENTER.

Like this way create different windows as per requirement. Then click on PAGE WINDOWS
button.

139
NIKHEEL D. SHINDE 14
shindenikheel@gmail.com

Attaching created windows on PAGE go to EDITCREATE ELEMENT.

Double click on created window, which is listed to add on the created page. Give default width &
height for display on page.

140
NIKHEEL D. SHINDE 14
shindenikheel@gmail.com

After attaching all the windows, adjust those windows on created page graphically. Click on
SETTINGFORM PAINTER.

Checks on GRAPHICAL FORM PAINTER option then ENTER.

Adjust the windows position & size of window on page. For closing PAGE LAYOUT mode again
click on SETTINGFORM PAINTER. Uncheck the GRAPHICAL FORM PAINTER option &
ENTER.

140
NIKHEEL D. SHINDE 14
shindenikheel@gmail.com

Add text contents in required window, double click on that window and make it in highlighted
blue color & press F9.

Enter the required paragraph in that window then BACK(F3) to main screen of SAP Script &
SAVE (Ctrl+S). For uploading image on page window, open required windows TEXT ELEMENT.
Click on INSERT GRAPHICS.

141
NIKHEEL D. SHINDE 14
shindenikheel@gmail.com

Select 1st tab STRORED ON DOCUMENT SERVER then press F4. Checks on required option &
F8.

Select required image then ENTER.

Checks on required option, give resolution from given number list & ENTER.

IMAGE in query format. It will display at time of execution.

142
NIKHEEL D. SHINDE 14
shindenikheel@gmail.com

BOX query for designing table. TEXT ELEMENT for connecting script(SE71) to program(SE38).

Click on PARAGRAPH FORMAT button. Give name & meaning. Set the properties as per
requirement using multiple options & SAVE (Ctrl+S). Click on HEADER button.

Click on BASIC SETTING button. Set FIRST PAGE & DEFAULT PARAGR.

Click on FORMACTIVATE.
143
NIKHEEL D. SHINDE 14
shindenikheel@gmail.com

CALL SAP-SCRIPT IN SE38 ::

WHEN CREATING TABLE SCRIPT :: CODING :

TYPES: BEGIN OF STR,


MATNR TYPE MARA-MATNR,
ERSDA TYPE MARA-ERSDA,
ERNAM TYPE MARA-ERNAM,
END OF STR.

DATA : IT TYPE TABLE OF STR WITH HEADER LINE.

SELECT * FROM MARA INTO CORRESPONDING FIELDS OF TABLE IT UP TO 20 ROWS


.

CALL FUNCTION 'OPEN_FORM'


EXPORTING
FORM = 'YSIMT_SCRIPT'
144
NIKHEEL D. SHINDE 14
shindenikheel@gmail.com

LANGUAGE = SY-LANGU.

LOOP AT IT.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'SIMTEJ7'

WINDOW = 'MAIN'.
ENDLOOP.

CALL FUNCTION 'CLOSE_FORM'


* IMPORTING
* RESULT =
* RDI_RESULT =
* TABLES
* OTFDATA =.

--------------------------SAVE (CTRL+S) & ACTIVATE (CTRL+F3)  EXECUTE (F8) -------------------------------

EXECUTE SAP-SCRIPT PROGRAM :

Set OUTPUT DEVICE: LP01. Click on PRINT PREVIEW.

145
NIKHEEL D. SHINDE 14
shindenikheel@gmail.com

9.4 SMARTFORMS
9.4.1 Introduction

 Smart form is a GUI Tool which is used to design the business legal documents such as
Delivery note, Purchase order, Invoice etc.
 The transaction code is SMARTFORMS.
 Smartforms are client independent objects.
 Smartforms are advanced version of SAP Scripts.
 It is a GUI tool and it is user friendly.

9.4.2 Architecture

9.4.3 COMPONENTS OF SMARTFORMS.

There are two main nodes in Smartforms.

1. Global settings:

It is used to provide the basic settings for the smartform.

A. Form Attributes:

It specifies the general attributes like who created, Date, time, package, translate options, default
smartstyle, Page format (DINA4/DINA5).

B. Form interface:

It acts as a mediator between a driver program and a smart form.

146
NIKHEEL D. SHINDE 14
shindenikheel@gmail.com

The main functionality of form interface is, it will import the parameters which are exported by
driver program.

The parameters can be variables, work areas, internal tables..etc.

C. Global definition:

It will contain the variables to be used within the smart form.

We can define variables, user defined data types, field symbols, initialization code,Subroutine,
currency/quantity fields.

It is mainly used for declaring or defining the above variables.

2. Pages and Windows

A. Pages and windows

This will contain all the pages and the windows, which are used in the smartform.

By default, a page will be created by name %page1.

By default, a window will be created by name 'Main' under the page1.

For each page, we need to specify the next page.


Eg: page = %page1
Next page = %page1 or %page2

Nodes under pages

Page: It is used to define the layout of a smartform.

We can have different pages with different layouts.

Window: it is used to display information or text at a particular place on a page.

B. Graphic: it is used to display logos or images on the smartforms.

C. Address: It is used to display the address of customer or vendor or employee, organization


address, workplace address etc.

Just provide address no, it will automatically display the address as per the country formats.

Nodes under the window

D. Text: it is used to display the information or text in a window.

E. Table: It is used to display the information in the form of table.

Whenever we create table by default HEADER, MAIN AREA, FOOTER will be displayed.

The main functionality of a table is, it expands automatically depending on the internal table data.

147
NIKHEEL D. SHINDE 14
shindenikheel@gmail.com

We need to provide the name of the internal table for a table.

F. Template: template is also like a table which does not expand. That means it will have
fixed number of rows and columns.

G. Program lines: it is used to write some lines of abap code.

Window Types in Smartforms

Main window: For continuous output .

Secondary window: For output with a fixed length.

Final window: Special type of secondary window for outputting the information that is not known
until the end of form processing.

Copies window: Special type of secondary window for marking pages as copy or original.

Example Smartform GUI

148
NIKHEEL D. SHINDE 14
shindenikheel@gmail.com

10.Data
migration technique

149
NIKHEEL D. SHINDE 15
shindenikheel@gmail.com

10 The Data Transfer Techniques


Data can be uploaded into an SAP system with some predefined standard data transfer techniques.
Depending on the requirements of the user, the data can be transferred directly, through a batch
input session, or by using the BAPI technique.

10.1 Data transfer techniques


1. The batch input technique
2. The direct input technique
3. The BAPI technique

1. The Batch Input Technique:


In the batch input technique, data is transferred through a batch input session. For this, a batch
input session first is created by the data transfer program (also known as the batch input program).
This batch input session holds all the transferable data related to a transaction. This data is then
processed and transferred to the SAP system.

The following are some of the benefits of the batch input technique:

Facilitates transfer of large sets of data from a non-SAP system to an SAP system or between
two SAP systems.

Allows periodic data transfer at regular intervals, such as hourly or monthly.

Needs less monitoring as compared to other techniques. Only a periodic check made by the
system administrator is sufficient to ensure that all the batch input sessions are running properly.

Data Transfer Decision-Making:

The batch input process begins only after the decision to transfer data related to a transaction from
an external source to an SAP system is made. The external source from where the data is
transferred can
150
NIKHEEL D. SHINDE 15
shindenikheel@gmail.com

be a legacy system or any other external system. For example, the data related to the customers in
the older versions of SAP systems can be transferred to a new SAP system with the batch input
process.

Set Up Batch Input for Data Transfers:

The data related to a transaction can be entered in an SAP system either all at once or in small
chunks at regular intervals. The manner in which data is transferred can be set with the help of
customization settings in the SAP customization system.

Process Sessions :

The data to be transferred in an SAP system is maintained in the batch input session. Running any
batch input session means executing the transactions stored in the sessions and finally transferring
the data into an SAP system. Usually, the SAP system automatically executes the batch input
sessions; however, the data can also be processed with the SM35 transaction code. A batch input
session is processed in the following three modes:

Process/foreground mode— Specifies that you can interactively correct the incorrect
transactions.

Background mode— Specifies that you want to process the session in the background.

Display errors-only mode— Specifies that transactions that are not yet processed and do not
have any errors can be run non-interactively. If an error occurs in a transaction, the processing of
the session stops and the screen on which the error has occurred is displayed.

Check Batch Input:

The system administrator checks whether all the batch input sessions are running successfully.
This check can be performed with the help of the SM35 transaction code provided by SAP.

Analyze Errors:

In the Analyze Errors step, the system administrator analyzes the errors that have occurred while
processing the transactions.

Correct Errors:

After analyzing the errors, they need to be corrected, which is done by the combined effort of the
system administrator and the department associated with the data transfer. The batch input system
ensures that the processed transactions in a session are not executed again.

2. The Direct Input Technique:


In the direct input technique of data transfer, the data to be transferred into an SAP system is
stored in a data transfer file. This data transfer file is then checked to verify whether it meets
certain criteria for data transfer, such as the format of data being transferred. If the criteria
assigned by the SAP system are met, the data is transferred directly into the SAP system and the

151
NIKHEEL D. SHINDE 15
shindenikheel@gmail.com

database of the SAP system is updated. The following are the two ways in which the direct input
technique can be triggered:

 Starting the program directly— In this case, the system does not generate an error log.
Moreover, it is not possible to restart the system if an error occurs.
 Processing the data in the background— In this case, if any logical error occurs during the
processing of data, or the program performing the data transfer ends abruptly, the processing of
data can be restarted in the background. In background processing, the input file is not stored
on the application server.

In the direct input technique of data transfer, the load on the SAP system is reduced because no
data can be transferred twice in the SAP system.

3. The BAPI Technique:


A BAPI is a set of standard programming interfaces that provide access to the different business
processes and data used in a business application system, such as SAP. Apart from accessing
different business processes running within a business application system, BAPIs define their own
interfaces. These interfaces are implemented outside the SAP system in such a way that they can
be called from different external systems or applications developed by different customers.

At times, you might need to transfer legacy data files from one SAP system to another or from a
non-SAP system to an SAP system. Batch Data Communication (BDC) and Legacy System
Migration Workbench (LSMW) are two migration tools used to transfer data in the SAP system.
BDC uses some methods, such as the session and call transaction methods, to transfer data from
one SAP system to another or from a non-SAP system to an SAP system. It is used to transfer data
through SAP transactions. This means when you use the BDC tool for data transfer, the sequence
of steps is the same as when you use standard SAP transaction screens to upload data. The only
difference is that you can use different options for foreground and background processing.

10.2 Types of Data Migration:


1. BDC (Batch Data Control)
2. LSMW (Legacy System Migration Workbench)

152
NIKHEEL D. SHINDE 15
shindenikheel@gmail.com

10.4 BDC (Batch Data Control):

10.4.1 Data Transfer Methods


In an SAP system, various methods and techniques are used to transfer data. In this section, we
explore certain predefined methods that facilitate easy transfer of data in an SAP system:
1. The direct input method
2. The call transaction method
3. The batch input with sessions method

1. The Direct Input Method


The direct input method generally is used when you need to transfer a large amount of data
directly into an SAP system. In this method, a number of function modules are called to
transfer data directly to the database of an SAP system. These function modules also make
relevant checks to avoid any kind of errors during data transfer. If an error occurs, the error is
fixed with the help of a restart mechanism. However, to activate this mechanism, direct input
programs must be executed in the background. Table

2. The Call Transaction Method


In the call transaction method, an ABAP program is created to transfer data. This ABAP
program uses an ABAP statement, CALL TRANSACTION USING, to run an SAP
transaction. In this method, the data to be transferred does not need to be stored in a session for
later processing. Instead, the entire processing takes place directly with the ABAP program.
The call transaction method transfers data quicker than the batch input with session method,
which we discuss next.

3. The Batch Input with Session Method


In the batch input with session method, an ABAP program first reads the external data that is
to be transferred to an SAP system. This data is then stored in a batch input session (also
known as a session) created by the ABAP program. This session uses SAP transactions to
record all the actions required to transfer data into an SAP system. The transactions in the
generated sessions are executed whenever the session is processed.
A session can be monitored easily with the batch input management function. You can start the
batch input management function by selecting System > Services > Batch Input from the SAP
Easy Access screen.

Parameter Call Transaction Method Batch Input with Session


Method
Data processing The data is processed synchronously. The data is processed
asynchronously.
Data transfer The data from an individual transaction is The data can be transferred
transferred each time the CALL from many transactions at a
TRANSACTION USING statement is time.
called.
Data update in The data can be updated in the database of The data can be updated in
the SAP database the SAP system both synchronously and the database of the SAP
asynchronously. system synchronously.
Processing log No processing log is created for the batch A batch input processing log
input to be transferred. is generated for a session.

153
NIKHEEL D. SHINDE 15
shindenikheel@gmail.com

10.4.2 Data Transfer by Using the BDCDATA Structure

The data to be transferred in an SAP system is first processed by a call transaction or a batch input
session method. For this, you must first create an internal table. This internal table must be
structured according to the predefined ABAP Dictionary structure named BDCDATA. The
internal table stores the data that has to be transferred to an SAP system and all the actions needed
to process the required transactions. The following syntax shows how to declare an internal table
in an ABAP program:

DATA: <bdc_internal_tab> LIKE BDCDATA OCCURS <occurs-parameter>


WITH HEADER LINE.

In this syntax, the <bdc_internal_tab> expression shows the name of the internal table.
BDCDATA represents the predefined ABAP Dictionary structure of the internal table. This
BDCDATA structure consists of five fields: PROGRAM, DYNPRO, DYNBEGIN, FNAM, and
FVAL.

Field Name Type Length Short Text


PROGRAM CHAR 40 BDC module pool
DYNPRO NUMC 4 BDC screen number
DYNBEGIN CHAR 1 BDC screen start
FNAM CHAR 132 BDC field name
FVAL CHAR 132 BDC field content

10.4.3 Recording procedure for BDC:


Go to T-Code: SHDB. Click on NEW RECORDING button.

Give any name in RECORDING field & enter required T-Code, then press START RECORDING
button

154
NIKHEEL D. SHINDE 15
shindenikheel@gmail.com

Perform recording process for feeding data in required field & save.

After saving your values in required fields, BACK to RECORDING PROGRAM SCREEN.

155
NIKHEEL D. SHINDE 15
shindenikheel@gmail.com

SAVE recording program, BACK to RECORDING LIST SCREEN. Select the created recording,
then click on PROGRAM button.

Give the program name starts with Y/Z, select TRANSFRE FROM RECORDING option &
ENTER.

Give the TITLE for program & select TYPE: EXECUTABLE, then select SOURCE CODE button.
SAVE into your package & modify the given SE38 code of BDC with required types of BDC.

156
NIKHEEL D. SHINDE 15
shindenikheel@gmail.com

10.4.4 Creating BDC CALL TRANSACTION program:


TYPES : BEGIN OF STR,
MBRSH TYPE RMMG1-MBRSH,
MTART TYPE RMMG1-MTART,
MAKTX TYPE MAKT-MAKTX,
MEINS TYPE MARA-MEINS,
BISMT TYPE MARA-BISMT,
END OF STR.

DATA : AMAN TYPE TABLE OF STR WITH HEADER LINE,


BDCDATA LIKE TABLE OF BDCDATA WITH HEADER LINE.
*include bdcrecx1.

CALL FUNCTION 'UPLOAD'


EXPORTING
FILENAME =''
FILETYPE = 'DAT'
TABLES
DATA_TAB = AMAN.

LOOP AT AMAN.
REFRESH BDCDATA.
PERFORM AMMY.
CALL TRANSACTION 'MM01' USING BDCDATA MODE 'A'.
" A: FOREGROUND PRO ;; E: BACKGROUND PRO BUT DISPLAY ERROR ON
FOREGROUND ;; N: BACKGROUND PRO
ENDLOOP.
*perform open_group.

FORM AMMY.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'=AUSW'.
perform bdc_field using 'RMMG1-MBRSH'
AMAN-MBRSH.
perform bdc_field using 'RMMG1-MTART'
AMAN-MTART.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'MAKT-MAKTX'
157
NIKHEEL D. SHINDE 15
shindenikheel@gmail.com

AMAN-MAKTX.
perform bdc_field using 'BDC_CURSOR'
'MARA-BISMT'.
perform bdc_field using 'MARA-MEINS'
AMAN-MEINS.
perform bdc_field using 'MARA-BISMT'
AMAN-BISMT.
*perform bdc_transaction using 'MM01'.
*
*perform close_group.

ENDFORM.

FORM BDC_DYNPRO USING PROGRAM DYNPRO.


CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM.

FORM BDC_FIELD USING FNAM FVAL.


IF FVAL <> SPACE.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDIF.
ENDFORM.

10.4.5 Creating BDC SESSION program:

TYPES : BEGIN OF STR,


MBRSH TYPE RMMG1-MBRSH,
MTART TYPE RMMG1-MTART,
MAKTX TYPE MAKT-MAKTX,
MEINS TYPE MARA-MEINS,
BISMT TYPE MARA-BISMT,
END OF STR.

DATA : AMAN TYPE TABLE OF STR WITH HEADER LINE,


BDCDATA LIKE TABLE OF BDCDATA WITH HEADER LINE.
*include bdcrecx1.

CALL FUNCTION 'UPLOAD'


EXPORTING
158
NIKHEEL D. SHINDE 15
shindenikheel@gmail.com

FILENAME =''
FILETYPE = 'DAT'
TABLES
DATA_TAB = AMAN.

CALL FUNCTION 'BDC_OPEN_GROUP'


EXPORTING
GROUP = 'AMAN'
KEEP = 'X'
USER = SY-UNAME.

LOOP AT AMAN.
REFRESH BDCDATA.
PERFORM AMMY.

CALL FUNCTION 'BDC_INSERT'


EXPORTING
TCODE = 'MM01'
TABLES
DYNPROTAB = BDCDATA.
ENDLOOP.

CALL FUNCTION 'BDC_CLOSE_GROUP'


* EXCEPTIONS
* NOT_OPEN =1
* QUEUE_ERROR =2
* OTHERS =3

*perform open_group.
FORM AMMY.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'=AUSW'.
perform bdc_field using 'RMMG1-MBRSH'
AMAN-MBRSH.
perform bdc_field using 'RMMG1-MTART'
AMAN-MTART.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
159
NIKHEEL D. SHINDE 16
shindenikheel@gmail.com

perform bdc_field using 'MAKT-MAKTX'


AMAN-MAKTX.
perform bdc_field using 'BDC_CURSOR'
'MARA-BISMT'.
perform bdc_field using 'MARA-MEINS'
AMAN-MEINS.
perform bdc_field using 'MARA-BISMT'
AMAN-BISMT.
*perform bdc_transaction using 'MM01'.
*
*perform close_group.

ENDFORM.

FORM BDC_DYNPRO USING PROGRAM DYNPRO.


CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM.
FORM BDC_FIELD USING FNAM FVAL.
IF FVAL <> SPACE.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDIF.
ENDFORM.

160
NIKHEEL D. SHINDE 16
shindenikheel@gmail.com

10.5 LSMW (Legacy System Migration Workbench):

10.5.1 Significance of Data Migration:


 Data migration comes in the end of R/3 implementation.
 To start with Data Migration first configuration should be fully completed.
 Data migration is about 20% to 40% of the total implementation expenses.
 The LSM Workbench is an R/3-based tool that supports you when transferring data from
1. Non-SAP systems ("Legacy Systems") to R/3
2. Once or Periodically.
 The tool supports conversion of data
 The data can be imported into the R/3 system via
a. Batch Input
b. Direct Input
c. BAPI’s
d. IDocs.

10.5.2 LSM Workbench Versions:


 Version 1.0 of the LSM Workbench was made available to about 350 interested customers and
partners in the frame of the First Customer Shipment between March 1998 (CeBIT) and
middle of August 1998.
 In August 1998, version 1.0 of the LSM Workbench was made available to the public. Until
today, LSMW has been requested more than 1,000 times.
 In June 1999, version 1.5 of the LSM Workbench has been released.
 Since July 1999, version 1.6 of the LSM Workbench has been available.
 Presently we are using version 1.7

10.5.3 Basic Principles of the LSM Workbench:

The LSM Workbench was developed on the basis of the following principles:
 Most of the functions should reside in R/3. No collection of individual programs on different
platforms.
 The quality and consistence of the data imported into R/3 should be more important than speed
and performance of data migration. • Existing knowledge and coding should be used.
 The developed ”mapping" and rules should be reusable and thus be used repeatedly in projects.

10.5.4 Advantages of the LSM Workbench:


 Part of R/3 and thus independent of individual platforms.
 A variety of technical possibilities of data conversion.
 Data consistency due to standard import techniques:
1. Batch input
2. Direct input
3. BAPIs (Business Application Programming Interfaces)
4. IDocs (Intermediate Documents)
 Generation of the conversion program on the basis of defined rules.
161
NIKHEEL D. SHINDE 16
shindenikheel@gmail.com

 Clear interactive process guide.


 Interface for data in spreadsheet format.
 Creation of data migration objects on the basis of recorded transactions.

10.5.5 Functions of LSMW:


The LSM Workbench is a tool that supports data transfer from non-SAP systems to R/3.
The main functions of the LSM Workbench are:
 Import data (legacy data in spreadsheet tables and/or sequential files)
 Convert data (from source format to target format)
 Import data (into the database of the R/3 application)

10.5.6 Preconditions:

The following items should be considered in particular:


 Make sure that R/3 customizing is finished.
 Determine the data contained in your legacy system and which of the data will be required in
the future (with respect to business operation).
 Decide whether it makes sense to use this tool with respect to the data volume to be
transferred. (It may be easier to transfer very small data volumes into R/3 manually. In the case
of a very large data volume, batch input or Idoc techniques may cause extremely long
runtimes.)
 Identify the transaction(s) in R/3 via which you want to import the data into your SAP system.
 Run the relevant transaction in R/3 manually with test data from the legacy system and see
which fields must be filled. There may be required fields that do not correspond to data fields
in the legacy system. In such a case, you should better assign a fixed value or establish an
optional field for data transfer.
 Map the fields in advance in written form: Assign the source fields to the target fields.
 Determine the form in which non-SAP data will be transferred into the SAP system.
 In which way will the data be extracted from the non-SAP system? Note: The LSMW does
not extract data.
 In which form is the legacy data available? Determine accordingly which of the LSMW
functions will be applied.

If only a part of your legacy system will be replaced by R/3, determine which function will be
provided by the SAP system and which by the legacy system. If applicable, set up a concept of
data flows and interface architecture.

10.5.7 LSMW Procedure

Give PROJECT, SUB-PROJECT &OBJECT name then press CREATE.

162
NIKHEEL D. SHINDE 16
shindenikheel@gmail.com

Give SHORT DESCRIPTION for every field & ENTER, then EXECUTE.

Double click on 1STSTEP.

Press Ctrl+F1 for change mode.

Select BATCH INPUT RECORDING option, click on RECORDING OVERVIEW button.

163
NIKHEEL D. SHINDE 16
shindenikheel@gmail.com

Click on NEW RECORDING button, give RECORDING name & DESCREIPTION & ENTER.

Give required T-Code name & ENTER.

Perform recording steps by feeding the values in required fields.

After feeding the data in fields SAVE it & BACK to RECORDING PROGRAM SCREEN.

164
NIKHEEL D. SHINDE 16
shindenikheel@gmail.com

Double click on feeded value, give NAME & DESCRIPTION, also delete DEFAULT VALUE &
SAVE.

Back to RECORDING SCREEN, then back to 1st step’s initial screen.

165
NIKHEEL D. SHINDE 16
shindenikheel@gmail.com

Give created recording name, then SAVE &BACK.

Double click on 2nd step.

Click on CREATE STRUCTURE button, give STRUCTURE NAME at least length of 4 numeric-
character, then give DESCRIPTION & ENTER.

BACK to LSMW screen, then double click on 3RD STEP.

166
NIKHEEL D. SHINDE 16
shindenikheel@gmail.com

Press Ctrl+F1. Select created structure name. Click on MAINTAINAN SOURCE FIELD button.

Create required fields as per the sequence of fields present in recording &also assign its relevent
data type and length, then SAVE & BACK.

SAVE & BACK.

Double click on 4th step. Press Ctrl+F1 then SAVE & BACK.

167
NIKHEEL D. SHINDE 16
shindenikheel@gmail.com

Double click on 5th step, Press Ctrl+F1.

Put the cursor on 1 field & click on SOURCE FIELD button. Follow this procedure for each field.

168
NIKHEEL D. SHINDE 16
shindenikheel@gmail.com

SAVE & BACK to LSMW initial screen. Skip 6th step.

Create 1 notepad/excel non sap file (outside of SAP SYSTEM).

169
NIKHEEL D. SHINDE 17
shindenikheel@gmail.com

Double click on 7th step then press Ctrl+F1. Double click on 1st LEGACY DATA option.

Give file path & any NAME. Select TABULATOR option & ENTER.

SAVE & BACK to LSMW initial screen.

170
NIKHEEL D. SHINDE 17
shindenikheel@gmail.com

Double click on 8th step. Press Ctrl+F1 SAVE  BACK.

Double click on 9th step.

EXECUTE & BACK.

171
NIKHEEL D. SHINDE 17
shindenikheel@gmail.com

Double click on 10th step

ENTER.

BACK.

Double Click on 11th step.

172
NIKHEEL D. SHINDE 17
shindenikheel@gmail.com

EXECUTE &BACK.

Double Click on 12th step.

ENTER.

BACK.

173
NIKHEEL D. SHINDE 17
shindenikheel@gmail.com

Double Click on 13th step.

EXECUTE. ENTER.

Double Click on 14th step.

Select created SESSION FILE name & click on PROCESS button.

174
NIKHEEL D. SHINDE 17
shindenikheel@gmail.com

Select PROCESSING MODE & check 1st 2 options from ADDITION FEACTURE, then enter.

175
NIKHEEL D. SHINDE 17
shindenikheel@gmail.com

11.module pool
programming

176
NIKHEEL D. SHINDE 17
shindenikheel@gmail.com

11. Introduction to module pool programming

It is a special type of programming which is used to create custom SAP screens.

Transaction code for creating module pool programs is SE80.

Every module pool program must be executed with a transaction (T-code).

Events in Module pool programming

There are four events available in module pool programming.

PBO (Process Before Output):Triggered before MPP screen is displayed.

PAI (Process After Input): Triggered after MPP screen is displayed whenever user raises an
action. Also, Now PBO is also triggered.

POV (Process On Value Request): Triggered when User Clicks on search help or F4 Button.

POH (Process On Help Request): Triggered when User Clicks on search help or F4 Button.

Modularization techniques in Module Pool

Basically there are four include programs which are created automatically for an MPP program.

<MPP name>_TOP "top include program ,All data declarations.


<MPP name>_O01 "PBO include program , All logic related to PBO event
<MPP name>_I01 "PAI include program , All logic related to PAI event
177
NIKHEEL D. SHINDE 17
shindenikheel@gmail.com
<MPP name>_F01 "Forms include program , All logic related to subroutines

178
NIKHEEL D. SHINDE 17
shindenikheel@gmail.com

SCREEN

It is a visible layout which is displayed in the output. The components of the Screen are

Components of Screen:

 Attributes : Properties of screen


 Element List : List of UI/Library elements
 Flow-Logic : Abap logic related to MPP
 Layout : Screen Designing Area

Flow Logic in module pool

It will contain the logic related to screen in the form of modules By default, 2 events will be
available with their corresponding modules as below: Just uncomment the modules and create
them and write the abap logic.

PROCESS BEFORE OUTPUT.


*MODULE STATUS_0100.
PROCESS AFTER INPUT.
*MODULE USER_COMMAND_0100.

MODULE:

 It is an sub-program which contains the ABAP code for a screen .


 Flow-Logic cannot understand ABAP statements. So the entire ABAP code is written in
the form of modules.
 Since the entire abap logic is divided in the form of modules, that is why it is called
MODULE POOL PROGRAMMING

179
NIKHEEL D. SHINDE 18
shindenikheel@gmail.com

12. Enhancements

180
NIKHEEL D. SHINDE 18
shindenikheel@gmail.com

12.1 Enhancements

 SAP is a ERP software in which all standard business applications are delivered, some times
customer may need to add additional functionality to the existing applications based on
customer business requirements.
 The enhancement is a concept of adding your own functionality to SAP's standard business
applications without having to modify the original applications. To modify the standard SAP
behavior as per customer requirements, we can use enhancement framework.

Types of enhancements in SAP

12.2 User Exits


Initially SAP implemented enhancements in the form of User Exits and these are only available in
SD module, user exits are implemented in the form of subroutines and hence are also called as
FORM EXITS, User exits are empty subroutines that SAP developers have provided for you, you
can add your own source code in the empty subroutines.

All user exits starts with the word USEREXIT.

These are implemented in the form of subroutines and hence are also known as FORM EXITs.
The user exits are generally attached to the standard program by the SAP.

User exits are a type of system enhancement that was originally developed for the R/3 SD (Sales
and distribution) module.

User-exits are empty subroutines that SAP Developers have provided for you.

You can fill them with your own source code. Technically this is a modification.

All User exits start with the word USEREXIT_...FORM USEREXIT_XXXX ... ENDFORM.
User exits can be found in the following ways:

Go to Object Navigator (SE80), select Package and put VMOD (Application development R/3 SD
customer modification) and press enter. You will find all the includes for user exits in SD. You
will get User exits for Sales order, Delivery, Billing, Pricing etc. Most of the time documentation
is maintained for each subroutine which helps developer for better understanding of the
subroutine. Select the subroutine according to the requirement and start coding within the
subroutine.

12.3 Customer Exits


These are one type of enhancements that are available in some specific programs, screens and
menus within standard SAP Applications. These are Function Modules with a custom empty
include program, you can add your own functionality in these include programs.

Customer Exits are available in all SAP modules, where as user exits are only available in SD

180
NIKHEEL D. SHINDE 18
shindenikheel@gmail.com
module.

181
NIKHEEL D. SHINDE 18
shindenikheel@gmail.com

All customer exits ( Function Modules) starts with CALL CUSTOMER word.

SAP creates customer exits for specific programs, screens, and menus within standard
applications. These exits do not contain any functionality. Instead, the customer exits act as hooks.
You can hang your own add-on functionality onto these hooks.

Customer exits are nothing but a include in customer name space will be provided in the function
module which starts with CALL CUSTOMER. You can fill them with your own source code.
Technically this is an enhancement. User exits generally refer to SD module while customer exits
refer to all modules like MM, SD, PP, FICO etc.

Advantages of Customer Exits:


- They do not affect standard SAP source code .
- They do not affect software updates .
Disadvantages of Customer Exits:

- Customer exits are not available for all programs and screens found in the SAP System. You can
only use customer exits if they already exist in the SAP System.

Types of Customer Exits

1. Function Module exits.


2. Screen exits.
3. Menu exits.

1. Function Module exits.

Function module exits are exits developed by SAP. The exit is implemented as a call to a function
module. The code for the function module is written by the developer. You are not writing the
code directly in the function module, but in the include that is implemented in the function
module.

Format: CALL CUSTOMER-FUNCTION '910' The naming standard of function modules for
function module exits is:
EXIT_<program name>_<3 digit suffix>.
Examples: Function Module Exits: EXIT_SAPMF02K_001.
2. Screen Exits:

Allow customer to add fields to a screen via a sub screen in an SAP program. The sub screen is
called within the standard screen's flow logic. For this we need to implement FM Exits/Menu
Exits to write the logic for Screen Exits . All screen exits will be subscreens.

3. Menu exits:

Menu exits allow you to add your own functionality to menus. Menu exits are implemented by
SAP and are reserved menu entries in the GUI interface. The developer can add his/her own text
and logic for the menu.

Function codes for menu exits all start with "+". Format: +CUS (additional item in GUI status)

182
NIKHEEL D. SHINDE 18
shindenikheel@gmail.com

Methods to find out customer Exits:

There are numbers of way by using we can find out Customer Exits.

Enhancement: It is a group or container of the FM exits/Menu Exits/Screen Exits .

Project: It is an SAP Object which contains list of Enhancements. A project must be created for
each enhancement so that the corresponding exits in an enhancement will be in active state.

So, A project is group of Enhancements An Enhancement cannot be linked to more than one
project. It throws error CMOD is the Tcode for creating a project.

Finding customer exit with CALL CUSTOMER

We know every transaction is linked to a program, all customer exits(Function Modules) inside
programs starts with CALL CUSTOMER, so we can use CALL CUSTOMER to find them.

12.4 Difference Between User Exit & Customer Exit


User Exit Customer Exit
User exit is implemented in the form of a Subroutine A customer exit can be implemented as:
i.e. PERFORM xxx.
PERFORM userexit_save_document_prepare.  Function exit
 Screen Exit
 Menu Exit
 Field Exit

Example: CALL Customer function "XXX"


INCLUDE ZXXX. ."create and add logic
In case of a PERFORM, you have access to almost all You have access only to the importing,
the data. So you have better control, but more risk of exporting, changing and tables parameter of
making the system unstable. the Function Module. So you have limited
access to data.
User exit is considered a modification and not an A customer exit is considered an
enhancement because we are changing the existing enhancement because we are adding
code. additional functionality to the existing
one..not changing any thing.
You need Access Key for User Exit. You do not need access key.
Changes are lost in case of an upgrade. Customer exits came later and they
overcome the shortcomings of User Exit.
User Exit will be activated automatically when ever To activate a function exit, you need to
you activate the application (program). create a project in CMOD and activate the
project.

183
NIKHEEL D. SHINDE 18
shindenikheel@gmail.com

13. Badi

184
NIKHEEL D. SHINDE 18
shindenikheel@gmail.com

13 BADI (Business Add Ins)


Business Add-Ins may be simply defined as an object-oriented extension of the SAP enhancement
technique.

 Multiple implementations for same BADI can be done as BADI supports encapsulation of
data.
 They can be inserted into the SAP System to accommodate user requirements too specific to
be included in the standard delivery. Since specific industries often require special functions,
SAP allows you to predefine these points in your software.
 The Business Add-In enhancement technique differentiates between enhancements that can
only be implemented once and enhancements that can be used actively by any number of
customers at the same time. In addition, Business Add-Ins can be defined according to filter
values. This allows you to control add-in implementation and make it dependent on specific
criteria (on a specific Country value, for example).
 All ABAP sources, screens, GUIs, and table interfaces created using this enhancement
technique are defined in a manner that allows customers to include their own enhancements in
the standard. A single Business Add-In contains all of the interfaces necessary to implement a
specific task.
 The actual program code is enhanced using ABAP Objects.
 For each Business Add-In you have one interface and an adapter class that implements this.
The interface is implemented by the user.
 The generated class (Add-In adapter) has the following tasks:
 Control
 The adapter class calls the active implementations.
 Filtering
 If a Business Add-In is to be executed only under certain conditions, the adapter class ensures
that only certain implementations will be executed.
 This concept ensures mutlple use. Any Business Add-In that has been implemented once
already can be implemented again by those groups listed to the right of the software chain
shown in the above graphic.

13.2 Architecture:

185
NIKHEEL D. SHINDE 18
shindenikheel@gmail.com

In order to enhance a program, you must first define a Business Add-In. The application developer
creates an interface for the add-in. From this, enhancement management creates an adapter class
that implements the interface and thus provides the interface for implementation by the customer,
partner, and so on. The developer then creates an instance of the adapter class in the application
program and calls the corresponding method at the appropriate time.

13.3 Advantages of BADI


 The main advantage of using BADI is , we can create multiple implementations for a single
BADI definition.
 Whereas with the exits, we can create a single implementation.i.e a single project for a
enhancement.
 We cannot create another project (implementation) for enhancement which is already used.
That is why we go for BADI.

13.4 Types of BADI


 Single implementation BADI.
 Multiple implementation BADI.
 Filter BADI.
 Custom BADI (Not used/Rarely used)

Single implementation BADI:- A BADI which has only one implementation (single class) is
called single implementation BADI.

Multiple implementation BADI:- A BADI which has multiple implementations is called


multiple implementation BADI. By default all the implementations will be executed.

We cannot control the sequence of execution of multiple implementations.

Filter BADI It is type of BADI which has a filter value so that only those implementations which
satisfy the filter value are executed. The remaining implementations are not executed this type of
BADI is called a filter BADI.

Properties of BADI

 If WITH IN SAP checkbox is selected then this BADI is only used by sap.
186
NIKHEEL D. SHINDE 18
shindenikheel@gmail.com

 If multiple use checkbox is selected then it is a multiple implementation BADI.


 If multiple use checkbox is not selected then it is a single implementation BADI.
 If filter dependent checkbox is selected then it is filter dependent BADI. We need to specify
the filter type such as land1, bukrs, werks for the filter BADI.

13.5 Differences between BADI and Customer Exit

BADI Customer-exit
Business Add-Ins is a new SAP enhancement CUSTOMER EXITS (enhancements) are
technique based on ABAP Objects. FUNCTIONS so they are called using CALL
FUNCTION (or more exactly CALL
CUSTOMER FUNCTION
Badi’s allow for a multi-level system Customer exits assumes a two-level
landscape (SAP, partner, and customer infrastructure (SAP and customer solutions)
solutions, as well as country versions,
industry solutions, and the like). Business
Add-Ins can be created at each level within
such a system infrastructure
Some BADI can have multiple independent Customer-exit implemented in one project
implementations, which is much better for cannot be implemented in other.
software deployment as several developers
can implement the same BADI
independently.

187
NIKHEEL D. SHINDE 18
shindenikheel@gmail.com

14. Enhancement
framework

188
NIKHEEL D. SHINDE 18
shindenikheel@gmail.com

14.1 Enhancement Framework


Definition

The Enhancement Framework provides a technology for enhancing source code units without
modifying them. The basic mechanism is to offer the so-called enhancement options in
development objects. These enhancement options function like “hooks” where you can attach your
enhancements. The enhancement options are part of the development objects which can be
enhanced. When you assign an enhancement to an enhancement option, at runtime the
enhancement is processed when the control flow reaches the option. At runtime the enhancement
behaves as if it belongs to the development object it enhances, while the enhancement as a
transport object does not belong to the enhanced object.

Basic Concepts

The basic concepts in the Enhancement Framework are:

● Enhancement options: positions in repository objects where you can make enhancements.
Enhancement options can be explicit and implicit.

● Enhancement spots: containers for explicit enhancement options.

● Enhancement implementation elements: these contain the actual enhancement, for example, the
source code to be added.

● Enhancement implementations: containers for both enhancement implementation elements of


both implicit and explicit enhancement options.

14.2 The enhancement options are divided into two classes:


● Implicit enhancement options are provided by the framework and exist without any particular
preparation by a developer, they do not have to belong to a container (an enhancement spot).

● Explicit enhancement options have to be inserted explicitly in the source code. They are created
in an initial system and must be made known to developers in target systems by means of
enhancement spots.

The figure below shows an overview of enhancement spots and enhancement implementations.
The left part shows the relevant terminology for enhancement spots and the relationships between
them. It only applies to explicit enhancement options. No enhancement spots are required for
implicit enhancement options.

The right part shows the relevant terminology for enhancement implementations and the
relationships between them. This applies to enhancement implementations of both explicit and
implicit enhancement options.

189
NIKHEEL D. SHINDE 19
shindenikheel@gmail.com

On the implementation side, all implementation elements belong to other containers regardless of
whether they enhance implicit or explicit enhancement options. The containers on the definition
side and those on the implementation side are assigned to each other with a particular cardinality.

14.3 Grouping Enhancements


Enhancement options and their implementations must not be grouped together as they belong to
different stages of development. In the Enhancement Framework there are containers for the
enhancement options on the definition side and containers for the implementations on the
implementation side:

· Simple containers

These can only contain enhancement options or enhancement implementation elements. These
containers cannot be nested. One basic container can only hold elements of one type. For example,
a simple container cannot hold BAdIs and enhancement options at the same time.

· Composite containers

To make room for a nested structure there are composite containers that can hold basic containers
and other composite containers. These composite containers can contain basic containers for
different enhancement types. Since these composite containers can be nested, you can build a
structure that really fulfills the needs of your project. A simple structure looks like this:

190
NIKHEEL D. SHINDE 19
shindenikheel@gmail.com

When you create an enhancement from scratch, you always have to create the respective
containers first. This is similar to creating a method. A method is always part of a class. In the
same way, there is no standalone BAdI. Each BAdI is part of an enhancement spot and it is the
spot that functions as a transport object. That is why you cannot build a new BAdI and just forget
about the framework in the way you might be accustomed to with classic BAdIs. It is also not
possible to build the BAdI first and take care of how it fits in the structure of containers later.
When building a BAdI, you have to put the BAdI within the relevant structure from the very
beginning. But it is only mandatory to have simple containers. Composite enhancements spots and
composite enhancement implementations are not enforced by the tools.

14.4 Creating, Editing, and Deleting Enhancement Spots

Procedure:

Start the Object Navigator (SE80)

If you want to Then


Create a composite 1. Select the package in which you want to create the enhancement spot.
enhancement spot 2. Open the context menu and choose Create → Enhancement →
Composite Enhancement Spot.

A dialog appears.

3. Specify a name and a short description.

Optionally, you can assign the new spot to an already existing composite
enhancement spot.

4. Choose Activate to activate the new spot.

Create a 1. Open the desired package.

190
NIKHEEL D. SHINDE 19
shindenikheel@gmail.com

subordinate 2. Select the composite enhancement spot to which your new subordinate
composite composite point will belong.
enhancement point 3. Open the context menu and choose Create → Subordinate Composite
Enhancement Point.

A dialog appears.

4. Specify a name and a short description.


5. Choose Activate to activate the new subordinate point.
Result:

● The selected composite enhancement spot and its newly created


subordinate enhancement point are displayed in the object list in a list form
(not as a tree) on the same level.

● Choose the composite enhancement spot and select the Spot Composites
tab to check whether the new subordinate composite point is properly
attached.

● The header of the new subordinate point has to contain the name of the
composite enhancement spot to which this subordinate is attached.

● Use a forward navigation to navigate from parent to child and back.


Create a simple 1. Select the package in which you want to create the simple enhancement
enhancement spot spot.
2. Open the context menu and choose Create → Enhancement →
Enhancement Spot.

A dialog appears.

3. Specify a name and a short description.

Optionally, you can assign the new spot to an already existing composite
enhancement spot.

4. Select the desired technology from the Technology list.

Currently it is only possible to create enhancement spots of type “BAdI“.

Source code plug-ins can only be created inside the editor, because they
contain points and sections.

5. Choose Activate to activate the new simple enhancement spot.

Edit an 1. Select the package and expand it.


enhancement spot 2. Expand the Enhancements node.
3. Expand the Enhancement Spot node.
4. Select the desired enhancement spot.
191
NIKHEEL D. SHINDE 19
shindenikheel@gmail.com

5. Choose Change from the context menu.

Choose Display if you only want to display the enhancement spot.


Delete an 1. Select the package and expand it.
enhancement spot 2. Expand the Enhancements node.
3. Expand the Enhancement Spot node.
4. Select the desired enhancement spot.
5. Choose Delete from the context menu.

14.5 Creating, Editing, and Deleting Enhancement Implementations

Use

● If you have enhancement options, you have to create the enhancement implementations for the
related enhancement spots.

● If you have implicit enhancement options, you create the enhancement implementations directly.

Procedure:

1. Start the Object Navigator (SE80).


2. Open the package in which an enhancement implementation is defined or is to be created.

If you want to Then


Create an enhancement ● If you have an explicit enhancement option, select the enhancement
implementation spot in the Object Navigator and in the context menu choose Implement.

● For an implicit enhancement option, open the Enhancement Builder in


the relevant tool (ABAP Editor, Function Builder, Class Builder) for
executing an enhancement and continue with the following steps:

26. 1. Enter a name for the (simple) enhancement implementation.


27. 2. Enter a short text for the (simple) enhancement implementation.
28. 3. Select a composite enhancement implementation, or create a new
one.
29. 4. Choose Creation of Enhancement (Enter).

The subsequent process depends on the enhancement technology of the


enhancement spot.
Edit an enhancement 30. 1. Select the package and expand it.
implementation 31. 2. Expand the Enhancements node.
32. 3. Expand the Enhancement Implementations node.
33. 4. Select the desired enhancement implementation.
34. 5. Select Change from the context menu.

192
NIKHEEL D. SHINDE 19
shindenikheel@gmail.com

If you only want to display the enhancement implementation, choose


Display.

Delete an enhancement 35. 1. Select the package and expand it.


implementation 36. 2. Expand the Enhancements node.
37. 3. Expand the Enhancement Implementations node.
38. 4. Select the desired enhancement implementation.
39. 5. In the context menu, choose Delete.

193
NIKHEEL D. SHINDE 19
shindenikheel@gmail.com

15.Sap cross
application

194
NIKHEEL D. SHINDE 19
shindenikheel@gmail.com

15.1 SAP Cross Application


SAP released cross applications concept from SAP R/3 3.0 release, the purpose is to support sap
application developments across different SAP and NON-SAP systems.

Advantages of SAP Cross Applications

 Exchange of business data between different systems.


 Allows secure data transfer between SAP to NON-SAP systems.
 Business friendly architecture with multiple systems .

Components of SAP Cross applications.

 ALE(Application Link Enabling).


 BAPI(Business Application Programming Interface).
 EDI(Electronic Data Interchange).
 RFC(Remote Function Call).

15.2 RFC Concept


RFC (Remote Function Call)

 These are Special type of Function Module’s which are used to communicate with
remote servers.
 The remote servers can be SAP to SAP or SAP to Non-SAP servers.
 To make a function modules as remote enables function modules we have to add some
additional properties.
 Whenever we make a function module remote enables, an additional interface will be
created internally.
 All parameter interface (import/export) must be pass by value not pass by reference.

A remote enabled function module (RFC) is used to communicate with remote servers, how? We
must know about RFC Destination.
195
NIKHEEL D. SHINDE 19
shindenikheel@gmail.com

RFC Destination

RFC Destination is a communication network between two remote servers, by using this two
servers can communicate each other.

SM59 is the T-code to create RFC Destination, in general RFC destinations will be created by
Basis Consultants.

Why RFC function modules?

These RFC function modules very much useful in communicating with other servers in a business
process, in real time business most of the companies maintain more than one servers, they need to
communicate each other to perform a business operation.(Example: In my current company sales
order will be created in some other system(NON SAP), materials will be maintained some other
system(SAP), they often need to communicate to process a sales order, purchase order ).

15.3 BOR (Business Object Repository)


The Business Object Repository (BOR) is the object-oriented repository in the R/3 System. It
contains the SAP business object types and SAP interface types as well as their components, such
as methods, attributes and events.
BAPIs are defined as methods of SAP business object types (or SAP interface types) in the BOR.
Thus defined, the BAPIs become standard with full stability guarantees as regards their content
and interface.
For general information on creating business objects see the documentation on

Use:
The BOR has the following functions for SAP business object types and their BAPIs:
1. Provides an object oriented view of R/3 System data and processes.
2. R/3 application functions are accessed using methods (BAPIs) of SAP Business Objects.
Implementation information is encapsulated; only the interface functionality of the method
is visible to the user.
3. Arranges the various interfaces in accordance with the component hierarchy, enabling
functions to be searched and retrieved quickly and simply.
4. This finds the functionality searched for quickly and simply.
5. Manages BAPIs in release updates.
6. BAPI interface enhancements made by adding parameters are recorded in the BOR.
Previous interface versions can thus be reconstructed at any time. When a BAPI is created
the release version of the new BAPI is recorded in the BOR. The same applies when any
interface parameter is created.
7. The version control of the function module that a BAPI is based on is managed in the
Function Builder.
8. Ensures interface stability.
9. Any interface changes that are carried out in the BOR, are automatically checked for
syntax compatibility against the associated development objects in the ABAP Dictionary.
Integration:
A BAPI is implemented as a function module, that is stored and described in the Function Builder.
You should only define a BAPI as a method of an SAP business object type in the BOR, if the
function module that the BAPI is based on has been fully implemented.
196
NIKHEEL D. SHINDE 19
shindenikheel@gmail.com

15.4 BAPI (Business Application Programming Interface)

What is a BAPI?

BAPI is a remote enabled function module, which is used to communicate between SAP to SAP, SAP
to NON-SAP systems.

BAPI RFC function module will be inserted into business object, it will convert into BAPI.

How BAPI is created?

 Remote Enabled Function Module created.


 Remote enabled function module inserted into a business object.
 BAPI created.

Uses of BAPI

In SAP BAPI`s can be used for

 Generating reports.
 For communication between different servers SAP to SAP or SAP to NON-SAP.
 BAPI`s can be used for data migration.

Difference between BAPI and RFC.

BAPI RFC
Used for communication Between SAP to SAP Used for communication Between SAP to SAP and
and SAP to non-SAP SAP to non-SAP
BAPI is a part of business object, it can RFC is a standalone function module, it cannot
communicate with other BAPI`s. communicate with other RFC`s
BAPI Uses Object Oriented concepts RFC uses procedure oriented concepts

197
NIKHEEL D. SHINDE 19
shindenikheel@gmail.com

15.5 COMMIT BAPI


 By simply looking at BAPI_TRANSACTION_COMMIT code, we see quickly what is
different from COMMIT WORK. It calls BUFFER_REFRESH_ALL function module right
after COMMIT WORK.
 So BAPI_TRANSACTION_COMMIT additionally refreshes a "BAPI buffer".
 Here is what BAPI buffer is for:
 Assuming your program calls BAPIs consecutively and use a COMMIT
WORK/BAPI_TRANSACTION_COMMIT only at the end so that to commit all BAPI
updates once (better performance).
 As you know, BAPIs need to check errors like data missing in database. For example, the
second BAPI may have to check the existence of data written by the previously called BAPI.
The data doesn't exist in database yet, but as it knows it will be written later at COMMIT
WORK time, it uses a buffer (memory) to store this information, so that no error is raised.
 Let's suppose the update during the COMMIT WORK fails (for any reason), the data is not
written to database. If you have not refreshed the buffer using
BAPI_TRANSACTION_COMMIT, the next BAPI calls will consider that some data will
exist later, that is wrong.
 The same kind of logic applies to the rollback: you must call
BAPI_TRANSACTION_ROLLBACK instead of ROLLBACK WORK. It will empty the
BAPI buffer too. Here's why:
 If you rollback the first BAPI using ROLLBACK WORK statement, you must absolutely
refresh the buffer, otherwise the next BAPI could think that the data will exist and would
attempt erroneously to write data.
 To test a BAPI, you need to use a test sequence in SE37, for calling
BAPI_TRANSACTION_COMMIT.
 SAP library documentation about BAPI template code shows why buffers were initially
required at an older time: as only PERFORM ON COMMIT was available (CALL
FUNCTION IN UPDATE TASK did not exist yet), all data had to be retained in memory
(because the form is called once though registered several times).
 Now, as only CALL FUNCTION IN UPDATE TASK should be used, it makes obsolete this
documentation and the need for storing data in memory. But buffer is still in use as I explained
above.

198
NIKHEEL D. SHINDE 19
shindenikheel@gmail.com

1 .Ale idoc

199
NIKHEEL D. SHINDE 20
shindenikheel@gmail.com

16.1 ALE IDOC


What is IDOC?

IDOC is acronym for Intermediate Document, which is a standard data format of SAP to
interchange data between two systems.IDOC enables connection between different applications
using a message based interface.

Features and Advantages of IDOC

 Structured data exchange.


 Automatic posting of data in application documents.
 Error handling.
 Reduction of very complex structures to simple structure.
 Reduce processing time.
 Standard communication.
 Availability of data in electronic form.
 Flexible business process by connecting to multiple systems.
 Real-time data transfer between different applications.

ALE

Application link enabling is a mechanism through which multiple SAP R/3 systems can
communicate each other. Integration of distributed systems is possible with application link
enabling.

EDI

EDI stands for Electronic Data Interchange, which is used to exchange business documents
between different systems with a standard data format over a communication network, the systems
can be SAP - SAP or SAP - Non-SAP.

Types of processes of EDI/ALE EDI/ALE has two kinds of processes

 Inbound Process
 Outbound Process

What is inbound process and how it works?

Inbound process is the process of transferring data into a SAP system from an SAP R/3 system of
Non-SAP system. The following steps will takes place in inbound IDOC process.

200
NIKHEEL D. SHINDE 20
shindenikheel@gmail.com

Inbound IDOC process happens in the following steps:

1. EDI converted to IDOC


2. IDOC passed to application
3. Application processes data
4. Updates status to IDOC

What is outbound IDOC and hot it works?

Outbound IDOC is the process of transferring data from an SAP system to another SAP system or
to Non-SAP system.

The following steps will takes place in outbound IDOC process.

1. IDOC Generated
2. IDOC transferred SAP to EDI layer
3. IDOC converted to EDI format
4. Data transferred to partner
5. New status will be updated

Structure of IDOC

Basically IDOC flows with three types of records

1. Control Record

Every IDOC has only one control record, it carries only one record with information related to
port, partner of sender and receiver etc.

2. Data Record

This is the record which carries actual business data in the form of segment's example Material
Master Data, Customer master data etc.

There may be n number of data records for an IDOC.

3. Status Record

This is the record, which stores the status of IDOC processing stages ex: application document
posted, Document contains errors etc. There may be n number of status records for an IDOC.

201
NIKHEEL D. SHINDE 20
shindenikheel@gmail.com

202
NIKHEEL D. SHINDE 20
shindenikheel@gmail.com

17.SAP
STANDARD
TABLES

203
NIKHEEL D. SHINDE 20
shindenikheel@gmail.com

Tables for practice:

1. Flight Table 2. Patient

Flight No Primary Key Patient id Primary key


Date Name
Max seats Address
Fair Per person cost (CURR) City
Age

3. Course 4. Login table

Course id Primary key Login id Primary key


Name Username Primary key
Duration Password
Fees (CURR) First name
Last name

5. Doctor 6. Hospital table


Doctor id Primary key Bed no Primary key
Name Doctor id Foreign key (doctor table)
Designation Patient id Foreign key (patient table)
Address Admit date
City Charges per day (CURR)
salary Total amount (CURR)

7. Student Booking id Primary key


Booking Flight no Foreign key (flight table)
Customer name
Student id Primary key Address
Course id Foreign key City
(course table) Phone no
Student name Email id
Address Payment type CASH/CHEQUE/CARD
City Card no 16 digit
Phone no Amount (CURR)
Grade

204
NIKHEEL D. SHINDE 20
shindenikheel@gmail.com

205
NIKHEEL D. SHINDE 20
shindenikheel@gmail.com

13.T-CODES
LIST

206
NIKHEEL D. SHINDE 20
shindenikheel@gmail.com

207
NIKHEEL D. SHINDE 20
shindenikheel@gmail.com

208
NIKHEEL D. SHINDE 20
shindenikheel@gmail.com

209
NIKHEEL D. SHINDE 21
shindenikheel@gmail.com

210
NIKHEEL D. SHINDE 21
shindenikheel@gmail.com

210

You might also like