Anda di halaman 1dari 107

1.

INSTITUTIONAL PROFILE
TERAS CONSULTING:
Teras Consulting is established for fulfillment of the need of IT Industry. Company is growing
from last decade and deliver IT training and Development solution to both Public and Private
sector Organizations. Teras Consultants Noida have invested significantly in this sector to
develop

their

own

methodology

and

way

of

teaching

and

training.

The specialized area of our Institute training is SAP ERP (Enterprise Resource Planning),
Language Training, Database and other IT skills. We have excellent well equipped labs or
classrooms, and first class support for students and trainees

Course Structure
Course content are specially designed according to current trends and need of the IT industry
which offers unique opportunity to the students who are looking for Job or for higher
Education classes are tailored made to suit Individual requirements on weekdays and weekend
classes Saturday/Sunday.

Best Trainers
The Trainers in our Institute are highly qualified and have practical experience of their
respective field .The are hired from different houses, universities, professions and service for
their expertise. Our Faculty is used world class modern tools & Approach in delivering
technical contents.

Training
With years of Experience in both national & International level in Technology and functional
domains related to ERPs, we are capable and confident in designing Delivering substantial
training to Corporate and Individual in these areas.
A one stop shop for all your training and documentation needs. Provide best in class training
through experienced and integrated team. Keep improving our service in training and content
development. Our trainers and consultants can work closely with your users and experts to
develop and document the content and curriculum for training. Our training team will keep
providing support throughout the training periods and beyond that.

1240998

Page 1

Placements:
Arrangements for Pre-Placement Talks, Written Tests, Interviews and Group Discussions are
made as per the requirement of the visiting companies.
Key Recruiters for Teras Consulting

SAP Labs

IBM
Orange

Accenture

Business
Services

Infosys

SVAM
SunLife

Wipro

Financial

Cognizant Technologies

Nirma Cement

CSC

ERA Group
Abyeti

TCS

Technologies

Our Placement cell gives job in top MNC of India and abroad with complete satisfaction to
the students.

Training courses

SAP/ERP
CLOUD COMPUTING
HADOOP
ASP .NET
JAVA/J2EE
SOFTWARE TESTING
ANDROID/IPHONE
EMBEDED
SAS BI
ORACLE/ORACLE DBA
PHP TRAINING
CCNA/CCNP

1240998

Page 2

SERVICES

Teras Consulting Services:

Teras Consulting provides Education, personality development, IT staffing and KPO Services.
Where you can learn, you can improve yourself, get a job & job opportunity.

Education

Teras Consulting is a place where you can improve your IT skills and SAP Knowledge. We
hire consultants to give a practical knowledge to improve yourself and get a good opportunity
in market. We provide you a good place for work. We are providing education and placed you
in our own organization.

Personality Development

Teras Consulting also increase your personality. Where we can improve your body language,
Communication skills and build up leadership

behavior. Improve postiveness in your

attitude.
After that we also dealing with IT Staffing an KPOs

IT STAFFING
Teras Consulting concern to customers to understand their overall skill set requirements for
company. Our employee Augmentation Model offers such things. we basically provide
solution for small ,mid-size and large enterprises. We understand the companies & Industry
need and full fill this with talented professionals.

We Focus on:
Estimating man power requirement, recruiting, selection, placement and orientation and
finally provide training and development.

2. HISTORY:
1240998

Page 3

ABAP (Advanced Business Application Programming, originally Allgemeiner BerichtsAufbereitungs-Prozessor German for "general report creation processor") is a high-level
programming language created by the German software company SAP. It is currently
positioned, alongside Java, as the language for programming the SAP Application Server,
which is part of the NetWeaver platform for building business applications.
ABAP is one of the many application-specific fourth-generation languages (4GLs) first
developed in the 1980s. It was originally the report language for SAP R/2, a platform that
enabled large corporations to build mainframe business applications for materials
management and financial and management accounting.
ABAP used to be an abbreviation of Allgemeiner Berichts Aufbereitungs Prozessor, German
for

"generic

report

preparation

processor",

but

was

later

renamed

to

the

English Advanced Business Application Programming. ABAP was one of the first languages
to include the concept of Logical Databases (LDBs), which provides a high level of
abstraction from the basic database level(s).
The ABAP language was originally used by developers to develop the SAP R/3 platform. It
was also intended to be used by SAP customers to enhance SAP applications customers can
develop custom reports and interfaces with ABAP programming. The language is fairly easy
to learn[opinion] for programmers but it is not a tool for direct use by non-programmers.
Knowledge of relational database design and preferably also of object-oriented concepts is
necessary to create ABAP programs.
ABAP remains as the language for creating programs for the client-server R/3 system, which
SAP first released in 1992. As computer hardware evolved through the 1990s, more and more
of SAP's applications and systems were written in ABAP. By 2001, all but the most basic
functions were written in ABAP. In 1999, SAP released an object-oriented extension to ABAP
called ABAP Objects, along with R/3 release 4.6. SAP's current development platform Net
Weaver supports both ABAP and Java.
ABAP has an abstraction between the business applications, the operating system and
database. This ensures that applications do not depend directly upon a specific server or
database platform and can easily be ported from one platform to another.
SAP

Netweaver

currently

runs

on UNIX (AIX, HP-UX, Solaris, Linux), Microsoft

Windows, i5/OS on IBM System i (formerly iSeries, AS/400), and z/OS on IBMSystem
z (formerly zSeries, S/390). Supported databases are IBM DB2, Informix, MaxDB, Oracle,
and Microsoft SQL Server (support for Informix was discontinued in SAP Basis release 7.00).
1240998

Page 4

2.1. ABAP runtime environment


