Abap 4
Abap 4
Abap 4
SHINDE 1
shindenikheel@gmail.com
SAP ABAP/4
1
NIKHEEL D. SHINDE 2
shindenikheel@gmail.com
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
5
NIKHEEL D. SHINDE 6
shindenikheel@gmail.com
1. ERP SAP
6
NIKHEEL D. SHINDE 7
shindenikheel@gmail.com
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 Vendors –
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)
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
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
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.
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).
The services offered by an application server are determined by the types of its work processes.
Dialog work processes deal with requests from an active user to execute dialog steps.
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 processes process programs that can be executed without user interaction
(background jobs).
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.
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.
• 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. Project Preparation
2. Business Blueprint
3. Realization
4. Final Preparation
5. Go Live & Support
14
NIKHEEL D. SHINDE 15
shindenikheel@gmail.com
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:
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.
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
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.
16
NIKHEEL D. SHINDE 17
shindenikheel@gmail.com
Change requests are named in a standard format as: <SID>K<Number> [Not modifiable by
system administrators]
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?
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.
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).
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.
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.
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.
Elementary types
Complex types
Reference types
22
NIKHEEL D. SHINDE 23
shindenikheel@gmail.com
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
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
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:
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
The processing block of the ABAP program consists of several statements, some of which are:
IF...ENDIF
CASE...ENDCASE
DO...ENDDO
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 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 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 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
28
NIKHEEL D. SHINDE 29
shindenikheel@gmail.com
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.
Write a required code & ACTIVATE (Ctrl+F3) the program. Then Execute Program (F8)
30
NIKHEEL D. SHINDE 31
shindenikheel@gmail.com
1. SPLIT - This function is used to split the given string value based an any
separator and save in separate string variables.
eg. code:
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.
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:
5. TRANSLATE - This string function is used to change the case of the given
string value.
44
eg. code:
6. CONDENSE - This string function is used to remove the blank spaces in the
given string.
eg. code:
7. REPLACE - This string function is used to replace the given string with
specified string value.
eg. code:
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
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.
33
NIKHEEL D. SHINDE 34
shindenikheel@gmail.com
Give SHOTR TEXT, then SAVE (Ctrl+S) & Click on MESSAGE tab
34
NIKHEEL D. SHINDE 35
shindenikheel@gmail.com
3. ABAP/DATA
DICTIONARY
35
NIKHEEL D. SHINDE 36
shindenikheel@gmail.com
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.
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
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.
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).
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.
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.
Technical settings— Specify the settings of the table, such as data class and size category.
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.
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
Database 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).
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.
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
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.
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) Data Element & BACK (F3) to field creation screen.
44
NIKHEEL D. SHINDE 45
shindenikheel@gmail.com
Set DATA CLASS = APPL0 & SIZE CATEGORY = 0, then SAVE(Ctrl+S) & BACK(F3).
45
NIKHEEL D. SHINDE 46
shindenikheel@gmail.com
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
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.
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 KEYFOREIGN KEY relationship.
Click on RELATIONSHIP button & select required table name with suitable key field relationship
& ENTER.
49
NIKHEEL D. SHINDE 50
shindenikheel@gmail.com
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
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.
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
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.
Give any suitable SHORT DECRIPTION & give that TABLE NAME for which we have to create
DATABASE VIEW& also having PREIMARY KEYFOREIGN KEY relationship.
56
NIKHEEL D. SHINDE 57
shindenikheel@gmail.com
Click on RELATIONSHIP button & select required table name with suitable key field relationship
& ENTER.
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.
58
NIKHEEL D. SHINDE 59
shindenikheel@gmail.com
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
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.
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 KEYFOREIGN 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
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 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:
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
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.
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 STRUCTURE field, give created & activated INCLUDE STRUCTURE name, then ENTER.
68
NIKHEEL D. SHINDE 69
shindenikheel@gmail.com
Insert required data with newly created field using INCLUDE STRUCTURE.
69
NIKHEEL D. SHINDE 70
shindenikheel@gmail.com
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.
Click on APPEND STRUCTURE button, then ENTER or select CREATE button icon.
71
NIKHEEL D. SHINDE 72
shindenikheel@gmail.com
Create fields as per requirement with regarding DATA ELEMENT & DOMAIN.
72
NIKHEEL D. SHINDE 73
shindenikheel@gmail.com
Insert required data with newly created field using INCLUDE STRUCTURE.
73
NIKHEEL D. SHINDE 74
shindenikheel@gmail.com
Press F8.
74
NIKHEEL D. SHINDE 75
shindenikheel@gmail.com
75
NIKHEEL D. SHINDE 76
shindenikheel@gmail.com
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.
Select SEARCH HELP option, give name starts with y/z then click on CREATE button.
76
NIKHEEL D. SHINDE 77
shindenikheel@gmail.com
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.
77
NIKHEEL D. SHINDE 78
shindenikheel@gmail.com
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.
80
NIKHEEL D. SHINDE 81
shindenikheel@gmail.com
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.
Press ENTER.
82
NIKHEEL D. SHINDE 83
shindenikheel@gmail.com
ELEMENTARY
SEARCH HELP-
SINGLE TAB
83
NIKHEEL D. SHINDE 84
shindenikheel@gmail.com
COLLECTIVE
SEARCH HELP-
MULTIPLE TAB
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.
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
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.
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.
REPORT YSP_INTERNAL_HL.
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.
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.
ctab-name = 'sam'.
ctab-salary = 6500.
DELETE TABLE ctab.
LOOP AT ctab.
WRITE : ctab-name, ctab-salary, /.
ENDLOOP.
salary TYPE i,
END OF itab1.
DATA : ctab1 like SORTED TABLE OF itab1 with UNIQUE KEY id WITH HEADER LINE.
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.
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.
LOOP AT ctab1.
WRITE : ctab1-id, ctab1-name, ctab1-phno, ctab1-salary, /.
ENDLOOP.
DATA : ctab2 like HASHED TABLE OF itab2 with UNIQUE KEY id WITH HEADER LINE.
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.
LOOP AT ctab2.
WRITE : ctab2-id, ctab2-name, ctab2-phno, ctab2-salary, /.
ENDLOOP.
LOOP AT ctab2.
WRITE : ctab2-id, ctab2-name, ctab2-phno, ctab2-salary, /.
ENDLOOP.
OUTPUT :
sid 5.000
sam 6.000
shree 7.000
sid 8.000
sam 6.500
shree 7.000
sid 8.000
shree 7.000
94
NIKHEEL D. SHINDE 95
shindenikheel@gmail.com
1 Om 947.845 8.600
1 Om 947.845 8.600
1 Om 947.845 8.600
REPORT YSP_INTERNAL_WA.
salary TYPE i,
END OF itab.
wa-name = 'sam'.
wa-salary = 5500.
INSERT wa INTO TABLE itab.
wa-name = 'shree'.
wa-salary = 8000.
APPEND wa to itab.
wa-name = 'shree'.
wa-salary = 7000.
MODIFY TABLE itab FROM wa.
wa-name = 'sam'.
96
NIKHEEL D. SHINDE 97
shindenikheel@gmail.com
wa-salary = 5500.
DELETE TABLE itab FROM wa.
OUTPUT :
sid 4.500
sam 5.500
shree 8.000
sam 5.500
sid 4.500
sam 5.500
shree 7.000
sid 4.500
shree 7.000
97
NIKHEEL D. SHINDE 98
shindenikheel@gmail.com
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>[].
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.
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 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.
AT FIRST.
ENDAT.
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.
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.
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.
WRITE:/14 gwa_spfli-connid,
29 gwa_spfli-cityfrom,44 gwa_spfli-cityto,
58 gwa_spfli-distance.
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
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.
Data Definition Language (DDL) statements are used to define the database structure or schema.
Some examples:
DML
Data Manipulation Language (DML) statements are used for managing data within schema
objects. Some examples:
DCL
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
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:
WRITE RESULT.
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:
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.
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:
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.
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.
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.
106
NIKHEEL D. SHINDE 10
shindenikheel@gmail.com
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.
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
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.
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.
110
NIKHEEL D. SHINDE 11
shindenikheel@gmail.com
2. Include programs:
Example:
***INCLUDE STARTTXT.
WRITE: / 'Program started by', SY-UNAME,
/ 'on host', SY-HOST,
'date: ' , SY-DATUM,
'time: ' , SY-UZEIT.
ULINE.
PROGRAM SAPMZTST.
INCLUDE STARTTXT. “ calling of include program
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:
Calling Subroutine:
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.
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> ..
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:
Enter your PACKAGE NAME in given field. Right click on your PACKAGE
NAMECREATEFUNCTION 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 nameACTIVATE.
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
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.
117
NIKHEEL D. SHINDE 11
shindenikheel@gmail.com
Select CALL FUNCTION option, give created FUNCTION MODULE name & ENTER.
118
NIKHEEL D. SHINDE 11
shindenikheel@gmail.com
7.Object oriented
abap/4
119
NIKHEEL D. SHINDE 12
shindenikheel@gmail.com
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.
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.
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
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 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 =>.
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: 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.
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
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.
CONSTRUCTOR.
These methods can only have importing parameters, there will not be any exporting parameters.
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.
122
NIKHEEL D. SHINDE 12
shindenikheel@gmail.com
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.
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
Inheritance
Inheritance is the concept of passing the behavior of one class to another 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
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.
Selection Screen
"Selection screen" is the screen where one specifies the input values for which the program should
run.
1. Parameters:
Parameters helps one to do dynamic selection. They can accommodate only one value for one
cycle of execution of the program.
Syntax:
2. Select-Options:
126
NIKHEEL D. SHINDE 12
shindenikheel@gmail.com
Syntax:
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.
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.
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.
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.
128
NIKHEEL D. SHINDE 12
shindenikheel@gmail.com
Example:
REPORT YSD_RPT.
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.
SELECT CARRID
CONNID
FLDATE
PRICE
SEATSMAX FROM SFLIGHT INTO TABLE FLT.
130
NIKHEEL D. SHINDE 13
shindenikheel@gmail.com
TYPE-POOLS : SLIS.
DATA : STL TYPE TABLE OF YPRSTUDENT WITH HEADER LINE,
CTL TYPE TABLE OF YPRCOURSE WITH HEADER LINE,
WEVN-NAME = 'USER_COMMAND'.
WEVN-FORM = 'DISP_COURSE'.
APPEND WEVN TO TEVN.
EXCEPTIONS
PROGRAM_ERROR =1
OTHERS =2
.
CASE UCM.
WHEN '&IC1'.
IF VL-FIELDNAME = 'CID'.
SELECT * FROM YPRCOURSE INTO TABLE CTL WHERE ID = VL-VALUE.
ENDIF.
ENDCASE.
ENDFORM.
132
NIKHEEL D. SHINDE 13
shindenikheel@gmail.com
9.Form
designing
133
NIKHEEL D. SHINDE 13
shindenikheel@gmail.com
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.
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.
Texts are nothing but a data, as per SAP all data is client dependent, so SAP Scripts are client
dependent.
136
NIKHEEL D. SHINDE 13
shindenikheel@gmail.com
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.
START_FORM: It is used to call another SAP Script into current SAP Script (Nested Scripts).
A program which contains business logic statements i.e., all select statements, loops, appends etc,
is called Driver program.
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
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 EDITCREATE 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
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
SETTINGFORM PAINTER.
Adjust the windows position & size of window on page. For closing PAGE LAYOUT mode again
click on SETTINGFORM 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.
Checks on required option, give resolution from given number list & ENTER.
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 FORMACTIVATE.
143
NIKHEEL D. SHINDE 14
shindenikheel@gmail.com
LANGUAGE = SY-LANGU.
LOOP AT IT.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'SIMTEJ7'
WINDOW = 'MAIN'.
ENDLOOP.
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
1. Global settings:
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:
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.
C. Global definition:
We can define variables, user defined data types, field symbols, initialization code,Subroutine,
currency/quantity fields.
This will contain all the pages and the windows, which are used in the smartform.
Just provide address no, it will automatically display the address as per the country formats.
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
F. Template: template is also like a table which does not expand. That means it will have
fixed number of rows and columns.
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.
148
NIKHEEL D. SHINDE 14
shindenikheel@gmail.com
10.Data
migration technique
149
NIKHEEL D. SHINDE 15
shindenikheel@gmail.com
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.
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.
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.
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.
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.
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.
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.
152
NIKHEEL D. SHINDE 15
shindenikheel@gmail.com
153
NIKHEEL D. SHINDE 15
shindenikheel@gmail.com
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:
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.
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
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.
FILENAME =''
FILETYPE = 'DAT'
TABLES
DATA_TAB = AMAN.
LOOP AT AMAN.
REFRESH BDCDATA.
PERFORM AMMY.
*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
ENDFORM.
160
NIKHEEL D. SHINDE 16
shindenikheel@gmail.com
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.6 Preconditions:
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.
162
NIKHEEL D. SHINDE 16
shindenikheel@gmail.com
Give SHORT DESCRIPTION for every field & ENTER, then EXECUTE.
163
NIKHEEL D. SHINDE 16
shindenikheel@gmail.com
Click on NEW RECORDING button, give RECORDING name & DESCREIPTION & ENTER.
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.
165
NIKHEEL D. SHINDE 16
shindenikheel@gmail.com
Click on CREATE STRUCTURE button, give STRUCTURE NAME at least length of 4 numeric-
character, then give DESCRIPTION & ENTER.
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.
Double click on 4th step. Press Ctrl+F1 then SAVE & BACK.
167
NIKHEEL D. SHINDE 16
shindenikheel@gmail.com
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
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.
170
NIKHEEL D. SHINDE 17
shindenikheel@gmail.com
171
NIKHEEL D. SHINDE 17
shindenikheel@gmail.com
ENTER.
BACK.
172
NIKHEEL D. SHINDE 17
shindenikheel@gmail.com
EXECUTE &BACK.
ENTER.
BACK.
173
NIKHEEL D. SHINDE 17
shindenikheel@gmail.com
EXECUTE. ENTER.
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
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.
Basically there are four include programs which are created automatically for an MPP program.
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:
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.
MODULE:
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.
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.
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.
- 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.
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
There are numbers of way by using we can find out Customer 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.
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.
183
NIKHEEL D. SHINDE 18
shindenikheel@gmail.com
13. Badi
184
NIKHEEL D. SHINDE 18
shindenikheel@gmail.com
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.
Single implementation BADI:- A BADI which has only one implementation (single class) is
called single implementation BADI.
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
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
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
● Enhancement options: positions in repository objects where you can make enhancements.
Enhancement options can be explicit and implicit.
● Enhancement implementation elements: these contain the actual enhancement, for example, the
source code to be added.
● 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.
· 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.
Procedure:
A dialog appears.
Optionally, you can assign the new spot to an already existing composite
enhancement spot.
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.
● 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.
A dialog appears.
Optionally, you can assign the new spot to an already existing composite
enhancement spot.
Source code plug-ins can only be created inside the editor, because they
contain points and sections.
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:
192
NIKHEEL D. SHINDE 19
shindenikheel@gmail.com
193
NIKHEEL D. SHINDE 19
shindenikheel@gmail.com
15.Sap cross
application
194
NIKHEEL D. SHINDE 19
shindenikheel@gmail.com
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.
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 ).
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
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.
Uses of BAPI
Generating reports.
For communication between different servers SAP to SAP or SAP to NON-SAP.
BAPI`s can be used for data migration.
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
198
NIKHEEL D. SHINDE 19
shindenikheel@gmail.com
1 .Ale idoc
199
NIKHEEL D. SHINDE 20
shindenikheel@gmail.com
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.
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.
Inbound Process
Outbound Process
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
Outbound IDOC is the process of transferring data from an SAP system to another SAP system or
to Non-SAP system.
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
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.
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
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