Sap Abap Book 1 Sap Abap Book 1
Sap Abap Book 1 Sap Abap Book 1
Sap Abap Book 1 Sap Abap Book 1
-1-
SAP –ABAP BOOK
Before Getting into the world of SAP, We must Understand the C oncept behind this Great Technology. The
Concept on which the SAP R/3 (ECC ) is built is ERP.
To be considered an ERP system, a software package must provide the function of at least two systems. For
example, a software package that provides both payroll and accounting functions could technically be
considered an ERP software package.
Examples of modules in an ERP which formerly would have been stand-alone applications include:
(1) Product lifecycle management, Supply chain management (e.g. Purchasing, Manufacturing and
Distribution), Warehouse Management, Customer Relationship Management (CRM), Sales Order
Processing, Online Sales, Financials, Human Resources, and Decision Support System.
The Below figure shows the various Resources of an Enterprise being Handled by the various Departments.
-2-
SAP –ABAP BOOK
Finance EHS
Accounts HR
Money Training
Costing
Production
Manpower
Ware House
QA
Transportation Materials
PPC
Purchasing Corporate
Marketing
Distribution Admin.
Methods
Sales R&D
Marketing SCM
CRM
FI PP
HR QM
MM SD
-3-
SAP –ABAP BOOK
(1) Data Needs to be Stored in Multiple servers (Replication of Data), which leads to complication of
the systems and require more Database space.
(2) Communication between different servers is possible only when an interface is developed and used.
(3) Data Needs to be moved to other servers regularly, otherwise there would be no data available.
Finance PP
HR QM
MM SD
Below Table shows the Various ERP Packages offered by different Companies.
-4-
SAP –ABAP BOOK
1C:Enterprise 1C Company
Accpac The Sage Group
Agresso Business World Unit 4 Agresso
CGI Group (formerly American Management
AMS Advantage Systems)
ERP LX (aka BPCS) Infor Global Solutions
Enterprise Business System Made2Manage Systems
Epicor Enterprise Epicor
ERManager SuperNova Solutions
ERP LN (aka Baan) Infor Global Solutions
IFS Applications Industrial & Financial Systems
JD Edwards EnterpriseOne Oracle
JD Edwards World Oracle
kVASy4 SIV.AG
Lawson Financials Lawson Software
MFG/PRO QAD
Microsoft Dynamics Microsoft
Movex Intentia
NetERP NetSuite Inc.
Oracle e-Business Suite Oracle
PeopleSoft Oracle
Ramco e.Applications Ramco Systems
Sage MAS 500 The Sage Group
SAP R/3 SAP
mySAP SAP
TQT iSystems, Inc
Visual Enterprise Infor Global Solutions
80
70
SAP
e 60
g
a 50 ORACLE
t
n
e 40 SIEBEL
c
r 30
e PEOPLESOFT
P 20
10 JDEDWARDS
0
) 4 ) 4 ) 4 ) 5 ) 5 ) 5 ) 5 )
0 4 '
'
( 0 '
( 0 '
( 0 '
( 0 '
( 0 '
( 0 '
( 0
(
The above Q 1graph 2 shows
Q Q
3 4 the 1percentage 2 3 4
Q Q Q Q Q of Market share of various ERP packages.
Quarter
SAP Enjoys 72% of Global ERP Market Share
-5-
SAP –ABAP BOOK
2. SAP
SAP is a German software company that produces the R/3 system and ECC . R/3 is an example of an ERP
(Enterprise Resource Planning) system. ERP systems
s ystems are used by corporations to track all information
related to the business, including financials, sales, and mate rials data.
(1) R/2 Stands for Real Time ,Two Tier
(2) R/3 Stands for Real Time, Three tier
(3) ECC Stands for ERP Central Component
R/3 is based on a client-server architecture and uses a relational database to track all information related to
a corporation. It’s made up of thousands of small programs called transactions. A transaction is a program
and set of screens that can be used to enter, change, or display data; monitor events within the R/3 system;
and change functionality in the R/3 system.
s ystem. R/3 gathers related transactions into groups known as modules.
A module is a set of transactions that deal with the same area of business functionality.
functionality. There are modules
for Materials, Financials, Human Resources, Sales, and other common business functions.
The simplest definition of an R/3 system is " one database." In one R/3 system, there is only one database.
To expand the definition, R/3 is considered to be all of the components attached to that one database. One
R/3 system is composed of one database server accessing a single database, one or more application servers,
and one or more presentation servers. By definition, it is all of the components attached to one database. If
you have one database, you have one system. If you have one s ystem, you have one database. During an
implementation, there is usually one system (or one database) assigned to development, one or more
systems designated for testing, and one assigned to production
-6-
SAP –ABAP BOOK
Presentation -
Server-
Tier 3 SAP-GUI
Layer
client-independent client-dependent
Application Server
An application server is a set of executables that collectively interpret the ABAP/4 programs and manage
the input and output for them. When an application server is started, these executables all start at the same
time. When an application server is stopped, they all shut down together. T he number of processes that start
up when you bring up the application server is defined in a single configuration file called the application
server profile.
Each application server has a profile that specifies its characteristics when it starts up and while it is
running. For example, an application sever profile specifies:
The application server exists to interpret ABAP/4 programs, and they only run there-the programs do not
run on the presentation server. An ABAP/4 program can start an executable on the presentation server, but
an ABAP/4 program cannot execute there.
If your ABAP/4 program requests information from the database, the application server will format the
request and send it to the database server.
-7-
SAP –ABAP BOOK
There is usually a separate computer dedicated to house the database server, and the RDBMS ma y run on
that computer also, or may be installed on its own computer.
Database Server
There is usually a separate computer dedicated to house the database server, and the RDBMS ma y run on
that computer also, or may be installed on its own computer.
What makes this integration work is the configuration of SAP to work with an individual corporation’s
business practices. In the context of SAP, the term configuration refers to the act of assigning values to
thousands of possible settings within the modules. These settings give users of SAP tremendous control
over how SAP functions.
As you can imagine, corporations are much like individuals — they have very different personalities. SAP
must be flexible enough to adapt to many different ways of doing business. For example, a purchase order
may be configured to require that a person’s name be entered as the requester of the purchase. In this setup,
when a user creates a purchase order in the system, he or she must enter the name of the requester in order
to save the information. On the other hand, if the purchase order form i s set up without this requirement, the
system allows a purchase order to be created without the name of the requester.
This configuration is done by analysts experienced in Business Process Reengineering, the art of
identifying business processes and changing them to achieve greater efficiency. After SAP is installed,
these configuration experts customize the modules to meet the corporation’s needs, or help the corporation
change its business practices to achieve the most efficiency out of SAP. This configuration doesn’t usually
involve programmers, but is instead done b y business analysts. When the configuration process is nearing
completion, the programmers are brought in to extend any part of SAP that can’t be configured to meet the
needs of the corporation.
-8-
SAP –ABAP BOOK
Although business analysts are responsible for configuration, the impact of this customization process on
programmers can’t be overstated. A program can’t be designed adequately until the configuration is stable.
Unfortunately, because of time constraints, the configuration is seldom completely finished before the
programmers must begin their design work. This is one of the unique challenges that face SAP
programmers.
SAP HISTORY
Over the course of three decades, SAP has evolved from a small, regional enterprise into a world-class
international company. Today, SAP is the global market leader in collaborative, inter-enterprise business
solutions. The company now employs more than 51,500 people, whose commitment and innovative spirit
pace our future success.
In 1972, five former IBM employees – Dietmar Hopp, Hans-Werner Hector, Hasso Plattner, Klaus Tschira,
and Claus Wellenreuther – launch a company called Systems Applications and Products in Data P rocessing
in Mannheim, Germany. Their vision: to develop standard application software for real-time business
processing.
One year later, the first financial accounting software is complete, forming the basis for the continuous
development of other software components in what later came to be known as the "R/1 system." "R" stands
for real-time data processing.
By the end of the decade, intensive examination of SAP's IBM database and dialog control system leads to
the birth of SAP R/2.
SAP moves into the company's first building on Max-Planck-Strasse in an industrial park in Walldorf, near
Heidelberg. Our software development area and its 50 terminals are all now under one roof. Fifty of the 100
largest German industrial firms are already SAP customers.
The SAP R/2 system attains the high level of stability of the previous generation of programs. Keeping in
mind its multinational customers, SAP designs SAP R/2 to handle different languages and currencies. With
this and other innovations in SAP R/2, SAP sees rapid growth.
By the middle of the decade, SAP founds its first sales organization outside Germany, in Austria. The
company makes its first appearance at the CeBIT computer fair in Hanover, Germany. Revenues reach DM
100 million (around $52 million), earlier than expected.
In August 1988, SAP GmbH becomes SAP AG. Starting on November 4, 1.2 million shares are listed on
the Frankfurt and Stuttgart stock exchanges.
e xchanges.
Germany's renowned business journal, manager magazine, names SAP its Company of the Year – a
distinction we would receive twice more in the next few years.
-9-
SAP –ABAP BOOK
With the founding of subsidiaries in Denmark, Sweden, Italy, and the United
U nited States, SAP's international
expansion takes a leap forward.
SAP R/3 is unleashed on the market. The client-server concept, uniform appearance of graphical interfaces,
consistent use of relational databases, and the ability to run on computers from different vendors meets with
overwhelming approval. With SAP R/3, SAP ushers in a new generation of enterprise software – from
mainframe computing to the three-tier architecture of database, application, and user interface. To this day,
the client-server architecture is the standard in business software.
A growing number of subsidiaries are managed out of Walldorf. The new Sales and Development Center in
Walldorf officially opens it doors. It symbolizes
s ymbolizes the global success of the company. In our twentieth year,
our business outside Germany exceeds 50 percent of total sales for the first time.
By 1996, the company has earned 1,089 new SAP R/3 customers. At the end of the year, SAP R/3 has been
installed in more than 9,000 systems
s ystems worldwide.
SAP celebrates its twenty-fifth anniversary in 1997 and now employs approximately 12,900 people. We
continue to strengthen our industry focus and build more and more industry-specific solutions. Henning
Kagermann becomes Co-Chairman and CEO of SAP AG with Hasso Plattner. On August 3, 1998, the
letters S-A-P appear for the first time on the Big B oard at the New York Stock Exchange (NYSE), the
largest stock exchange in the world.
As the decade draws to a close, Hasso Plattner, Co-Founder, Co-Chairman, and CEO a nnounces the
mySAP.com strategy, heralding the beginning of a new direction for the company and our product
portfolio. mySAP.com links e-commerce solutions to existing ERP a pplications, using state-of-the-art Web
technology.
With the Internet, the user becomes the focus of software applications. SAP develops SAP Workplace and
paves the way for the idea of an enterprise
e nterprise portal and role-specific access to information.
Currently, more than 12 million users work each day with SAP solutions. There are now 121,000
installations worldwide, more than 1,500 SAP partners, over 25 industry-specific business solutions,
solutions, and
more than 75,000 customers in 120 countries. SAP is the world's third-largest independent software vendor.
With service-oriented architecture and the underlying integration and application platform SAP NetWeaver,
SAP is providing our customers with solutions for end-to-end business processes. With SAP NetWeaver,
your company can integrate people, information, and processes within the company and beyond.
- 10 -
SAP –ABAP BOOK
BUSINESS IN BRIEF
SAP is the world's leading provider of business software, offering applications and services that enable
companies of all sizes across more than 25 industries to become best-run businesses. With more than
86,000 customers in over 120 countries,
c ountries, the company is listed on several exchanges, including the Frankfurt
stock exchange and NYSE, under the symbol "SAP."
• Applications
• SAP BusinessObjects portfolio
• On-demand solutions
• Industry-specific solution portfolios
• SAP NetWeaver
• SAP solutions for small businesses and midsize companies
• SAP Services
- 11 -
SAP –ABAP BOOK
Applications
For larger enterprises, SAP Business Suite offers modular enterprise software that supports end-to-end
industry processes. Powered by the SAP NetWeaver technology platform, SAP Business Suite currently
includes:
• SAP ERP
o Addresses the core business software requirements of the most demanding midsize
businesses and large organizations around the world – in all industries and sectors
o Includes four individual solutions that support key functional areas: SAP ERP Financials,
SAP ERP Human Capital Management, SAP ERP Operations, and SAP ERP Corporate Services . The
Functional Modules the are Included in SAP ERP are
(1) Material Management (MM)
(2) Sales & Distribution (SD)
(3) Finance (FI)
(4) Controlling (CO)
(5) Human Capital Management (HCM)
(6) Production Planning (PP)
(7) Quality Management (QM)
(8) Warehouse Management (WM)
(9) Project Life Cycle Management (PLM) Etc..,
- 12 -
SAP –ABAP BOOK
SAP BusinessObjects portfolio offers tools and applications designed to help customers optimize business
performance by connecting people, information, and businesses across business networks.
On-demand solutions
- 13 -
SAP –ABAP BOOK
From local businesses to global industry leaders, SAP has built its success on serving companies of all sizes
and industries around the world for more than three decades, developing best practices and delivering
software applications that target specific business needs. The result is a depth and breadth of industry
expertise and tailored software functionality that is difficult to match. SAP solutions are tailored to
industry-specific standards, best practices, and processes to help companies optimize business processes
and adapt quickly to changing market demands.
Through its industry solutions, SAP addresses the unique core processes of more than 24 distinct industries,
as well as numerous subsectors. And with its tailored offerings for small businesses and midsize companies
developed by, and delivered through, a global network of more than 2,500 solution resellers and partners,
SAP provides "micro-vertical" industry capabilities through a portfolio of 660 S AP Business All-in-One
partner solutions and 550 SAP Business One partner solutions.
SAP NetWeaver
As the foundation for service-oriented architecture, the SAP NetWeaver technology platform enables IT
departments to compose and orchestrate enterprise services using model-based development, helping
organizations evolve their current IT landscape into a strategic environment that drives business change.
With these enterprise services, companies can rapidly enhance their existing business processes or develop
and deploy new business processes.
- 14 -
SAP –ABAP BOOK
SAP NetWeaver unifies technology components into a single platform, allowing organizations to reduce IT
complexity and obtain more business value from their IT investments. It provides the best way to integrate
all systems running SAP or non-SAP software.
By delivering preconfigured, industry-oriented business content, SAP NetWeaver also solves companies'
challenges of integration and reduces the nee d for extensive custom implementations, making enterprise
applications simpler to implement, quicker to deploy, less expensive to own and more agile for future
business growth and innovation.
SAP and its channel partners offer flexible, scalable solutions tailored to company size as well as vertical
industry demands:
SAP Services
SAP Services delivers a comprehensive range of offerings to ensure optimum planning, deployment, and
operation through every phase of your software life cycle. From expert
e xpert guidance to complete execution,
- 15 -
SAP –ABAP BOOK
SAP Services combines the expertise, tools, and methodologies that accelerate implementations, transfer
knowledge, and continuously improve your business.
SAP Services offers service program innovations that address specific business issues. These offerings
include the following:
• SAP BusinessObjects consulting services – Provides consulting to help you optimize your solutions
for business intelligence (BI), enterprise performance management (EPM), and governance, risk, and
compliance (GRC)
• Business process outsourcing – Supports business process outsourcing (BPO) providers in setting
up BPO services that generate sustainable business value
• Consulting services – Offers best-in-class consulting through planning, implementation, and
optimization services
• Custom development – Incorporates SAP development strategies to deliver solutions that meet
unique business goals
• Financing for SAP solutions – Provides
Pr ovides companies with affordable, all-inclusive, and predictable
financing options that cover the entire cost of your SAP solution
• Product and service introduction – Provides a standardized process for introducing all SAP products
to the market, helping customers
c ustomers achieve rapid business value
• SAP Application Management – Provides the 24/7, level-one and level-two support you need to
manage and optimize the performance of your SAP landscapes – in part or i n whole, anytime, anywhere
• SAP Hosting – Provides a comprehensive range of timely, on-demand hosting services for helping
you integrate business processes, derive maximum value from your SAP solutions, and gain freedom from
your IT challenges – so you can realize your business objectives
• SAP NetWeaver MDM – Offers a comprehensive portfolio of tailored and targeted services for
supporting the master data management (MDM) life cycle at the level of engagement
• Services for Banking-Industry – Provides guidance in planning, implementing, and rolling out SAP
for Banking, helping you make the right decisions, and deploy the appropriate applications, that best
support your overall business strategy
• Services for SOA – Offers a proven, enterprise-oriented approach for adopting and operating SOA
• Software maintenance and support – Provides services for planning, implementation, and
operations
• Tools, technologies, and methodologies – Deliver the capabilities and knowledge that minimize
total cost of ownership and maximize your return on investment in SAP solutions
• Upgrade to SAP ERP – Delivers comprehensive upgrade services, tools, and content to support the
smooth implementation of low-risk and cost-effective upgrade projects.
IMPLEMENTATION PHASES
Phase 1: Project Preparation - During this phase the team goes through initial planning and preparation
for SAP project.
Phase 2: Business Blueprint - The purpose of this phase is to achieve a common understanding of how the
company intends to run SAP to
t o support their business.
- 16 -
SAP –ABAP BOOK
Phase 3: Realization - The purpose of this phase is to implement all the business process requirements
based on the Business Blueprint.
Phase 4: Final Preparation - The purpose of this phase is to complete the final preparation (including
testing, end user training, system management, and cutover activities) to finalize your readiness to go live.
Phase 5: Go Live and Support - The purpose of this phase is to move from a project-oriented, pre-
production environment to live production operation.
Phase 6: Run - The primary goal of this phase is to ensure the operability of the solution.
Each phase has a set of deliverables that are produced during the duration of the phase and serve as t he
input to follow-up phases. Each deliverable provides list of outputs it consist of and methods that are used
to produce the deliverable.
Select the Server you wish to LOG into. Double click on Button. You will get the Log
on screen as below.
- 17 -
SAP –ABAP BOOK
Client will come by default. No need to change. (you can change it if you want.)
Enter User id and password. No need to enter Language as the default language is set as EN (English).
Click on Enter Button. You will see the SAP Easy Access Screen as shown
shown below
- 18 -
SAP –ABAP BOOK
3.ABAP/4
ABAP/4 is the programming language used by SAP’s developers to build the transactions that make up the
R/3 application. It’s also used by
b y corporations to customize the R/3 application. In general, ABAP/4 isn’t
used by customers of SAP to develop complex applications from scratch, but is used instead to provide
additional business functionality.
functionality. For example, it’s not necessary for a customer to write a program in
ABAP/4 to manage inventory levels because SAP has already written transactions to accomplish this
objective.
The two most common uses for ABAP/4 are producing custom reports and developing custom interfaces
for SAP. In this context, a report is an ABAP/4 program that reads specific data from SAP’s database and
then displays the data via a computer screen or a printed page. An interface, on the other hand, is an
ABAP/4 program that moves data into SAP, or reads data from SAP and writes it out to a system file to be
transferred to an external computer system, such as a legacy mainframe. Other uses for ABAP/4 include
conversion programs that change data into a format usable by SAP, and custom transactions similar to the
SAP transactions that make up the R/3 application, but are written by users to fulfill some business function
not provided by SAP. This new version of the book
book covers programming in ABAP/4 up to the 3.1h release
of SAP R/3.
Almost all ABAP/4 programs manipulate data from the SAP database to some extent. Data managed by
SAP is often broken into two categories: master data and transactional data (called documents in SAP):
Master data is needed in order to create any document; for example, an invoice can’t be created without a
vendor to issue it. A change in inventory, referred to in SAP as a material movement, must refer to a
material and a plant. Each SAP module has master data that it manages and documents that are created in
the course of normal business operations. For example, the FI module, which manages finances and
accounting, manages master data such as general ledger accounts and documents such a s journal entries and
check payments.
ABAP/4 is a fourth-generation
f ourth-generation programming language
language with many of the features of other modern
programming languages such as the familiar C, Visual Basic, and PowerBuilder. It allows variables and
arrays to be defined,
de fined, modulation of programs via subroutines and function calls, access to the database via
SQL, and some event-oriented programming. Because this book covers all these major topics, you can use
the information contained here to learn how to write ABAP/4 programs that
t hat meet the most demanding
- 19 -
SAP –ABAP BOOK
business requirements.
SAP is an extremely
e xtremely complicated system; no one individual can understand all of it. This chapter focuses
on ABAP/4 programming but includes background information on the SAP environment, within which all
ABAP/4 programs run.
Each chapter discusses an area of ABAP/4 programming such as displaying data, accessing the SAP
database, and using conditional operators. The chapters build on each other, with examples taken from real-
world business problems.
You will get into ABAP Editor ,Enter the program Name.
- 20 -
SAP –ABAP BOOK
You will enter the ABAP Editor screen. There type a line command.
WRITE: ‘MY FIRST PROGRAM’.
- 21 -
SAP –ABAP BOOK
ABAP DICTIONARY
The ABAP Dictionary permits the central management of all the data
definitions used in the R/3 System.
In the ABAP Dictionary, you can create user-defined types such as,
(1) Data elements,
(2) structures, and
(3) table types
for use in the ABAP programs or in the interfaces of function modules. Database objects such as tables and
database views can also be defined in the ABAP Dictionary and created with this definition in the database.
The ABAP Dictionary also provides a number of services that support
program development. For example, setting and releasing locks, defining
an input help (F4 help), and attaching a field help (F1 help) to a screen f ield.
• There are several path to accessing the dictionary. Below is a list some of the ways to access the
Dictionary.
• To access the ABAP Dictionary:
– Use the menu path:
• Tools → ABAP Workbench → Development → ABAP Dictionary
– Use the menu path:
• Tools → ABAP Workbench → Overview → Object Navigator
• Pull down the Workbench menu and select Other objects… Select the
Dictionary tab from the pop up screen and enter the appropriate table name in the Database table field.
- 22 -
SAP –ABAP BOOK
The basic objects for defining data in the ABAP Dictionary are tables, data
elements, and domains. The domain is used for the technical definition of
a table field (for example, field type and length), while the data element is
used for the semantic definition (for example, short description).
Domain describes the value range of a field by its data type and length. The value range can be limited by
specifying fixed values.
Data element describes the meaning of a domain in a certain business context. The data element contains
primarily the field help (F1 documentation) and the field labels in the screen.A field is not an independent
object, but is table-dependent. The field canonly be maintained within a table.
You can enter the data type and number of places directly for a field. No data element is required in this
case. Instead, the data type and number of places are defined b y specifying a direct type. The data type
attributes of a data e lement can also be defined by specifyinga built-in type, where the data type and
number of places are entereddirectly.
- 23 -
SAP –ABAP BOOK
Domain
BC030_2.03.4
Foreign key definitions are generally imparted from the include to the including table. The attributes of the
foreign key definition are passed from
f rom the include to the including table. As a result, the foreign
for eign key
depends on the definition in the include. The structure of the objects of application
a pplication development are mapped
in tables on the underlying relational database. The attributes of these objects correspond to fields of the
table. A table consists of columns (fields) and rows (entries). It has a name and different attributes, such as
delivery class and maintenance authorization.
A field has a unique name and attributes and can be a key field.A table has one or more key fields called the
primary key.The values of these key fields uniquely identify a table entry.You must specify a reference
table for fields containing currency (data typeCURR) or quantity (data type QUAN). This table must
contain a field( reference field ) with the format for currency keys (data type CUKY) or forunits (data type
UNIT). The field is only assigned to the reference fieldat program runtime.
Unit 2
Tables in the ABAP Dictionary
Creating Tables
- 24 -
SAP –ABAP BOOK
- 25 -
SAP –ABAP BOOK
- 26 -
SAP –ABAP BOOK
You will get a pop-up as shown below. No need to do anything, just click on Enter Button
- 27 -
SAP –ABAP BOOK
Click on Activate Button (or) Ctrl + F3 (Activating the DE). Data Element is created
- 28 -
SAP –ABAP BOOK
Click on Enter.
- 29 -
SAP –ABAP BOOK
- 30 -
SAP –ABAP BOOK
Then Click on
- 31 -
SAP –ABAP BOOK
Save (Ctrl + S ) & Activate ( Ctrl + F2 ) & Come Back (F3) .After coming back, Save (Ctrl + S ) &
Activate ( Ctrl + F2 ) Now the Table is created.
Here we can observe that we are using the Data Element ZCHAR1_DE Multiple number of times in various
field definitions.
- 32 -
SAP –ABAP BOOK
Contents:
Data Types
As well as occurring as attributes of a data object, data types can also be defined independently.
The definition of a user-defined data type is based on a set of predefined elementary data types.
You can define data types either locally in the declaration part of a program (using the TYPES
statement) or globally in the ABAP Dictionary. You can use your own data types to declare data
objects or to check the types of parameters in generic operations.
Data objects
Data objects are the physical units with which ABAP statements work at runtime. Each ABAP
data object has a set of technical attributes, which are fully defined at all times when an ABAP
program is running. The technical attributes of a data object are its length, number of decimal
places, and data type. ABAP statements work with the contents of data objects and interpret them
according to their data type. You declare data objects either statically in the declaration part of an
ABAP program (the most important statement for this is DATA), or dynamically at runtime (for
example, when you call procedures). As well as fields in the memory area of the program, the
program also treats literals like data objects.
You may sometimes need to find out the attributes of a data object at runtime that were not
statically available. For example, you may need to find out the type of a generic interface
parameter in a subroutine. To do this, you would use the statement:
- 33 -
SAP –ABAP BOOK
• ABAP supports automatic type conversion and length adjustment for all of them except type
D (date) and type T (time) fields which cannot be converted into each other.
FIELD SYMBOLS:-
Field symbols are placeholders or symbolic names for other fields. They do not physically
reserve space for a field, but point to its contents. A field symbol cam point to any data object. The
data object to which a field symbol points is assigned to it after it has been declared in the
program.You can create field symbols either without or with type specifications. If you do not
specify a type, the field symbol inherits all of the technical attributes of the field assigned to it. If
you do specify a type, the system checks the compatibility of the field symbol and the field you are
assigning to it during the ASSIGN statement.
For field symbols, the angle brackets are part of the syntax. They identify field symbols in the
program code.
Static ASSIGN:-
If you already know the name of the field that you want to assign to the field symbol when you
write a program, use the static ASSIGN statement:
- 34 -
SAP –ABAP BOOK
When you assign the data object, the system checks whether the technical attributes of the data
object <f> correspond to any type specifications for the field symbol <FS>. The field symbol
adopts any generic attributes of <f> that are not contained in its own type specification. Following
the assignment, it points to <f> in memory.
Field groups:-
An extract dataset consists of a sequence of records. These records may have different structures.
All records with the same structure form a record type. You must define each record type of an
extract dataset as a field group, using the FIELD-GROUPS statement.
FIELD-GROUPS <fg>.
This statement defines a field group <fg>. A field group combines several fields under one name.
For clarity, you should declare your field groups at the end of the declaration part of your program.
A field group does not reserve storage space for the fields, but contains pointers to existing fields.
When filling the extract dataset with records, these pointers determine the contents of the stored
records.
FIELD-GROUPS HEADER.
This group is automatically placed before any other field groups when you fill the extract. This
means that a record of a field group <fg> always contains the fields of the field group HEADER.
When sorting the extract dataset, the s ystem uses these fields as the default sort key.
To define the structure of a record, use the following statement to add the required fields to a field
group:
This statement defines the fields of field group <fg>. Before you can assign fields to a field group,
you must define the field group <fg> using the FIELD-GROUPS statement. The fields in the field
group must be global data objects in the ABAP program. You cannot assign a local data object
defined in a procedure to a field group.
The INSERT statement, just as the FIELD-GROUPS statement, neither reserves storage space nor
transfers values. You use the INSERT statement to create pointers to the fields <f i > in the field
group <fg>, thus defining the structures of the extract records.
Once you have declared the possible record types as field groups and defined their structure, you
can fill the extract dataset using
u sing the following statements:
- 35 -
SAP –ABAP BOOK
EXTRACT <fg>.
When the first EXTRACT statement occurs in a program, the system creates the extract dataset
and adds the first extract record to it. In each subsequent EXTRACT statement, the new extract
record is added to the dataset.
The SORT statement terminates the creation of the extract dataset of a program and, at the same
time, sorts its records. Without the BY option, the system sorts the dataset by the key specified in
the HEADER field group.
Open SQL
Open SQL is a subset of the standard SQL92 language. It contains only Data Manipulation
Language (DML) statements, such as SELECT, IINSERT, and DELETE. It does not contain any
Data Definition Language (DDL) statements (such as CREATE TABLE or CREATE INDEX).
Functions of this type are contained in the ABAP Dictionary. Open SQL contains all of the DML
functions from SQL92 that are common to all of the database systems supported by SAP. It also
contains a few SAP-specific functions. ABAP programs that use only Open SQL statements to
access the database are fully portable. The database interface converts the OPEN SQL commands
into commands of the relevant database.
Native SQL
Native SQL statements are passed directly from the database interface to the database without first
being converted. It allows you to take advantage of all of your database’s characteristics in your
programs. In particular, it allows you to use DDL operations. The ABAP Dictionary uses Native
SQL for tasks such as creating database tables. In ordinary ABAP programs, it is not worth using
DDL statements, since you cannot then take advantage of the central administration functions of
thie ABAP Dictionary. ABAP programs that use Native SQL statements are database-specific,
because there is no standardized programming interface for SQL92.
Comparing Strings Similarly to the special statements for processing strings, there are
special comparisons that you can apply to strings with types C, D, N, and T. You can use the
following operators:
<operator> Meaning
CO Contains Only
CN Contains Not only
CA Contains Any
NA contains Not Any
CS Contains String
NS contains No String
CP Contains Pattern
NP contains No Pattern
- 36 -
SAP –ABAP BOOK
There are no conversions with these comparisons. Instead, the system compares the characters of
the string.
INTERNAL TABLES
Internal tables provide a means of taking data from a fixed structure and storing it in working
memory in ABAP. You should use internal tables whenever you want to process a dataset with a
fixed structure within a program. A particularly important use for internal tables is for storing and
formatting data from a database table within a program. They are also a good way of including
very complicated data structures in an ABAP program.
Table type:-
The table type determines how ABAP will access individual table entries. Internal tables can be
divided into three types:
Standard tables have an internal linear index. From a particular size upwards, the indexes of
internal tables are administered as trees. In this case, the index administration overhead increases
in logarithmic and not linear relation to the number of lines. The system can access records either
by using the table index or the key. The response time for key access is proportional to the number
of entries in the table. The key of a standard table is always non-unique. You cannot specify a
unique key. This means that standard tables can always be filled very quickly, since the system
does not have to check whether there are already existing entries. You should fill a standard table
by appending lines (ABAP APPEND statement), and read, modify and delete entries by specifying
the index
Sorted tables are always saved sorted by the key. They also have an internal index. The system
can access records either by using the table index or the key. The response time for key access is
logarithmically proportional to the number of table entries, since the system uses a binary search.
The key of a sorted table can be either unique or non-unique. When you define the table, you must
specify whether the key is to be unique or not. Standard tables and sorted tables are known
generically as index tables. You fill sorted tables using the INSERT statement. Entries are inserted
according to the sort sequence defined through the table key
Hashed tables have no linear index. You can only access a hashed table using its key. The
response time is independent of the number of table entries, and is constant, since the system
access the table entries using a hash algorithm. The key of a hashed table must be unique. When
you define the table, you must specify the key as UNIQUE.
You can specify the initial amount of main memory assigned to an internal table object when you
define the data type using the following addition:
- 37 -
SAP –ABAP BOOK
This size does not belong to the data type of the internal table, and does not affect the type check.
You can use the above addition to reserve memory space for <n> table lines when you declare the
table object.
When this initial area is full, the system makes twice as much extra space available up to a limit of
8KB. Further memory areas of 12KB each are then allocated.
• The optional addition WITH HEADER line declares an extra data object with the same name
and line type as the internal table. This data object is known as the header line of the internal table.
You use it as a work area when working with the internal table. When you use internal tables with
header lines, you must remember that the header line and the body of the table have the same
name. If you have an internal table with header line and you want to address the body of the table,
you must indicate this by placing brackets after the table name (<itab>[]). Otherwise, ABAP
interprets the name as the name of the header line and not of the body of the table. You can avoid
this potential confusion by using internal tables without header lines. In particular, internal tables
nested in structures or other internal tables must not have a header line, since this can lead to
ambiguous expressions.
TYPES VECTOR TYPE SORTED TABLE OF I WITH UNIQUE KEY TABLE LINE.
Like other data objects, you can make internal tables operands in the MOVE statement
<itab2> = <itab1>.
Like all data objects, you can initialize internal tables with the
CLEAR <itab>.
statement. This statement restores an internal table to the state it was in immediately after you
declared it. This means that the table contains no lines. However, the memory already occupied by
the memory up until you cleared it remains allocated to the table.
- 38 -
SAP –ABAP BOOK
If you are using internal tables with header lines, remember that the header line and the body of the
table have the same name. If you want to address the body of the table in a comparison, you must
place two brackets ([ ]) after the table name.
CLEAR <itab>[].
To ensure that the table itself has been initialized, you can use the
REFRESH <itab>.
statement. This always applies to the body of the table. As with the CLEAR statement, the memory
used by the table before you initialized it remains allocated. To release the memory space, use the
statement
FREE <itab>.
You can use FREE to initialize an internal table and release its memory space without first using
the REFRESH or CLEAR statement. Like REFRESH, FREE works on the table body, not on the
table work area. After a FREE statement, you can address the internal table again. It still occupies
the amount of memory required for its header (currently 256 bytes).
b ytes). When you refill the table, the
system has to allocate new memory space to the lines.
Sorting In
Internal Ta
Tables :-
:-
You can sort a standard or hashed table in a program. To sort a table by its key, use the statement
The statement sorts the internal table <itab> in ascending order by its key. The statement always
applies to the table itself, not to the header line. The sort order depends on the sequence of the
standard key fields in the internal table. The default key is made up of the non-numeric fields of
the table line in the order in which they occur.
You cannot sort a sorted table using the SORT statement. The system always maintains these
tables automatically by their sort order. If an internal table is statically recognizable as a sorted
table, the SORT statement causes a syntax error. If the table is a generic sorted table, the SORT
statement causes a runtime error if the sort key is not the same as an extract of the beginning of the
table key, you sort in descending order, or use the AS TEXT addition. In other words, the SORT
statement is only allowed for generic internal tables, if it does not violate the internal sort order.
Stable sort:-
Allows you to perform a stable sort, that is, the relative sequence of lines that are unchanged by the
sort is not changed. If you do not use the STABLE option, the sort sequence is not preserved. If
- 39 -
SAP –ABAP BOOK
you sort a table several times by the same key, the sequence of the table entries will change in each
sort. However, a stable sort takes longer than an unstable sort.
To ensure compatibility with previous releases, you can also specify formal parameters in
subroutines and function modules as TABLES parameters. This defines a formal parameter as a
standard table with default key and header line. Whenever you pass a table without a header line as
an actual parameter to a formal parameter with a header line (TABLES), the system automatically
creates the corresponding header line in the routine.
To find out the attributes of an internal table at runtime that were not available statically, use
the statement:
• Standard tables
The line is appended to the end of the internal table. This has the same effect as the explicit
APPEND statement.
• Sorted tables
The line is inserted into the table according to the table key. If the key is non-unique, duplicates
are inserted above the existing entry with the same key. The runtime for the operation increases
logarithmically with the number of existing table entries.
• Hashed tables
The table is inserted into the internal hash administration according to the table key.
INSERT LINES OF <itab1> [FROM <n 1>] [TO <n 2>] INTO TABLE <itab2>.
When the line is inserted, the system checks whether there is already a table entry that matches the
key. If there is no corresponding entry already in the table, the COLLECT statement has the same
- 40 -
SAP –ABAP BOOK
effect as inserting the new line. If an entry with the same key already exists, the COLLECT
statement does not append a new line, but adds the contents of the numeric fields in the work area
to the contents of the numeric fields in the existing entry
• Standard tables
• Sorted tables
Binary search, where the runtime is in logarithmic relation to the number of table entries.
• Hashed tables
The entry is found using the hash algorithm of the internal table. The runtime is independent of the
number of table entries.
MODIFY TABLE <itab> FROM <wa> [TRANSPORTING <f 1> <f 2> ...].
5) The AT statement introduces a statement block that you end with the ENDAT statement.
AT <level>.
<statement block>
ENDAT.
<level> Meaning
FIRST First line of the internal table
LAST Last line of the internal table
NEW <f> Beginning of a group of lines with the same contents in the field <f> and in
the fields left of <f>
END Of <f> End of a group of lines with the same contents in the field <f> and in the
fields left of <f>
You can use control level statements to react to control breaks in internal tables instead of
programming them yourself with logical expressions. Within the loop, you must order the AT-
- 41 -
SAP –ABAP BOOK
ENDAT statement blocks according to the hierarchy of the control levels. If the internal table has
the columns <f 1>, <f 2>, ...., and if it is sorted by these columns
If you are working with a work area <wa>, it does not contain the current line in the AT...
ENDAT statement block. All character fields to the right of the current group key are filled with
asterisks (*). All other fields to the right of the cu rrent group key contain their
t heir initial value.
Within an AT...ENDAT block, you can calculate the contents of the numeric fields of the
corresponding control level using the SUM statement.
READ TABLE <itab> ... INTO <wa>. READ TABLE <itab> ...
MODIFY TABLE <itab> FROM <wa> ... MODIFY TABLE <itab> ...
MODIFY <itab> FROM <wa> ...WHERE ... MODIFY <itab> ... WHERE ...
To open a file on the application server, use the OPEN statement as follows:
- 42 -
SAP –ABAP BOOK
To open a file for reading, use the FOR INPUT addition to the OPEN DATASET statement.
To open a file for writing, use the FOR OUTPUT addition to the OPEN DATASET statement.
To open a file so that you can append data to the end of it, use the FOR APPENDING addition in
the OPEN DATASET statement:
To open a file at a particular position, use the AT POSITION addition in the OPEN DATASET
statement.
OPEN DATASET <dsn> [FOR ....] [IN ... MODE] AT POSITION <pos>.
If your system is running under UNIX or WINDOWS NT, you can execute an operating system
command in the OPEN DATASET statement using the FILTER addition:
The operating system command in the field <filt> is processed when the file <dsn> is opened.
To receive the system message sent by the operating system when you try to open a file, use the
MESSAGE addition in the OPEN DATASET statement:
To write data to a file on the application server, use the TRANSFER statement:
To read data from a file on the application server, use the READ DATASET statement:
• OPEN DATASET
• READ DATASET
• TRANSFER
• DELETE DATASET
- 43 -
SAP –ABAP BOOK
To make programs portable, the R/3 System has a concept of logical filenames and paths. These
are linked to physical files and paths. The links are created in special tables, which you can
maintain according to your own requirements. In an ABAP program, you can then use the function
module FILE_GET_NAME to generate a physical filename from a logical one
itab-name = 'VIKRAM'.
itab-num = '24'.
APPEND itab.
IF sy-subrc = 0.
LOOP AT itab.
TRANSFER itab TO '\usr\JHSOFT.txt'.
ENDLOOP.
ENDIF.
CLOSE DATASET '\usr\JHSOFT.txt'.
TO READ DATA FROM APPLICATION SERVER
*&---------------------
*&---------------------------------
-------------------------
-------------------------
-----------------------
-----------*
*
*& Report Z_APPL_TEST_READ
*&---------------------
*&---------------------------------
-------------------------
-------------------------
-----------------------
-----------*
*
REPORT Z_APPL_TEST_READ .
- 44 -
SAP –ABAP BOOK
IF sy-subrc = 0.
DO.
READ DATASET p_file INTO it_read.
IF sy-subrc <> 0.
EXIT.
ENDIF.
APPEND it_read.
ENDDO.
ENDIF.
loop at it_read.
write:/ it_read-txt.
endloop.
* SELECTION-SCREENS *
The GUI status of a selection screen is generated by the system. The SET PF-STATUS statement
in the PBO event of the selection screen has no effect on the standard GUI status. If you want to
use your own GUI status for a selection screen or deactivate functions in the standard GUI status,
you can use one of the following function modules in the PBO event of the selection screen:
• RS_SET_SELSCREEN_STATUS
Sets another GUI status defined in the same ABAP program, or deactivates functions of the
standard GUI status.
• RS_EXTERNAL_SELSCREEN_STATUS
Sets a GUI status defined in an external function group. You must use the SET PF-STATUS
statement to set the status in a special function module in this function group. You must pass the
name of the function module that sets the Status as a parameter to the function module
RS_EXTERNAL_SELSCREEN_STATUS.
- 45 -
SAP –ABAP BOOK
The SPA/GPA Parameter Technique is a general procedure for filling the initial screen when a
program is called. To use this technique for parameters on selection screens, you must link the
parameter to an SPA/GPA parameter
para meter from the SAP memory as follows:
By default, the length of an input field on the selection screen is the same as the length of the
parameter in the ABAP program. However, you can define the visible length of a parameter as
smaller than its actual length (as is also possible for input/output fields on screens):
To define the input field of a parameter as a required field, you use the following syntax:
To check a user entry against a check table or against fixed values in the ABAP Dictionary,
you use the following syntax:
To suppress the display of the input field on the selection screen, you use the following syntax:
To modify the appearance of an input field on the selection screen, you must assign the
parameter to a modification group as follows:
The row type of a selection table is a structure that consists of the following four components:
SIGN, OPTION, LOW and HIGH. Each row of a selection table that contains values represents a
sub-condition for the complete selection criterion. Description of the individual components:
• SIGN
The data type of SIGN is C with length 1. The contents of SIGN determine for each row whether
the result of the row condition is to be included in or excluded from the resulting set of all rows.
Possible values are I and E.
– I stands for "inclusive" (inclusion criterion - operators are not inverted)
– E stands for "exclusive" (exclusion criterion - operators are inverted)
• OPTION
- 46 -
SAP –ABAP BOOK
The data type of OPTION is C with length 2. OPTION contains the selection operator. The
following operators are available:
– If HIGH is empty, you can use EQ, NE, GT, LE, LT,CP, and NP. These operators are the same
as those that are used for logical expressions. Yet operators CP and NP do not have the full
functional scope they have in normal logical expressions. They are only allowed if wildcards ( '*'
or '+' ) are used in the input fields, and no escape character is defined.
– If HIGH is filled, you can use BT (BeTween) and NB (Not Between). These operators
correspond to BETWEEN and NOT BETWEEN that you use when you check if a field belongs to
a range.
• LOW
The data type of LOW is the same as the column type of the database table, to which the selection
criterion is linked.
– If HIGH is empty, the contents of LOW define a single field comparison. In combination with
the operator in OPTION, it specifies a condition for the database selection.
– If HIGH is filled, the contents of LOW and HIGH specify the upper and lower limits for a range.
In combination with the operator in OPTION, the range specifies a condition for the database
selection.
• HIGH
The data type of HIGH is the same as the column type of the database table, to which the selection
criterion is linked. The contents of HIGH specify the upper limit for a range
ran ge selection.
If the selection table contains more than one row, the system applies the following rules when
creating the complete selection criterion:
1. Form the union of sets defined on the rows that have SIGN
S IGN field equal to I (inclusion).
2. Subtract the union of sets defined on the rows that have SIGN field equal to E (exclusion).
3. If the selection table consists only of rows in which the SIGN field equals E, the system
selects all data outside the set specified in the rows.
RANGES Tables
You can use the RANGES statement to create internal tables of the same type as selection tables.
RANGES <rangetab> FOR <f>.
This statement is simply a shortened form of the following statements:
DATA: BEGIN OF <rangetab> OCCURS 0,
SIGN(1),
OPTION(2)
LOW LIKE <f>,
HIGH LIKE <f>,
END OF <rangetab>.
Internal tables created with RANGES have the same structure as selection tables, but they do not
have the same functionality.
Selection tables created with RANGES are not components of the selection screen. As a result, no
relevant input fields are generated. Also, you cannot use a RANGES table as a data interface in
program <prog> called by the following statement:
SUBMIT <prog> WITH <rangetab> IN <table>.
- 47 -
SAP –ABAP BOOK
Besides the special additions, there are a number of other additions that you can use with the
SELECT-OPTIONS statement and that have the same syntax and the same function as for the
PARAMETERS statement. SPA/GPA parameters as default values
SELECT-OPTIONS
To place comments on the selection screen, and if you want write anything in selection-screen,
you use:
From any program in which selection screens are defined, you can call these screens at any
point of the program flow using the following statement:
(3) CALL SELECTION-SCREEN <numb> [STARTING AT <x1> <y 1>] [ENDING AT <x2>
<y 2>].
- 48 -
SAP –ABAP BOOK
Similarly to on screens, where you can define checkboxes and radio buttons with function
codes, you can do the same with checkboxes and radio buttons on selection screens. You do this
using the USER-COMMAND addition when you declare the relevant parameters:
AT SELECTION-SCREEN OUTPUT
event is triggered. This event block allows you to modify the selection screen directly before it is
displayed.
is triggered when the contents of each individual input field are passed from the selection screen to
the ABAP program. The input field <field> can be checked in the corresponding event block. If an
error message occurs within this event block, the corresponding field is made ready for input again
on the selection screen.
To create help for input fields that have no Dictionary reference, or to override the help
normally linked to the field, you can create an event block for the event
The event is triggered when the user calls the F1 help for the field <field>.
To create possible values help for input fields that have no Dictionary reference, or to override
the help normally linked to the field, you can create an event block for the event
The event is triggered when the user calls the F4 help for the field <field>.
LISTS
- 49 -
SAP –ABAP BOOK
You can output symbols or R/3 icons on a list by using the following syntax:
Syntax
You can replace both the above INCLUDE statements with one single INCLUDE statement:
INCLUDE <list>.
You can output the first character of a field as a checkbox on the output screen by using the
following syntax:
Syntax
During the event TOP-OF-PAGE, you can also fill the system fields SY-TVAR0 to SY-TVAR9
with values that should replace possible placeholders &0 to &9 in the standard page header
To trigger a page break during list processing, use the basic form of the
th e NEW-PAGE statement:
Syntax
• ends the current page. All other output appears on a new page.
• only starts a new page if output is written to the current page as well as to the new page
after NEW-PAGE. The system then increases the SY-PAGNO system field by one. You cannot
produce empty pages.
• does not trigger the END-OF-PAGE event. This means that the system does not output a
page footer even if one is defined.
- 50 -
SAP –ABAP BOOK
To execute a page break on the condition that less than a certain number of lines is left on a page,
use the RESERVE statement:
Syntax
This statement triggers a page break if less than <n> free lines are left on
o n the current list page
between the last output and the page footer. <n> can be a variable. Before starting a new page, the
system processes the END-OF-PAGE event. RESERVE only takes effect if output is written to the
subsequent page (the system will not generate an empty page).
To scroll through a list vertically by the size of the current window and independent of the
page length, use the following statement:
Syntax
To scroll horizontally to the left or right margin of a list, use the following options
o ptions of the
SCROLL statement:
Syntax
You can position a WRITE output in the same column as a previous WRITE output. Use the
formatting option UNDER of the WRITE statement:
Syntax
The system starts outputting <f> in the same column from which field <g> started. This statement
is not limited to the current page, that is, <g> must not appear on the same page.
To set the next output line to the first line of a block of lines defined with the RESERVE statement
use the BACK statement as follows:
Syntax
- 51 -
SAP –ABAP BOOK
RESERVE.
.....
BACK.
PROCESSING BLOCKS: -
Dialog modules
The OUTPUT addition defines the dialog module <mod> as one that may be called from the PBO
event of the flow logic of any screen.
The INPUT addition defines the dialog module <mod> as one that may be called from the PAI
event of the flow logic of any screen. INPUT is the standard addition. It may be omitted.
You can define two dialog modules, both called <mod>, in the same program as long as one of
them has the addition OUTPUT and the other has the addition INPUT.
Description of Events
This section describes in more detail the events that occur when you run an executable program.
The following events occur when you run a typical executable program with a logical database:
Event Occurs
INITIALIZATION Before the standard selection screen is displayed
AT SELECTION-SCREEN After user input on a selection screenscreen has been processed, but
while the selection screen is still active
START-OF-SELECTION After the standard selection screen has been processed, before data
is read from the logical database
GET <table> After the logical database has read an entry from the node <table>
GET <table> LATE After all of the nodes of the logical database have been processed
that are below <table> in the database hierarchy
END-OF-SELECTION After all data has been read by the logical database
- 52 -
SAP –ABAP BOOK
Event Occurs
TOP-OF-PAGE In list processing when a new page starts
END-OF-PAGE In list processing when a page ends
AT LINE-SELECTION When the user triggers the predefined function code PICK
AT PF<nn> When the user triggers the predefined function code PF<nn>
AT USER-COMMAND When the user triggers a function code defined in the program
INITIALIZATION: -
This event occurs before the standard selection screen is called. You can use it, for example, to
initialize the input fields of the standard selection screen. This is the only possible way to change
the default values of parameters or selection criteria defined in logical databases. To change a
selection criterion, you must fill at least the components <seltab>-SIGN, <seltab>-OPTION, and
<seltab>-LOW of the selection table <seltab>, otherwise it remains undefined.
AT SELECTION-SCREEN
The event AT SELECTION-SCREEN is the basic form of a whole series of events that occur
while the selection screen is being processed.
The standard selection screen in an executable program or in the logical database linked to it is
automatically called between the INITIALIZATION and START-OF-SELECTION events. When
you call the selection screen, and when users interact with it, the ABAP runtime environment
generates selection screen events, which occur between INITIALIZATION and START-OF-
SELECTION.
You can define event blocks for these events in your program to change the selection screen or
process user input
START-OF-SELECTION
This event occurs after the selection screen has been processed and before data is read using the
logical database. You can use it to prepare for reading data and creating the list by, for example,
setting values for internal fields and writing introductory notes on the output list.
In an executable program, any non-declarative statements that occur between the REPORT or
PROGRAM statement and the first processing block are also processed in the START-OF-
SELECTION block.
TOP-OF-PAGE: -
To layout a page header individually, you must define it in the processing block following the
event keyword TOP-OF-PAGE: Syntax
- 53 -
SAP –ABAP BOOK
TOP-OF-PAGE.
The TOP-OF-PAGE event occurs as soon as the system starts processing a new page of a list. The
system processes the statements following TOP-OF-PAGE before outputting the first line on a new
page.
During the event TOP-OF-PAGE, you can also fill the system fields SY-TVAR0 to SY-TVAR9
with values that should replace possible placeholders &0 to &9 in the standard page header
END-OF-PAGE :-
To define a page footer, use the END-OF-PAGE event. This event occurs if, while processing a list
page, the system reaches the lines reserved for the page footer, or if the RESERVE statement
triggers a page break. Fill the lines of the page footer in the processing block following the event
keyword END-OF-PAGE: Syntax
END-OF-PAGE.
WRITE: ....
The system only processes the processing block following END-OF-PAGE if you reserve lines for
the footer in the LINE-COUNT option of the REPORT statement
END-OF-SELECTION :-
This is the last of the events called by the runtime environment to occur. It is triggered after all of
the data has been read from the logical database, and before the list processor is started. You can
use the corresponding event block to process and format the data that the program has stored in
internal tables or extracts during the various
v arious GET events.
*������������������������������������������
*����������������������������� ���������������������������
�������������������*
�����*
* ������� : �����G�BA�IC�I
�����G�BA�IC�I����009
����009 *
* ����� : B���� ������ *
* A����� : �I��A� � *
* D���������� : C������� � ������ ��� �������� D������ *
*�����������������������������
*��������������� ���������������������������
���������������������������
�������������������*
�����*
* � � D I F I C A � I � � � � G :
*�����������������������������
*��������������� ���������������������������
���������������������������
�������������������*
�����*
* D��� C��������� ���������� D���� �� C�����
**===============================*
* 06/01/2007 �I��A� � I������ I�����������
I�������������
��
**����������������������������
**�������������� ���������������������������
���������������������������
�������������������*
�����*
�E���� ������������������009
������������������009 �� ��A�DA�D �AGE HEADI�G
�I�E�C���� 30(3) �I�E��I�E 150
�E��AGE�ID ���.
*��������������AB�E
*��������������A B�E DEC�E�A�I��
DEC�E�A�I��.������������
.������������������������*
������������*
�AB�E�: ����."����.
���E� : BEGI� �F ����1,
����� ���E ����������, "�A�E�IA� ���BE�.
����� ���E ����������, "�A�E �F �E����
����� ���E ����������, "�A�E�IA� ���E.
- 54 -
SAP –ABAP BOOK
E�D �F ����1.
*�����I��E��A��AB�E DEC�E�A�I��
*�����I��E��A��AB�E DEC�E�A�I��.
.
DA�A: ���1 ���E �AB�E �F ����1 �I�H HEADE� �I�E.
*������E�C�I����C�EE�
*������E�C�I���� C�EE� .
�E�EC�I����C�EE� BEGI� �F B��C� �1 �I�H F�A�E �I��E �����001.
�E�EC�����I��� �������� F�� ����������.
�E�EC�I����C�EE� E�D �F B��C� �1.
*�����I�I�IA�I�A�I��.
I�I�IA�I�A�I��.
������������ = '40'.
������������� = '1000'.
A��E�D ��������.
*������A� �E�EC�I����C
�E�EC�I����C�EE�.
�EE�.
A� �E�EC�I����C�EE�.
�E�EC�I����C�EE�.
�E�EC� �I�G�E * F��� ����
I��� C���E����DI�G FIE�D� �F ���1
�HE�E ����� I� ��������.
IF �������� �E 0.
�E��AGE �001.
E�DIF.
*�������A�� �F �E�EC�I�� E�E��.
��A����F��E�EC�I��.
�E�EC� ����� ����� �����
F��� ����
I��� C���E����DI�G FIE�D� �F �AB�E ���1
�HE�E ����� I� ��������.
*�����E�D �F �E�EC�I�� E�E��.
E�D��F��E�EC�I��.
���� A� ���1.
��I�E :/ ��������, 2(6) ��������,
��������, 25 ���1������, 46(10)
��������, 65 ���1������, 93(10)
��������,115 ���1������, 140(10)
��������.
��I�E.
E�D����.
HIDE ���1������.
*�����DI���A�I�G �AGE�HEADI�G.
�����F��AGE.
��I�E.
��I�E: 50 '�A�E�IA� DE�AI��'.
��I�E.
��I�E:/ ��������, '��.��' CE��E�ED C���� 1,
��������, 20 '�A�E�IA� ���BE�' CE��E�ED
CE��E�ED C����
C���� 1, 46
��������, 58 '�A�E �F �E���� C�EA�ED' CE��E�ED C���� 1, 93
��������, 110 '�A�E�IA� ���E'CE��E�ED C���� 1, 140
��������.
��I�E.
*�����DI���A�I�G E�D �F �AGE.
E�D��F��AGE.
��I�E.
- 55 -
SAP –ABAP BOOK
* INTERACTIVE REPORTS *
Lists are displayed in a special container screen. As with all other screens, you can link a dialog
status to it using the SET PF-STATUS statement. In the dialog status, you link function codes to
function keys, menu entries, icons in the standard toolbar, and pushbuttons in the application
toolbar.
. In list processing, the event is intercepted by the list processor and processed. Instead of calling
dialog modules, one of the three following list events may be called, depending on the function
code triggered by the user.
• AT PF<nn> (obsolete)
• AT LINE-SELECTION
• AT USER-COMMAND
If you have written the corresponding event blocks in your program, they are executed. You can
access the function code in the system field SY-UCOMM.
All lists created during an interactive list event are detail lists. Each interactive list event creates a
new detail list. With one ABAP program, you can maintain one basic list and up to 20 detail lists.
If the user creates a list on the next level (that is, SY-LSIND increases), the system stores the
previous list and displays the new one. The user can interact with whichever list is currently
displayed.
The system accepts only index values which correspond to existing list levels. It then deletes all
existing list levels whose index is greater or equal to the index you specify. For example, if you set
SY-LSIND to 0, the system deletes all secondary lists and overwrites the basic list with the current
secondary list.
After each user action on a list, the following ABAP system fields will be set in the corresponding
event block:
- 56 -
SAP –ABAP BOOK
The most important function is for selecting list lines by double-clicking. As described in Using a
GUI Status, the double-click function is always linked to the F2 key. If a function code is assigned
to the F2 key in the GUI status, it will be triggered when you double-click.
As with normal screens, you can define your own GUI status for lists and attach it to a list level
using the SET PF-STATUS statement. If you do not set a particular GUI status, the system sets a
default list status for the list screen in an executable program. In other programs, for example,
when you call a list from screen processing, you must set this status explicitly using the statement
This default interface always contains at least the functions described in the Standard
Stand ard List section.
Unlike normal dialog statuses, the default list status is affected by the ABAP program.
If you define event blocks in your program using the event keywords AT LINE-SELECTION or
AT PF<nn>, the system automatically assigns extra functions to other function keys that provide
additional functions.
• AT PF<nn> (obsolete)
All function keys of the keyboard F<nn> that are not used for predefined system functions, are set
to the function codes PF<nn>, where <nn> is a number between 01 and 24. During list processing,
the function codes PF<nn> are linked to the events AT PF<nn>. Choosing PF<nn> always
triggers AT PF<nn>. You should no longer use event blocks for PF<nn>.
• AT LINE-SELECTION
For this event, the F2 key (double-click) is assigned the function code PICK and function code
Choose. The function also always
alwa ys appears in the application toolbar. During
D uring list processing, the
PICK function code is assigned to the event AT LINE-SELECTION. PICK always triggers AT
LINE-SELECTION.
All other function codes are either intercepted by the runtime environment or trigger the event AT
USER-COMMAND. Function codes that trigger AT USER-COMMAND must be defined in your
- 57 -
SAP –ABAP BOOK
own GUI status. The easiest way to do this is to use the standard list status and add extra functions
of your own to it.
This statement sets the status <stat> for the current output list. The dialog status <stat> must be
defined for the current program, unless you have used the OF PROGRAM addition to set a status
from another program <prog>. The status is active for all subsequent list levels until you set
another status. The SY-PFKEY system field always contains
co ntains the status of the current list.
Using SET PF-STATUS, you can display different user interfaces for different list levels to
provide the user with different functions according to the individual requirements. Use SET PF-
STATUS SPACE to set the standard list status. This depends on the event blocks in the program,
as described above.
The EXCLUDING option allows you to change the appearance and available functions of a status
from within the program. This is useful if the individual user interfaces for a range of list levels are
very similar. You can define a single global status, and then just deactivate the functions you do
not need using EXCLUDING. Specify <f> to deactivate the function code stored in field <f>.
Specify <itab> to deactivate all function codes stored in the internal table <itab>. Field <f> and the
lines of table <itab> should be defined with reference to the system field SY-UCOMM.
The IMMEDIATELY addition is intended specially for list processing. You use it while creating a
detail list within an event block to change the status of the list currently displayed (index SY-
LISTI). Without this option, the system changes the status of the current secondary list (SY-
LSIND) that is displayed only at the end of the processing block.
During list processing, this statement sets the title of the user interface for the output list. It
remains active for all screens until you specify another using SET TITLEBAR. The GUI title
<title> must be a component of the current ABAP program, unless you use the OF PROGRAM
addition in the SET TITLEBAR statement to set a GUI status of another program <prog>.
You can use the WITH option of the SET TITLEBAR statement to replace these placeholders in
the title at runtime with the contents of the corresponding fields <g 1 > .... <g9>. The system also
- 58 -
SAP –ABAP BOOK
replaces '&' placeholders in succession by the contents of the corresponding <g i > parameters. To
display an ampersand character ‘&’, repeat it in the title ‘&&’.
From within the program, you can use the SY-UCOMM system field to access the function code.
There is no OK_CODE field that is filled.
When the user triggers the function code PICK, AT LINE-SELECTION is always triggered if the
cursor is positioned on a list line. The function code PICK is, by default, always linked with
function key F2 and hence with the mouse double-click. Consequently, if you have a simple
program that does not react to any further user actions, you only need to write this event block.
AT LINE-SELECTION.
<statements>.
As described in the section Dialog Status for Lists, the function code PICK is always added to the
standard list status when you have an AT LINE-SELECTION event in your program.
If you assign PICK to other function keys or menu entries, AT LINE-SELECTION is also
triggered
triggered when the user chooses then. You should avoid this for the sake of the semantics.
Conversely, if you have a more extensive program that does not react to line selection, you should
not use the function code PICK. Instead you should assign a different function code to F2 , to
ensure that as many events as possible trigger the AT USER-COMMAND event.
If the user chooses a function code during list processing that is neither processed by the system, or
PICK or PF<nn>, the system triggers the event AT USER-COMMAND. For this event, you must
define your own GUI status for a list. To react to your own function codes in a program, you must
define the following event block:
AT USER-COMMAND.
<statements>.
In this event block, you can use an IF or CASE structure to tell the function codes apart. They are
available in the system field SY-UCOMM. There are further system fields that are filled in list
events, such as SY-LSIND and SY-PFKEY, that allow you to make further case distinctions.
- 59 -
SAP –ABAP BOOK
This statement takes effect after the current list is completed. Before the list is displayed, the event
assigned to function code <fc> is triggered, regardless of the dialog status you are using.
You can display a list in a dialog box instead of on the full screen using the WINDOW statement:
Automatic data transfer happens by means of the system fields that are filled by the system for
each interactive event. For an overview of the relevant system fields, see Detail Lists.
System fields provide you with information about the list index, the position of the list in the
output window, and the cursor position. The only system field that contains the contents of the
selected line is SY-LISEL.
The system field SY-LISEL is a type C field with length 255. Although it contains the selected
line, it is only of limited use for passing the values of single fields, as it is a character string. To
process certain parts of SY-LISEL, you must specify the corresponding offsets.
To pass individual output fields or additional information from a line to the corresponding
processing block during an interactive event, use these statements:
• HIDE
The HIDE statement is one of the fundamental statements for interactive reporting. You use the
HIDE technique when creating a basic list. It defines the information that can be passed to
subsequent detail lists.
• READ LINE
Use the statements READ LINE and READ CURRENT LINE to read data from the lines of
existing list levels. These statements are closely connected to the HIDE technique.
• GET CURSOR
Use the statements GET CURSOR FIELD and GET CURSOR LINE to pass the output field or
output line on which the cursor was positioned during the interactive event to the ABAP program.
• DESCRIBE LIST
- 60 -
SAP –ABAP BOOK
The DESCRIBE LIST statement allows you to read certain list attributes, such as the number of
lines or pages, into program variables.
The following sections describe these statements in more detail:
The HIDE Technique
You use the HIDE technique while creating a list level to store line-specific information for later
use. To do so, use the HIDE statement as follows:
HIDE <f>.
This statement places the contents of the variable <f> for the current output line (system field SY-
LINNO) into the HIDE area. The variable <f> must not necessarily appear on the current line.
To make your program more readable, always place the HIDE statement directly after the output
statement for the variable <f> or after the last output statement for the current line.
As soon as the user selects a line for which you stored HIDE fields, the system fills the variables in
the program with the values stored. A line can be selected
• by an interactive event.
For each interactive event, the HIDE fields of the line on which the cursor is positioned during the
event are filled with the stored values.
You can think of the HIDE area as a table, in which the system stores the names and values of all
HIDE fields for each list and line number. As soon as they are needed, the system reads the values
from the table.
All of the lists generated by a single program are stored internally in the system. You can therefore
access any list in a program that was created for the same screen and that has not yet been deleted
by returning to a lower list level. To read lines, use the statements READ LINE and READ
CURRENT LINE.
To read a line from a list after an interactive list event, use the
th e READ LINE statement:
The statement without any options stores the contents of line <lin> from the list on which the event
was triggered (index SY-LILLI) in the SY-LISEL system field and fills all HIDE information
stored for this line back into the corresponding fields. As far as SY-LISEL and the HIDE area are
concerned, READ LINE has the same effect as an interactive line selection.
If the selected line <lin> exists, the system sets SY-SUBRC to 0, otherwise to 4.
• INDEX <idx>
- 61 -
SAP –ABAP BOOK
• FIELD VALUE <f 1 > [INTO <g 1 >] ... <f n> [INTO <g n>]
The system interprets the output values of the variables <f i > in line <lin> as character strings and
places them either into the same fields <f i > or, when using INTO, into the fields <g i >.When
refilling the fields, the system applies the conversion rules.
Fields that do not appear in a line do not affect the target field. If a field appears several times in a
line, the system uses only the first one.
The system transports the field contents using the output format, that is, including all formatting
characters. This may cause problems, such as converting editing characters to decimal characters
or other incompatible cases.
You use this option mainly to process user entries in list fields that accept input, since you cannot
use the HIDE technique in this case.
• OF CURRENT PAGE
With this option, <lin> is not the number of the line of the entire list, but the number of the line of
the currently displayed page of the addressed list. The system field SY-CPAGE stores the
corresponding page number.
• OF PAGE <p>
With this option, <lin> is not the number of the line of the entire list, but the number of a line on
page <p> of the addressed list.
This statement reads a line twice in succession. To do this, you use the READ CURRENT LINE
statement in your program:
READ CURRENT LINE [FIELD VALUE <f 1> [INTO <g 1>] ...].
This statement reads a line read before by an interactive event ( F2 ) or by READ LINE. The
FIELD VALUE option is the same as for READ LINE.
To retrieve information about the current cursor position in an interactive event, use the GET
CURSOR statement. You can retrieve information either about the current field or the current line.
This statement transfers the name of the field on which the cursor is positioned during
d uring a user action
into the variable <f>. If the cursor is on a field, the system sets SY-SUBRC to 0, otherwise to 4.
The system transports the names of global variables, constants, field symbols, or reference
parameters of subroutines. For literals, local fields, and VALUE parameters of subroutines, the
system sets SY-SUBRC to 0, but transfers SPACE as a s the name.
- 62 -
SAP –ABAP BOOK
• OFFSET <off>
The field <off> contains the position of the cursor within the field. If the cursor is on the first
column, <off> = 0.
• LINE <lin>
• VALUE <val>
The field <val> contains the character string output representation of the field on which the cursor
is positioned. The representation includes formatting ch aracters.
• LENGTH <len>
The field <len> contains the output length of the field on which the cursor is positioned.
For field information, use this syntax:
GET CURSOR LINE <lin> [OFFSET <off>] [VALUE <val>] [LENGTH <len>].
This statement transfers the number of the line on which the cursor is positioned during a user
action into the variable <lin>. If the cursor is on a list line, the system sets SY-SUBRC to 0,
otherwise to 4. You can use this statement to prevent the user from selecting invalid lines.
The options have the following effects:
• OFFSET <off>
The field <off> contains the position of the cursor within the list line. If the cursor is on the first
column, <off> = 0.
• VALUE <val>
The field <val> contains the character string output representation of the line on which the cursor
is positioned. The representation includes formatting ch aracters.
• LENGTH <len>
The field <len> contains the output length of the line on which the cursor is positioned.
If you need to know the attributes of list levels that are not stored in system variables, you can use
the DESCRIBE LIST statement.
- 63 -
SAP –ABAP BOOK
This statement writes the number of lines or pages of the list level <idx> into the variable <n>. If a
list with index <idx> does not exist,
e xist, the system sets SY-SUBRC unequal to 0, otherwise to 0.
This statement writes for list level <idx> the page number on which the list line number <lin> is
found into the variable <pag>. SY-SUBRC is set as follows: If there is no list with the index
<idx>, it is 8. If there is no line with number <line>, it is 4.
4 . Otherwise, it is 0.
This statement retrieves for list level <idx> the attributes specified in <options> for page <pag>.
SY-SUBRC is set as follows: If there is no list with the index <idx>, it is 8. If there is no page with
number <pag>, it is 4. Otherwise, it is 0.
• LINE-SIZE <col>
• LINE-COUNT <len>
• LINES <lin>
• FIRST-LINE <lin1>
writes the absolute number of the first line into the variable <lin1>.
• TOP-LINES <top>
writes the number of page header lines into the variable <top>.
• TITLE-LINES <ttl>
writes the number of list header lines of the standard page header into the variable <ttl>.
- 64 -
SAP –ABAP BOOK
• HEAD-LINES <head>
writes the number of column header lines of the standard page header into the variable <head>.
• END-LINES <end>
writes the number of page footer lines into the variable <end>.
Use DESCRIBE LIST for completed lists only, since for lists in creation (index is SY-LSIND)
some attributes are not up to date.
When you use the SCROLL statement with detail lists, you must remember the following:
• You can only use the SCROLL statement for completed lists. If you use SCROLL before
the first output statement of a list, it does not affect the list. If you use SCROLL after the first
output statement of a list, it affects the entire
en tire list, that is, all subsequent output statements as well.
• When you create a secondary list, a SCROLL statement without INDEX option always
refers to the previously displayed list on which the interactive event occurred
occu rred (index SY-LISTI).
• Only when creating the basic list does the SCROLL statement refer to the list currently
being created.
• You can use the INDEX option to scroll explicitly on existing list levels. To do this, the
lists need not be displayed. When the user displays the list again, it is scrolled to the specified
position. If the specified list level does not exist, the system sets SY-SUBRC to 8.
• If, during an interactive event, you want to scroll through the list you are currently creating,
use SY-LSIND as the index in the SCROLL statement. Note that changing SY-LSIND only takes
effect at the end of the event, regardless of where you change it in the processing block. If you
want to set the list level explicitly, you can change SY-LSIND in the last statement of the
processing block. This ensures that a SCROLL statement within the processing block accesses the
correct list.
You can set the cursor on the current list dynamically from within your program. You can do this
to support the user with entering values into input fields or selecting fields or lines. If input fields
occur on a list, the s ystem by default places the cursor into the first input field.
- 65 -
SAP –ABAP BOOK
To set the cursor, use the SET CURSOR statement. This statement sets the cursor in the most
recently-created list. While the basic list is being created, this is always the basic list itself. For a
detail list, it is the previous list.
With SET CURSOR, you can set the cursor to an absolute position, to a field, or to a line.
This statement sets the cursor to column <col> of line <lin> of the output window.
This statement sets the cursor on line <lin> onto the field whose name is stored in <f>. If a field
appears more than once on a line, the system sets the cursor to the first field. If the field does not
appear on the line or if it is outside the displayed area, the system ignores the statement. You can
use the SCROLL statement to scroll the line into the visible area of the
th e screen.
To modify the lines of a completed list from within the program, use the MODIFY LINE
statement. There are two ways to specify the line you want to modify:
• Explicitly:
To pass control from the dialog processor to the list processor, you must include the following
statement in one of the dialog modules:
You can include this statement in either the PBO or the PAI event. Its effect is to start the list
processor and display the basic list after the PAI processing of the current screen. The basic list
contains any list output from all PBO and PAI modules that have been executed up to that point.
- 66 -
SAP –ABAP BOOK
If detail lists are defined in the corresponding event blocks of the ABAP program (AT LINE-
SELECTION, AT USER-COMMAND), user actions on the basic list will lead to the detail list,
and further interaction will lead to further list levels.
LEAVE LIST-PROCESSING.
In both cases, control returns from the list processor to the dialog processor. Each time this occurs,
the entire list system is initialized . Any subsequent list output statements in PBO and PAI
modules apply to an empty basic list.
By default, the dialog processor returns to the PBO processing of the screen from which the list
processor was called. The optional addition AND RETURN TO SCREEN allows you to specify a
different screen in the current screen sequence at whose PBO event you want to resume
processing. In particular, the statement
LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.
can be used to end the current screen sequence and return to the point from which it had originally
been called.
Recommended Procedure
If you want to display lists during screen processing, you should create a separate screen for each
list system that you want to call. This screen encapsulates the creation and display of the basic list.
It can then be called from anywhere in the program using CALL SCREEN.
The actual screen mask of this screen can remain empty. You do not need any PAI modules, and
only a single PBO module. In the PBO module, you define the basic list of the list system and call
the list processor.
statement to call the list display at the end of the screen, and to ensure that, after leaving the list,
you return to the point from which the screen was called.
2. Next, set a GUI status for the list; for example, the default list status SPACE or a list status
of your own.
3. Use one of the following statements to ensure
ensu re that the empty screen is not displayed:
SUPPRESS DIALOG.
or
LEAVE SCREEN. Instead, the list is displayed immediately at the end of the screen.
4. Now define the entire basic list, and place any necessary data in the HIDE area.
- 67 -
SAP –ABAP BOOK
The context from the time of the call is retained. If you call a screen sequence during processing of
a particular list level, it is processed until the end of a screen with next screen 0. Then the dialog
processor returns control to the list processor, and processing carries on after the CALL SCREEN
statement
PRINT PARAMETERS:-
Consequently, you must program the list in such a way that it can both be displayed and printed.
Therefore, in the REPORT statement, do not specify the page width wider than 132 characters
(LINE-SIZE option) and do not set the page length (LINE-COUNT option) at all
Message Management
Messages are single texts, stored in table T100, that you can maintain in Transaction SE91 or by
forward navigation in the ABAP Workbench. T100 has the following structure:
• Language key
• Twenty-character message class
• Message number
• Message text (up to 72 characters)
To specify the message class, message number, and message type dynamically, use the following
form of the MESSAGE statement:
MESSAGE ID <id> TYPE <t> NUMBER <n> [WITH <f1> ... <f4>] [RAISING <exc>].
where <id>, <t>, and <n> are fields containing the message class, message number, and message
type respectively. The system uses the field contents to read the appropriate message from table
T100 and displays it according to the message context.
Within function modules and methods, you can use the RAISING addition in the MESSAGE
statement to trigger exception:
- 68 -
SAP –ABAP BOOK
If the calling program does not handle the exception <exc> itself, the message is displayed, and the
program continues processing in the manner appropriate to the message type and context. If the
calling program handles the exception, the message is not displayed, but the exception is triggered.
In this case, the message class, message number, message type, and any values of placeholders are
placed in the system fields SY-MSGID, SY-MSGNO, SY-MSGTY, and SY-MSGV1 to SY-
MSGV4 in the calling program.
Message processing depends on the message type specified in the MESSAGE statement, and the
program context in which the statement occurs.
Message Types
A Termination The message appears in a dialog box, and the program terminates.
When the user has confirmed the message, control returns to the
next-highest area menu.
I Information The message appears in a dialog box. Once the user has confirmed
the message, the program continues immediately after the
MESSAGE statement.
With only two exceptions (AT SELECTION-SCREEN and GET), event blocks have no local data
area. All declarative statements in event blocks are handled with the global data declarations in the
program. You should therefore include all of your declarations at the start of the program
- 69 -
SAP –ABAP BOOK
If you use the STOP statement within an event block, the system stops processing the block
immediately. The ABAP runtime environment triggers the next event.
Before and during selection screen processing, the next event in the prescribed sequence is always
called. From the AT SELECTION-SCREEN event onwards, the system always jumps from a
STOP statement directly to the END-OF-SELECTION statement. Once the corresponding event
block has been processed, the system displays the list.
If you use the STOP statement within an event block but not in a loop, the system stops
processing the block immediately
Before and during selection screen processing, the next event in the prescribed sequence is always
called. From the START-OF-SELECTION event onwards, the system starts the list processor
directly when the EXIT statement occurs, and displays the list.
If the EXIT statement occurs in a loop using DO, WHILE, or LOOP, it is the loop that terminates,
not the processing block.
If you use the CHECK <expr> statement within an event block but not within a loop, and the
condition <expr> is not fulfilled, the system exits the processing block immediately.
<expr> can be any logical expression or the name of a selection table. If you specify a selection
table and the contents of the corresponding table work are do not fulfill the condition in the
selection table, it is the same as a false logical expression.
If the CHECK statement occurs in a loop using DO, WHILE, or LOOP, it is the loop that
terminates, not the processing block.
Within a GET event block, this means the next GET event at the same hierarchical level. When it
leaves the event block, the logical database reads the next line of the current node, or the next-
highest node if it has already reached the end of the hierarchy level. Nodes that are lower down in
the hierarchical structure of the logical database are not processed.
Inside GET events, you can use an extra variant of the CHECK statement:
CHECK SELECT-OPTIONS.
This statement checks the contents of the table work area of the current node against all selection
tables linked to that node.
- 70 -
SAP –ABAP BOOK
Note that CHECK statements for checking database contents in GET events are only processed
after the data has been read from the logical database. For performance reasons, you should
therefore avoid using checks
The REJECT statement was specially developed for leaving GET event blocks. Unlike CHECK
and EXIT, REJECT always refers to the current GET event block. If CHECK and EXIT occur in a
loop, they refer to the loop, and in a subroutine, they always refer to the subroutine. The REJECT
statement, on the other hand, allows you to exit a GET event block directly from a loop or a
subroutine
always terminates the processing of the current line of the node of the logical database. Without
the optional <dbtab>, the logical database automatically reads the next line of the same node, and
the next GET event at the same hierarchy level is triggered. If you use the optional <dbtab>, the
logical database reads the next line of the node <dbtab>. The node <dbtab> must occur above the
current node in the logical database hierarchy.
*&---------------------
*&---------------------------------
-------------------------
-----------------------*
----------*
*& Report Z_TRNG_REPORT02_T010
*&---------------------
*&---------------------------------
-------------------------
-----------------------*
----------*
BEGIN OF TY_VBAP,
VBELN TYPE VBELN,
POSNR TYPE POSNR,
MATNR TYPE MATNR,
END OF TY_VBAP.
- 71 -
SAP –ABAP BOOK
**** Initialization
INITIALIZATION.
so_vbeln-low = '4969'.
so_vbeln-high = '5190'.
so_vbeln-sign = 'I'.
so_vbeln-option = 'BT'.
APPEND so_vbeln.
*********START-OF-SELECTION.
START-OF-SELECTION.
SELECT VBELN
ERDAT
NETWR FROM VBAK INTO CORRESPONDING FIELDS OF TABLE it_VBAK
WHERE VBELN IN so_VBELN.
- 72 -
SAP –ABAP BOOK
ENDIF.
AT LINE-SELECTION.
CASE SY-LSIND.
WHEN '1'.
SELECT VBELN
POSNR
MATNR FROM VBAP INTO TABLE it_VBAP WHERE VBELN = WA_VBAK-
VBELN.
WRITE :/ wa_VBAP-VBELN,
wa_VBAP-POSNR,
wa_VBAP-MATNR.
* ULINE.
ENDLOOP.
ENDIF.
ENDCASE.
**********TOP-OF-PAGE.
TOP-OF-PAGE.
* Top of Page Display
WRITE (142) 'INTERACTIVE LIST' CENTERED COLOR 2.
WRITE:/125 'PAGE:',sy-pagno LEFT-JUSTIFIED.
END-OF-PAGE.
WRITE:/ V_NETWR.
clear v_netwr.
- 73 -
SAP –ABAP BOOK
*&---------------------
*&---------------------------------
-------------------------
-------------------------
-----------------------
-----------------------
-----------------------
------------------*
-------*
*& Report: Z_TRNG_SHIPTOPARTY_T009 *
*& Title : Report to display ship-to-party details *
- 74 -
SAP –ABAP BOOK
*-----TABLES------------------
*-----TABLES-----------------------------
-------------------------
-------------------*
-----*
TABLES: vbak,kna1.
*-----DATA DECLERATION-----------
DECLERATION----------------------
----------------------
-----------*
*
DATA: BEGIN OF it_sales OCCURS 0,
kunnr TYPE vbpa-kunnr, "Customer Number
vbeln TYPE vbak-vbeln, "Sales Document
erdat TYPE vbak-erdat, "Creation Date
ernam TYPE vbak-ernam, "Person Created
netwr TYPE vbak-netwr, "Net Val Sales Order
name1 TYPE kna1-name1, "Name of Customer
END OF it_sales,
checkfield,
v_field LIKE dd03l-fieldname,
v_value LIKE vbak-vbeln,
v_words LIKE spell. "Amount in words
*-----SELECTION-SCREEN-----------------------------
*-----SELECTION-SCREEN---------------------------------*
----*
SELECT-OPTIONS so_vbeln FOR vbak-vbeln.
START-OF-SELECTION.
*-----POPULATING OWN GUI
GU I STATUS------------------*
STATUS------------------*
- 75 -
SAP –ABAP BOOK
END-OF-SELECTION.
SORT it_sales BY kunnr.
*-----DISPLAYING DATA FROM BASIC
B ASIC LIST---------------*
LOOP AT it_sales.
AT NEW kunnr.
AT END OF kunnr.
SUM.
"FORMAT COLOR 3.
WRITE:/27 text-249 COLOR 3,it_sales-netwr CURRENCY '2' COLOR 3.
FORMAT COLOR OFF.
- 76 -
SAP –ABAP BOOK
AT LAST.
SUM.
FORMAT COLOR 3.
WRITE:/7 text-241,it_sales-netwr CURRENCY '2'.
FORMAT COLOR OFF.
ENDAT.
ENDLOOP.
AT USER-COMMAND.
- 77 -
SAP –ABAP BOOK
*-----CALLING LIST----------------------
LIST----------------------------------
-------------------*
-------*
AT LINE-SELECTION.
GET CURSOR FIELD v_field VALUE v_value.
IF sy-lsind EQ 2.
CASE v_field.
WHEN 'IT_VBAP-MATNR'.
SET PARAMETER ID 'MAT' FIELD v_value.
CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
WHEN 'IT_VBAP-VBELN'.
SET PARAMETER ID 'AUN' FIELD v_value.
CALL TRANSACTION 'VA02' AND SKIP FIRST SCREEN.
WHEN OTHERS.
MESSAGE i000.
ENDCASE.
ENDIF.
- 78 -
SAP –ABAP BOOK
JH SOFTECH
JH SOFTECH
303,Kaveri Queen’s Building, Opp Aradhana Theater, Tarnaka, Hyderabad.
Ph: 040
040 – 40202178 , 040 – 65870996
9293002250
www.jhsoftech.com
ALV
- 79 -
SAP –ABAP BOOK
The ABAP List Viewer unifies and identifies and simplifies the uses of lists in t he R/3 System.
The ABAP List Viewer can be used to view both single-level lists and multilevel sequential lists.
• Single level lists consist any number of lines that have n o hierarchical relationship to each other.
• Multilevel Sequential level lists consist any number of lines t hat have two hierarchical levels. Multilevel lists have
header rows and item rows: the item rows are subordinate to the header rows. For each header rows there can be
any number of su bordinate items rows.
There are number of the function modules used to view the list. The selection of function module depends on the way
that how you want to display your list .So me useful function modules are listed below: -
1. REUSE_ALV_LIST_DISPLAY
2. REUSE_ALV_HIERSEQ_LIST_DISPLAY
3.REUSE_ALV_FIELDCATALOG_MERGE
4.REUSE_ALV_COMMENTARY_WRITE
5.REUSE_ALV_EVENTS_GET
6.REUSE_ALV_BLOCK_LIST_INIT
7.REUSE_ALV_BLOCK_LIST_APPEND
8.REUSE_ALV_BLOCK_LIST_HS_APPEND
9.REUSE_ALV_BLOCK_LIST_DISPLAY
10.REUSE_ALV_LIST_LAYOUT_INFO_GET
11.REUSE_ALV_LIST_LAYOUT_INFO_SET
12.REUSE_ALV_POPUP_TO_SELECT
13.REUSE_ALV_VARIANT_DEFAULT_GET
14.REUSE_ALV_VARIANT_F4
15.REUSE_ALV_VARIANT_EXISTENCE
- 80 -
SAP –ABAP BOOK
VALUE(I_SCREEN_START_LINE) DEFAULT 0
VALUE(I_SCREEN_END_COLUMN) DEFAULT 0
VALUE(I_SCREEN_END_LINE) DEFAULT 0
EXPORTING
VALUE(E_EXIT_CAUSED_BY_CALLER)
VALUE(ES_EXIT_CAUSED_BY_USER) TYPE SLIS_EXIT_BY_USER
TABLES
T_OUTTAB
EXCEPTIONS
PROGRAM_ERROR .
I_INTERFACE_CHECK: -
To avoid overloading list output with interface consistency checks, they are only made in an extra call mode.
If this parameter is 'X', the consistency of the interface is checked
When the function module is called, and an error log is output.
This parameter should only be set for development test purposes (e.g. in
debugging).
The interface check can also be made on the results list by entering the
function code &SOS.
I_CALLBACK_PROGRAM: -
Program which calls the function module and contains the exit routines. It must be a Report, Function group, Module
pool or Form routine pool (not an Include).
Include).
Note: Never pass SY-REPID directly in the interface. If the desired program name is in SY-REPID, it must be
assigned to an intermediate variable, which is then passed to the interface.
I_CALLBACK_PF_STATUS_SET: -
Passing an EXIT routine tells ALV that the caller wants to set his or her own user status.
The default ALV status is then not set.
The form routine interface must be defined as follows:
I_CALLBACK_USER_COMMAND: -
Passing an EXIT routine tells ALV that the application wants to react to certain function codes itself.
These are general function codes which ALV does not recognize (not ALV standard functions) and which were
defined and set by an application status.
See also the documentation of the parameter I_CALLBACK_PF_STATUS_SET.
FORM user_command
user_command USING r_ucomm LIKE sy-ucomm rs_selfield
rs_selfield TYPE slis_selfield.
The parameter R_UCOMM contains the function code called.
- 81 -
SAP –ABAP BOOK
o sumindex : if >0,
>0, the cursor is on a subtotal row
o value : field contents
o refresh : (exporting) list is to be refreshed
o col_stable:(exporting)
col_stable:(exporting) keep column positions
positions in refresh
refresh
o row_stable:(exporting)
row_stable:(exporting) keep row positions
positions in refresh
o exit :(exporting) leave list (and ALV)
o before_action: jump
jump before performing
performing standard action
o after_action : jump after
after performing standard action,
action, before creating
list
o ignore_multi : internal use
o sel_tab_field: internal use
The exit routine always runs when a function code occurs which ALV does not recognize, or a jump before or after a
standard function code is defined by the interface parameter IT_EVENT_EXIT.
I_STRUCTURE_NAME: -
If the internal output table is defined via an ABAP/4 Dictionary structure (INCLUDE STRUCTURE stru ct or LIKE
struct), the field catalog can be built-up automatically by passing the structure name.
Display options
• colwidth_optimize
value set: SPACE, 'X'
'X' = optimzes the column width so that all contents are displayed completely.
o no_colhead
value set: SPACE, 'X'
'X' = column headers are not output
o zebra
value set: SPACE, 'X'
'X' = striped pattern (e.g. for wide lists)
o no_vline
- 82 -
SAP –ABAP BOOK
o no_min_linesize
Value set: SPACE, 'X'
Not relevant for block lists
'X' = line size depends on list width
' ' = Line size is set to 80 or MIN_LINESIZE (if > 0) .
o min_linesize
value set: 0, 10 - 250
minimum width of the list (to change default of 80)
If the list is wider, the format uses the list width (maximum 250 or MAX_LINESIZE (if > 0)).
prerequisite: no_min_linesize = ' '.
o max_linesize
value set: 0, 80 - 1020
maximum list width (to change the default of 250) interactively-definable
interactively-definable maximum list width setting.
Caution: wide lists are difficult to read and to print.
Exceptions
o lights_fieldname
value set: SPACE, internal output table field name internal output table field containing the codes of exceptions
to be output.
Output table field code:
'1' = red traffic light
'2' = yellow traffic light
'3' = green traffic light
light
o lights_tabname
value set: SPACE, internal output table name
Only relevant for hierarchichal-sequential
hierarchichal-sequential lists.
Name of the internal output table, which contains the field in the parameter LIGHTS_FIELDNAME.
If LIGHTS_FIELDNAME is not empty, this field must also b e filled for
hierarchical-sequential
hierarchical-sequential lists.
o lights_rollname
Value set: SPACE, data element name
The documentation of this data element is displayed when you call F1
help for an exception column.
o lights_condense
Value set: SPACE, 'X'
'X' = the 'maximum' exception of the items in the subtotal is output at subtotal level.
Ex.: if a list record is output with 'red traffic
traffic light', each subtotal which includes this record
record is also output with 'red
traffic light'.
Totals
o no_sumchoice
Value set: SPACE, 'X'
'X' = fields which are to be su mmed, passed by the calling program
(FIELDCAT-DO_SUM = 'X'). The user u ser should not be able to change this
value interactively.
o no_totalline
Value set: SPACE, 'X'
- 83 -
SAP –ABAP BOOK
'X' = no total record is to be output. Subtotals can still be calculated and output. The fields in the subtotals are
flagged DO_SUM = 'X' in the field list.
• no_subchoice
o no_subtotals
Value set: SPACE, 'X'
'X' = no subtotals.
o totals_only
Value set: SPACE, 'X'
'X' = only total records are output.
An interactive breakdown of simple and hierarchical-sequential
hierarchical-sequential lists is possible.
Prerequisite: the IMPORTING parameter IT_SORT contains the sort criteria and subtotal flags.
See also the documentation of the IMPORTING parameter IT_SORT.
o totals_text
Value set: SPACE, string(max.60)
' ' = the first column in the total record contains
contains an appropriate number of '*'s to indicate the total by default. If the
first column is wide enough, the string 'Total' is output after the asterisks.
'string' = the string passed is output after the total
total indicated by
'*', if the column is wide enough.
o subtotals_text
Value set: SPACE, string(max.60)
' ' = in the first
first column of subtotal records,
records, the subtotal is indicated
indicated by an appropriate
appropriate number of '*' by default. If
the first column is not a subtotal criterion, the string 'Total' is output after the asterisks, if the column is wide
enough.
'string' = the string p assed is output after the subtotal indicated b y
'*', if the column is wide enough and th e first column is not a subtotal criterion.
If it is a subtotal criterion,
criterion, its value is repeated after the total,
total, if the column is wide enough.
o numc_sum
Value set: SPACE, 'X'
' ' = By default N UMC fields cannot be totalled
'X' = NUMC fields can beb e totalled. If this flag is set, the total can
be controlled via the FIELDCAT-NO_SUM parameter per NUMC column.
Interaction
o box_fieldname
Value set: SPACE, internal output table field name if the list has checkboxes at the start of records (for selecting
several records), this parameter contains the internal output table fi eld name indicated by the checkbox selection
column.
The field is a checkbox at the start of list records without a list header.
o box_tabname
- 84 -
SAP –ABAP BOOK
hierarchical-sequential
hierarchical-sequential lists.
o no_input
Value set: SPACE, 'X'
'X' = all ready-for-input fields in a list are displayed as not ready-for-input.
(Record selection checkboxes and fields which can be made ready-for-input via the field list parameter
FIELDCAT-INPUT = 'X')
o expand_fieldname
Value set: SPACE, internal header table field name
If the field contains 'X' for a header entry, the items for this header appear, and the folder symbol
The user can show or hide the items by clicking on the folder symbol (hotspot).
If the items for a header entry are only to be read by the calling program and passed to ALV when a header has
been expanded interactively,
interactively, this can be controlled
controlled via the CALLBACK
CALLBACK event 'ITEM_DATA_EXPAND'.
o f2code
Value set: SPACE, function code
meaning in the ALV standard interface:
To assign an ALV standard function code to double-click (F2), assign
the function code to this parameter.
Ex.: to assign the ALV standard function 'Detail' ('&ETA') to F2 .
=> LAYOUT-F2CODE = '&ETA'
o key_hotspot
Value set: SPACE, 'X'
The columns defined in the field catalog as key fields
(FIELDCAT-KEY = 'X') are output as hotspots, i.e. clicking on a key
column (highlighted in color in the list) calls the function under F2.
o reprep
- 85 -
SAP –ABAP BOOK
Example:
If Report Writer report group 7KOI with function code class '3' (SAP setting) is assigned as a receiver for the
sender RKTFGS15, this receiver report group is called by function code 'BEB3' via t he Re/Re interface. The
report restrictions and the key information of the selected records are passed to the Re/Re interface as selection
criteria.
o group_buttons
Value set: SPACE, 'X'
Not relevant for block lists (output of several lists consecutively)
Prerequisite:
Group output fields via FIELDCAT-SP_GROUP in the field list, and pass
the group name to the list module in the interface parameter
IT_SPECIAL_GROUPS.
Further information:
See the documentation
documentation of the IMPORTING parameter
parameter IT_SPECIAL_GROUPS.
and the field catalog parameter FIELDCAT-SP_GROUP of the IMPORTING
parameter <DS:FU.REUSE_ALV_LIST_DISPLAY
IT_FIELDCAT>IT_FIELDCAT.
A group 'All fields' is added by the System when grouping logic is used (= the above prerequisite is satisfied),
regardless of the setting of this parameter.
- 86 -
SAP –ABAP BOOK
o no_keyfix
o get_selinfos
Value set: SPACE, 'X'
If the calling program is a report with an ABAP/4 selection screen, setting this parameter makes ALV read the
selection screen again. If the selections are read successfully, a pushbutton, via which the user can call a popup
which lists the report selections in a simple form, becomes active on the results list output by ALV. The contents of
this popup are printed, if the interface IS_PRINT structure parameter
NO_PRINT_SELINFOS
NO_PRINT_SELINFOS is not set. You can ensure that they are printed on
a separate page by setting the parameter IS_PRINT-NO_COVERPAGE.
For more information about printed output, see the documentation of
the parameter IS_PRINT.
o group_change_edit
Value set: SPACE, 'X'
'X' = the user can enter a format option for each sort criterion in
the sort/subtotal popup, for the list format when this value changes
(e.g. new page or undeline).
For further information about sorting see the documentation of the parameter IT_SORT.
Detail screen
o detail_popup
Value set: SPACE, 'X'
' ' = list record detail display in full-screen mode, with top-of-page.
'X' = list record detail display in popup (without top-of-page).
o detail_initial_lines
o value set: SPACE, 'X'
' ' = only fields whose contents are not initial are output in the
detail view.
'X' = initial field contents are also output in detail.
o detail_titlebar
Value set: SPACE, string(max.30)
' ' = 'Detail: Display' is output as the title of the detail window.
'string' = the string passed is output as the title of the detail window.
- 87 -
SAP –ABAP BOOK
You can toggle between display field and field list views via pushbuttons in the display variant definition popup for
hierarchical-sequential
hierarchical-sequential lists. The views refer to the hierarchy level of the fields. T his is technically a toggle between
the header table and item table fields.
' ' = The header table field pushbutton text is 'Header' by default.
CHAR (20) = header table field pushbutton text.
o item_text
Value set: SPACE, CHAR(20)
Only relevant for hierarchical-sequential
hierarchical-sequential lists
You can toggle the view between the display fields and the field list via pushbuttons in the display variant
definition popup for hierarchical-sequential lists. The views refer to the hierarchy level of the fields. This is
technically a toggle between the header table and item table fields.
' ' = the pushbutton text for the item table fields is 'Item' by default.
CHAR(20) = item table field pushbutton text.
o item_default
Value set: SPACE, 'X'
Only relevant for hierarchical-sequential
hierarchical-sequential lists
' ' = The header table fields are displayed by default in the display variant definition popup. The user can switch to
the item table fields interactively.
'X' = the item table fields are displayed by default in the display variant Definition Popup. The user can switch to
the header table
t able fields interactively.
Color
o info_fieldname
Value set: SPACE, internal output table field name
A whole list record can be colored individually using acolor code in a column of the internal output table for the
record. Assign the name of the field containing the color code to this parameter.
The internal output table field must be of type CHAR(3).
The code must have the following syntax:
'Cxy':
C = color (all codes must start with 'C')
x = color number ('1'-'9')
y = bold ('0' = off, '1' = on)
Note: the color of the key columns is not affected. Key columns can b e colored at record or cell level using the
complex coloring which is described in the next parameter COLTAB_FIELDNAME.
To color columns, see the th e documentation of the field catalog parameter
FIELDCAT-EMPHASIZE of the IMPORTING parameter IT_FIELDCAT.
o coltab_fieldname
Value set: SPACE, internal output table field name
Cells can be colored individually using a color code which is contained in a column of the internal output table for
the record containing the cell.
Assign the name of the field to this parameter.
The internal output table field must be of type SLIS_T_SPECIALCOL_ALV.
Principle: the color code field is entered for the record containing the cells to be colored. The field contains an
internal table with the above structure, containing the field names of the cells to be colored and the color code. The
cell coordinates are determined by the record position containing the color code and the column information in the
color table.
The record structure of the internal color table of type
SLIS_T_SPECIALCOL_ALV is as follows:
- 88 -
SAP –ABAP BOOK
If the parameter color table-FIELDNAME is not filled, the coloring applies to all fields, so the entire record is
colored.
Others
o list_append
Value set: SPACE, 'X'
Only relevant for block
block lists which are not output with the REUSE_ALV_BLOCK_... modules.
It is only useful to output block-lists without specifying the above modules if the number of list blocks exceeds, or
may exceed, the maximum number specified in the block module documentation.
These operations are not possible for user-defined block lists.
Principle: to output a list of n blocks
Call the function module for the list type for the first block.
The caller must enter the maximum list width of the n blocks in the parameter LAYOUT-MIN_LINESIZE in the
first call. The event table IT_EVENTS of the event END_OF_LIST must contain the associated form routine name
(see also the documentation
documentation of the interface
interface parameter IT_EVENTS).
The parameter LAYOUT-LIST_APPEND must be initial .
After the first list has been output, the form routine specified in the event END_OF_LIST is called by Callback. The
remaining n-1 blocks are then output by calling the function module for the list type. The parameter LAYOUT-
LIST_APPEND must be set = 'X' for these n-1 calls.
The event table IT_EVENTS
IT_EVENTS should not contain the the event END_OF_LIST or at least
least be assigned to a different
form routine name from the first call.
IT_FIELDCAT: -
The field catalog for the output table is built-up in the caller's coding. The build-up can be completely or partially
automated by calling the REUSE_ALV_FIELDCATALOG_MERGE module.
The minimal field catalog is documented under 'default'. The caller can use the other optional parameters to assign
output attributes to a field w hich differ from the default.
A field catalog need not be built-up and passed explicitly only under the following conditions:
o The internal table to be output has the same structure as a Data Dictionary structure which is referred to in the
internal table declaration using LIKE or INCLUDE STRUCTURE.
o all fields in this structure are to be output
o the structure name is passed to ALV in the parameter I_STRUCTURE_NAME.
See also the documentation
documentation of the IMPORTING
IMPORTING paramter I_STRUCTURE_NAME.
Positioning
o row_pos (row
(row position)
position)
Value set: 0, 1 - 3
Only relevant if the list output is to be multi-line (two or three lines) by default.
A multi-line list can also b e defined by the user interactively if the default list is o ne-line.
The parameter specifies the relative output line of the column in a multi-line list.
- 89 -
SAP –ABAP BOOK
The parameter specifies the relative column position of the field in the list output. The column order can be changed
interactively by the user. If t his parameter is initial for all field catalog entries, columns appear in the field catalog field
sequence.
Identification
o fieldname (field name)
Value set: internal output table field n ame (required parameter)
Name of the internal output table field which is described by this field catalog entry
o tabname (internal
(internal output table)
Value set: SPACE, internal output table name
This parameter is used in 'manual' field catalog build-up only for
hierarchical-sequential
hierarchical-sequential lists.
Name of the internal output table which contains the field
FIELDCAT-FIELDNAME.
o ctabname (internal
(internal currency unit
unit field output table)
table)
Value set: SPACE, output table field name only relevant for hierarchical-sequential
hierarchical-sequential lists Name of the internal
output table containing
containing the FIELDCAT-CFIELDNAME field.
o qtabname (internal
(internal measurement unit
unit field output table)
Value set: SPACE, output table field name
Only relevant for hierarchical-sequential
hierarchical-sequential lists
Name of the internal output table containing the FIELDCAT-QFIELDNAME field.
- 90 -
SAP –ABAP BOOK
o key_sel (hideable
(hideable key column)
Value set: SPACE, 'X'
Only relevant when FIELDCAT-KEY = 'X'
Key field which can be hidden interactively.
The key column sequence cannot be changed interactively by the user.
The output is controlled by the FIELDCAT-NO_OUT parameter analogously
to non-key fields.
o tech (technical
(technical field)
field)
Value set: SPACE, 'X'
'X' = technical field
Field cannot be output in the list and cannot be displayed interactively.
Field can only be used in the field catalog (not in IT_SORT, . ..).
o emphasize (highlight
(highlight columns in color)
Value set: SPACE, 'X' or 'Cxyz' (x:'1'-'9'; y,z: '0'=off '1'=on)
'X' = column is colored with the default column highlight color.
'Cxyz' = column is colored with a coded color:
- C: Color (coding
(coding must begin
begin with C)
- x: color
color number
number
- y: bold
- z: inverse
o hotspot (column
(column as hotspot)
Value set: SPACE, 'X'
'X' = column cells are output as hotspots
- 91 -
SAP –ABAP BOOK
IF A COLUMN WITHOUT THIS FLAG IS OUTPUT, ONLY THE COLUMNS TO THE LEFT
o do_sum (sum
(sum over column)
Value set: SPACE, 'X'
'X' = a sum is to be calculated over this internal output table field.
This function can also be
b e called by the user int eractively.
• symbol
o just (justification)
Value set: SPACE, 'R', 'L', 'C'
Only relevant for fields of data type CHAR or NUMC
' ' = default justification for this data type
- 92 -
SAP –ABAP BOOK
o no_sign (no
(no +/- sign)
Value set: SPACE, 'X'
Only relevant for value fields
'X' = value output without +/ sign
Texts
The following text parameters should be specified for program fields without a Data Dictionary reference.
The texts are taken from the Data Dictionary for fields with a Data
Dictionary reference. If this is not desired, the text parameters can also be specified. The Data Dictionary texts are
then ignored.
If the user changes the column width interactively, the column header text with the appropriate length is always
used.
The interactive function 'Optimize column width' takes account of both the field contents and the column headers:
if all field contents are shorter than the shortest column header, the column width depends on the column header.
The 'long field label' is also used in display variant definition, sort, etc. popups.
o seltext_m (medium
(medium field label)
o reptext_ddic (header)
Analogous to the Data element maintenance 'Header'
The specified text is not necessarily output in the list, an optimum among all texts is sought.
o ddictxt (specify text)
Value set: SPACE, 'L', 'M', 'S'
You can specify with values 'L', 'M', and 'S', the keyword that should always be used as column header. If the
column width changes, no attempt is made in this case to find an appropriate header for the new output width.
Parameters for program fields without Data Dictionary reference see also 'Text' parameters
o datatype (data type)
type)
Value set: SPACE, Data Dictionary data type (CHAR, NUMC,... )
Only relevant for fields without Data Dictionary reference
Program field data type
o ddic_outputlen (external
(external output
output length)
value set: 0 (initial), n
Only relevant for fields without Data Dictionary reference whose
output is nevertheless to be modified by a conversion exit.
Prerequisites:
- FIELDCAT-EDIT_MASK = '==conv'
See also the documentation of the parameter FIELDCAT-EDIT_MASK
- 93 -
SAP –ABAP BOOK
- FIELDCAT-INTLEN = n
See also the documentation of the parameter FIELDCAT-INTLEN
n = external format field output length
The column width FIELDCAT-OUTPUTLEN need not be th e same as the
external format output length (FIELDCAT-DDIC_OUTPUTLEN).
o intlen (internal
(internal output length)
Value set: 0 (initial), n
Only relevant for fields without Data Dictionary reference whose output is nevertheless to be modified by a
conversion exit.
Prerequisites:
- FIELDCAT-EDIT_MASK = '==conv'
See also the documentation of the parameter FIELDCAT-EDIT_MASK
- FIELDCAT-DDIC_OUTPUTLEN = n
o reprep (Report/Report
(Report/Report interface selection
selection criterion)
Value set: SPACE, 'X'
Prerequisites:
- The system contains
contains the Report/Report interface
(function group RSTI, table TRSTI)
- Parameter LAYOUT-REPREP
LAYOUT-REPREP = 'X'
(see also the documentation of the parameter
LAYOUT-REPREP of the IMPORTING parameter p arameter
IS_LAYOUT)
'X' = When the Report/Report interface is called, the value of this
field is passed in the selected interface start record as a selection criterion.
Value range
Default
- 94 -
SAP –ABAP BOOK
Notes:
Information which is explicitly entered in the field catalog is not overwritten by information from th e Data
Dictionary.
Priority rule:
Entries in the field catalog have priority over differing entries in the Data Dictionary.
o The following entries are usually sufficient for internal table fields
fields without a reference to the Data Dictionary
(program fields):
- fieldname
- outputlen
- datatype
- seltext_s
- seltext_m
- seltext_l
Notes:
F1 help can be provided for program fields by assigning a data element to the parameter ROLLNAME.
IT_EXCLUDING :-
The optional IMPORTING parameter IT_EXCLUDING is an internal table. It is only needed if the caller uses the list
tool standard interface but wants to deactivate interface functions which he or she does not need.
In this case the function codes of these standard functions are entered in the table.
IT_SPECIAL_GROUP :-
The caller specifies the sorting and/or subtotalling of the basic list in th e internal table IT_SORT.
- 95 -
SAP –ABAP BOOK
o fieldname
Internal output table field name
o tabname
Only relevant for hierarchical-sequential
hierarchical-sequential lists
Name of the internal output table
o up
O DOWN
Subtot
'X' = subtotal at group value change
o group
'* ' = New page
p age at group value change
'UL' = underline at group value change
The formatting options are constants of the domain SLIS_CTRLS.
See also the documentation of GROUP_CHANGE_EDIT of the interface structure IS_LAYOUT for more
information about group value change formatting.
o comp (INTERNAL
(INTERNAL USE ONLY)
o expa
Prerequisite:
IT_SORT-SUBTOT = 'X', i.e.
i. e. sort criterion is also subtotal criterion
If the first list output is only to be expanded to total level n, and can then be further expanded interactively by
the user, the flag should be set at the total level criterion for level n.
IT_FILTER: -
Filter criteria which result, e.g. from explicitly loading an initial display variant, can be passed to list output in t his
parameter.
Complex type for modifying the information displayed in the selection info popup:
o mode: 'R' = only the entries passed in the internal table
IS_SEL_HIDE-T_ENTRIES are output in the popup.
Selection info which the list tool read in the selection screen (when called by a report with a
selection screen) are replaced by the values passed.
'S' = the selection info which the list tool read in the selection screen of the calling report
are modified by the entries in the table
IS_SEL_HIDE-T_ENTRIES.
- 96 -
SAP –ABAP BOOK
o t_entries-selname:
t_entries-selname: (only used in t_entries-mode
t_entries-mode = 'D')
Name of the select option or parameter.
The following table fields are only used in t_entries-mode = 'A'. They
contain the selection information to be added.
o t_entries-field: DDIC field name of the field
field for which selection
information is to be output.
The remaining fields are used internally and are not relevant for the
caller.
I_DEFAULT: -
I_SAVE: -
Value range
o ' ' = display variants cannot be saved
Defined display variants (e.g. delivered display variants) can be selected for presentation independently of this
flag.
Changes can not be saved.
- 97 -
SAP –ABAP BOOK
o 'A' = standard
standard and user-specific
user-specific saving
The user can save a display variant user-specifically and as standard display variant. The user chooses in the
display variant save popup.
Default
SPACE
This structure is only relevant if display variants are to be saved and/or read.
Variant information including the name of the list output variant.
The access path must be specified in the fields REPORT (required field),
HANDLE (optional) and/or LOG_GROUP (optional) to allow ALV to read
display variants.
If display variants are also to be saved, the parameter I_SAVE must also be entered.
o the logical group if, e.g. the same list is made with
with different settings (LOG_GROUP) via different
different transactions.
The logical group is a unique user-assigned CHAR(4) field which d etermines the assignment.
Example:
The program x is called via the transactions T1 and T2. The fi eld catalog fields offered to the user vary depending
on the transaction code by assignment to logical groups.
If variants are saved for the program and logical group, the logical group must not change.
Value range
- 98 -
SAP –ABAP BOOK
The above fields must be specified to be able to call a list with a variant.
Default : If the structure is initial but saving is active (I_SAVE is not initial),
IS_VARIANT-REPORT is set to I_CALLBACK_PROGRAM.
IT_EVENTS:
IT_EVENTS: -
This table tells ALV which events are processed by the caller by CALLBA CK.
You can display the names of the constants in the t ype pools SLIS which represent the individual events using the
individual test function in the function module
REUSE_ALV_EVENT_NAMES_GET. Only Onl y events with a form routine name are
processed.
- List processing
processing events
events
IMPORTANT: The application Callback r outine must not manipulate the internal output table and/or its header
record. This restriction applies to all Callbacks which are called in the list output and run under the 'List processing
events'.
- 99 -
SAP –ABAP BOOK
- 100 -
SAP –ABAP BOOK
o IT_EVENTS-FORM
Name of the form routine, which should be called in the calling program
at the event.
IT_EVENT_EXIT: -
Table for passing ALV standard function codes, to return control to the user before and/or after execution with the
callback event USER_COMMAND.
This table should only be passed when the application wants to react to the execution of standard functions.
This could, e.g. be to check the authorization for a standard function or to select data depending on the current display
variant.
Note: the functions 'Back (F3)', 'Cancel (F15)' and 'Exit (F12)' are NOT standard ALV functions, they are s ystem
functions. If the application wants to react to these (e.g. to send a confirmation prompt before leaving the list), these
functions must be occupied by application function codes.
o before
'X' = the application gets control before ALV executes the function.
o after
'X' = the application gets control after ALV has executed the function, but before the list is output.
Example:
ucomm = '&OL0' and after = 'X'.
The application gets control after the user has left the display variant d efinition popup.
In the function code
code processing form routine
routine which is passed to ALV in the I_CALLBACK_USER_COMMAND
parameter, the application can now get the
field catalog which may have been modified by the user, using the module
REUSE_ALV_LIST_LAYOUT_INFO_GET, and then reselect the data for the
new output fieldes in the i nternal output table, if necessary.
If the application sets the SELFIELD-REFRESH flag (USER_COMMAND form
routine interface reference
reference parameter) after
after the selection, the list is output again. Output fields added by the user
and reselected data
now appear.
IS_PRINT: -
o PRINT
Value set: SPACE, 'X'
'X' = the list is to be printed and not displayed on the screen. Other settings can be made in the print parameter
screen.
o NO_PRINT_SELINFOS
- 101 -
SAP –ABAP BOOK
o NO_COVERPAGE
Value set: SPACE, 'X'
'X' = do not print selection information and list status on a separate page.
• NO_NEW_PAGE
Value set: SPACE, 'X'
For internal use only
o RESERVE_LINES
Value set: 0, n
Not relevant for hierarchical-sequential lists and block lists.
n = number of lines to
to be printed
printed by the user
user in the footer area in the Callback
Callback at the event END_OF_PAGE.
o NO_PRINT_LISTINFOS
Value set: SPACE, 'X'
'X' = Do not print list status (sort, subtotal and filter information).
information).
o NO_CHANGE_PRINT_PARAMS
Value set: SPACE, 'X'
SPACE = (default) The output format (number of columns) is d ynamically
adjusted to the list width (max. 255).
'X' = The current print parameters are used. If the list is wider, the output width is not dynamically adjusted.
IS_REPREP_ID: -
Initialization key for Re/Re interface.
I_SCREEN_START_COLUMN: -
I_SCREEN_START_LINE: -
Only to be used if the list is o utput in a popup
y coordinate of the top left-hand corner of the popup.
I_SCREEN_END_COLUMN: -
Only to be used if the list is o utput in a popup
x coordinate of the bottom right-hand corner of the popup.
I_SCREEN_END_LINE: -
Only to be used if the list is output in a popup
y coordinate of the bottom right-hand corner of the popup.
If one of the ALV standard function codes for 'Back', 'Cancel' or 'Exit' occurs, the current list is discarded and the ALV
function module ends.
In this case the exporting structure ES_EXIT_CAUSED_BY_USER contains one of the following flags:
o ES_EXIT_CAUSED_BY_USER-BACK = 'X' 'Back' occurred
- 102 -
SAP –ABAP BOOK
Internal table with any structure containing the data to be output in list form.
This table can contain more fields than are relevant for the list output (display fields and field list).
Only the fields named in field catalog and the layout structure are used for the list output. Other internal table fields
are ignored.
The value of the field FIELDCAT-NO_OUT in the field catalog determines whether a field is output directly in the
list, or whether this field is initially put in the field list.
The user can interactively move fields between this field list and the output field list to display or hide them.
If the internal table is defined in the calling program without a header, no F1 help is possible in the list.
- 103 -
SAP –ABAP BOOK
TABLES
T_OUTTAB_HEADER
T_OUTTAB_ITEM
EXCEPTIONS
PROGRAM_ERROR
- 104 -
SAP –ABAP BOOK
Enter the foreign key field names in the fields KEYINFO-HEADERxx and
KEYINFO-ITEMxx. The foreign key field names of the header and item tables are usually identical.
The item table has other key fields as well as the header table foreign key. These other key fields should also be named
in this structure. The corresponding header table field (HEADERxx) must be SPACE.
Naming the other key fields guarantees a stable item table sort sequence.
a Report, Function group, Module pool or Form routine pool (not an Include).
Value range
'X', SPACE
SPACE: client fields (type CLNT) in the structure passed are flagged as technical (=> no screen output) in the field
catalog.
- 105 -
SAP –ABAP BOOK
4. REUSE_ALV_COMMENTARY_WRITE: - (this module is used for list body comment block output)
IMPORTING
VALUE(IT_LIST_COMMENTARY) TYPE SLIS_T_LISTHEADER
IT_LIST_COMMENTARY: - (Comment block)
Internal table with the following fields:
o TYP: Possible values:
- (H)eader: - List header
- only the contents of INFO are
output (KEY is ignored)
- usually one line = one entry
Attributes: - left-justified
- bold
- followed by empty line
Attributes: - left-justified
left-justified
- Bold (KEY=on/INFO=off)
- Followed by empty line
5. REUSE_ALV_EVENTS_GET: - (this module returns table of possible events for a list type)
IMPORTING
VALUE(I_LIST_TYPE) TYPE SLIS_LIST_TYPE DEFAULT 0
EXPORTING
VALUE(ET_EVENTS) TYPE SLIS_T_EVENT
EXCEPTIONS
LIST_TYPE_WRONG
I_LIST_TYPE: -(List type (0,1,2,3))
0 = simple list (REUSE_ALV_LIST_DISPLAY)
1 = hierarchcal-sequential list (REUSE_ALV_HIERSEQ_LIST_DISPLAY)
2 = simple block list (REUSE_ALV_BLOCK_LIST_APPEND)
3 = hierarchical-sequential block list (REUSE_ALV_BLOCK_LIST_HS_APPEND)
The event table is returned with all possible CALLBACK events for the s pecified list type (column 'NAME').
For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is
ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants
from the type pool SALV.
- 106 -
SAP –ABAP BOOK
6. REUSE_ALV_BLOCK_LIST_INIT: - (This module is used for the initialization of blocks & called first
before calling REUSE_ALV_BLOCK_LIST_APPEND or REUSE_ALV_BLOCK_LIST_HS_APPEND)
IMPORTING
VALUE(I_CALLBACK_PROGRAM) LIKE SY-REPID
VALUE(I_CALLBACK_PF_STATUS_SET) TYPE SLIS_FORMNAME
DEFAULT SPACE
VALUE(I_CALLBACK_USER_COMMAND) TYPE SLIS_FORMNAME
DEFAULT SPACE
VALUE(IT_EXCLUDING) TYPE SLIS_T_EXTAB OPTIONAL
I_CALLBACK_PROGRAM: -
SAME AS IN REUSE_ALV_LIST_DISPLAY
IS_LAYOUT: -
SAME AS IN REUSE_ALV_LIST_DISPLAY
IT_FIELDCAT: -
Same as in REUSE_ALV_LIST_DISPLAY
I_TABNAME: -
IT_EVENTS: -
Same as in REUSE_ALV_LIST_DISPLAY
IT_SORT: -
Same as in REUSE_ALV_LIST_DISPLAY
I_TEXT: -
T_OUTTAB: -
Same as in REUSE_ALV_LIST_DISPLAY
- 107 -
SAP –ABAP BOOK
IS_LAYOUT: -
SAME AS IN REUSE_ALV_HIERSEQ_LIST_DISPLAY
IT_FIELDCAT: -
Same as in REUSE_ALV_HIERSEQ_LIST_DISPLAY
IS_KEYINFO: -
Same as in REUSE_ALV_HIERSEQ_LIST_DISPLAY
I_HEADER_TABNAME: -
Same as I_TABNAME_HEADER in REUSE_ALV_HIERSEQ_LIST_DISPLAY
I_ITEM_TABNAME: -
Same as I_TABNAME_ITEM in REUSE_ALV_HIERSEQ_LIST_DISPLAY
IT_EVENTS: -
Same as in REUSE_ALV_HIERSEQ_LIST_DISPLAY
IT_SORT: -
Same as in REUSE_ALV_HIERSEQ_LIST_DISPLAY
I_TEXT: -
T_OUTTAB_HEADER: -
Same as in REUSE_ALV_HIERSEQ_LIST_DISPLAY
T_OUTTAB_ITEM: -
Same as in REUSE_ALV_HIERSEQ_LIST_DISPLAY
SAME AS IN REUSE_ALV_LIST_DISPLAY
IS_PRINT: -
- 108 -
SAP –ABAP BOOK
Same as in REUSE_ALV_LIST_DISPLAY
I_SCREEN_START_COLUMN: -
Same as in REUSE_ALV_LIST_DISPLAY
I_SCREEN_START_LINE: -
Same as in REUSE_ALV_LIST_DISPLAY
I_SCREEN_END_COLUMN: -
Same as in REUSE_ALV_LIST_DISPLAY
I_SCREEN_END_LINE: -
Same as in REUSE_ALV_LIST_DISPLAY
E_EXIT_CAUSED_BY_CALLER: -
Same as in REUSE_ALV_LIST_DISPLAY
ES_EXIT_CAUSED_BY_USER: -
Same as in REUSE_ALV_LIST_DISPLAY
10. REUSE_ALV_LIST_LAYOUT_INFO_GET: - (this module is used to read current ALV list information)
XPORTING
VALUE(ES_LAYOUT) TYPE SLIS_LAYOUT_ALV
VALUE(ET_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV
VALUE(ET_SORT) TYPE SLIS_T_SORTINFO_ALV
VALUE(ET_FILTER) TYPE SLIS_T_FILTER_ALV
VALUE(ES_LIST_SCROLL) TYPE SLIS_LIST_SCROLL
VALUE(ES_VARIANT) LIKE DISVARIANT
STRUCTURE DISVARIANT
XCEPTIONS
NO_INFOS
PROGRAM_ERROR
ES_LAYOUT: -
ET_FIELDCAT: -
Same as IT_FIELDCAT in REUSE_ALV_LIST_DISPLAY
ET_SORT: -
Same as IT_SORT in REUSE_ALV_LIST_DISPLAY
ET_FILTER: -
ES_LIST_SCROLL: -
Structure with fields which describe the current list scroll status:
o lsind
See the documentation of the system field SY-LSIND
o cpage
See the documentation of the system field SY-CPAGE
o staro
See the documentation of the system field SY-STARO
o cursor_line
- 109 -
SAP –ABAP BOOK
Current cursor row position in the list (not in the internal output
Table)
o cursor_offset
current cursor column position in the list (not in the internal output table)
ES_VARIANT: -
Same as IS_VARIANT in REUSE_ALV_LIST_DISPLAY
IS_LAYOUT: -
SAME AS IN REUSE_ALV_LIST_DISPLAY
IT_FIELDCAT: -
12.REUSE_ALV_POPUP_TO_SELECT: -(This module is used to List in popup to choose one or m ore entries (or
display only))
IMPORTING
VALUE(I_TITLE) OPTIONAL
- 110 -
SAP –ABAP BOOK
Name of the internal output table field containing the color code.
A complete list row is colored individually by color coding in a column of the internal output table. T he name of this
field is assigned to this parameter.
- 111 -
SAP –ABAP BOOK
'Cxy':
C = color (each code must begin with 'C')
x = color number ('1'-'9')
y = highlight ('0' = off, '1' = on)
Prerequisite:
A row has been color highlighted and its index in the internal output table is greater than the number of entries which
can be displayed in the popup without scrolling.
IT_FIELDCAT: -
SAME AS IN REUSE_ALV_LIST_DISPLAY
IT_EXCLUDING: -
At most the following functions are active in the standard and can be deactivated using IT_EXCLUDING:
o Function code:
code: &ETA (Detail)
o Function code: &SC (Find)
o Function code:
code: &SC+ (Find next)
o Function code:
code: &OUP (Sort
(Sort ascending)
ascending)
o Function code:
code: &ODN (Sort
(Sort descending)
o Function code:
code: &ILT (Filter)
o Function code: &OL0 (Display variant)
o Function code: &CRB
&CRB (Horizontal scroll: First
First column)
o Function code: &CRL
&CRL (Horizontal scroll: Previous column)
o Function code: &CRR
&CRR (Horizontal scroll: Next column)
o Function code: &CRE
&CRE (Horizontal scroll: Last column)
o Function code: &AC1
&AC1 (Cancel)
- 112 -
SAP –ABAP BOOK
I_CALLBACK_PROGRAM: -
Same as in REUSE_ALV_LIST_DISPLAY
I_CALLBACK_USER_COMMAND: -
Same as in REUSE_ALV_LIST_DISPLAY
ES_SELFIELD: -
The structure SELFIELD contains the following information about the current cursor position
o tabname : internal
internal output
output table
table name
name
o tabindex : internal output table index
o fieldname: field name
o value : field contents
Only the fields named in the field catalog and in the I_CHECKBOX_FIELDNAME parameter are used for the list
output. Other internal table fields are ignored.
SAME AS IN REUSE_ALV_LIST_DISPLAY
SAME AS IN REUSE_ALV_LIST_DISPLAY
- 113 -
SAP –ABAP BOOK
SAME AS IN REUSE_ALV_LIST_DISPLAY
I_TABNAME_HEADER: -
SAME AS IN REUSE_ALV_HIERSEQ_LIST_DISPLAY
I_TABNAME_ITEM: -
SAME AS IN REUSE_ALV_HIERSEQ_LIST_DISPLAY
IT_DEFAULT_FIELDCAT: -
SAME AS IN REUSE_ALV_LIST_DISPLAY
I_SAVE: -
SAME AS IN REUSE_ALV_LIST_DISPLAY
ES_VARIANT: -
SAME AS IN REUSE_ALV_LIST_DISPLAY
- 114 -
SAP –ABAP BOOK
PROGRAM_ERROR
I_SAVE: -
SAME AS IN REUSE_ALV_LIST_DISPLAY
CS_VARIANT: -
SAME AS IN REUSE_ALV_LIST_DISPLAY
TYPE-POOLS: SLIS.
TABLES: VBAK.
*-----POPUATING STRUCTURE.
*-----POPULATING SELECT-OPTIONS.
START-OF-SELECTION.
SELECT VBELN
ERDAT
AUDAT
AUART FROM VBAK INTO TABLE IT_1
WHERE VBELN IN SO_SATH.
WA_SATH-COL_POS = '2'.
WA_SATH-FIELDNAME = 'ERDAT'.
WA_SATH-SELTEXT_M = 'ORDER_DATE'.
- 115 -
SAP –ABAP BOOK
WA_SATH-COL_POS = '3'.
WA_SATH-FIELDNAME = 'AUDAT'.
WA_SATH-SELTEXT_M = 'DOC_DATE'.
APPEND WA_SATH TO IT_SATH.
WA_SATH-COL_POS = '4'.
WA_SATH-FIELDNAME = 'AUART'.
WA_SATH-SELTEXT_M = 'DOC_TYPE'.
APPEND WA_SATH TO IT_SATH.
- 116 -
SAP –ABAP BOOK
Out Put
- 117 -
SAP –ABAP BOOK
*-----TABLES-----------------------------------------
*-----TABLES------------------------------------------------*
-------*
TABLES: vbak, vbpa, kna1.
*-----TYPE-POOLS DECLAIRATION-----------------
DECLAIRATION------------------------*
-------*
TYPE-POOLS: slis.
*-----TYPE DECLERATION-------------------
DECLERATION----------------------------------*
---------------*
TYPES: BEGIN OF str_1,
vbeln LIKE vbak-vbeln, "Sales Document
erdat LIKE vbak-erdat, "Date of record created
ernam LIKE vbak-ernam, "Name of Person Created
netwr LIKE vbak-netwr, "Net Value of Sales Order
END OF str_1,
BEGIN OF str_2,
vbeln LIKE vbap-vbeln, "Sales Document
posnr LIKE vbap-posnr, "Sales Document Item
matnr LIKE vbap-matnr, "Material Number
END OF str_2.
*-----DATA DECLERATION-------------------
DECLERATION---------------------------------*
--------------*
DATA: it_vbak TYPE str_1 OCCURS 0,
wa_vbak TYPE str_1,
*-----SELECTION-SCREEN---------------------------------*
*-----SELECTION-SCREEN---------------------------------*
SELECT-OPTIONS: so_vbeln FOR vbak-vbeln OBLIGATORY.
*-----START-OF-SELECTION-----------------------------*
START-OF-SELECTION.
- 118 -
SAP –ABAP BOOK
wa_fieldcat-col_pos = '2'.
wa_fieldcat-fieldname = 'ERDAT'.
wa_fieldcat-seltext_m = text-002.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '3'.
wa_fieldcat-fieldname = 'ERNAM'.
wa_fieldcat-seltext_m = text-003.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '4'.
wa_fieldcat-fieldname = 'NETWR'.
wa_fieldcat-seltext_m = text-004.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat1-col_pos = '2'.
wa_fieldcat1-fieldname = 'POSNR'.
wa_fieldcat1-seltext_m = text-005.
APPEND wa_fieldcat1 TO it_fieldcat1.
CLEAR wa_fieldcat1.
wa_fieldcat1-col_pos = '3'.
wa_fieldcat1-fieldname = 'MATNR'.
wa_fieldcat1-seltext_m = text-006.
APPEND wa_fieldcat1 TO it_fieldcat1.
CLEAR wa_fieldcat1.
*-----FORM HEADER------------------------------
HEADER--------------------------------------*
--------*
- 119 -
SAP –ABAP BOOK
*-----FORM HEADER---------------
HEADER------------------------------
-----------------------*
--------*
*-----HEADER FOR ITEM DETAILS------------------------*
DETAILS------------------------*
FORM h2.
it_page-typ = 'H'.
it_page-info = 'SALES DOCUMENT DETAILS'.
APPEND it_page.
CLEAR it_page.
type-pools: slis.
- 120 -
SAP –ABAP BOOK
tables: vbak.
BEGIN OF ty_item_data,
vbeln TYPE vbeln,
posnr TYPE posnr,
arktx TYPE arktx,
werKS TYPE werks,
END OF ty_item_data.
t y_item_data.
v_prog_name = 'Z_TRNG_HIERARCHICALALVREPORT01'.
v_tabname_header = 'VBAK'.
v_tabname_ITEM = 'VBAP'.
IS_KEYINFO-HEADER01 = 'VBELN'.
IS_KEYINFO-ITEM01 = 'VBELN'.
** DEVELOPING FIELDCATALOG
wa_fcat-col_pos = 1.
wa_fcat-fieldname = 'VBELN'.
wa_fcat-seltext_m = 'ORDER NO'.
wa_fcat-tabname = 'VBAK'.
wa_fcat-outputlen = '100'.
APPEND wa_fcat TO it_fcat.
CLEAR WA_FCAT.
wa_fcat-col_pos = 2.
wa_fcat-fieldname = 'ERDAT'.
wa_fcat-seltext_m = 'ORDER DATE'.
wa_fcat-tabname = 'VBAK'.
APPEND wa_fcat TO it_fcat.
CLEAR WA_FCAT.
wa_fcat-col_pos = 3.
wa_fcat-fieldname = 'NETWR'.
wa_fcat-seltext_m = 'ORDERVALUE'.
wa_fcat-tabname = 'VBAK'.
- 121 -
SAP –ABAP BOOK
wa_fcat-col_pos = 4.
wa_fcat-fieldname = 'POSNR'.
wa_fcat-seltext_m = 'ITEM NO'.
wa_fcat-tabname = 'VBAP'.
APPEND wa_fcat TO it_fcat.
CLEAR WA_FCAT.
wa_fcat-col_pos = 5.
wa_fcat-fieldname = 'ARKTX'.
wa_fcat-seltext_m = 'ITEM DESCRIPTION'.
wa_fcat-tabname = 'VBAP'.
APPEND wa_fcat TO it_fcat.
CLEAR WA_FCAT.
wa_fcat-col_pos = 6.
wa_fcat-fieldname = 'WERKS'.
wa_fcat-seltext_m = 'PLANT'.
wa_fcat-tabname = 'VBAP'.
APPEND wa_fcat TO it_fcat.
CLEAR WA_FCAT.
START-OF-SELECTION..
select vbeln erdat netwr
from vbak
into table it_header_data
where vbeln in so_vbeln.
if it_header_data[] is not initial.
select vbeln posnr arktx werks
from vbap
into table it_item_data
for all entries in it_header_data
where vbeln = it_header_data-vbeln.
endif.
- 122 -
SAP –ABAP BOOK
* I_DEFAULT = 'X'
* I_SAVE =''
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
i_tabname_header = v_tabname_header
i_tabname_item = v_tabname_item
* I_STRUCTURE_NAME_HEADER =
* I_STRUCTURE_NAME_ITEM =
is_keyinfo = is_keyinfo
* IS_PRINT =
* IS_REPREP_ID =
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
tables
t_outtab_header = it_header_data
t_outtab_item = it_item_data
EXCEPTIONS
PROGRAM_ERROR =1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-
MSGV3 SY-MSGV4. ENDIF.
SAP ABAP
SCRIPTS
Often there are instances where an output from a SAP program is required on a physical
paper in a pre-designed format. Using normal ABAP code this is not possible. Instead
SAP provides an object called SAPSCRIPT to generate such kind of documents which
can contain logos, tables and other objects and which can look like pre-printed
documents.
This article focuses on the design and use of Layout sets in ABAP programs to generate
beautified output in SAP.
A layout set is a template designed in SAP to place the stream of data coming from a
SAP program on different parts of a physical page. The designer needs to lay out the
out the
various elements that need to be printed on the page and store it as an object in the SAP
system. An ABAP program will subsequently call this object to generate an instance of
the template – thus generating an output document from the program.
- 123 -
SAP –ABAP BOOK
Language
Language in which the data coming on to the layout set will be printed. Generally, this will
be the language that has been set up as default in the SAP system
Header
Section to define the various attributes of the layout set on a global level. Changing these
attributes will affect all the components of the layout set.
• Administration Information
This shows the information about the layout set – details of the designer, details of
changes occurring to the design, development class of the layout set and the
language details for the layout set
• Standard Attributes
• Font Attributes
Here the various attributes and the base font applicable to the document can be defined.
This font setting can be overridden at a lower level using the character strings
Paragraphs
Used to define the start and end positions for the different texts and objects that need to
be printed on the output document.
- 124 -
SAP –ABAP BOOK
Character Strings
Used to define the fonts and the formatting and printing styles for each and every
character that needs to be printed on the output document. The start of the character
string is indicated by <string name>, while the end of the character string is indicated by
</>
Pages
The designer needs to organise the template as a series of pages. When an actual output
document is printed, it will refer to each page for putting the data coming from the ABAP
program. The order of pages is also taken from the template i.e the layout set defined.
Windows
Various parts of the output document can be conveniently organised on the pages using
windows. Thus the data stream coming from the ABAP program can be logically grouped
into various parts and can be placed on different locations on a page
There are 2 main types of windows that can be used in a layout set:
CONSTANT - A layout set can have any number of constant windows. A constant window
can be used once per page
Text Elements
Any text that needs to be written on the output document should be placed within a text
element. This includes constant text as well as variable data like internal table data
coming from the ABAP program.
The fields of various tables defined in the ABAP program will be included under these text
elements. These fields are carriers of data. Every field should be included in a pair of &
characters. (e.g. &aufk-aufnr&)
Page Windows
Choose the window and click the Text Elements button to go to the Layout Set Editor.
This consists of 2 parts
- 125 -
SAP –ABAP BOOK
The small space on the left is for specifying the type of command, while the window
adjacent to it is for writing the command or the text that needs to go under a text element.
Command Purpose
* Default paragraph
= Extended Line
( Raw Line
/ Line Feed
<PN> This is either the name of the paragraph that should be applicable from that line of the
layout set
The steps for including graphical elements in the layout set are as follows
follow s
• The graphical element (like company logo) should be in valid graphic file format
like .bmp or .jpg
• Use appropriate software to convert the above file into a .TIFF file
- 126 -
SAP –ABAP BOOK
• The SAP system suggests a name for the file ( like ZHEX-MARCO-* ). The *
indicates the type of file. For e.g. if the file contains a logo then the name can be
ZHEX-MACRO-LOGO
• Running the program will convert this .TIFF file into a text element
• Incorporate this converted logo in the appropriate window under the appropriate
text element by giving
Command Use
New-page <page name> Prints the text following this command on a new page (when
a page name is specified then that page is taken as the next
page)
Protect ….. Endprotect This acts like a conditional page break. Putting the text
within this command prevents the breaking of the text across
multiple pages. If there is not enough
enou gh space for the entire
paragraph to be printed in the space remaining on the page,
then the entire paragraph is printed on the next page
Box <xpos> <ypos> <width> <height> The BOX command draws a box as per the specifications.
<frame> <intensity> The x y co-ordinates are for the upper left corner relative to
the values in the position command.
Position <xorigin> <yorigin> <window>
<page> POSITION command is used to set the x y co-ordinates with
respect to the start position of the window.
Size <width> <height> <window>
<page> SIZE command is used to specify the size of the box that we
need to draw.
IF ….. END IF This allows the conditional printing of the text on the output
document. The various conditional operators that can be used
are as follows
= EQ Equal to
- 127 -
SAP –ABAP BOOK
NOT, AND, OR
The best way to explain the various steps in designing a SAP script is to visualize
the creation of a document. The entire process is explained as a series of steps.
Let us assume that we need to design the document Invoice.doc for the ABC Company
Limited.
3. Decide the FIRST page of the document and the pages that are going to follow.
4. Find out the various fonts and styles (bold, italics, etc) that are used in the
document.
5. Also try to group the data printed on the document into logical parts.
6. Create all the character strings that have been used in the document
7. Create all the paragraphs that have been used in the document
10. Define the pages that form the parts of the document
- 128 -
SAP –ABAP BOOK
14. Use function module WRITE_FORM to write the text elements in various windows
Steps:
- 129 -
SAP –ABAP BOOK
Enter Description
Save ( Ctrl + S )
Click on Pages
- 130 -
SAP –ABAP BOOK
Page1
Save
Enter P1
Enter Description
- 131 -
SAP –ABAP BOOK
Goto - Header
- 132 -
SAP –ABAP BOOK
- 133 -
SAP –ABAP BOOK
- 134 -
SAP –ABAP BOOK
Element MAIN
P1 <B>Customer/Supplier:</>,,&KNA1-NAME1&
/
P1 <B>PO No:</>,,&EKPO-EBELN&
/
P1 <B>Part No:</>,,&MAKT-MATNR&
/
P1 <B>Description:</>,,&MAKT-MAKTX&
/
P1 <B>Quantity:,,</>&EKPO-MENGE&
/
P1 <B>Sign:</>&uline(81)&
/
P1 <B>Date:</>&EKKO-AEDAT&
- 135 -
SAP –ABAP BOOK
- 136 -
SAP –ABAP BOOK
FOOTER
Element FOOTER
/: POSITION XORIGIN 2 CM YORIGIN '-0.5 CM'
/: BOX XPOS 1 CM YPOS 1 CM WIDTH 18 CM HEIGHT 1 CM FRAME 10 TW
INTENSITY 10
/
/
/
P2 ,,<B>PLEASE SIGN THE PO BEFORE DISPATCH</>
/
- 137 -
SAP –ABAP BOOK
Activate.
Below is the Program that you need to write in SE38 (ABAP EDITOR)
REPORT ZPSAPSCRIPT.
TABLES : EKKO,
EKPO,
KNA1,
USR01,
MARA,
MAKT.
CLEAR EKPO.
SELECT SINGLE * FROM EKPO
WHERE EBELN = P_EBELN AND
EBELP = P_EBELP.
CLEAR KNA1.
SELECT SINGLE NAME1 FROM KNA1
INTO KNA1-NAME1
WHERE KUNNR = EKPO-KUNNR.
CLEAR MAKT.
SELECT SINGLE MAKTX FROM MAKT
INTO MAKT-MAKTX
WHERE MATNR = EKPO-MATNR AND
SPRAS = SY-LANGU.
- 138 -
SAP –ABAP BOOK
CLEAR USR01.
SELECT SINGLE * FROM USR01 WHERE BNAME = SY-UNAME.
- 139 -
SAP –ABAP BOOK
EXCEPTIONS
ELEMENT = 1.
SMARTFORMS
Smart Forms:
Transaction Code for Create Smarf Forms: SMARTFORMS
Transaction Code for Create Styles (Paragraph Formats, Character Formats, etc.,) Used in Smart
Forms: SMARTSTYLES
1. Enter the Form Name (e.x. ZEKKO_EKPO) and Press Create Button.
2. Enter Form Description and Select the “Output options” Tab Enter the Page
Format (e.x. DINA4) and Style (e.x.SF_STYLE_01).
- 140 -
SAP –ABAP BOOK
- 141 -
SAP –ABAP BOOK
- 142 -
SAP –ABAP BOOK
10. Change the %PAGE1 to “FIRST” or any name and Enter the Description
Descripti on (e.x. First
Page).
11. Select the Next Page as “FIRST”
- 143 -
SAP –ABAP BOOK
13. Select the “Background Picture” Tab, and Enter the Name, Object and Id of the
image file. (Before this step, go to SE78 and import the image first) for the Image
which has to be appeared in the Background of the Script.
14. If you want to add any LOGO in the First Page of the Script then right click the
“FIRST New Page” in the Left Sub-tree from the Menu option “Create” select the
“Graphic”.
- 144 -
SAP –ABAP BOOK
15. Double click the “%Graphic1 New Graphic 1” in the Left Sub-tree.
16. Give the Name and Description (e.x. Graphic = “COMP_LOGO” and Description =
“LOGO WINDOW”)for the New Graphic Inserted.
17. Enter Name, Object and ID for the Graphic image and Select the Color grid screen
(BCOL) option button in the “General attributes” Tab.
Click - Output options Tab. Set Left and Upper Margins as given:
- 145 -
SAP –ABAP BOOK
18. Right click the “FIRST New Page” in the Left Sub-tree and from the Menu option
“Create” select the “Window”.
19. Double click the “%WINDOW1 New Window1” in the Left Sub-tree and enter the
Window name and Description (e.x. Window = “ADD_WIN” and Description =
“Address Window”)
- 146 -
SAP –ABAP BOOK
Set the Left and Upper margins for the ADD_WIN as follows:
20. Right click “ADD_WIN Address Window” in Left Sub-tree and from the Menu option
“Create” select the “Program Lines”.
21. Enter the Program Lines name and description (e.x. Program Lines =
“ADD_FETCH” and Description = “FETCHING COMPANY ADDRESS”)
- 147 -
SAP –ABAP BOOK
- 148 -
SAP –ABAP BOOK
24. Double click the “%ADDRESS1 New address1” and change the Address name
and description (e.x. Address = COMP_ADD and Description = “COMPANY
ADDRESS”).
- 149 -
SAP –ABAP BOOK
26. Set the Main window attributes like this: (Setting of window co-ordinates)
27. Right click the “MAIN Main Window” in the Left Sub-tree and from the Menu option
“Create” select the “Program Lines”.
- 150 -
SAP –ABAP BOOK
28. Enter the name and description (e.x. Program Lines = “SELECT_RECORD” and
Description = “SELECTING RECORDS”).
- 151 -
SAP –ABAP BOOK
- 152 -
SAP –ABAP BOOK
31. Enter the Section name and description (e.x. Section = “PO_LOOP” and
Description = “PURCHASE ORDER NUMBER LOOP”) and check the “Repeat
processing” check box and select the “Output type” as Unstructured (i.e. select the
Unstructured radio button) in the “General attributes” Tab.
- 153 -
SAP –ABAP BOOK
34. Right click “PO_LOOP PURCHASE ORDER NUMBER LOOP” in Left Sub-tree and
from the Menu option “Create” select the “Text”.
35. Enter the Text name and description (e.x. Text = “PO_NO_DISPLAY” and
Description = “PURCHASE ORDER NUMBER DISPLAY”) and enter the values as
in the screen shot
- 154 -
SAP –ABAP BOOK
- 155 -
SAP –ABAP BOOK
Display the values of Company Code and Purchase Order Number as shown
below:
- 156 -
SAP –ABAP BOOK
36. Right click the “PO_LOOP PURCHASE ORDER NUMBER LOOP” in the Left Sub-
tree and from the Menu option “Create” select the “Template”.
37. Double click on “%TEMPLATE1 New template” and enter the Template name and
description (e.x. Template Name = “OI_HEAD” and Description = “ORDER ITEM
HEADER”).
- 157 -
SAP –ABAP BOOK
Before press save or enter click the “Table Painter Button” which will take you to
following screen.
To avoid the “cross line” in the Editor click the “Settings Button”
which will result in the following popup, in which you un-check the “Cross” Check
Box and press enter.
- 158 -
SAP –ABAP BOOK
38. Split the Cell into Four or into any number of columns you
you want to display in the
script by right clicking the “%C1”.
and press “Back” Button.
39. Select the pattern of the table to be displayed in the script by the clicking
clicki ng “Select
pattern” Button
- 159 -
SAP –ABAP BOOK
- 160 -
SAP –ABAP BOOK
42. Enter the Text name and description (e.x. Text = “HEAD1” and Description =
“COLUMN1”) and enter the values as in the screen shot (i.e. as explained in the
point no 34).
43. Inorder to match the Template Column with the insertedText “HEAD1 COLUMN1”,
select the “Output options” Tab and Enter the Line Number and Column Number
in which the above Text has to be printed in the form
- 161 -
SAP –ABAP BOOK
44. Repeat Step No.40 & 41 for all the remaining column headings.
- 162 -
SAP –ABAP BOOK
- 163 -
SAP –ABAP BOOK
- 164 -
SAP –ABAP BOOK
45. The Form is ready with all data upto Table Header. Inorder to populate data
data under
each column header, insert a table.
46. Insert the Table under “PO_LOOP PURCHASE ORDER NUMBER LOOP” by right
clicking the same.
47. Enter Table Name and Description (e.x. Table Name = “OI_DISPLAY” and
Description = “ORDER ITEM DISPLAY”)
- 165 -
SAP –ABAP BOOK
48. Match the column width with the “OI_HEAD ORDER ITEM HEADER” Template
(refer step no 38 screet shot no 2) and Select the “Default” radio button and “No
page break” check box. Click the “Select pattern” push button to select the table
pattern to be displayed.
Column width
with OI_HEAD
ITEM HEADER
49. Click the “Data” and populate the Item details by looping the Internal Table
I_EKPO into the Work Area WA_EKPO sorted by EBELN and EBELP as shown in
the following screen shot
- 166 -
SAP –ABAP BOOK
50. Inorder to Display the values for each column, we have to Insert Separate Text for each
column under the Table “OI_DISPLAY ORDER ITEM DISPLAY” by Right clicking the
same. Enter the Name and Description for the Each Text Inserted under the Table.
Column 1 for Line Item of each Purchase Order – Populate the values for each
column as explained in the step no 34.
- 167 -
SAP –ABAP BOOK
Inorder to Match the Item values with the Template Header, In the Inserted Text
“ORD_ITM_COL COLUMN1” Click the “Output options” and Select the “New line”
Check box and Select the “Line type” as “Detail” and also check the “New cell”
Check box.
- 168 -
SAP –ABAP BOOK
For the Second Column Text You need only to select the “New cell” Check box.
- 169 -
SAP –ABAP BOOK
For the Third Column Text also You need only to select the “New cell” Check box.
52. Before Inserting the 4 th Text for the 4 th Column, we have to calculate the Amount
by Multiplying the Quantity and Unit Price and for the same we have to insert
“Program Lines” by Right clicking “OI_DISPLAY ORDER ITEM DISPLAY”
- 170 -
SAP –ABAP BOOK
53. Similarly calculate the subtotal by adding the totals and calculate the grand total by
adding the subtotals.
Before doing the calculations, declare variables for total, subtotal and grand total in
Global definitions.
- 171 -
SAP –ABAP BOOK
54. Now add the 4 th Text to display the 4 th column in the Form.
For the Fourth Column Text also You need only to select the “New cell” Check box.
- 172 -
SAP –ABAP BOOK
- 173 -
SAP –ABAP BOOK
56. Enter the Name and Description for the Inserted Text (e.x. Text =
“SUB_TOTAL_DISPLAY” and Description = “SUB_TOTAL_DISPLAY” and
populated the value for subtotal.
57. After each purchase order, the Variable V_SUBTOTAL has to be refreshed,
Inorder the clear the subtotal variable we have to insert “Program Lines” by right
clicking the “OI_DISPLAY ORDER ITEM DISPLAY”.
- 174 -
SAP –ABAP BOOK
58. Enter Name and Description for the Program Lines (%CODE1 New program lines
1) Inserted (e.x. Program lines = “CLR_VAR” and Description = “CLEAR
SUBTOTAL VARIABLE”. Input parameters = “V_SUBTOTAL”. Clear the variable
as shown below:
- 175 -
SAP –ABAP BOOK
59. Now, we have to display the Grand Total (i.e. summation of all the subtotals).
Insert “Text” under the “PO_LOOP PURCHASE ORDER NUMBER LOOP” by
right clicking the same.
- 176 -
SAP –ABAP BOOK
Text “%TEXT1 New text1” gets inserted. Now enter the name and description for
the same and also populated the value for grand total
- 177 -
SAP –ABAP BOOK
60. Inorder to display the Current Page Number and Total Number of pages in the
form we need a separate window and to obtain the same right click the “FIRST
First Page” and the insert window.
- 178 -
SAP –ABAP BOOK
Window “%WINDOW1 New window 1” get inserted under the first page.
- 179 -
SAP –ABAP BOOK
61. Enter the Window name and description (e.x. Window = “PG_WIN” and
Description “PAGE NUMBER WINDOW”)
Set the window co-ordinates for page number window “PG_WIN” as given below:
- 180 -
SAP –ABAP BOOK
- 181 -
SAP –ABAP BOOK
Text “%TEXT1 New text 1” gets inserted and now enter the text name and
description.
- 182 -
SAP –ABAP BOOK
- 183 -
SAP –ABAP BOOK
66. Another page gets inserted with name “%PAGE1 New page 1”.
- 184 -
SAP –ABAP BOOK
67. Enter Page name and description for the inserted new page (e.x. Page =
“SECOND” and Description = “Second Page”) and set the next page as inserted
second page and select the mode as increase counter as shown below:
68. Now change the “FIRST First Page”s Next page as “SECOND” and change the
mode as Initialize counter.
- 185 -
SAP –ABAP BOOK
69. Now copy the Main, Company Address, Page No windows from “FIRST First Page
“ to “SECOND Second Page”.
70. Arrange all the windows under the Main window in both first and second page.
Inorder to restrict the company logo to be printed only in the first page, go to the
first page and double click the “LOGO_WIN LOGO WINDOW” and select the
“Conditions” tab and Check the “only on first page” Check Box.
- 186 -
SAP –ABAP BOOK
- 187 -
SAP –ABAP BOOK
LOGO
- 188 -
SAP –ABAP BOOK
72. Inorder to restrict the Company address to be printed only in the last page
page and not
in the remaining pages, double click the “ADD_WIN ADDRESS WINDOW” in the
first page and Check the “only after end of main window” Check Box. Repeat the
same process for the second page also.
- 189 -
SAP –ABAP BOOK
- 190 -
SAP –ABAP BOOK
- 191 -
SAP –ABAP BOOK
74. Condition-2: Purchase
Purchase order’s whose value is more than 5000 only should get
displayed / printed.
Inorder to achieve the same,
same, right click the “PO_LOOP PURCHASE ORDERORDER
NUMBER LOOP” and select the “Loop”.
- 192 -
SAP –ABAP BOOK
77. Select the “Data” Tab Loop the Internal I_EKPO as shown below:
- 193 -
SAP –ABAP BOOK
78. Inorder to check the subtotal value for each purchase order (i.e. purchase order
value should be more than 5000), Insert a program lines under the new loop
inserted.
- 194 -
SAP –ABAP BOOK
80. Enter the name and description for Program lines. Before calculating thethe subtotal
declare two variables one for total and another for subtotal in Global definitions.
Calculate the Subtotal as shown below:
- 195 -
SAP –ABAP BOOK
81. Now we calculated the subtotal for each purchase order. Inorder to restrict the
display of purchase orders whose values are more than 5000, we need to insert
“Alternate” and for the same right click the “PO_LOOP PURCHASE ORDER
NUMBER LOOP” and from the menu path create select the “Alternate”.
- 196 -
SAP –ABAP BOOK
83. Enter Alternate name and description. Select the “General attributes” Tab and
Enter the condition of subtotal > 5000 as shown:
- 197 -
SAP –ABAP BOOK
85. In the “FALSE” part (i.e. If subtotal value is less than 5000, then clear the variable),
insert program lines and code as shown:
86. Only those purchase order whose value is more than 5000 gets displayed – First
Page.
- 198 -
SAP –ABAP BOOK
Only those purchase order whose value is more than 5000 gets displayed –
Second Page.
- 199 -
SAP –ABAP BOOK
- 200 -
SAP –ABAP BOOK
87. Condition-3 Each Purchase Order should get printed in a new page. Logo should
get printed in the first page along with the first purchase order and similarly, Grand
total should get printed in the last page with the last purchase order.
88. Inorder to achieve this, when the first successful purchase order whose value is
more than 5000 is found then increase one counter variable by 1 (this is required
because the “New page command” should not get triggered in the first page itself”)
and for the same we have to insert a “Program lines” under the “TRUE” part of
“CHK_COND SUBTOTAL CONDITION”.
Before increasing the counter variable first declare the counter variable in the
“Global definitions” part.
- 201 -
SAP –ABAP BOOK
89. Inorder to avoid triggering “New page command” in the first page,
page, we have to insert
“Command” in the “TRUE” part of “CHK_COND SUBTOTAL CONDITION” by right
clicking the same as shown below:
- 202 -
SAP –ABAP BOOK
91. Enter name and description for the inserted Alternative. Select “General attributes”
Tab and check whether for the counter variable is more than 1.
- 203 -
SAP –ABAP BOOK
92. If the counter variable is more than 1 means, we got the second successful
purchase order whose value is more than 5000. Hence, we can trigger new page
command here and for the same right click the “TRUE” part in “NEW_PG NEW
PAGE COMMAND” as shown:
- 204 -
SAP –ABAP BOOK
93. Enter the name and description for Command and select the “General attributes”
Tab and Check the “Go to new page” and select the page as “SECOND” as shown
below:
- 205 -
SAP –ABAP BOOK
94. The following is the output: First Page with company logo and without company
address window, first purchase order whose value is more than 5000.
- 206 -
SAP –ABAP BOOK
Second page: without company logo and with company address window for the
last purchase order whose value is more than 5000.
- 207 -
SAP –ABAP BOOK
- 208 -
SAP –ABAP BOOK
96. Inorder to solve the above problem Double Click the “PG_DISP PAGE NUMBER
DISPLAY” and Click the Text Editor.
- 209 -
SAP –ABAP BOOK
Upon clicking the text editor it will take you to the following screen:
Cut (Ctrl+X) the “SFSY-FORMPAGES” and delete the remaining things as shown.
Which will result you in the following popup and fill the popup as shown.
- 210 -
SAP –ABAP BOOK
99. Press back and then check, activate and execute – You can observe that the
problem has resolved.
- 211 -
SAP –ABAP BOOK
BUSINESS ADD-INS
CONTENTS
I. Basic concept
- 212 -
SAP –ABAP BOOK
b. Architecture
Architecture
c. Technical details
i. Defining a Business Add-in
ii. Implementation of BAdi
iii. Calling BAdi in the Application
iv. Filter dependent Badi
v. Multiple use Badi
V. Advantages of
of BADI’s
BASIC CONCEPT
SAP has introduced new enhancement technique Business Add-ins from release 4.6A.
Business Add-in is the new enhancement technique based on ABAP O bjects. BADI is an exit point in
a source
source that allows specific industry sectors, partners, and customers to attach additional software to
standard SAP source code with out modifying the original object.
The users of Business Add-ins can customize the logic according to requirement or they can use
the standard logic one available.
SAP guarantees the upward compatibility of all Business Add-in interfaces. Release upgrades do not
affect enhancement calls from within the standard software nor do they affect the validity of call interfaces.
BADI IN DETAIL
Business Add-ins infrastructure is multi-level system landscape (SAP, partner, customer solutions,
as well as country versions, and industry solutions). Definitions and implementations of Business Add-ins at
each level within system infrastructure.
i nfrastructure.
Different Views
a) The different views of the BADI’s are:
- 213 -
SAP –ABAP BOOK
software to standard SAP source code with out having to modify the original
object.
ii. Implementation view, the users of Business Add-ins can cu stomize the logic
they need or use a standard logic if available.
Architecture
a) Architecture:
i.First define a Business Add-In, application developer creates an interface for the
add-in.
ii. Enhancement management creates an adapter class that implements the interface
and thus provides the interface for implementation by the customer, partner and
so on.
iii. The programmer/developer creates an instance of the adapter class in the
application program and calls the corresponding method at the appropriate time.
c) Standard BADI’s:
i. For Standard Business Add-ins, the interface and adapter class will be predefined
by SAP. The adapter class that implements the interface
interface and provides the
interface for implementation by the customer, partner specific to business.
d) Each Business Add-in will have one interface and an adapter class that implements
interface. Depending on the business requirement user will implement the interface. The
generated class (Adapter class) has the following tasks.
i. Control, the adapter class calls the active implementations.
Control,
- 214 -
SAP –ABAP BOOK
ii. Filtering, If the Add-in has to be executed under certain conditions, then the
Filtering,
adapter class ensures that only certain implementations will be executed.
Technical Details
e) BAdIs are contained in the system and are fully operational as of Release 4. 6B. SAP creates
Add-ins for specific programs, menus, and screen enhancements for standard R/3
applications. This Add-ins doesn’t contain any functionality. Instead you
you can add-on
functionality onto these hooks.
f) Customers can find the enhancements in their system in the implementation guide
and in the component hierarchy. If customer wishes to use a Business Add-in, he
has to first create an implementation. The customer must implement the methods
and the enhancements, and afterwards activate the implementation of the
enhancement. The enhancement’s active components are then called at runtime.
SAP provides the Badi’s where are applicable in the standard applications. Application
programmer who ever wishes to have a Business Add-ins in a particular program can
define the interface for an enhancement in the Business Add-in builder. Programmer has to
program the interface call in the program at the appropriate place. Customers can select the
- 215 -
SAP –ABAP BOOK
d) Double click on the interface name field. The system branches to the class builder.
- 216 -
SAP –ABAP BOOK
e) In the class builder assign a method to the interface and define a parameter with the
attributes.
f) Save and activate the interface and navigate back to the Business Add-in definition.
Now in the Badi screen, displays the method you have created for the interface.
When you maintain the interface methods, corresponding executing class (Adapter
class) is generated.
g) Save your entries and document the description of the Business Add-in.
Documentation is important for the users to understand the purpose of the Add-in.
- 217 -
SAP –ABAP BOOK
Implementation of Badi
a) The list of Business Add-ins available in the system can be found through SAP
Reference Implementation guide (IMG) or in component hierarchy. Badi’s
definition is included in IMG so that the customer/partner can create suitable,
company-specific implementations.
b) In the SAP menu, choose ABAP Workbench -> Utilities -> Business Add-ins or
transaction code SE19.
c) Enter the implementation name and click on the create button.
- 218 -
SAP –ABAP BOOK
f) Double click on the implementation class and insert the desired source code for the
implementation between the ������ �������������������������� ������ A�� ������. In
��������������������������������
- 219 -
SAP –ABAP BOOK
this particular example enter the statement translate parameter to upper case.
Save and activate your entries and return to the change implemention screen.
g) Choose Activate, now you can use this implementation when the application
program is executed. Several implementations may exist for a Business Add-in but
that is not used in multiple use basis. However only one implementation can be
activate at any one time. But in case of multiple use of the BAdi, we can have
multiple implementations activate. The instance generation of the implementing
class must set the attribute as public and not as private, protected or abstract.
System will give dump if you do so.
h) Following is the code for the class ZCL_CONVERSION_BADI_IMPL method
CONVERSION
������ �IF�E��B��I�E��ADDI��C���E
�IF�E��B��I�E��ADDI��C���E��I��.
��I��.
���������.
�E���� ����E���BADI.
* I�������� ���������
����: �������������� ���� ��� �� �IF�E��B��I�E��ADDI�.
�IF�E��B��I�E��ADDI�.
* ������
����: �����(15) ���� � ����� '����� ����'.
***************************************
*************************************************
**********
****����� �� ��������� E����.....................
E����.....................
**************************
***************************************
**********************
*********
������������������.
���� ������ ��������������=>���������
��������������=>������������
���
��������
�������� = ��������������.
��������������.
�����: / '������ ����� ����'.
**************************
***************************************
***********************
**********
- 220 -
SAP –ABAP BOOK
****A� �������������
��������������
� E����.........
E����.....................
............
**************************
***************************************
**********************
*********
�� ��������������.
��������������.
�����.
�����: / 'C�������� ����', �����.
a) Business Add-in definition level (for example a country, industry sector) we can
have filter dependent option. If an enhancement for country specific versions then it
is likely that different partners can implement this enhanc ement. The individual
countries can create and activate their own implementation.
b) In the enhancement definition, all the methods created in the enhancement’s
interface need to have filter value as their importing parameter. The application
program provides the filter values for the implementation
i mplementation method.
c) Filter dependent BAdi is called using one filter value only, it is possible to check
active implementation for the filter value using the function module
SXC_EXIT_CHECK_ACTIVE.
a) There are multiple use and single use Business Add-ins. This option can be choose
at Business Add-in definition.
b) The distinction is base on the procedure or event character of an enhancement. In
the first case the program waits for the enhancement to return a return code. Typical
example is benefit calculation in HR depending on the implementation, alternative
calculations can be executed. In case of multiple use add-ins, an event that may be
interest to other components in program flow. Any number of components could
use this event as a hook to hang their own additional actions on to.
c) There is no sequence control for multiple-use implementations of BAdi’s. Sequence
control is technically impossible, at the time of the definition the interface does not
know which implementations parameters will be change the implementations.
d) The concept of multiple use of the Business Add-in is that has been implemented
once already can be implemented again by right of the software chain.
- 221 -
SAP –ABAP BOOK
iii. The concept of the BADI is similar to Business Transaction Events (Open FI). BTE’s
was developed specific to Financial Accounting module. But were as BADI’s was
developed in generalised to all modules.
iv. BTE’s can only be used to make the program enhancements. You can not enhance
user interface with Open FI, but you can with Business Add-ins.
v. Open FI assumes that enhancement can only take place on three l evels i.e. SAP-
partners – customers, but in case of BAdi’s you can crea te and implement
enhancements in as many software layers as you like.
vi. Function modules are used for program enhancements in Open FI. With BAdi’s,
ABAP Objects is used to enhance programs.
b) Difference between customer exits and BAdi’s.
i. Customer exits assume a two-tiered system infrastructure (SAP - Customers). Where
as in case of BAdi’s you can created and implement enhancements in as many software
layers as you like.
ii. BAdi’s are considered as generalized BTE’s that can be used to bundle program, menu
and screen enhancements into a single add-in. BAdi’s can be created and employed in
each of the various software levels.
ADVANTAGES OF BADI’S
a) This enhancement technique has the advantage of being based on a multi-level system
landscape (SAP, country versions, IS solutions, partner, customer and so on).
b) We can create definitions and implementations of business add-ins at any level of the
system landscape.
TECHNICAL STUFF
- 222 -