All ABAP programs reside inside the SAP database. They are not stored in separate external
files like Java or C++ programs. In the database all ABAP code exists in two forms: source
code, which can be viewed and edited with the ABAP Workbench tools; and generated code, a
binary representation somewhat comparable with Java byte code. ABAP programs execute
under the control of the runtime system, which is part of the SAP kernel.
The runtime system is responsible for processing ABAP statements, controlling the flow logic
of screens and responding to events (such as a user clicking on a screen button); in this respect
it can be seen as a Virtual Machine comparable with the Java VM. A key component of the
ABAP runtime system is the Database Interface, which turns database-independent ABAP
statements ("Open SQL") into statements understood by the underlying DBMS ("Native
SQL"). The database interface handles all the communication with the relational database on
behalf of ABAP programs; It also contains extra features such as buffering of tables and
frequently accessed data in the local memory of the application server.

2.2. SAP systems and landscapes


All SAP data exists and all SAP software runs in the context of a SAP system. A system
consists of a central relational database and one or more application ("instances") accessing
the data and programs in this database. A SAP system contains at least one instance but may
contain more, mostly for reasons of sizing and performance. In a system with multiple
instances, load balancing mechanisms ensure that the load is spread evenly over the available
application servers.
Installations of the Web Application Server (landscapes) typically consist of three systems:
one for development; one for testing and quality assurance; and one for production. The
landscape may contain more systems (e.g., separate systems for unit testing and preproduction testing) or it may contain fewer (e.g., only development and production, without
separate QA); nevertheless three is the most common configuration. ABAP programs are
created and undergo first testing in the development system. Afterwards they are distributed to
the other systems in the landscape. These actions take place under control of the Change and
Transport System (CTS), which is responsible for concurrency control (e.g., preventing two
1240998

Page 5

developers from changing the same code at the same time), version management, and
deployment of programs on the QA and production systems.
The Web Application Server consists of three layers: the database layer; the application layer;
and the presentation layer. These layers may run on the same or on different physical
machines. The database layer contains the relational database and the database software.
The application layer knowledge contains the instance or instances of the system. All
application processes, including the business transactions and the ABAP development, run on
the application layer. The presentation layer handles the interaction with users of the system.
Online access to ABAP application servers can go via a proprietary graphical interface, which
is called "SAP GUI", or via a Web browser.

2.3. Transactions
A transaction in SAP terminology is the execution of a program. The normal way of executing
ABAP code in the SAP system is by entering a transaction code (for instance, VA01 is the
transaction code for "Create Sales Order"). Transactions can be called via system-defined or
user-specific, role-based menus. They can also be started by entering the transaction code
directly into a command field, which is present in every SAP screen. Transactions can also be
invoked programmatically by means of the ABAP statements CALL TRANSACTION and
LEAVE TO TRANSACTION.
The term "transaction" must not be misunderstood here; in the context just described, a
transaction simply means calling and executing an ABAP program. In application
programming, "transaction" often refers to an indivisible operation on data, which is either
committed as a whole or undone (rolled back) as a whole. This concept exists in SAP and is
called a LUW (Logical Unit of Work). In the course of one transaction (program execution),
there can be different LUWs. Transaction for ABAP Workbench could be invoked using
transaction code SE80 to work on all ABAP development related activities

3. Introduction to ABAP
1240998

Page 6

3.1. What is SAP R/3:


SAP stands for Systems, Applications and Products in Data Processing. It is the name of the
company and also the name of the software. R/3 stands for Runtime System Three. It is one of
the

ERP (Enterprise Resource Planning) systems around. Similar products are Oracle and

People soft. ERP is used by companies to plan, organize, integrate and manage their various
operations like accounting, finance, manufacturing and human resources. The main aim is to
improve efficiency and accuracy.

3.2. SAP R/3 architecture and where ABAP fits in:


R/3 is based on client/server architecture and uses a relational database to track all
information related to a company. It is made up of small programs called transactions. A
transaction is a program and set of system; and change functionality in the R/3 system. R/3
gathers related transactions together into groups and call them modules. Thus a module is a
set of transactions that deal with the same area of business functionality. R/3 modeled in a
three-tier hierarchy is shown below.

Presentation level User Interface


Application level business logic layer that runs on a server
Database level stores data managed by SAP

ABAP (Advanced Business Application Programming) is the programming language used by


SAP developers to build transactions that make up the R/3 application. Its also used by
companies to customize the R/3 application i.e. providing additional business functionality. It
is a fourth-generation programming language with some features similar to some modern
programming languages such as C, Visual Basic and Power Builder. It allows variables to be
defined, modulation of programs via subroutines and function calls, access to the database via
open SQL and some event-oriented programming.

1240998

Page 7

3.4.

The Major Common Uses of ABAP/4:

Custom reports a program that reads specific data from the database and then
displays the data via the computer screen or printer. The purpose of a report is to
read data from the database and write it out. It consists of mainly two screens. The
first screen is called the selection screen. It contains input fields allowing the user
to enter criteria for the report. For example, the report may produce a list of sales
for a given date range, so the date range input fields would appear on the reports
selection screen. The second screen is the output screen. It contains the list. The
list is the output from the report, and usually does not have any input fields. In our
example, it would contain a list of the sales that occurred within the specified date
range. The selection screen is optional. Not all reports have one. However, all

reports generate a list.


Interface a program that moves data into SAP BDC, Call Transaction or reads
data from SAP and writes it to a system file to be transferred to an external

computer e.g. a legacy mainframe DATA EXTRACT


Custom Transaction a program similar to SAP transactions to fulfill some
business function not provided by SAP Dialog Programming.

3.5. ABAP Development Workbench Tools:


The most important tools are:
ABAP Editor for writing and editing program code.
ABAP Dictionary for editing tables and other ABAP Dictionary Objects.
Menu Painter for designing the user interface (menu bar, standard toolbar, application
toolbar)
Screen Painter for designing screens for user dialogs
Function Builder for programming function modules (subroutines with a fixed
interface that are available system wide)
1240998

Page 8

All development objects created with the development tools found in the ABAP Workbench
are classified as Repository Objects and are stored centrally in the R/3 Repository. The R/3
Repository is a special part of the SAP systems central database. The Repository is organized
according to application. Each application is further divided into logical subdivisions called
development classes.
Repository objects are often made up of sub-objects that are themselves Repository objects.
Each Repository object must be assigned a development class when it is created.

3.6. ABAP Programming Syntax:


Whichever type of program, ABAP syntax includes the following:

ABAP programs are made up of individual statements


Each statement ends with a period.
The first word in a statement is called a key word.
Words must always be separated by at least one space.
Statements can be indented.
Statements can take up more than one line

3.7. Naming Standards:


The company you work for is a customer of SAP. Therefore, programs that you create at your
company are called customer programs. For programs, the customer name range is two to
forty characters long and the program name must start with the letter Y or Z. SAP reserves the
letter A through X for their own programs.

1240998

Page 9

3.8. Object Navigator:


The object navigator is also called in previous releases Object Browser (Rel 3x), Repository
Browser (Rel 4.x).Object Navigator automatically calls other tools when actions require them.
For example, creating

a new program from the Object Navigator screen. The Object

Navigator calls the ABAP Editor and, after creating the program, returns back to the Object
Navigator screen. An entire application can be created using the Object Navigator without
directly calling any of the other tools. In fact, the recommended method for creating an
application is from the Object
Navigator because you can see what you build. The Object navigator provides an overview of
all the elements in an application and access to all necessary administration tools from one
single interface.
Object Navigator can be accessed in 2 ways:

SAP Main Screen > Tools > ABAP Workbench > Overview > Object Navigator
(Double Click)

Another way to reach the Object Navigator is to from the SAP Main Screen enter the
transaction SE80 into the transaction field and press Enter

1240998

Page 10

Either way the Object Navigator is displayed. There are two input fields on this screen. Object
List Group This contains a list of the objects contained within this environment: Local
Objects,

Application

Hierarchy

Program,

Development

Class,

Function

Group,

Class/Interface, Internet Service. Select Local Objects in this field.

If you select the down-arrow key in the second input field, object group selected in the first
field will be displayed. Click on the Display input field.

A211 Create an ABAP program using the object navigator


1. Start the object navigator by typing se80 in the command field from the SAP Main screen.
2. Select Programs in the first input field.
3. Type in the desired name of the new program, e.g. ZKKPROG1 in the second input field.
Click on display button. NOTE: All third-party program names can only begin with Y or Z.
This way customer program can clearly be distinguished from SAP programs

1240998

Page 11

If the program already exists, it will be display under the object list. If it doesnt exist, a
dialog box pops open, click the YES pushbutton for SAP to create the program.

As soon as you click on YES another dialog box pops open querying about the program
structure either as an individual file or a framework program for includes. Large programs can
be split up into several sub programs (includes).

For now deselect the With TOP INCL flag. Click on tick Enter to continue

1240998

Page 12

If this is the first time ever you are creating an ABAP program, another dialog window will
pop open requesting you to enter the Access Key so this user can be added as a Developer.
Enter your 20 Character access key here and click on continue. ( Note: this dialog only pops
up once. )

A new template pops up where you will define the important attributes of the new application.
There are three important fields that must be maintained. And these are;
Title: Short description of the program. The program name comes up as default in this field.
You can add more text to it. For example Khans First ABAP Program
Program Type: Chose Executable program. Reports are usually this type.
Application: Which the program will be assigned to. Select Cross-application.
Other fields are optional: status, authorization groups, logical database. After entering all the
values, click on SAVE.

1240998

Page 13

When you save a new object for the first time, the system displays a correction and transport
dialog box. Here the Development Class field needs to be maintained. For now click the local
object pushbutton.

You will be returned to the opening screen of the object navigator. Go to the course code
screen by double clicking on the object name.

1240998

Page 14

Source code appears in display mode with just one line of code report and report name.
To switch from display mode to change mode click on the pencil mark

Place cursor after the period at the end of first sentence and press enter to get you to the next
line. Type WRITE Hello World!

1240998

Page 15

Activate the program by going to Programs > Activate

Or click on the magic wand which is a shortcut for activate.

A message Object Activated appears at the bottom of the screen.

Press F8 to test the program

1240998

Page 16

A list is produced. To go back to the editor from the report output window, click on the back
arrow or F3 function key.

3.9. ABAP Editor:


The ABAP Editor is a tool that you use to write ABAP programs, class methods, function
modules, screen flow logic, type groups and logical databases. ABAP Editor can be accessed
in two ways.
Menu Path:

SAP Main Screen > Tools > ABAP Workbench > Development > ABAP Editor
(Double Click)

1240998

Page 17

Or simply use transaction code SE38 to start ABAP Editor

ABAP/4 programs consist of five components


1. Source Code
2. Attributes
3. Text Elements
4. Documentation
5. Variants
Only the source code and program attributes components are required. The rest of the
components are optional.
All development objects and their components are stored in the R/3 Database. ABAP/4
programs are interpreted; they are not compiled. The first time you execute a program, the
system automatically generates a runtime object. The runtime object is a pre-processed for of
the source code. However, it is not an executable that you can run at the operating system
level. Instead, it requires the R/3 system to interpret it. The runtime object is also known as
the generated form of the program. If you change the source code, the runtime object is
automatically regenerated the time you execute the program.

3.10. Editor Mode:


The ABAP Editor has two different modes:
1. Front-end Editor
2. Back-end Editor
Front-end Editor:
The front-end editor uses the SAP Text edit Control from the SAP Control Framework. It
loads your source code onto the front-end and allows you to perform many tasks without any
communication with the application server.
1240998

Page 18

In the front-end editor, the ABAP source code is loaded onto the front-end and edited locally.
The advantage of this is that all editing functions that do not require communication with the
backend can be performed very quickly
Back-end Editor
The back-end editor allows you to use the traditional back-end editor for editing your ABAP
code. The editor is line-based, and to use normal editor functions such as cut, copy and paste,
you must first select a block of lines. If is often useful to use the clipboards in this mode. If
you have a very long program (and specially if you are working in a WAN environment), the
back-end editor can produce better performance than the front-end editor.
Furthermore, back-end editor allows you to edit any development object that is based on the
ABAP Editor. You can change the mode from front-end to back-end by doing the following
steps. To change the editor mode from anywhere in the ABAP workbench: Chose utilities >
settings

The User Specific Settings dialog box appears. Choose ABAP Editor. Set the editor mode to
back-end editor.

1240998

Page 19

3.11. Uploading and Downloading Source:


To upload a file into the ABAP Editor
1. Chose utilities from the ABAP Editor screen
2. Click more utilities
3. Click on Upload/download
4. Click Upload

5. Enter the path and filename of the file you want to read in the dialog box, then choose
copy.

1240998

Page 20

3.12. ABAP/4 Attributes Screen:


The following section provides information about program attributes. Note that some of these
attributes only apply to executable programs (reports), and not to other ABAP program types.
Version
These fields are used for version administration. The system fills them.
Title
In the required entry field TITLE enter a program description that describes the function of
the program. Thus, you can edit the title when maintaining the text elements.
Maintenance Language
The maintenance language is the logon language of the user who creates the program. The
system fills this field automatically. You can change the maintenance language. If you
maintain the program or its components in another logon language.
Type
In the Type Field you must specify the execution mode of your program.
1240998

Page 21

Use Type 1 (report) to declare your program as executable. This means that program can run
on its own, and that you can start it in the R/3 system without a transaction code. You can also
run executable programs (reports) in the background.
Use Type M to declare your program as a module pool. This means that your program cannot
run on its own, but serves as a frame for program modules used for dialog programming.
User Type I for include program. An include program is an independent program with two
main functions: On one hand, it contains program code that can be used by different
programs. On the other hand, it modularizes source code, which consists of several different,
logically related parts. Each of these part is stored in different include program. Include
programs make your source code easier to read and maintain.
Status
This entry describes the status of the program development, for example, T for test program.
Application
This field contains the short form of your application, for example, F for Financial
accounting. This required entry enables the system to allocate the program to the correct
business area.
Authorization Group
In this field, you can enter the name of a program group. This allows you to group different
programs together for authorization checks. The group name is a field of the two authorization
objects S_DEVELOP (program development and program execution) and S_PROGRAM
(program maintenance). Thus you can assign authorization to users according to program
groups. For more information about creating function modules, refer to the Users and
Authorization documentation.
Development Class
The development class is important for transports between systems. You combine all
Workbench objects assigned to one development class in one transportation request. If you are
working in a team you may have to assign your program to an existing development class, or
you may be free to create a new class on Workbench Organizer covers this. All programs
assigned to the development class $TMP are private objects and cannot be transported into

1240998

Page 22

other systems. You can enter the development class directly into this field. Otherwise, the
system prompts for it when you save the attributes.
Choosing Local Objects is equivalent to entering $TMP in the field Development Class. You
can change the development class of a program later on by choosing Object Directory Entry
from the GOTO menu, click change, type in the desired development class.
Logical Database From Application
(Only for Executable Programs Reports)
These attributes determine the logical database used by the executable program (report) to
read data, and the application to which it belongs. Logical databases have unique names
within their application. However, system wide, you can have more than one logical database
with the same name. This is why you also need to specify the application. If you read data
directly in your program instead of using a logical database, you should enter an application,
but leave the logical database field empty.
Selection Screen Version
(Only for Executable Programs Reports)
If you do not specify a selection screen version, the system automatically creates a selection
screen based on the selection criteria of the logical database and the parameters and select
options statement in the program.
If you want to use a different selection screen, enter the number here (not 1000, since this is
reserved for the standard selection screen). The number must be smaller than 1000 and
correspond to an additional selection screen of the logical database. The possible values help
displays a list of available selection screens. You can also look in the selection include of the
logical database (Program DBxxxSEL, where xxx is the name of the logical database).

4. DATA DICTIONARY:
A data dictionary is a central source of information for the data in a information management
system. Its main function is to support the creation and management of data definitions (or
"metadata").
Data dictionary used for:

Management of data definitions

1240998

Page 23

Provision of information for evaluations


Support for software development
Support for documentation
Ensuring that data definitions are flexible and up-to-date

Objects in the ABAP Dictionary resided on three levels that support their re-usability. These
levels are:
1. Tables and structures
2. Data elements
3. Domains

Domains:

Describes the technical characteristics of a table field


Specifies a value range which describes allowed data values for the fields
Fields referring to the same domain (via the data elements assigned to them) are

changed when a change is made to the domain


Ensures consistency

1240998

Page 24

Data Elements:

Describes the role played by a field in a technical context

Fields of same semantic meaning can refer to the same data element

Contains the field information

Tables:
Represent the Database Tables where data actually resides.
Tables can be defined independently of the database in the ABAP Dictionary.
The fields of the table are defined with their (database-independent) SAP ABAP data types
and lengths.

1240998

Page 25

Aggregated Objects of ABAP Dictionary:


Aggregated means consisting of several components. In the ABAP Dictionary, aggregated
objects are objects which come from several different transparent tables.
1. Views
2. Search Help
3. Lock Objects

1240998

Page 26

Views:

Views in SAP _ ABAP are used to summarize data which is distributed among several
tables

The data of a view is not actually physically stored. The data of a view is instead
derived from one or more other tables

It is tailored to the needs of a specific application

Search Help

A Search help is a tool to help you search for data records in the system
An efficient and user-friendly search assists users where the key of a record is
unknown

1240998

Page 27

Lock Objects:

Simultaneous accessing of the same data record by two users in the SAP system is
synchronized by a lock mechanism.

Locks are set and released by calling certain function modules. These function
modules are generated automatically from the definition of so-called lock objects in the
ABAP/4 Dictionary

Function modules: Enqueue_<obj name> - to lock the table dequeue_<obj name> - to


release the lock

1240998

Page 28

5. INTERNAL TABLES
Internal tables are used to obtain data from a fixed structure for dynamic use in ABAP.
Each line in the internal table has the same field structure. The main use for internal tables
is for storing and formatting data from a database table within a program.

Work area:
Work areas are single rows of data. They should have the same format as any of the
internal tables. It is used to process the data in an internal table one line at a time.

Types of Internal Tables:


There are two types of internal tables.

Internal tables with HEADER line


Internal tables without HEADER line.

Internal Tables with Header Line

Here the system automatically creates the work area.


The work area has the same data type as internal table.
This work area is called the HEADER line.

1240998

Page 29

It is here that all the changes or any of the action on the contents of the table are done.
As a result of this, records can be directly inserted into the table or accessed from the
internal table directly.

Internal Tables without Header Line:

Here there is no work area associated with the table.


Work area is to be explicitly specified when we need to access such

tables.
Hence these tables cannot be accessed directly.

6. Modularization Techniques in ABAP


Modularization is breaking down the application code into smaller units, so that it is easy to
maintain. Suppose if we want to implement the same logic like adding two numbers in several
places of the same program, then write the logic inside a modularization unit and call the
modularization unit where ever we want to add two numbers.
Even if we want to declare the same variables in multiple programs or use the same logic in
different programs then code the common part in the modularization unit and use it in
different programs.

Advantages of Modularization are as follows.

Easier to read, maintain and debug.


Eliminates redundancy of code and increases reusability of code.

Different types of Modularization units called from ABAP programs.

Macros If you want to reuse the same set of statements more than once in a
program, you can include them in a macro. You can only use a macro within the
program in which it is defined.

1240998

Page 30

Include Programs Include programs allow you to use the same source code in
different programs. They are mainly used for modularizing source code and have no
parameter interface.

Subroutines Subroutines are normally called internally i.e. called from the same
program in which it is declared. But subroutines can also be called from external
programs. A subroutine can be defined using FORM and ENDFORM statements.

FORM <subroutine name>.


...

ENDFORM.

Function Modules Function Modules are stored in the central library and can be
called from any program. Even the function modules (RFC enabled) can be called
from non-SAP systems

Components of Function Module:


Import: These are input parameters of a Function Module.
Export: These are output parameters of a Function Module.
Changing: These are parameters which acts as importing and exporting parameters
to a Function Module.
Tables: These are internal tables which also acts as importing and exporting
parameters.
Exceptions: Exceptions in Function Modules are used to catch certain type of errors.

Methods Methods used ABAP object oriented programming

1240998

Page 31

STEP: 1

STEP: 2 Go to SE37, provide a Function Module name ZSAPN_GET_MATERIAL, click


on create.

1240998

Page 32

STEP: 3 Select Import tab and enter IM_MATNR under Parameter name, TYPE under
typing and MARA-MATNR under Associated Type, enter.

STEP: 4 Select Export tab and enter EX_MARA under Parameter name, TYPE under
typing and MARA under Associated Type, enter.

1240998

Page 33

STEP: 5 Select Source Code tab and write below code to get material details, save as local
object and activate.

STEP: 6 Click on Execute icon (F8), and give a material no, execute (F8).

It will get material details

1240998

Page 34

Code To Call Function Module In Program.


REPORT ZSAPN_GET_MATERIAL.
DATA : WA_MARA TYPE MARA .
PARAMETERS : P_MATNR TYPE MARA-MATNR .
START-OF-SELECTION.
CALL FUNCTION 'ZSAPN_GET_MATERIAL'
EXPORTING
IM_MATNR

= P_MATNR

IMPORTING
EX_MARA

= WA_MARA .

IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
WRITE: WA_MARA-MATNR, WA_MARA-MTART, WA_MARA-MEINS, WA_MARAMBRSH . "Display result

1240998

Page 35

7. Control Break Statements:


Control break statements are like events inside the loop. There are 5 control break statements
in ABAP. These are used within loop. (Except ON CHANGE OF which can be used outside
the loop as well).

AT FIRST - ENDAT

AT NEW - ENDAT

AT END OF - ENDAT

AT LAST - ENDAT

ON CHANGE OF

AT FIRST : Will trigger at the first run of the loop.


AT LAST: Will trigger at the last run of the loop.
AT END OF : When we use At end for a field, it will trigger whenever there is any change in
any of the fields from the left to that of the particular field. The trigger point will be the at the
last occurrence of the same value for the field.
AT NEW: When we use At new for a field, it will trigger whenever there is any change in
any of the fields from the left to that of the particular field.The trigger point will be the at the
first occurrence of the new value for the field.
PROGRAM:

1240998

Page 36

1240998

Page 37

OUTPUT:

1240998

Page 38

8. Comparison String:
<operator>

Meaning

CO

Contains Only

CN

Contains Not only

CA

Contains Any

NA

contains Not Any

CS

Contains String

NS

contains No String

CP

Matches pattern

NP

Does not match pattern

There are no conversions with these comparisons. Instead, the system compares the characters
of the string. The operators have the following functions:
CO (Contains Only)
The logical expression
<f1> CO <f2>
is true if <f1> contains only characters from <f2>. The comparison is case-sensitive. Trailing
blanks are included. If the comparison is true, the system field SY-FDPOS contains the length
of <f1>. If it is false, SY-FDPOS contains the offset of the first character of <f1> that does not
occur in <f2>.
CN (Contains Not only)
The logical expression
<f1> CN <f2>
is true if <f1> does also contains characters other than those in <f2>. The comparison is casesensitive. Trailing blanks are included. If the comparison is true, the system field SY-FDPOS
contains the offset of the first character of
<f1> that does not also occur in <f2>. If it is false, SY-FDPOS contains the length of <f1>.
CA (Contains Any)
The logical expression
1240998

Page 39

<f1> CA <f2>
is true if <f1> contains at least one character from <f2>. The comparison is case-sensitive. If
the comparison is true, the system field SY-FDPOS contains the offset of the first character of
<f1> that also occurs in <f2> . If it is false, SY-FDPOS contains the length of <f1>.
NA (contains Not Any)
The logical expression
<f1> NA <f2>
is true if <f1> does not contain any character from <f2>. The comparison is case-sensitive. If
the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false,
SY-FDPOS contains the offset of the first character of
<f1> that occurs in <f2> .
CS (Contains String)
The logical expression
<f1> CS <f2>
is true if <f1> contains the string <f2>. Trailing spaces are ignored and the comparison
is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the offset
of <f2> in
<f1> . If it is false, SY-FDPOS contains the length of <f1>.
NS (contains No String)
The logical expression
<f1> NS <f2>
is true if <f1> does not contain the string <f2>. Trailing spaces are ignored and the
comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS
contains the length of <f1>. If it is false, SY-FDPOS contains the offset of <f2> in <f1>.
CP (Contains Pattern)
The logical expression
<f1> CP <f2>
is true if <f1> matches the pattern <f2>. If <f2> is of type C, you can use the following
wildcards in <f2>:
1240998

Page 40

for any character string: *

for any single character: +

Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true,
the system field SY-FDPOS contains the offset of <f2> in
<f1> . If it is false, SY-FDPOS contains the length of <f1>.
If you want to perform a comparison on a particular character in <f2>, place the escape
character # in front of it. You can use the escape character # to specify

characters in upper and lower case

the wildcard character "*" (enter:#*)

the wildcard character "+" (enter:#+ )


the escape symbol itself (enter:## )
blanks at the end of a string (enter:#___ )

NP (contains No Pattern)
The logical expression
<f1> NP <f2>
is true if <f1> does not match the pattern <f2>. In <f2>, you can use the same wildcards and
escape character as for the operator CP.
Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true,
the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the
offset of <f2> in <f1>

CODE OF PROGRAM:

1240998

Page 41

1240998

Page 42

1240998

Page 43

OUTPUT:

9. JOINS In ABAP:
The data that can be selected with a view depends primarily on whether the view implements
an inner join or an outer join. With an inner join, you only get the records of the crossproduct for which there is an entry in all tables used in the view. With an outer join, records
are also selected for which there is no entry in some of the tables used in the view.
The set of hits determined by an inner join can therefore be a subset of the hits determined
with an outer join.
Database views implement an inner join. The database therefore only provides those records
for which there is an entry in all the tables used in the view. Help views and maintenance
views, however, implement an outer join.

1240998

Page 44

Code Of Program

1240998

Page 45

Output Of Inner Join:

Output Of Outer Join:

1240998

Page 46

10. REPORTS:
CLASSICAL REPORTS:
These are the most simple reports. Programmers learn this one first. It is just an output of
data using the Write statement inside a loop. Classical reports are normal reports. These
reports are not having any sub reports. IT IS HAVING ONLY ONE SCREEN/LIST FOR
OUTPUT.
Events in Classical Reports:
INTIALIZATION: This event triggers before selection screen display.
AT-SELECTION-SCREEN: This event triggers after processing user input still
selection screen is in active mode.
START OF SELECTION: Start of selection screen triggers after processing selection
screen.
END-OF-SELECTION: It is for Logical Database Reporting.
SOURCE CODE:

1240998

Page 47

SUBROUTINE IN SOURCE CODE:

1240998

Page 48

1240998

Page 49

OUTPUT SCREEN:

OUTPUT:

1240998

Page 50

CLASSICAL INTERACTIVE REPORT:


As the name suggests, the user can Interact with the report. We can have a drill down into the
report data. For example, Column one of the report displays the material numbers, and the
user feels that he needs some more specific data about the vendor for that material, he can
HIDE that data under those material numbers. And when the user clicks the material number,
another report (actually sub report/secondary list) which displays the vendor details will be
displayed. We can have a basic list (number starts from 0) and 20 secondary lists (1 to 21).
Events associated with Interactive Reports are:
AT LINE-SELECTION

AT USER-COMMAND

1240998

Page 51

SOURCE CODE:

1240998

Page 52

SUBROUTINE

OUTPUT SCREEN:

1240998

Page 53

OUTPUT:

ALV REPORTS (ABAP List Viewer):


ALV stands for ABAP List Viewer. ALV gives us a standard List format and user interface to
all our ABAP reports. ALV is created by a set of standard function modules provided by SAP.
1240998

Page 54

ALV provides a lot of inbuilt functions to our reports and some of the functions are listed
below.

Sorting of records
Filtering of records
Totals and Sub-totals
Download the report output to Excel/HTML
Changing the order of the columns in the report
Hide the unwanted columns from the report

Because of the above functions, ALV substantially decreases the report development time.
ALV takes care of rendering the list and we can concentrate only on the data retrieval part.

SOURCE CODE:

1240998

Page 55

SUBROUTINE:

1240998

Page 56

1240998

Page 57

1240998

Page 58

OUTPUT:

1240998

Page 59

INTERACTIVE ALV REPORTS (ABAP List Viewer):


This is a Interactive ALV Code that may help an ABAP developer understand the basic ALV
Interactive Programming. This is an Interactive ALV report, where on line selection we
can see the secondary list.

SOURCE CODE:

1240998

Page 60

1240998

Page 61

SUBROUTINES:

1240998

Page 62

1240998

Page 63

1240998

Page 64

1240998

Page 65

1240998

Page 66

OUTPUT OF INTERACTIVE ALV REPORT:

1240998

Page 67

11. ENHANCEMENTS SAP ABAP:


Enhancements are the means by which we add our own/ modify existing functionality to
SAP's standard business applications. If you try to modify any SAP standard program, it will
ask you for access key which you can get from SAP market place by requesting SAP.
But enhancements normally dont require any special access key and can be implemented
directly. There are 4 ways of doing enhancements in SAP:

User exits: These are technically modifications. SAP provides many subroutine(s)
with name USEREXIT_ * (i.e ex: FORM USEREXIT_001 ). These are saved in many
includes which can be found via SE80 >> Search for Package VMOD. These are also
called as Form exits. Custom coding can be done in the subroutine. But the main

1240998

Page 68

disadvantage of these exits are It requires Access key and only SD module supports
this kind of enhancements.

Customer exits: Technically enhancements. Will not affect the source code of
SAP program and hence no problem during upgrade. There are 3 kinds of Customer
exits:

Function exits:
Provided by means of FM's (Function modules) .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 'Z'
include that is implemented in the function module.
Ex: open any Function module EXIT_* in se37
Ex: EXIT_SAPMF02K_001. but in the SAPMF02K program you will see this as
CALL CUSTOMER-FUNCTION '001'. It will have a Z include file , just edit the file directly
. No Access key required.
Menu Exits:
Enhances the menu available in standard SAP program. 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).

Screen exits:
Used to enhance the screen, add elements in screen etc. Format: CALL CUSTOMERSUBSCREEN CUSTSCR2.

BADI's: Business Add-Ins may be simply defined as an object-oriented extension of


the SAP enhancement technique. Multiple implementation for same BADI can be
done as BADI supports encapsulation of data.
1240998

Page 69

Enhancement Frameworks: This is the new kind of enhancement technique


provided by SAP. These provides some hooks or places where custom logic can be
coded in the standard program. There are 2 kinds of Enhancement frameworks:
Implicit enhancement :
These are provided in specific areas of standard source code:
1. At the end of the programs (reports, includes, function pools, module pool)
2. At the begin and end of subroutine forms.
3. At the end of the functional module
In this case you do not need to create and enhancment spot. You directly put your curosr on
the enhancement option and create your inplementations by right click.

Explicit enhancement:
It can be anywhere in your source code. You need to explicitly have a enhancement point. It is
of two types:

a) Enhancement spot: It is the point where you can add your code. It can have
multiple implementations. All the implementations can active at a time but the
sequence of executions of the implementations can be anything.
b) Enhancement section: If you want to execute your own code instead of some
portion standard code. Only the active implementation is execute. Only one
implementation is active at a time.

12. MODULE POOL PROGRAMING:


1240998

Page 70

SAP-ABAP supports two types of programs - Report Program and Dialog Program. If your
ABAP program demands user input Dialog programming is used. A user dialog is any form of
interaction between the user and the program and could be any of the following

Entering data

Choosing a menu item

Clicking a button

Dialog program is also used when we need to navigate back and forth between screens.
Dialog programs are created with type as 'M' - Module Pool. They cannot be executed
independently and must be attached to at least one transaction code in which you specify an
initial screen.

Difference between Report and Dialog Programs:

1240998

Page 71

Dialog Program:
A dialog program allows you to work interactively with the system and to change the contents
of the database tables. Each dialog program has a certain sequence of screens that are
processed by the system one after the other.

Components of Dialog Program:


Unlike report which generally entails the creation of one autonomous program which can be
executed independently of other objects, dialog program development entails development of
multiple objects none of which can be executed on it's own. Instead all objects are linked
hierarchically to the main program and and are executed in a sequence dictated by the Dialog
Main Program.

The components of a dialog program are:


1) Transaction code:
The transaction code starts a screen sequence.
You create transaction codes in the Repository Browser in the ABAP Workbench or
using Transaction SE93.
A transaction code is linked to an ABAP program and an initial screen.
2) You can start a screen sequence from any ABAP program using the CALL SCREEN
statement.
3) Screens:
Each dialog in an SAP system is controlled by one or more screens.
You create screens using the Screen Painter in the ABAP Workbench through

transaction SE51
Each screen belongs to an ABAP program.
These screens consist of a "screen mask" or "layout" and its flow logic. The screen has
a layout that determines the positions of input/output fields and other graphical
elements such as checkboxes and radio buttons. A flow logic determines the logical

processing within screen.


4) GUI status:
Each screen has a GUI status which are independent components of a program.
This controls the menu bars, standard toolbar, application toolbar, with which the user
can choose functions in the application.
You create them in the ABAP Workbench using the Menu Painter.
5) ABAP Program:
Each screen and GUI status in the R/3 System belongs to one ABAP program.
1240998

Page 72

The ABAP program contains the dialog modules that are called by the screen flow

logic, and also process the user input from the GUI status.
ABAP programs that use screens are also known as dialog programs.
In a module pool (type M program); the first processing block to be called is always a
dialog module. However, you can also use screens in other ABAP programs, such as
executable programs or function modules. The first processing block is then called
differently; for example, by the runtime environment or a procedure call. The screen

sequence is then started using the CALL SCREEN statement.


6) Screen Flow Logic:
Screen Flow logic is primarily divided into four components.

7)

Process Before Output (PBO) event: which is processed before the screen is displayed
Process After Input (PAI) event: which is processed after a user action on the screen
Process on help request (POH): which is processed when F1 is pressed
Process on value request (POV):which is processed when F4 is pressed
Dynpro:
A screen together with its Flow logic is called a Dynpro ("Dynamic Program" since

the screen flow logic influences the program flow)


Each dynpro controls exactly one step of your Dialog Program.
The screens belonging to a program are numbered. The screen flow sequence can be
either linear or cyclic. From within a screen chain, you can even call another screen
chain and, after processing it, return to the original chain. You can also override the

statically-defined next screen from within the dialog modules of the ABAP program.
8) ABAP Module Pool:
On a PBO or PAI event a Dynpro calls an ABAP dialog program. Collection of such

programs is called the ABAP module pool.


For example modules called at the PAI event are used to check the user input and to

trigger appropriate dialog steps, such as the update task.


All dynpros to be called from within one transaction refer to a common module pool.

1240998

Page 73

1240998

Page 74

EXECUTE:

1240998

Page 75

13. BDC (BATCH DATA COMMUNICATION):


When SAP is implemented we need Data to migrate from non-SAP system i.e. Legacy
system to SAP system. One way of doing this is BDC (Batch Data Communication).
Requirement:- For Developing BDC using CALL TRANSACTION method we need to do
the recording of the corresponding transaction & flat file in which data is stored. Flat file can
be Text file or Excel File. In CALL TRANSACTION we also have to create the Error Log
file.
In BDC we use structure BDCDATA for Batch Input, which has following components.
PROGRAM - BDC module pool
DYNPRO-

BDC Screen number

DYNBEGIN-

BDC screen start

FNAM-

Field name

FVAL-

BDC field value

A BDCDATA structure can contain the batch input data for only a single run of a transaction
In CALL TRANSACTION method, we need to create Log for the Error Message, for this we
use structure BDCMSGCOLL. For our demo purpose, we would be considering the file
format.

Define the internal table structure as per the above file structure.
1240998

Page 76

DATA:
BEGIN OF fs_field,
bsart TYPE eban-bsart,

Document Type.

matnr TYPE eban-matnr,

" Material Number.

menge TYPE eban-menge,

" Quantity Requested.

werks TYPE eban-werk

" Plant.

END OF fs_field.
Recoding is done using the Transaction SHDB.
Here we have done Recording for the transaction- ME51.
The Recording which you get will be in following format.

1240998

Page 77

*Structure for error message


TYPES : BEGIN OF ty_s_error,
msg_err(60) TYPE c,
END OF ty_s_error.
*Input Path
SELECTION-SCREEN BEGIN OF BLOCK blck WITH FRAME TITLE text-011.
PARAMETERS:
p_file TYPE rlgrap-filename,

" File Path

e_file TYPE rlgrap-filename OBLIGATORY,

" Error File Path

p_mode TYPE c OBLIGATORY DEFAULT 'N'.

" Mode

SELECTION-SCREEN END OF BLOCK blck.


* Structure Decleration
DATA :
BEGIN OF fs_field,
bsart TYPE eban-bsart,
matnr TYPE eban-matnr,
menge TYPE eban-menge,
werks TYPE eban-werks,

" Document Type.


" Material Number.
" Quantity Requested.
" Plant.

END OF fs_field.
*Internal table decleration
DATA:
t_field

LIKE TABLE OF fs_field,

t_bdcdata LIKE TABLE OF bdcdata.


DATA:
fs_bdcdata LIKE LINE OF t_bdcdata, " Structure type of bdcdata
w_str TYPE string.
* Data decleration
DATA:
1240998

Page 78

wa_path TYPE string ,


wa_error TYPE string,
wa_cnt TYPE i,
w_mode

TYPE c,

wa_cnt1(2) TYPE n,
it_output type table of ty_s_error,
wa_output like line of it_output.
AT SELECTION-SCREEN.
* Mode 'A' = Foreground mode
* Mode 'N' = Background mode
IF p_mode = 'A' OR p_mode = 'N' .
w_mode = p_mode.
ELSE.
*Error Message
MESSAGE 'PLEASE ENTER THE MODE A or N' TYPE 'E'.
ENDIF.
* Opening window for path selection
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name

=''

IMPORTING
file_name

= p_file.

TYPES:
fs_struct(4096) TYPE c OCCURS 0 .

1240998

Page 79

DATA:
w_struct TYPE fs_struct.
* Uploading excel file.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator

= 'X'

* I_LINE_HEADER

i_tab_raw_data
i_filename

= w_struct
= p_file

TABLES
i_tab_converted_data

= t_field

EXCEPTIONS
conversion_failed
OTHERS

=1
=2

.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*Opening window for Error file download
AT SELECTION-SCREEN ON VALUE-REQUEST FOR e_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name

=''

IMPORTING
file_name

= e_file.

* start of selection event.


START-OF-SELECTION.
1240998

Page 80

LOOP AT t_field INTO fs_field .


REFRESH: t_bdcdata.
CLEAR fs_bdcdata.
PERFORM populate_bdcdata.
PERFORM insert_data.
ENDLOOP.

" LOOP AT it_c.

*********************(populate_bdcdata)***********************
* part 1
FORM populate_bdcdata.
PERFORM :
fill_bdc_data USING 'SAPMM06B' '0100' 'X' ' ' ' ',
fill_bdc_data USING '' '' ' 'EBAN-BSART' fs_field-bsart, " Document Type.
fill_bdc_data USING '' '' '' 'BDC_OKCODE' '/00',

" Enter.

fill_bdc_data USING 'SAPMM06B' '0106' 'X' ' ' ' ',


fill_bdc_data USING '' '' '' 'EBAN-MATNR(01)' fs_field-matnr, " Material Number.
fill_bdc_data USING '' '' '' 'EBAN-MENGE(01)' fs_field-menge, " Quantity Requested.
fill_bdc_data USING '' '' '' 'EBAN-WERKS(01)' fs_field-werks, " Plant.
fill_bdc_data USING '' '' '' 'BDC_OKCODE' '/00',

" Enter.

fill_bdc_data USING 'SAPMM06B' '0102' 'X' '' '' ,


fill_bdc_data USING '' '' '' 'BDC_OKCODE' '=BU'.
ENDFORM.

" Form populate_bdc.

* part 2
FORM fill_bdc_data USING value(p_program)
value(p_dynpro)
value(p_dynbegin)
value(p_fnam)
value(p_fval).
CLEAR fs_bdcdata .
1240998

Page 81

" Save.

IF p_dynbegin = 'X' .
fs_bdcdata-program = p_program .
fs_bdcdata-dynpro = p_dynpro .
fs_bdcdata-dynbegin = p_dynbegin .
APPEND fs_bdcdata TO t_bdcdata.
ELSE.
fs_bdcdata-fnam = p_fnam.
fs_bdcdata-fval = p_fval.
CONDENSE fs_bdcdata-fval.
APPEND fs_bdcdata TO t_bdcdata.
ENDIF.

" IF p_dynbeg..

ENDFORM .

" Fill_entry

*********************(insert_data)****************************
FORM insert_data.
*Data decleration for Error Message
DATA:
t_msg TYPE TABLE OF bdcmsgcoll, " Collecting Error messages
w_msg TYPE bdcmsgcoll,
w_msg1(51).
* Call transaction 'ME51'
CALL TRANSACTION 'ME51' USING t_bdcdata
MODE w_mode
UPDATE 'S'
MESSAGES INTO t_msg.
IF sy-subrc EQ 0.
*

Uploaded into the database


WRITE :/ 'DATA UPLOADED IN TABLE EBAN...' .
ELSE.

1240998

Page 82

Error Found
LOOP AT t_msg INTO w_msg WHERE msgtyp EQ 'E'.

Format Message
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid

= w_msg-msgid

msgnr

= w_msg-msgnr

msgv1

= w_msg-msgv1

msgv2

= w_msg-msgv2

msgv3

= w_msg-msgv3

msgv4

= w_msg-msgv4

IMPORTING
message_text_output = w_msg1.

wa_output-msg_err = w_msg1.
*Error message in downloaded file
data:
wa_string(10) type c.
wa_string = fs_field-matnr.
concatenate wa_string wa_output-msg_err into wa_output-msg_err separated by space.
APPEND wa_output-msg_err TO it_output.
wa_error = e_file.

CALL FUNCTION 'GUI_DOWNLOAD'


EXPORTING
*

BIN_FILESIZE

1240998

=
Page 83

filename

= wa_error

FILETYPE

= 'ASC'

APPEND

=''

write_field_separator

= 'X'

TABLES
data_tab

= it_output

*
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

" IF sy-subrc <> 0.

ENDLOOP.
ENDIF.
ENDFORM.

"insert_data

Enter the path of file you need to upload.


And then enter the path of a file where error log will be created.
Finally select the mode. We have following option for the mode.
1. A = Foreground (Step by step processing will be done by you)
1240998

Page 84

2. N = Background (All the Processing will be done in Background)


3. E = Display Error ( If there is any error, it will be displayed in log otherwise it is similar
to background mode)

1240998

Page 85

14. INTERFACE IN SAP:


BAPI(Business Application Programming Interface):
A Business Application Programming Interface (BAPI) is a precisely defined interface
providing access to processes and data in business application systems such as R/3. BAPIs are
defined as API methods of SAP business object types. These business object types and their
BAPIs are described and stored in the Business Object Repository (BOR). A BAPI is
implemented as a function module, that is stored and described in the Function Builder.
BAPIs can be called within the R/3 System from external application systems and other
programs. BAPIs are the communication standard for business applications. BAPI interface
technology forms the basis for the following developments:

Connecting:

New R/3 components, for example, Advanced Planner and Optimizer (APO) and
Business Information Warehouse (BW).

Non-SAP software

Legacy systems

Isolating components within the R/3 System in the context of Business Framework

Distributed R/3 scenarios with asynchronous connections using Application Link


Enabling (ALE)

Connecting R/3 Systems to the Internet using Internet Application Components (IACs)

1240998

Page 86

PC programs as frontends to the R/3 System, for example, Visual Basic (Microsoft) or
Visual Age for Java (IBM).

Workflow applications that extend beyond system boundaries

Customers' and partners' own developments


BAPI is basically a RFC enabled function module. The difference between RFC enabled
function module and BAPI is business objects. You create business objects and those are then
registered in your BOR (Business Object Repository) which can be accessed outside the SAP
system by using some other applications (Non-SAP) such as VB or JAVA. In this case you
only specify the business object and its method from external system. In BAPI there is no
direct system call, while RFC are direct system call. Some BAPIs provide basic functions and
can be used for most SAP business object types. These BAPIs should be implemented the
same for all business object types. In short BAPI is a RFC enabled function module on the
wrapper of Business object.
In this guide I have started with creating a structure in dictionary. Then I am creating a simple
remote enabled function module. The function module fetches some details from Table T001
based on the input company code (BUKRS). Table T001 contains the Company Codes. The
next step is creating a business object using SWO1 and we are adding the above function
module as a method of that business object. After completing the steps in SWO1 we will find
our created BAPI in BAPI Explorer. Then we will do the testing of BAPI by inputting some
values.
Stage1: Creating a structure in SE11
Step 1: Go to transaction SE11 and create a structure as shown or as per your requirement.

1240998

Page 87

Stage2: Creating the function module in SE37


Step 2: Go to transaction SE37 where you create function modules.

Step 3: A message will be displayed Function module name is reserved for SAP. Just click
continue.

1240998

Page 88

Step 4: A screen will be displayed as below. In the attributes tab, make the processing type as
Remote-Enabled Module.

1240998

Page 89

Step 5: Now go to the Import tab and enter the details as follows or as per your requirement.
Here I am giving the associated type as ZBAPISTRT001-BUKRS that we have created in
previous stage.

Step 6: In the export tab enter the details as below.

1240998

Page 90

Step 7: In the Tables tab enter the details as below.

Step 8: Now go to the source code tab and enter the code as shown below.

1240998

Page 91

Step 9: Next we have to release the function module by Function Module>Release>Release.

Stage 3: Creating the business object in SWO1


Step 10: Go to transaction SWO1 and enter the name of the BAPI you would like to create
and click create. Here I have given the name ZBAPI_ABY. In the coming screen Enter the
details as below or as per requirement and click continue. That will ask you to save the object.
Save it in a package.

1240998

Page 92

Step 11: In the resulting screen click on the methods to drop down and see what methods are
provided by default. There would be two methods, showing in red color which comes by
default while creating the BAPI. Now select Add Method from Utilities > API Methods >
Add Method.

Step 12: On the screen that follows, provide the function module name that we just created in
the previous stage and click on the continue icon. In the coming pop-up, click the next step
icon. We observe that the information is predefined in the fields.

1240998

Page 93

Step 13: This is the next screen where you would just click on the next icon.

Step 14: A popup will be displayed as below.

1240998

Page 94

Click on Yes. You can see an information message reading ZBAPIT001 inserted.

Step 15: Now save after you add the method. Select & Double click on the API method.
Go to Tab: ABAP Check 'API Function' as shown below.

1240998

Page 95

Select the Radio button reading API Function as already said above.

Step 16: Now select the Object ZBAPI_ABY as shown below.

Step 17: Now Go to : Edit > Change Release Status > Object type > To Modeled.

Step 18: The below shown screen will be displayed. Click on yes.
1240998

Page 96

The message shows, The object type status set to modeled. ( or already modeled )
Step 19: Now go to: Edit > Change Release Status > Object type >To Implemented. You can
see a message reading Object type status set to implemented.
Step 20: Now, go to: Edit > Change Release Status > Object > To Released. There would be
two pop ups coming up. Click continue on the Pop Ups.
Step 21: Keep the cursor on the 'Method'. Now go to: Edit > Change Release Status > Object
type component > To Modeled. (Shown as below).

1240998

Page 97

Step 22: Now, go to: Edit > Change Release Status > Object type component > To
Implemented. You can see the message reading status for method zbapifmt001 set to
implemented.
Step 23: Now go to: Edit > Change Releasse Status > Object type component > To Released.
You can see the message reading status for method zbapifmt001 set to Released.
Step 24: Click on Generate from Object Type as shown below.

After clicking on the generate button, you can see the message reading Object type
'ZBAPI_ABY' generated successfully. Now we are done with the creation of a BAPI.
Stage 4: Viewing the created BAPI in BAPI Explorer
Step 25: Go to BAPI Explorer (Transaction code is BAPI) there we can find the BAPI (our
BAPI). You can click on the Alphabetical tab so that you can browse the BAPIs in an
alphabetical order. Find your BAPI as shown.

1240998

Page 98

Stage 5: Test your BAPI


Step 26: Enter the name of your BAPI in the transaction SWO1 and click on Test.

Step 27: The below screen is displayed. Click on the Execute icon (circled in red) against the
BAPI as shown

1240998

Page 99

Step 28: The below screen will be displayed where you would require entering the data
against the empty input fields.

Step 29: You could use the input help as shown below; here I have selected 0001. And click
the execute button.

1240998

Page 100

Step 30: The resulting screen is displayed below, where you can see 1 Entry (circled in red)
against ITEMTAB. Double click on 1 Entry.

The results as per our input are as shown below.

1240998

Page 101

ALE (Application Link Enabling):


Application Link Enabling (ALE) is a mechanism for the exchange of business data between
loosely-coupled R/3 applications built by customers of SAP, the enterprise resource
management program. ALE provides SAP customers with a program distribution model and
technology that enables them to interconnect programs across various platforms and systems.
There are three layers in the ALE system: application services, distribution services, and
communication services. The vehicle for data transfer is called an IDoc (intermediate
document), which is a container for the application data to be transmitted. After a user
performs an SAP transaction, one or more IDocs are generated in the sending database and
passed to the ALE communication layer. The communication layer performs a Remote
Function Call (RFC), using the port definition and RFC destination specified by the customer
model. The IDoc is transmitted to the receiver, which may be an R/3, R/2, or some external
system. If the data is distributed from a master system, the same transaction performed by the
1240998

Page 102

sender will be performed by the receiving system, using the information contained in the
IDoc.
Changes made to fields in master data tables can be set to trigger distribution of the changes
to slave systems, so that multiple database servers can update the same information
simultaneously. IDocs carry information directly between SAP systems. In order to
communicate with a non-SAP system, an IDoc is first transmitted to an intermediary system
that translates the data to a format that will be understood by the receiver. Return data also
passes through the translating system, where it is again encapsulated into an IDoc.

15. FORMS IN SAP-ABAP:


SAP SCRIPT:
SAP script is the SAP System's own text-processing system. It looks and feels a lot like other
leading text-processing systems. It is used to print preformatted text in pre-formatted forms.
Components of SAP Script:
1.

An editor for entering and editing the lines of a text

2.

Styles and layout sets for print layout. These are created independent of the individual
texts using the corresponding maintenance transactions and are allocated to the texts later

3.

The composer is a central output module. The SAP script composer is invisible to the
outside

1240998

Page 103

4.

A programming interface that allows you to include SAP script components into your
own application programs and to control the output of layout sets from within the
programs

5.

Several database tables for storing texts, styles and layout sets.
Layout Set:

To output documents using the programming interface, R/3 application programs need socalled layout sets (a kind of form).In SAP script a layout set describes the layout of the
individual print pages and uses text elements to supply definable output blocks, which a print
program can call. A layout set can be defined as a page design for a document.

Layout set on its own doesn't contain any data. The selection of data for the document is done
through the print program. The print program selects the data from database table and feeds
it to the layout set. When the print program is executed the document is printed on the screen,
printer. Usually a SAP Script Layout consists of following components:
1.

Header Data: Header data is used for information and control of SAP printing. The
header data comprises of 2 parts - Device Independent - Stores information like Start
page , Default paragraph ,Language Attributes etc. And Device Dependent stores
information like Page format ,Orientation Lines per inch etc

2.

Paragraph and Character Formats: Paragraphs are formatted using various


attributes. For instance Standard paragraph attributes specify Left or Right margin,
Alignment, Line spacing etc. Font attributes specify Font family, Font size etc. Character
formats allow to format entire blocks of text within a paragraph

3.

Windows and Text Elements: Windows are individual text areas (header address,
date, footer) in a page. It helps combine the information contained in a document into
certain groups and make each group appear on the printed page in an individual area.You
can define text elements (window texts) for each window. The print program accesses text
elements by name, formats them and prints them in the respective window. The paragraph
and the character formats used must be defined in the form.

1240998

Page 104

4.

Pages: They are individual pages of a document and must have a unique name. You
will often find different layouts for individual pages: The first page of an invoice differs
from the subsequent pages, on which you need not repeat general information, such as
address or customer data.

5.

Page Windows: While defining windows and pages, you do not yet determine the
position and spacing of the texts to be output. A page window defines the rectangular
output area in the output medium by specifying the left upper edge of the output area and
its width and height.
Print Program:

The execution of script is done through an ABAP program, which is referred as Print
Program. Each print program should have an ENTRY form, which will be called from
customization.
For a standard configuration we can see the form name (script name), print program name and
output type in the table TNAPR. The print program uses the Form control functions to call the
script.
The print program call either all or some of the form control functions to execute the script

OPEN_FORM (Mandatory) Opens the layout set output

CLOSE_FORM (Mandatory) Ends the layout set output

START_FORM (Optional) Starts a new layout set

WRITE_FORM (Mandatory) Calls a layout set element

END_FORM (Optional) Ends the current layout set

Billing invoice through SAP SCRIPT:

1240998

Page 105

SMARTFORMS IN SAP:
SAP Smart Forms is used to create and maintain forms for mass printing in SAP Systems. As
output medium SAP Smart Forms support a printer, a fax, e-mail, or the Internet (by using the
generated XML output). SAP introduced Smart Forms in 1998 to overcome the limitations in
SAP Scripts. Smart Forms are easier to develop, maintain and transport than SAP Script.
1240998

Page 106

Advantages of Smart Forms:

They help adapting forms without any programming knowledge due to entirely
graphical user interface

When activating the smart form the system automatically generates the function
module and at the runtime .

To make any changes we have to use the Drag & Drop, Cut & Paste. These actions do
not include writing of coding lines or using a script language.

We can insert static and dynamic tables. These include the line feeds in the individual
table cells, triggering events for table headings and subtotals and sorting data before
output.

The smart forms allow the user to include graphics, which can be displayed as a part
of the form or as background graphics. During printout the user can suppress the
background graphic as and when necessary.

Web Publishing is possible using the generated XML output.

1240998

Page 107

Anda mungkin juga menyukai