Вы находитесь на странице: 1из 222

SAP –ABAP BOOK

SAP ABAP BOOK 1

-1-
SAP –ABAP BOOK

ENTERPRISE RESOURCE PLANNING

Before Getting into the world of SAP, We must Understand the Concept behind this Great Technology. The
Concept on which the SAP R/3 (ECC ) is built is ERP.

ERP stands for ENTERPRISE RESOURCE PLANNING

ERP : A Software Package which can manage functions of multiple departments of an Enterprise is called
an ERP.

Initially ERP originated as an extension of MRP (material requirements planning; later manufacturing
resource planning) and CIM (Computer Integrated Manufacturing). It was introduced by research and
analysis firm Gartner in 1990. ERP systems now attempt to cover all core functions of an enterprise,
regardless of the organization's business or charter. These systems can now be found in non-manufacturing
businesses, non-profit organizations and governments.

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

Material Mgmt. Maintenance


Machinery

Purchasing Corporate
Marketing
Distribution Admin.
Methods
Sales R&D

Marketing SCM

CRM

FI PP

HR QM

MM SD

Before Implementing ERP

Above figures shows the scenario where various departments are being managed by different software
packages.

-3-
SAP –ABAP BOOK

The Disadvantages in the above Scenario are:

(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.

After Implementing ERP

Finance PP

HR QM

MM SD

Following are the Advantages of Implementing an ERP.

(1) Single integrated software program


(2) Single database
(3) Information shared and communicated
(4) Automates customer orders, order fulfilment , billing, shipping, etc.
(5) Tracking . Easy to track any transaction through out the Enterprise.

Below Table shows the Various ERP Packages offered by different Companies.

-4-
SAP –ABAP BOOK

Proprietary ERP Software

ERP Product Company

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

Big 5 Market Share Evolution (%)

80
70
SAP
60
Percentage

50 ORACLE
40 SIEBEL
30
PEOPLESOFT
20
10 JDEDWARDS
0
4)

Q 4)

Q 4)

Q 4)

Q 5)

Q 5)

Q 5)
5)
'0

'0

'0

'0

'0

'0

'0

'0
1(

2(

3(

4(

1(

2(

3(

4(

The above graph shows the percentage of Market share of various ERP packages.
Q

Quarter
SAP Enjoys 72% of Global ERP Market Share

-5-
SAP –ABAP BOOK

2. SAP

SYSTEMS APPLICATIONS AND PRODUCTS

SAP Stands for Systems Applications and Products in Data Processing

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 are used by corporations to track all information
related to the business, including financials, sales, and materials 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. 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. 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 system, 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

SAP – Three Tier Architecture


Presentation Server:
The presentation server is actually a program named sapgui.exe. It is usually installed on a user's
workstation. To start it, the user double-clicks on an icon on the desktop or chooses a menu path. When
started, the presentation server displays the R/3 menus within a window. This window is commonly known
as the SAPGUI, or the user interface (or simply, the interface). The interface accepts input from the user in
the form of keystrokes, mouse-clicks, and function keys, and sends these requests to the application server
to be processed. The application server sends the results back to the SAPGUI which then formats the output
for display to the user.

-6-
SAP –ABAP BOOK

Presentation -
Server-
Tier 3 SAP-GUI
Layer

Application - Tier 2 ABAP-Program


Server-
Layer

client-independent client-dependent

Database Repository Customizing -Tables


(all Dev.- Tier 1 Application -Tables
Objects)

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. The 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:

• Number of processes and their types


• Amount of memory each process may use
• Length of time a user is inactive before being automatically logged off

The application server exists to interpret ABAP/4 programs, and they only run there-the programs do not
run on the presentation server. 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.

The database server is a set of executables that accept database requests from the application server. These
requests are passed on to the RDBMS (Relation Database Management System). The RDBMS sends the
data back to the database server, which then passes the information back to the application server. The
application server in turn passes that information to your ABAP/4 program.

-7-
SAP –ABAP BOOK

There is usually a separate computer dedicated to house the database server, and the RDBMS may run on
that computer also, or may be installed on its own computer.

Database Server

The Latest Versions of R/3 are now named as ECC.


The Versions in ECC are
SAP ECC 5.0, SAP ECC 6.0, SAP ECC 6.2 ETC...,

The database server is a set of executables that accept database requests from the application server. These
requests are passed on to the RDBMS (Relation Database Management System). The RDBMS sends the
data back to the database server, which then passes the information back to the application server. The
application server in turn passes that information to your ABAP/4 program.

There is usually a separate computer dedicated to house the database server, and the RDBMS may run on
that computer also, or may be installed on its own computer.

Introducing the SAP Software Program


In the past, other vendors have offered applications that manage a single area of business functionality —
such as inventory control, general ledger accounting, or customer lists. Rather than simply package several
such applications together into a single box, SAP has instead produced a suite of major business
applications that are tightly integrated. One of the reasons for the immense success of SAP is this
integration between its modules. Thus, when a vendor fulfills a purchase order by sending the requested
materials, inventory levels are adjusted, invoices are verified, checks are issued, and so on. An event in one
module, such as Materials, can initiate automatic responses in others, such as Sales or Plant Maintenance.
All of this processing takes place within the normal SAP functionality — without any custom
programming.

The Role of Configuration in Implementing SAP

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 is 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 by 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

FROM START-UP SOFTWARE VENDOR TO GLOBAL MARKET LEADER

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.

The 1970s: A Real-Time Vision

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 Processing
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.

The 1980s: Rapid Growth

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.

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 States, SAP's international
expansion takes a leap forward.

The 1990s: A New Approach to Software and Solutions

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 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 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 Board 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 announces 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 applications, using state-of-the-art Web
technology.

The 2000s: Innovation for the New Millennium:

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 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, 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.

To further demonstrate our commitment for ongoing innovation, growth, and market leadership, SAP
acquired Business Objects in 2008. Together, SAP and Business Objects, an SAP company, offers the
industry's most comprehensive portfolio of business performance and optimization solutions for companies
of all sizes.

- 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, the company is listed on several exchanges, including the Frankfurt
stock exchange and NYSE, under the symbol "SAP."

Business and Corporate Overview (U.S. GAAP)


Total Revenue €11,565 million (FY 2008)
Software and Software-Related
€8,457 million (FY 2008)
Service Revenue
Operating Income €2,840 million (FY 2008)
Employees 51,500 (FTE at Dec. 31, 2008)
More than 86,000 in over 120
Customers
countries
Partners More than 2,400 certified partners
€1,631 million / 14% of total revenue
R & D Investment
(FY 2008)

SOLUTIONS AND SERVICES PORTFOLIO

In 2007, SAP introduced "innovation without disruption" with enhancement packages, a radical new
concept that is unique in the software industry that does away with the traditional software upgrades.
Customers can install these packages during live operation, deciding themselves which of the new functions
to activate, thus considerably reduces operating costs.

Learn more about:

• 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..,

There are many more modules.

• SAP CRM (Customer Relationship Management )


o Provides agile platform needed to help companies achieve a 360-degree view of the
customer that engages the broader business ecosystem in order to help identify trends before they hit
o Enables customer-driven growth by helping organizations to
 Satisfy their customers through superior interactions and experiences across all
channels
 Empower their teams to perform business functions and manage interactions with
customers, anytime and anywhere
 Grow their business by capitalizing on insights into their customers, providing a
superior customer experience, and making the most of their business advantage
o Builds on SAP's focus on delivering strong standard CRM functionality with deep industry
processes enabled through unique SAP front-to-back-office integration
• SAP SCM (Supply Chain Management )
o Helps organizations transform a linear supply chain into an adaptive supply chain network,
in which communities of customer-centric, demand-driven companies share knowledge, intelligently adapt
to changing market conditions, and proactively respond to shorter, less predictable life cycles
• SAP SRM (Supplier Relationship Management )
o Helps organizations manage their all-important vendor relationships, providing strategic
value through sustainable cost savings, contract compliance, and quick time-to-value
• SAP PLM (Product Lifecycle Management )

- 12 -
SAP –ABAP BOOK

o Provides an integrated, single source of all product-related information needed for


collaborating with business partners and supporting processes – including product innovation, design and
engineering, quality and maintenance management, and control of environmental issues

SAP BusinessObjects Portfolio

SAP BusinessObjects portfolio offers tools and applications designed to help customers optimize business
performance by connecting people, information, and businesses across business networks.

• Solutions for Large Enterprises


o Intelligence platform – Connects all people to all information on one platform, providing a
unified view of the business
o SAP BusinessObjects governance, risk, and compliance solutions – Helps customers
promote corporate accountability by unifying corporate strategy, control initiatives, opportunity discovery,
and loss mitigation across the extended enterprise
o SAP BusinessObjects enterprise performance management solutions – Enables customers
to become more agile and competitive by providing organizational alignment, visibility, and greater
confidence
• Solutions for Small Businesses and Midsize Companies
o SAP BusinessObjects Edge – A connected, interactive, and open business intelligence
solution for midsize companies
o Crystal Reports – A complete report management solution for small companies
o Xcelsius – Dynamic and customizable data visualization software.

On-demand solutions

• SAP Business ByDesign


o Is the "game-changing" addition to the SAP portfolio of distinct solutions for small
businesses and midsize companies and complements the existing solutions
o Is the industry's most complete and adaptable on-demand business solution, built around
four key principles – completeness, ease of use, adaptability and significantly cutting total cost of
ownership – allowing customers to exploit the full potential of new business trends
o Supports the complete array of core business processes, lowers total cost of ownership by
bundling software, e-learning, services, and support for easy configuration, adaptation, and ongoing
operation without requiring extensive IT infrastructure and resources.
• SAP CRM on-demand solution
o Delivers quick time-to-value and enables strategic growth as the only enterprise CRM
solutions that offer a flexible deployment model
o Helps organizations can transition from on-demand to hybrid and on-premise SAP CRM at
any time, avoiding data losses or interruptions to productivity
o Includes three specific on-demand solutions targeted for sales, marketing, and service.
• SAP E-Sourcing on-demand solution
o Delivers easy adoption, rapid cost savings, and a low subscription investment via a hosted
delivery model
o Comes with all components and supporting services to enable sustainable sourcing success

Industry-specific solution portfolios

- 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 SAP Business All-in-One
partner solutions and 550 SAP Business One partner solutions.

SAP currently offers the following industry solutions (IS):

• SAP for Banking


• SAP for Insurance
• SAP for Defense & Security
• SAP for Healthcare
• SAP for Higher Education & Research
• SAP for Public Sector
• SAP for Aerospace & Defense
• SAP for Automotive
• SAP for Chemicals
• SAP for Consumer Products
• SAP for Engineering, Construction & Operations
• SAP for High Tech
• SAP for Industrial Machinery & Components
• SAP for Life Sciences
• SAP for Mill Products
• SAP for Mining
• SAP for Oil & Gas
• SAP for Travel & Logistics Services
• SAP for Media
• SAP for Professional Services
• SAP for Retail
• SAP for Telecommunications
• SAP for Utilities
• SAP for Wholesale Distribution

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 need 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.

The Various Modules are:

(1) Exchange Infrastructure (XI)


(2) Business Intelligence (BI)
(3) Mobile Infrastructure (MI)
(4) Web Application Server (Web As)
(5) Enterprise Portal (EP)
(6) Master Data Management (MDM)

SAP solutions for small businesses and midsize companies

SAP and its channel partners offer flexible, scalable solutions tailored to company size as well as vertical
industry demands:

• SAP Business All-in-One


o Covers demands of midsize companies with in-depth industry requirements
o Provides streamlined business management and configuration tools for rapid time to value
and predictable costs
o Is used by approximately 13,450 customers worldwide
o Contains more than 660 micro-vertical industry solutions
o Is delivered through 1,100 partners in more than 50 countries
• SAP Business One
o Tailored to the demands of small businesses
o Used by approximately 22,600 customers worldwide
o Supported by more than 1,200 business partners worldwide
o Available in 40 country versions
• SAP Business ByDesign
o Launched on September 19, 2007, making it the latest addition to the SAP portfolio of
distinct solutions for small businesses and midsize companies that complements existing solutions
o Designed for fast growing midsize companies
o Is the industry's most complete and adaptable on-demand business solution
o Supports the complete array of core business processes, lowers total cost of ownership by
bundling software, e-learning, services and support for easy configuration, adaptation and ongoing
operation without requiring extensive IT infrastructure and resources.

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 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 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 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 in 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

ASAP METHODOLOGY FOR IMPLEMENTATION

The individual phases of the ASAP Implementation Roadmap are:

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 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 the
input to follow-up phases. Each deliverable provides list of outputs it consist of and methods that are used
to produce the deliverable.

Logging into SAP.

Double click on Button on your desk top.

You will see a pop as below

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 below

- 18 -
SAP –ABAP BOOK

3.ABAP/4

ABAP Programming Language

Advanced Business Application Programming

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 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. 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 covers programming in ABAP/4 up to the 3.1h release
of SAP R/3.

How ABAP/4 and Data Interact in SAP

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 information that usually corresponds to physical objects, such as materials, vendors,
customers, or plants.

• A document is information that usually corresponds to an event such as a purchase order, an invoice, a
change in inventory, or a sales order. Documents can be identified in the system by a document number,
which can be externally assigned or assigned by SAP, depending on the configuration.

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 as journal entries and
check payments.

ABAP/4 is a fourth-generation programming 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, 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 meet the most demanding

- 19 -
SAP –ABAP BOOK

business requirements.

SAP is an extremely 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.

Creating your First ABAP Program.


Log-on to transaction SE38

You will get into ABAP Editor ,Enter the program Name.

You will see another pop-up as seen below. Click on Button

- 20 -
SAP –ABAP BOOK

You will enter the ABAP Editor screen. There type a line command.
WRITE: ‘MY FIRST PROGRAM’.

Save the program :Click on Button (or) type Ctrl + S


Check Syntax : Cick on Button (or ) type Ctrl + F2
Activate : Click on Button (or) type Ctrl + F3
Execute : Click on Button (or ) type F8

Below is the Output you get.

- 21 -
SAP –ABAP BOOK

ABAP DICTIONARY

Basics of 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 field.

• 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.

Use transaction code SE11

Three different type categories exist in the ABAP Dictionary:


. Data elements: Describe an elementary type by defining the data type, length, and possibly decimal
places.
. Structures: Consist of components that can have any type.
. Table types: Describe the structure of an internal table.
Any complex user-defined type can be built from these basic types.

- 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 by specifying a direct type. The data type
attributes of a data element can also be defined by specifyinga built-in type, where the data type and
number of places are entereddirectly.

- 23 -
SAP –ABAP BOOK

Basic Objects of the ABAP


Data Dictionary
Table A Table B Table C

Data Element 1 Data Element 2

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 the include to the including table. As a result, the foreign key
depends on the definition in the include. The structure of the objects of application 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.

Figure 7: Basic Objects of the ABAP Dictionary

Unit 2
Tables in the ABAP Dictionary
Creating Tables

- 24 -
SAP –ABAP BOOK

Requirement: Create a Vendor General Data Using Below Information.

Field Name Data Type Length Description


LIFNR CHAR 10 Vendor Acc No
NAME1 CHAR 35 Name of Vendor
ORT01 CHAR 35 City
STRAS CHAR 35 District
LAND1 CHAR 35 Country Key

For the Above requirement we need to Create a DB Table


To create DB Table we have two different approches.
(1) Top Down (Table -> Data element -> Domain)
(2) Bottom Up (Domain -> Data element -> Table)
We will go with Bottom Up approach.
First create 2 different Domains.
One for field LIFNR and another for rest 4 fields

Steps to Create Data Base Table:


(1) Create Domain
(2) Create Dataelement
(3) Create Database Table
(1) Create Domain
Goto transaction SE11.

Now you will enter the ABAP Dictionary


Select the Radio Button beside Domain.
Enter the Name of the Domain as ZLIFNR
Click on create button or press F5 Button.

- 25 -
SAP –ABAP BOOK

Click on Save Button (or ) Ctrl + S You will get a pop-up as shown below. Click on
button.

Click on Activate Button (or) Ctrl + F3


(Activating the Domain)

Click on Activate Button (or) Ctrl + F3 (Activating the Domain)

2. Create Data element


Goto transaction SE11.

- 26 -
SAP –ABAP BOOK

Now you will enter the ABAP Dictionary


Select the Radio Button beside Data type.
Enter the Name of the Data element as ZLIFNR_DE
Click on create button or press F5 Button.

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.

Save , Check Syntax and Activate.

(4) Create Database Table

- 29 -
SAP –ABAP BOOK

Now you will enter the ABAP Dictionary


Select the Radio Button beside Data base table.
Enter the Name of the Data base Table as ZLFA1
Click on create button or press F5 Button.

- 30 -
SAP –ABAP BOOK

Click on Save (or ) Ctrl + S.

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.

This is one of the advantages of Date element,


Similarly a Domain can be used multiple number of times in any number of Data elements.

Create Data in a Database Table.


To create Data in DB table ,follow the below path.

- 32 -
SAP –ABAP BOOK

Save and reset. We can create as many records as we need. To Display

Contents Click on Button Or type Ctrl + Shift + F1

Contents:

(1) Classical Reporting


Basic List
Interactive List

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.

Determining the Attributes of 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:

DESCRIBE FIELD <f> [LENGTH <l>] [TYPE<t>] [COMPONENTS<n>]


[OUTPUT-LENGTH <o>] [DECIMALS<d>] [EDIT MASK <m>] [HELP-ID <h>].

- 33 -
SAP –ABAP BOOK

The following table shows the different ways of expressing basic arithmetic operations in ABAP:

Operation Statement using Statement using

mathematical expression Keyword


Addition <p> = <n> + <m>. ADD <n> TO <m>.
Subtraction <p> = <m> - <n>. SUBTRACT <n> FROM <m>.
Multiplication <p> = <m> * <n>. MULTIPLY <m> BY <n>.
Division <p> = <m> / <n>. DIVIDE <m> BY <n>.
Integer division <p> = <m> DIV <n>. ---
Remainder of division <p> = <m> MOD <n>. ---
Powers <p> = <m> ** <n>. ---

• 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.

To declare a field symbol, use the statement

FIELD-SYMBOLS <FS> [<type>|STRUCTURE <s> DEFAULT <wa>].

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:

ASSIGN <f> TO <FS>.

- 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:-

Declaring Extract Records as 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.

You can also define a special field group called HEADER:

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 system uses these fields as the default sort key.

Defining the Structure of a Field Group

To define the structure of a record, use the following statement to add the required fields to a field
group:

INSERT <f1>... <f n> INTO <fg>.

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 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.

Initial Memory Requirement:-

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:

INITIAL SIZE <n>

- 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.

DATA: ITAB TYPE VECTOR,


JTAB LIKE ITAB WITH HEADER LINE.

* MOVE ITAB TO JTAB. <- Syntax error!

MOVE ITAB TO JTAB[].

Assigning Internal Tables:-

Like other data objects, you can make internal tables operands in the MOVE statement

MOVE <itab1> TO <itab2>.

or the equivalent 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). When you refill the table, the
system has to allocate new memory space to the lines.

Sorting Internal Tables :-

You can sort a standard or hashed table in a program. To sort a table by its key, use the statement

SORT <itab> [ASCENDING|DESCENDING] [AS TEXT] [STABLE].

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:-

SORT <itab> ... STABLE.

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:

DESCRIBE TABLE <itab> [LINES <l>] [OCCURS <n>] [KIND <k>].

Operations on internal table

1) To add a line to an internal table, use the statement:

INSERT <line> INTO TABLE <itab>.

Lines are added to internal tables as follows:

• 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.

To add several lines to an internal table, use the statement:

INSERT LINES OF <itab1> [FROM <n1>] [TO <n 2>] INTO TABLE <itab2>.

2) The following statement allows you to summate entries in an internal table:

COLLECT <wa> INTO <itab>.

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

3) To read a single line of any table, use the statement:

READ TABLE <itab> <key> <result>.

The system searches for the relevant lines as follows:

• Standard tables

Linear search, where the runtime is in linear relation to the number of table entries.

• 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.

4) To change a single line, use the following statement:

MODIFY TABLE <itab> FROM <wa> [TRANSPORTING <f1> <f 2> ...].

5) The AT statement introduces a statement block that you end with the ENDAT statement.

AT <level>.
<statement block>
ENDAT.

You can react to the following control level changes:

<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 <f1>, <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 current group key contain their 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.

Operations without header line Operations with header line

Operations for all Table Types

INSERT <wa> INTO TABLE <itab>. INSERT TABLE ITAB.

COLLECT <wa> INTO <itab>. COLLECT <itab>.

READ TABLE <itab> ... INTO <wa>. READ TABLE <itab> ...

MODIFY TABLE <itab> FROM <wa> ... MODIFY TABLE <itab> ...

MODIFY <itab> FROM <wa> ...WHERE ... MODIFY <itab> ... WHERE ...

DELETE TABLE <itab> FROM <wa>. DELETE TABLE <itab>.

LOOP AT ITAB INTO <wa> ... LOOP AT ITAB ...

Operations for Index Tables

APPEND <wa> TO <itab>. APPEND <itab>.

INSERT <wa> INTO <itab> ... INSERT <itab> ...

MODIFY <itab> FROM <wa> ... MODIFY <itab> ...

File Handling in ABAP

ABAP contains three statements for working with files:

• OPEN DATASET for opening files


• CLOSE DATASET for closing files
• DELETE DATASET for deleting files

To open a file on the application server, use the OPEN statement as follows:

OPEN DATASET <dsn> [Additions].

- 42 -
SAP –ABAP BOOK

To open a file for reading, use the FOR INPUT addition to the OPEN DATASET statement.

OPEN DATASET <dsn> FOR INPUT.

To open a file for writing, use the FOR OUTPUT addition to the OPEN DATASET statement.

OPEN DATASET <dsn> FOR OUTPUT.

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:

OPEN DATASET <dsn> FOR APPENDING.

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:

OPEN DATASET <dsn> FILTER <filt>.

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:

OPEN DATASET <dsn> MESSAGE <msg>.

To write data to a file on the application server, use the TRANSFER statement:

TRANSFER <f> to <dsn> [LENGTH <len>].

To read data from a file on the application server, use the READ DATASET statement:

READ DATASET <dsn> INTO <f> [LENGTH <len>].

When you access sequential files on the application server using the following statements:

• OPEN DATASET
• READ DATASET
• TRANSFER
• DELETE DATASET

the system automatically checks the user’s authorization against the authorization object
S_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

TO LOAD THE DATA INTO APPLICATION SERVER


*&-------------------------------------------------------------------*
*& Report Z_APPL_TEST *
*& *
*&-------------------------------------------------------------------*
REPORT z_appl_test .

DATA: BEGIN OF itab OCCURS 0,


name(10),
num TYPE n,
END OF itab.

itab-name = 'VIKRAM'.
itab-num = '24'.
APPEND itab.

DATA: BEGIN OF it_read OCCURS 0,


txt(100),
END OF it_read.

OPEN DATASET '\usr\JHSOFT.txt' FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

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 .

parameter p_file like rlgrap-filename.

data: begin of it_read occurs 0,


txt(300),
end of it_read.

- 44 -
SAP –ABAP BOOK

OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

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 *

User-defined selection screens

The two statements:

SELECTION-SCREEN BEGIN OF SCREEN <numb> [TITLE <title>] [AS WINDOW].


...
SELECTION-SCREEN END OF SCREEN <numb>.

GUI Status of 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 from the SAP memory as follows:

PARAMETERS <p> ...... MEMORY ID <pid>......

 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):

PARAMETERS <p> ... VISIBLE LENGTH <len> ...

If <len> is smaller than the field length of <p>, the input field is displayed in the length <len>.

 To define the input field of a parameter as a required field, you use the following syntax:

PARAMETERS <p> ...... OBLIGATORY ......

 To check a user entry against a check table or against fixed values in the ABAP Dictionary,
you use the following syntax:

PARAMETERS <p> TYPE <type> ... VALUE CHECK ...

 To suppress the display of the input field on the selection screen, you use the following syntax:

PARAMETERS <p> ...... NO-DISPLAY ......

 To modify the appearance of an input field on the selection screen, you must assign the
parameter to a modification group as follows:

PARAMETERS <p> ...... MODIF ID <key> ......

Structure of Selection Tables:-

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 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 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

(1) SELECT-OPTIONS <seltab> FOR <f> ... MEMORY ID <pid>..........

• Upper and lower case for selection criteria:

(2) SELECT-OPTIONS <seltab> FOR <f> ... LOWER CASE ..............

• To make the From field a required field on the selection screen, use:

(3) SELECT-OPTIONS <selcrit> FOR <f> ... OBLIGATORY ..............

• To hide input fields on the selection screen, use:

(4) SELECT-OPTIONS <selcrit> FOR <f> ... NO DISPLAY ..............

• To modify input fields on the selection screen, use:

(5) SELECT-OPTIONS <selcrit> FOR <f> ... MODIF ID <key> ...........

 To place comments on the selection screen, and if you want write anything in selection-screen,
you use:

SELECTION-SCREEN COMMENT [/]<pos(len)> <comm> [FOR FIELD <f>] [MODIF


ID <key>].

 To create a logical block of elements on the selection screen, you use:

(1) SELECTION-SCREEN BEGIN OF BLOCK <block>


[WITH FRAME [TITLE <title>]] [NO INTERVALS].
...
(2) SELECTION-SCREEN END OF BLOCK <block>.

 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>].

 To create a pushbutton on the selection screen, you use:

- 48 -
SAP –ABAP BOOK

(4) SELECTION SCREEN PUSHBUTTON [/]<pos(len)> <push> USER-COMMAND


<ucom> [MODIF ID <key>].

 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:

PARAMETERS ... AS CHECKBOX | RADIOBUTTON GROUP ... USER-COMMAND


<ucom>.

 In the PBO of the selection screen, the

AT SELECTION-SCREEN OUTPUT

event is triggered. This event block allows you to modify the selection screen directly before it is
displayed.

 In the PAI event of the selection screen, the event

(1) AT SELECTION-SCREEN ON <field>

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.

 In the PAI event of the selection screen, the event

(2) AT SELECTION-SCREEN ON BLOCK <block>

 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

(3) AT SELECTION-SCREEN ON HELP-REQUEST FOR <field>

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

(4) AT SELECTION-SCREEN ON VALUE-REQUEST FOR <field>

The event is triggered when the user calls the F4 help for the field <field>.

LISTS

- 49 -
SAP –ABAP BOOK

The ABAP statements that create lists actually create the list on the application server, where it is
buffered. The list is then displayed either when the LEAVE TO LIST-PROCESSING statement
occurs in the program, or, for executable programs, automatically. In executable programs, the
list that you create is displayed (at the latest) after the last event block in the program.

You can output symbols or R/3 icons on a list by using the following syntax:

Syntax

WRITE <symbol-name> AS SYMBOL.

WRITE <icon-name> AS ICON.

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

WRITE <f> AS CHECKBOX.

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

Unconditional Page Break

To trigger a page break during list processing, use the basic form of the NEW-PAGE statement:

Syntax

NEW-PAGE. This statement

• 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.

Conditional Page Break- Defining a Block of Lines:-

- 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

RESERVE <n> LINES.

This statement triggers a page break if less than <n> free lines are left on 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

SCROLL LIST FORWARD|BACKWARD [INDEX <idx>].

 To scroll horizontally to the left or right margin of a list, use the following options of the
SCROLL statement:

Syntax

SCROLL LIST LEFT | RIGHT [INDEX <idx>].

 Positioning Output Underneath Other Output

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

WRITE <f> UNDER <g>.

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.

 Positioning Output in the First Line of a Line Block

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.

If BACK follows RESERVE, the subsequent output appears in the first line written after
RESERVE. You can use this statement, for example, to jump back to a specific line after writing
an output from within a loop.

PROCESSING BLOCKS: -

Dialog modules

Dialog modules are defined using the following pair of statements:

MODULE <mod> OUTPUT|[INPUT].


...
ENDMODULE

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 screen 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

List processor events:

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 GET events.

*-------------------------------------------------------------*
* Program : Z_TRNG_BASICLIST_T009 *
* Title : Basic Report *
* Author : VIKRAM M *
* Description : Creating a Report for Material Details *
*-------------------------------------------------------------*
* M O D I F I C A T I O N L O G :
*-------------------------------------------------------------*
* Date Correction Programmer Descr of Change
**===============================*
* 06/01/2007 VIKRAM M Initial Implementation
**------------------------------------------------------------*
REPORT z_trng_basiclist_t009 NO STANDARD PAGE HEADING
LINE-COUNT 30(3) LINE-SIZE 150
MESSAGE-ID zid.
*-------------TABLE DECLERATION.------------------------*
TABLES: mara."marc.
TYPES : BEGIN OF str_1,
matnr TYPE mara-matnr, "MATERIAL NUMBER.
ernam TYPE mara-ernam, "NAME OF PERSON
mtart TYPE mara-mtart, "MATERIAL TYPE.

- 54 -
SAP –ABAP BOOK

END OF str_1.
*-----INTERNALTABLE DECLERATION.
DATA: it_1 TYPE TABLE OF str_1 WITH HEADER LINE.
*-----SELCTION-SCREEN .
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS so_matnr FOR mara-matnr.
SELECTION-SCREEN END OF BLOCK b1.
*-----INITIALIZATION.
INITIALIZATION.
so_matnr-low = '40'.
so_matnr-high = '1000'.
APPEND so_matnr.
*------AT SELECTION-SCREEN.
AT SELECTION-SCREEN.
SELECT SINGLE * FROM mara
INTO CORRESPONDING FIELDS OF it_1
WHERE matnr IN so_matnr.
IF sy-subrc NE 0.
MESSAGE i001.
ENDIF.
*-----START OF SELECTION EVENT.
START-OF-SELECTION.
SELECT matnr ernam mtart
FROM mara
INTO CORRESPONDING FIELDS OF TABLE it_1
WHERE matnr IN so_matnr.
*-----END OF SELECTION EVENT.
END-OF-SELECTION.
LOOP AT it_1.
WRITE :/ sy-vline, 2(6) sy-tabix,
sy-vline, 25 it_1-matnr, 46(10)
sy-vline, 65 it_1-ernam, 93(10)
sy-vline,115 it_1-mtart, 140(10)
sy-vline.
ULINE.
ENDLOOP.
HIDE it_1-matnr.
*-----DISPLAYING PAGE-HEADING.
TOP-OF-PAGE.
ULINE.
WRITE: 50 'MATERIAL DETAILS'.
ULINE.
WRITE:/ sy-vline, 'SL.NO' CENTERED COLOR 1,
sy-vline, 20 'MATERIAL NUMBER' CENTERED COLOR 1, 46
sy-vline, 58 'NAME OF PERSON CREATED' CENTERED COLOR 1, 93
sy-vline, 110 'MATERIAL TYPE'CENTERED COLOR 1, 140
sy-vline.
ULINE.
*-----DISPLAYING END OF PAGE.
END-OF-PAGE.
ULINE.

- 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.

 System Fields for Details Lists

After each user action on a list, the following ABAP system fields will be set in the corresponding
event block:

System field
Information
SY-LSIND Index of the list created during the current event (basic list = 0)
SY-LISTI Index of the list level from which the event was triggered
SY-LILLI Absolute number of the line from which the event was triggered
SY-LISEL Contents of the line from which the event was triggered
SY-CUROW Position of the line in the window from which the event was triggered (counting
starts with 1)
SY-CUCOL Position of the column in the window from which the event was triggered (counting
starts with 2)

- 56 -
SAP –ABAP BOOK

SY-CPAGE Page number of the first displayed page of the list from which the event was
triggered
SY-STARO Number of the first line of the first page displayed of the list from which the event
was triggered (counting starts with 1). This line may contain the page header.
SY-STACO Number of the first column displayed in the list from which the event was triggered
(counting starts with 1)
SY- Function code that triggered the event
UCOMM
SY-PFKEY Status of the list currently being displayed.

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.

 The Standard List Status

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

SET PF-STATUS space.

This default interface always contains at least the functions described in the Standard 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 appears in the application toolbar. During 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.

 Setting a Dialog Status

You set the dialog status for lists in the same way as for normal screens, that is, using the statement

SET PF-STATUS <stat> [EXCLUDING <f>|<itab>]


[OF PROGRAM <prog>]
[IMMEDIATELY].

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 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.

 Setting a Title for a List

As with normal screens, you can set a title for a list as follows:

SET TITLEBAR <ttl> [WITH <g1> ... <g9>]


[OF PROGRAM <prog>].

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.

 Event Block for Function Code PICK

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 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.

 Event Block for User-Defined Function Codes

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.

 Triggering a List Event from the Program

You can trigger a list event from the program as follows:

SET USER-COMMAND <fc>.

- 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.

 Lists in Dialog Boxes

You can display a list in a dialog box instead of on the full screen using the WINDOW statement:

WINDOW STARTING AT <left> <upper> [ENDING AT <right> <lower>].

 Passing Data Automatically

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.

 Passing Data by Program Statements

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.

• by the READ LINE statement.

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.

 Reading Lines from Lists

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 READ LINE statement:

READ LINE <lin> [INDEX <idx>]


[FIELD VALUE <f1> [INTO <g 1>] ... <f n> [INTO <g n>]]
[OF CURRENT PAGE|OF PAGE <p>].

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.

The options have the following effects:

• INDEX <idx>

- 61 -
SAP –ABAP BOOK

The system reads the information for line <lin> from the list of level <idx>.

• 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 <f1> [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.

 Reading Lists at the Cursor Position

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.

For field information, use this syntax:

GET CURSOR FIELD <f> [OFFSET <off>] [LINE <lin>]


[VALUE <val>] [LENGTH <len>].

This statement transfers the name of the field on which the cursor is positioned during 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 the name.

- 62 -
SAP –ABAP BOOK

The options have the following effects:

• 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>

The field <lin> contains the number of the list line on which the cursor is positioned (SY-LILLI).

• VALUE <val>

The field <val> contains the character string output representation of the field on which the cursor
is positioned. The representation includes formatting characters.

• 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 characters.

• LENGTH <len>

The field <len> contains the output length of the line on which the cursor is positioned.

 Determining the Attributes of Lists

If you need to know the attributes of list levels that are not stored in system variables, you can use
the DESCRIBE LIST statement.

To retrieve the number of lines or pages of a list, use:

- 63 -
SAP –ABAP BOOK

DESCRIBE LIST NUMBER OF LINES|PAGES <n> [INDEX <idx>].

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, the system sets SY-SUBRC unequal to 0, otherwise to 0.

To retrieve the page number for a certain line number, use:

DESCRIBE LIST LINE <lin> PAGE <pag> [INDEX <idx>].

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. Otherwise, it is 0.

To retrieve the attributes of a certain page, use:

DESCRIBE LIST PAGE <pag> [INDEX <idx>] [<options>]

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.

The <options> of the statement are:

• LINE-SIZE <col>

writes the page width into the variable <col>.

• LINE-COUNT <len>

writes the page length into the variable <len>.

• LINES <lin>

writes the number of displayed lines into the variable <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.

 Scrolling in Detail Lists

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 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 (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.

SCROLL LIST LEFT BY 12 PLACES

SCROLL LIST RIGHT BY 12 PLACES

 Setting the Cursor from within the Program

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 system 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.

 Setting the Cursor Explicitly

To set the cursor to a certain position in the output window, use:

SET CURSOR <col> <lin>.

This statement sets the cursor to column <col> of line <lin> of the output window.

 Setting the Cursor to a Field

To set the cursor to a certain field on a line of the displayed list, use:

SET CURSOR FIELD <f> LINE <lin> [OFFSET <off>].

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 screen.

 Modifying List Lines

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:

MODIFY LINE <n> [INDEX <idx>|OF CURRENT PAGE|OF PAGE <p>]


[<modifications>].
Without the first line of options, this statement modifies line <n> of the list on which an interactive
event occurred (index SY-LISTI).

 Switching Between Screen and List Processing

To pass control from the dialog processor to the list processor, you must include the following
statement in one of the dialog modules:

LEAVE TO LIST-PROCESSING [AND RETURN TO SCREEN <nnnn>].

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.

You can leave list processing in two ways:

• By leaving the basic list using the Back, Exit, or Cancel function.
• By using the following statement during list processing:

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.

1. First, use the

LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.

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 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.

 Calling Screens from List Processing

- 67 -
SAP –ABAP BOOK

To call a screen from list processing, use the statement

CALL SCREEN <nnnn>.

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:-

If the user chooses Execute + print on the selection screen of the report, the system displays the
Print List Output dialog window before creating the list. The user enters the print parameters. The
function module SET_PRINT_PARAMETERS allows you to set default values for the dialog box

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)

 Specifying the Message Dynamically

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.

 Messages and Exceptions

Within function modules and methods, you can use the RAISING addition in the MESSAGE
statement to trigger exception:

- 68 -
SAP –ABAP BOOK

MESSAGE..... RAISING <exc>.

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.

E Error Depending on the program context, an error dialog appears or


the program terminates.

I Information The message appears in a dialog box. Once the user has confirmed
the message, the program continues immediately after the
MESSAGE statement.

S Status The program continues normally after the MESSAGE statement,


and the message is displayed in the status bar of the next screen.

W Warning Depending on the program context, an error dialog appears or


the program terminates.

X Exit No message is displayed, and the program terminates with a short


dump. Program terminations with a short dump normally only
occur when a runtime error occurs. Message type X allows you to
force a program termination. The short dump contains the message
ID.

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

 Leaving Event Blocks Using STOP

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.

 Leaving Event Blocks Using EXIT

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.

 Leaving Event Blocks Using CHECK

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

 Leaving a GET Event Block Using REJECT

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

The statement REJECT [<dbtab>].

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
*&--------------------------------------------------------*

REPORT Z_TRNG_REPORT02_T010 NO STANDARD PAGE HEADING


LINE-COUNT 25(1). "RESERVE 3 LINES .

******* TABLE DECLARATION


TABLES : VBAK.

**** STRUCTURE DECLARATION

TYPES : BEGIN OF TY_VBAK,


CB1 TYPE C,
VBELN TYPE VBELN,
ERDAT TYPE ERDAT,
NETWR TYPE NETWR,
END OF TY_VBAK,

BEGIN OF TY_VBAP,
VBELN TYPE VBELN,
POSNR TYPE POSNR,
MATNR TYPE MATNR,
END OF TY_VBAP.

*** INTERNAL TABLE & WORK AREA DECLARATION.

- 71 -
SAP –ABAP BOOK

DATA : IT_VBAK TYPE TABLE OF TY_VBAK,


WA_VBAK TYPE TY_VBAK,

IT_VBAP TYPE TABLE OF TY_VBAP,


WA_VBAP TYPE TY_VBAP,
V_NETWR TYPE vbak-NETWR.

********* SELECTION-SCREEN DESIGN

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS so_vbeln FOR vbAk-vbeln.

SELECTION-SCREEN END OF BLOCK b1.

**** 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.

IF NOT it_VBAK[] IS INITIAL.

LOOP AT it_VBAK INTO wa_VBAK.


*** v_netwr = v_netwr + wa_vbak-netwr.
WRITE : /5 WA_VBAK-CB1 AS CHECKBOX,
15 wa_VBAK-VBELN,
35 wa_VBAK-ERDAT,
55 wa_VBAK-NETWR.
HIDE WA_VBAK-VBELN.
* ULINE.
AT LAST.
SUM.
WRITE : / 'TOTAL OF NETWR ', 55 WA_VBAK-NETWR.
ENDAT.
ENDLOOP.

- 72 -
SAP –ABAP BOOK

ENDIF.

*****AT LINE SELECTION

AT LINE-SELECTION.
CASE SY-LSIND.
WHEN '1'.
SELECT VBELN
POSNR
MATNR FROM VBAP INTO TABLE it_VBAP WHERE VBELN = WA_VBAK-
VBELN.

IF NOT it_VBAP[] IS INITIAL.

LOOP AT it_VBAP INTO wa_VBAP.

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

*& Author: VIKRAM M *


*& Desc : This report retrieve the sales document *
* related info & associated item information and *
* displays & results in the basic list and secondary list. *
*&---------------------------------------------------------------------------------------------------*
*&---- M O D I FI C A T I O N---L O G
*&-------------------------------------------------------------
*& DATE TRANSPORT# CHANGED_BY DESCRIPTION
*&--------- ------------ ---------- ------------------------
*& 01/11/07 N/A VIKRAM M Initial creation.
*&-------------------------------------------------------------
REPORT z_trng_shiptoparty_t009 NO STANDARD PAGE HEADING
LINE-COUNT 37(3) MESSAGE-ID zsap.

*-----TABLES------------------------------------------------*
TABLES: vbak,kna1.

*-----DATA 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,

BEGIN OF it_vbap OCCURS 0,


vbeln TYPE vbap-vbeln, "Sales Document
posnr TYPE vbap-posnr, "Sales Document Item
matnr TYPE vbap-matnr, "Material number
matkl TYPE vbap-matkl, "Material Group
END OF it_vbap,

BEGIN OF it_vbeln OCCURS 0,


vbeln TYPE vbak-vbeln,
END OF it_vbeln,

checkfield,
v_field LIKE dd03l-fieldname,
v_value LIKE vbak-vbeln,
v_words LIKE spell. "Amount in words

*-----SELECTION-SCREEN---------------------------------*
SELECT-OPTIONS so_vbeln FOR vbak-vbeln.

START-OF-SELECTION.
*-----POPULATING OWN GUI STATUS------------------*

- 75 -
SAP –ABAP BOOK

SET PF-STATUS 'MENU'.

*-----FETCHING DATAS FROM TABLE------------------*


SELECT vbpa~kunnr vbak~vbeln vbak~erdat vbak~ernam vbak~netwr
INTO TABLE it_sales
FROM vbak JOIN vbpa
ON vbak~vbeln = vbpa~vbeln
AND vbpa~parvw = 'WE'
WHERE vbak~vbeln IN so_vbeln.

SELECT vbeln posnr matnr


FROM vbap
INTO TABLE it_vbap FOR ALL ENTRIES IN it_sales
WHERE vbeln = it_sales-vbeln.

END-OF-SELECTION.
SORT it_sales BY kunnr.
*-----DISPLAYING DATA FROM BASIC LIST---------------*
LOOP AT it_sales.
AT NEW kunnr.

*-----DISPLAYING DATA IN NEW PAGE-------------------*


NEW-PAGE.
SELECT SINGLE name1
FROM kna1
INTO kna1-name1
WHERE kunnr EQ it_sales-kunnr.
ENDAT.

*-----RETRIEVE MATERIAL DETAILS FROM TABLE--------*


WRITE:/1 sy-vline, checkfield AS CHECKBOX,
5 it_sales-vbeln,
13 sy-vline,
14 it_sales-erdat,
26 sy-vline,
27 it_sales-ernam,
38 sy-vline,
39(17) it_sales-netwr CURRENCY '2' RIGHT-JUSTIFIED,
55 sy-vline.
ULINE:/(55).

AT END OF kunnr.
SUM.
"FORMAT COLOR 3.
WRITE:/27 text-249 COLOR 3,it_sales-netwr CURRENCY '2' COLOR 3.
FORMAT COLOR OFF.

*-----FUNCTION MODULE TO DISPLAY IN WORDS-------*

- 76 -
SAP –ABAP BOOK

CALL FUNCTION 'SPELL_AMOUNT'


EXPORTING
amount = it_sales-netwr
currency = 'INR'
language = sy-langu
IMPORTING
in_words = v_words.
WRITE: / text-333 COLOR 3,18 v_words-word COLOR 5. "DISPLAY TOTAL IN
WORDS
WRITE / v_words-decword UNDER v_words-word COLOR 5.
ENDAT.

AT LAST.
SUM.
FORMAT COLOR 3.
WRITE:/7 text-241,it_sales-netwr CURRENCY '2'.
FORMAT COLOR OFF.
ENDAT.
ENDLOOP.

*-----HEADER FOR PAGES---------------------------------*


TOP-OF-PAGE.
WRITE:35 text-007 COLOR 1,
/ text-221 COLOR 2,
text-223 COLOR 1,17 kna1-name1,
/ text-222 COLOR 2,17 it_sales-kunnr.
ULINE:/(55).

*-----RETRIEVE MATERIAL DETAILS FROM TABLE--------*


WRITE:/1 sy-vline,
2 text-230 COLOR 4,
13 sy-vline,
14 text-231 COLOR 4,
26 sy-vline,
27 text-232 COLOR 4,
38 sy-vline,
39 text-101 COLOR 4,
55 sy-vline.
ULINE:/(55).

AT USER-COMMAND.

*-----USER BASED OPERATION-----------------------------


IF sy-ucomm = 'ITEM' AND sy-lsind = '1'.
DO.
READ LINE sy-index FIELD VALUE : checkfield,it_sales-vbeln.
IF checkfield EQ 'X'.
UNPACK it_sales-vbeln TO it_sales-vbeln.

- 77 -
SAP –ABAP BOOK

APPEND it_sales-vbeln TO it_vbeln.


CLEAR it_vbeln.
ELSEIF sy-subrc NE 0.
EXIT.
ENDIF.
CLEAR: checkfield,it_sales-vbeln.
ENDDO.

*-----RETRIVEING ITEM DETAILS IN LIST---------------*


LOOP AT it_vbeln.
LOOP AT it_vbap WHERE vbeln = it_vbeln-vbeln.

*-----RETRIEVE MATERIAL DETAILS FROM TABLE-------*


WRITE:/ sy-vline,2 it_vbap-vbeln HOTSPOT,
23 sy-vline,24 it_vbap-posnr,
43 sy-vline,44 it_vbap-matnr HOTSPOT,
59 sy-vline,60 it_vbap-matkl,
74 sy-vline.
ULINE:/(74).
ENDLOOP.
ENDLOOP.
REFRESH it_vbeln.
ENDIF.
SET PF-STATUS space. "Remove the own GUI Status

*-----CALLING 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.

*-----PAGE HEADING DURING LINE SELECTION----------*


TOP-OF-PAGE DURING LINE-SELECTION.
WRITE:25 text-225 COLOR 1 CENTERED.
ULINE:/(74).

- 78 -
SAP –ABAP BOOK

*-----RETRIEVE MATERIAL DETAILS FROM TABLE--------*


WRITE:/ sy-vline,2 text-226 COLOR 2, "SALES DOCUMNET NUMBER
23 sy-vline,24 text-227 COLOR 2, "SALES DOCUMENT ITEM
43 sy-vline,44 text-228 COLOR 2, "MATERIAL NUMBER
59 sy-vline,60 text-229 COLOR 2, "MATERIAL GROUP
74 sy-vline.
ULINE:/(74).

JH SOFTECH

SAP ABAP - BOOK 3

JH SOFTECH
303,Kaveri Queen’s Building, Opp Aradhana Theater, Tarnaka, Hyderabad.
Ph: 040 – 40202178 , 040 – 65870996
9293002250
www.jhsoftech.com

ALV

- 79 -
SAP –ABAP BOOK

ABAP LIST VIEWER

The ABAP List Viewer unifies and identifies and simplifies the uses of lists in the 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 no hierarchical relationship to each other.
• Multilevel Sequential level lists consist any number of lines that 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 subordinate 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 .Some 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

1. REUSE_ALV_LIST_DISPLAY: - (This function module is used to display simple list.)


IMPORTING
VALUE(I_INTERFACE_CHECK) DEFAULT SPACE
VALUE(I_CALLBACK_PROGRAM) LIKE SY-REPID DEFAULT SPACE
VALUE(I_CALLBACK_PF_STATUS_SET) TYPE SLIS_FORMNAME
DEFAULT SPACE
VALUE(I_CALLBACK_USER_COMMAND) TYPE SLIS_FORMNAME
DEFAULT SPACE
VALUE(I_STRUCTURE_NAME) LIKE DD02L-TABNAME OPTIONAL
VALUE(IS_LAYOUT) TYPE SLIS_LAYOUT_ALV OPTIONAL
VALUE(IT_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV OPTIONAL
VALUE(IT_EXCLUDING) TYPE SLIS_T_EXTAB OPTIONAL
VALUE(IT_SPECIAL_GROUPS) TYPE SLIS_T_SP_GROUP_ALV
OPTIONAL
VALUE(IT_SORT) TYPE SLIS_T_SORTINFO_ALV OPTIONAL
VALUE(IT_FILTER) TYPE SLIS_T_FILTER_ALV OPTIONAL
VALUE(IS_SEL_HIDE) TYPE SLIS_SEL_HIDE_ALV OPTIONAL
VALUE(I_DEFAULT) DEFAULT 'X'
VALUE(I_SAVE) DEFAULT SPACE
VALUE(IS_VARIANT) LIKE DISVARIANT STRUCTURE DISVARIANT DEFAULT SPACE
VALUE(IT_EVENTS) TYPE SLIS_T_EVENT OPTIONAL
VALUE(IT_EVENT_EXIT) TYPE SLIS_T_EVENT_EXIT OPTIONAL
VALUE(IS_PRINT) TYPE SLIS_PRINT_ALV OPTIONAL
VALUE(IS_REPREP_ID) TYPE SLIS_REPREP_ID OPTIONAL
VALUE(I_SCREEN_START_COLUMN) DEFAULT 0

- 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).

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:

FORM set_pf_status USING rt_extab TYPE slis_t_extab


The table RT_EXTAB contains the function codes which are hidden in the standard interface.

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.

The interface of the specified form routine must be defined as follows:

FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.


The parameter R_UCOMM contains the function code called.

The structure RS_SELFIELD contains the following information:


o tabname : internal output table name
o tabindex : internal output table index
o fieldname: field name
o endsum : cursor is on the final total row

- 81 -
SAP –ABAP BOOK

o sumindex : if >0, the cursor is on a subtotal row


o value : field contents
o refresh : (exporting) list is to be refreshed
o col_stable:(exporting) keep column positions in refresh
o row_stable:(exporting) keep row positions in refresh
o exit :(exporting) leave list (and ALV)
o before_action: jump before performing standard action
o after_action : jump after performing standard 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 struct or LIKE
struct), the field catalog can be built-up automatically by passing the structure name.

The field catalog is internally built up for this structure as follows:


o All fields are in the list (NO_OUT = SPACE) except fields of data type
CLNT.
o The key fields of the Dictionary structure are also key fields in the field catalog.
o Dictionary references to unit fields are copied if the reference
fields are in the structure.
o If a field catalog is also passed as parameter, the structure
information is combined with this field catalog.

IS_LAYOUT:- (list layout specifications)


Output list description structure.

The parameters are described under the following headers:


o Display options
o Exceptions
o Totals
o Interaction
o Detail screen
o Display variants (only for hierarchical-sequential lists)
o Color
o Other

Note the section 'Default'.

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

Value set: SPACE, 'X'


Not relevant for: hierarchical-sequential lists and multiple-line
lists.
'X' = columns separated by SPACE

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 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

o lights_tabname
value set: SPACE, internal output table name
Only relevant for 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 be filled for
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 light', each subtotal which includes this record is also output with 'red
traffic light'.

Totals
o no_sumchoice
Value set: SPACE, 'X'
'X' = fields which are to be summed, passed by the calling program
(FIELDCAT-DO_SUM = 'X'). The user 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

Value set: SPACE, 'X'


'X' = value whose change triggers subtotals, provided by the calling
program.
The user should not be able to change this value interactively.
See also the documentation of the IMPORTING parameter IT_SORT.

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 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 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 indicated by
'*', if the column is wide enough.

o subtotals_text
Value set: SPACE, string(max.60)
' ' = in the first column of subtotal records, the subtotal is indicated by an 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 passed is output after the subtotal indicated by
'*', if the column is wide enough and the first column is not a subtotal criterion.
If it is a subtotal criterion, its value is repeated after the total, if the column is wide enough.

o numc_sum
Value set: SPACE, 'X'
' ' = By default NUMC fields cannot be totalled
'X' = NUMC fields can be 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 field 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

Value set: SPACE, internal output table name


Only relevant for hierarchical-sequential lists. Name of the internal
output table which contains the field in the parameter BOX_FIELDNAME.
If BOX_FIELDNAME is not empty, this field must also be filled for

- 84 -
SAP –ABAP BOOK

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

Only relevant for hierarchical-sequential lists


If hierarchical-sequential list items are to be expandable and collapsable, the internal header table must contain an
additional CHAR(1) field which contains the expansion status of the header entry.
The name of this field must be assigned to the parameter
IS_LAYOUT-EXPAND_FIELDNAME.
The initial value of the field in the header table is that the items are not displayed and the folder symbol

SYM_PLUS_FOLDER appears in the list before the header entry.

If the field contains 'X' for a header entry, the items for this header appear, and the folder symbol

SYM_MINUS_FOLDER appears on the list before the header entry.

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, this can be controlled via the 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'

Effect in 'user interface':


Case 1:
The ALV standard function code for F2 '&IC1' is left in the copied application interface, but F2 is to have a
function which is not under F2 in the interface (ALV standard function or application function).
Pass this function codeto ALV in the parameter F2CODE.
Case 2:
The ALV standard function code for F2 '&IC1' was deleted from the application interface and replaced by another
function code (ALV standard function or application function). Pass this function code to ALV in the parameter
F2CODE. This is the prerequisite for column selection in this case.
o confirmation_prompt
Value set: SPACE, 'X'
'X' = if one of the functions 'Back(F03)', 'Exit(F15)' or 'Cancel(F12)' occurs, a confirmation prompt appears.

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

Value set: SPACE, 'X'


'X' = activate Report/Report interface:
Prerequisite: application system (=> Report RKKBRSTI exists).
List module is a possible sender in the Report/Report interface logic
(poss. initialization of the interface...).
The calling report/module pool... of type RT=Report in
I_CALLBACK_PROGRAM is passed to the Report/Report interface as sender
report.
If the sender report is assigned to receiver reports in the table
TRSTI, the function code BEBx is active
(x = function code class).

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 the Re/Re interface. The
report restrictions and the key information of the selected records are passed to the Re/Re interface as selection
criteria.

For further information about the Report/Report interface see the


documentation of the function group 'RSTI'.

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 of the IMPORTING 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.

' ' = if the prerequisite is fulfilled, but the parameter is not set, the function code '&OL0' calls the display variant
popup in which you can show the visible fields in the field list by their groups. All fields in the field list are
visible by default. The user can go to the group views in the popup.
The fields can be classified into any number of logical groups (1:n).

'X' = a maximum of five logical groups can be formed. The display


Variant popup for each of these groups can be called by its own function in the interface. The fields in the field list
belong to this group. The ALV standard interface contains pushbuttons for the first three groups (the first three
entries in the internal table
IT_SPECIAL_GROUPS). The group text passed in IT_SPECIAL_GROUPS is
displayed as pushbutton text. The display variant popup for the fourth and fifth groups can be called via the right-
hand mouse key function selection.
When the display variant popup for a field group is called, that group is selected, but the user can change the group
view in the popup.
The function codes &OLx (x=1,2,3,4,5) call the display variant popups
for the respective group.
There are pushbuttons for the function codes &OL1, &OL2 and &OL3 in the ALV standard interface (function
group KKBL status STANDARD). The functions &OL4 and &OL5 only have function keys.

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

Value set: SPACE, 'X'


Not relevant for block lists (output of several lists consecutively)
' ' = The key columns defined in the field catalog by FIELDCAT-KEY =
'X' are fixed in the list output. These columns do not scroll horizontally. The item table key columns are fixed in
hierarchical-sequential lists. The header table key fields are not considered here.
'X' = key columns not fixed

The user can change these general settings interactively.


To fix a column by default which is not a key column, set the parameter to 'X' and control it via the field list.
See the documentation of the field list parameter FIELDCAT-FIX_COLUMN of the IMPORTING parameter
<DS:FU.REUSE_ALV_LIST_DISPLAY
IT_FIELDCAT>IT_FIELDCAT.

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 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.

Display variants (only relevant for hierarchical-sequential lists)


o header_text
Value set: SPACE, CHAR(20)

Only relevant for hierarchical-sequential lists

- 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 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 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 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 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 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 be colored at record or cell level using the
complex coloring which is described in the next parameter COLTAB_FIELDNAME.
To color columns, see the 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:

Color table-FIELDNAME = field name of the cell to be colored


Color table-COLOR-COL = color number (1 - 9)
Color table-COLOR-INT = bold (0 = off, 1 = on)
Color table-COLOR-INT = inverse (0 = off, 1 = on)
Color table-NOKEYCOL = ignore key coloring ('X' = yes, ' ' = no)

- 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 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 of the 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 should not contain the event END_OF_LIST or at least be assigned to a different
form routine name from the first call.

IT_FIELDCAT: -

Field catalog containing descriptions of the list output fields (usually


a subset of the internal output table fields).

A field catalog is required for every ALV list output.

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.

See also the documentation of the function module


REUSE_ALV_FIELDCATALOG_MERGE.

The minimal field catalog is documented under 'default'. The caller can use the other optional parameters to assign
output attributes to a field which 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 of the IMPORTING paramter I_STRUCTURE_NAME.

Positioning
o row_pos (row 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 be defined by the user interactively if the default list is one-line.
The parameter specifies the relative output line of the column in a multi-line list.

o col_pos (column position)


Value set: 0, 1 - 60
Only relevant when the default relative column positions differ from the field catalog field sequence.

- 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 this 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 name (required parameter)
Name of the internal output table field which is described by this field catalog entry

o tabname (internal output table)


Value set: SPACE, internal output table name
This parameter is used in 'manual' field catalog build-up only for
hierarchical-sequential lists.
Name of the internal output table which contains the field
FIELDCAT-FIELDNAME.

Data Dictionary reference


o ref_fieldname (reference field name)
Value set: SPACE, Data Dictionary field name
Name of the Data Dictionary field referred to.
This parameter is only used when the internal output table field described by the current field catalog entry has a
reference to the Data Dictionary (not a program field), and the field name in the internal output table is different
from the name of the field in the nambiguous and is therefore explicitly output by the caller in the list header, the
field catalog units field entry can take the parameter FIELDCAT-TECH = 'X'.

The association of a value field to a unit affects the output as follows:


- appropriate decimal places display for the unit
- an initialized field with a link to a non-initial unit is output as '0' for the unit (if FIELDCAT-NO_ZERO is
initial). When this field is summed, this unit affects whether the units are homogeneous.
- an initialized field with a link to an initial unit is output as SPACE. When this field is summed, the unit SPACE
does not affect the homogeneity of the units.
- When non-initial fields with an initial unit are summed, the unit SPACE is considered to be a unit.
Link to currency unit
o cfieldname (currency unit field name)
Value set: SPACE, output table field name
Only relevant for amount columns with associated unit.
Name of the internal output table field containing the currency unit associated with the amount field FIELDCAT-
FIELDNAME.
The field in FIELDCAT-CFIELDNAME must have its own field catalog entry.

o ctabname (internal currency unit field output table)


Value set: SPACE, output table field name only relevant for hierarchical-sequential lists Name of the internal
output table containing the FIELDCAT-CFIELDNAME field.

Link to measurement unit


o qfieldname (measurement unit field name)
Value set: SPACE, output table field name
Only relevant for quantity columns with unit link.
Name of the internal output table field containing the measurement unit associated with the quantity field
FIELDCAT-FIELDNAME.
The field in FIELDCAT-QFIELDNAME must have its own field catalog entry.

o qtabname (internal measurement unit field output table)


Value set: SPACE, output table field name
Only relevant for hierarchical-sequential lists
Name of the internal output table containing the FIELDCAT-QFIELDNAME field.

- 90 -
SAP –ABAP BOOK

Column output options


o outputlen (column width)
Value set: 0 (initial), n
For fields with a Data Dictionary link this parameter can be left initial.
For fields without a Data Dictionary link (program field) the parameter must be given the value of the desired
field list output length (column width).
Initial = column width is the output length of the referred Data
Dictionary field (domain).
n = column width is n characters

o key (key column)


Value set: SPACE, 'X'
'X' = key field (key field output in color)
Key fields can not be interactively hidden.
Parameter FIELDCAT-NO_OUT must be left initial.
For exceptions see the documentation of the FIELDCAT-KEY_SEL parameter.

o key_sel (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 no_out (field in field list)


Value set: SPACE, 'X'
'X' = field is not displayed in the current list.
The user can interactively choose the field for output from the field list.
The user can display the contents of these fields at line level using the 'Detail' function.
See also the 'Detail screen' documentation of the parameter IS_LAYOUT.

o tech (technical 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 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 must begin with C)
- x: color number
- y: bold
- z: inverse

o hotspot (column as hotspot)


Value set: SPACE, 'X'
'X' = column cells are output as hotspots

o fix_column (fix column)


Value set: SPACE, 'X'
Not relevant for block lists (output of several lists consecutively)
'X' = column fixed (does not scroll horizontally)
All columns to be fixed must have this flag, starting from the left.

- 91 -
SAP –ABAP BOOK

IF A COLUMN WITHOUT THIS FLAG IS OUTPUT, ONLY THE COLUMNS TO THE LEFT

of this column are fixed.


The user can change the column fixing interactively.
See also the documentation of the Layout parameter
IS_LAYOUT-NO_KEYFIX of the IMPORTING paramter IS_LAYOUT.

o do_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 called by the user interactively.

o no_sum (sums forbidden)


Value set: SPACE, 'X'
'X' = no sum can be calculated over this field, although the data type of the field would allow summing.

o input (column ready for input)


Function not available

Format column contents


o icon
Value set: SPACE, 'X'
'X' = column contents to be output as an icon.
The internal output table column contents must be valid icon strings
(@xx@).
The caller must consider the printability of icons.

• symbol

Value set: SPACE, 'X'


'X' = column contents are to be output as a symbol.
The internal output table column must be a valid symbol character.
The caller must consider the printability of symbols.
Symbols can usually be printed, but may not always be output correctly, depending on the printer configuration.

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

'R' = right-justified output


'L' = left-justified output
'C' = centered output
The justification of the column header always follows the justification of the columns. Independent justification of
the column header is not possible.

o lzero (leading zeros)


Value set: SPACE, 'X'
Only relevant for fields of data type NUMC
ALV outputs NUMC fields right-justified without leading zeros by default.
'X' = output with leading zeros

Note: If a NUMC field is output left-justified or centered by


FIELDCAT-JUST, leading zeros are output.
If the output of leading zeros is suppressed by a Data Dictionary reference ALPHA conversion exit, the output is
always left justified.

- 92 -
SAP –ABAP BOOK

o no_sign (no +/- sign)


Value set: SPACE, 'X'
Only relevant for value fields
'X' = value output without +/ sign

o no_zero (suppress zeros)


Value set: SPACE, 'X'
Only relevant for value fields
'X' = suppress zeros

o edit_mask (field formatting)


Value set: SPACE, template
template = see documentation of WRITE formatting option
USING EDIT MASK template
The output conversion conv can be made by template = '== conv'.

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_l (long field label)

o seltext_m (medium field label)

o seltext_s (short 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)
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 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 the same as the
external format output length (FIELDCAT-DDIC_OUTPUTLEN).

o intlen (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

See also the documentation of the parameter FIELDCAT-DDIC_OUTPUTLEN


n = internal format field output length

o rollname (data element)


Value set: SPACE, Data Dictionary data element name
F1 help can be provided for a program field without a Data Dictionary reference, or F1 help which differs from
the Data Dictionary help can be provided for a field with a Data Dictionary reference, using this parameter.
When F1 help is called for this field, the documentation of the specified data element is displayed.

IF THE FIELDCAT-ROLLNAME IS INITIAL FOR FIELDS WITH A DATA DICTIONARY

reference, the documentation of the data element of the referred Data


Dictionary field is output.
Others
o sp_group (field group key)
Value set: SPACE, CHAR(1)
Field group key.
Keys are assigned to group names in the IT_SPECIAL_GROUPS parameter
(see also the documentation of the parameter IT_SPECIAL_GROUPS).
When such an assignment is made in the field catalog and in
IT_SPECIAL_GROUPS, the fields are grouped correspondingly in the
display variant popup.

o reprep (Report/Report interface selection criterion)


Value set: SPACE, 'X'
Prerequisites:
- The system contains the Report/Report interface
(function group RSTI, table TRSTI)
- Parameter LAYOUT-REPREP = 'X'
(see also the documentation of the parameter
LAYOUT-REPREP of the IMPORTING parameter
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

o The following entries are usually sufficient for internal table fields
with a reference to a field defined in the Data Dictionary :
- fieldname
- ref_tabname

Notes:

ALV gets the remaining information from the Data Dictionary.

If no relative column position (COL_POS) is specified, the fields are output in the list in the order in which they
were added to the field catalog.

REF_FIELDNAME need only be specifid when the name of the internal table
field differs from the name of the referred Data Dictionary field.

Information which is explicitly entered in the field catalog is not overwritten by information from the 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 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.

If the parameters SELTEXT_S, SELTEXT_M, SELTEXT_L, and REPTEXT_DDIC


contain appropriate field labels, the program field column headers are also adjusted appropriately when the column
width changes.

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 :-

If fields have been grouped in the field catalog by a shared value of the parameter SP_GROUP, the technical key of
the group (FIELDCAT-SP_GROUP) is assigned to the field group text in this internal table.

IT_SORT: - Sort criteria for first list display

The caller specifies the sorting and/or subtotalling of the basic list in the internal table IT_SORT.

This internal table has the following fields:


o spos
Sort sequence

- 95 -
SAP –ABAP BOOK

o fieldname
Internal output table field name

o tabname
Only relevant for hierarchical-sequential lists
Name of the internal output table

o up

'X' = SORT IN ASCENDING ORDER

O DOWN

'X' = sort in descending order

Subtot
'X' = subtotal at group value change

o group
'* ' = New page 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 USE ONLY)

o expa
Prerequisite:
IT_SORT-SUBTOT = 'X', 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 table

Filter criteria which result, e.g. from explicitly loading an initial display variant, can be passed to list output in this
parameter.

This table should never be built-up 'manually'.


IS_SEL_HIDE: -

Only relevant when the layout parameter


LAYOUT-GET_SELINFOS of the IMPORTING structure IS_LAYOUT is set.

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: Selection info table

o t_entries-mode: 'A' = output the selection info for the current


table record additionally in the info popup.
'D' = do not output select option or SELNAME
parameter selection info in the popup.

o t_entries-selname: (only used in 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 for which selection
information is to be output.

o t_entries-table: DDIC table names of t_entries-field.

o t_entries-stext: Field name in info popup.


If t_entries-field and t_entries-table have been
entered, this text is taken from DDIC.
o t_entries-valuf: Selection condition 'from' value (external format)

o t_entries-valut: Selection condition 'to' value (external format)

o t_entries-sign0: (I)nclusive (E)xclusive

o t_entries-optio: All values of the select options Option field


allowed.

The remaining fields are used internally and are not relevant for the
caller.
I_DEFAULT: -

Initial variant logic active/inactive.


Prerequisite:
The parameter IS_VARIANT has the appropriate value.
See also the documentation of the IMPORTING parameter IS_VARIANT.
Value Range:-
‘ ‘ = no variant can be defined

‘X’= VARIANT CAN BE DEFINED

I_SAVE: -

Controls the storage mode


Prerequisite:
The IS_VARIANT parameter has the appropriate value.
See also the documentation of the IMPORTING parameter IS_VARIANT.

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 'X' = standard save


Display variants can be saved as standard display variants.
User-specific saving is not possible.

o 'U' = only user-specific saving

The user can only save display variants user-specifically

o 'A' = standard and 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

IS_VARIANT- Variant Information

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.

See also the documentation of the IMPORTING parameter I_SAVE.

A variant is identified uniquely by:


• the program to which it is assigned (REPORT)

o the handle if, e.g. several lists with various structures and data are called (HANDLE) in a program
(I_CALLBACK_PROGRAM)
The handle is a unique user-assigned CHAR(4) field, which assigns the call to the current internal output table
structure.
Example:
Various lists can be output in program x, depending on a user action.
Display variants are to be able to be defined for each of these lists.
This functionality is guaranteed by assigning a HANDLE for each list.
If variants are saved for this program and handle, the handle must not change.

o the logical group if, e.g. the same list is made with different settings (LOG_GROUP) via different transactions.
The logical group is a unique user-assigned CHAR(4) field which determines the assignment.
Example:
The program x is called via the transactions T1 and T2. The field 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.

o the user name, if variants are saved user-specifically (USERNAME)


This parameter is never entered manually as the variant name is unique.

• the variant name (VARIANT).


This parameter is only to be entered if a particular variant is to be read and the list is to be output with this variant
via this structure.

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: -

This table tells ALV which events are processed by the caller by CALLBACK.

The table of possible events per list type can be initialized using the module REUSE_ALV_EVENTS_GET.

You can display the names of the constants in the type pools SLIS which represent the individual events using the
individual test function in the function module
REUSE_ALV_EVENT_NAMES_GET. Only events with a form routine name are
processed.

The table structure contains the fields:


o IT_EVENTS-NAME
Name of the Callback event.
Possible Callback events:
- Action
USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD
Process actions on the list
As this is a frequently-used Callback event, the form routine can also be passed directly in the interface in the
IMPORTING parameter I_CALLBACK_USER_COMMAND.

PF_STATUS_SET USING RT_EXTAB TYPE SLIS_T_EXTAB


If a user list status is to be set, it must be done in the form routine assigned to this event. The ALV function codes,
which must not be active, are in the Parameter RT_EXTAB. This table must be passed with the SET PF-STATUS
command (with inactive user function codes as well, if necessary).
The STANDARD status of the function group SALV should be used as a template for a user-specific status.
As this is a frequently-used Callback event, its form routine can also be passed directly in the interface in the
IMPORTING parameter
I_CALLBACK_PF_STATUS_SET.

ITEM_DATA_EXPAND USING RS_SELFIELD TYPE SLIS_SELFIELD


RFLG_ALL TYPE C
Only relevant for hierarchical-sequential lists using the layout parameter IS_LAYOUT-EXPAND_FIELDNAME of
the structure IS_LAYOUT.
Exit for passing item entries (ITEM table) for a header record, which was expanded interactively by the user.
RS_SELFIELD-TABINDEX contains the header table index for which the item entries are to be put in the global item
output table (T_OUTTAB_SLAVE). The Callback is only called if ALV has no items for a header which is to be
expanded.
RFLG_ALL is passed with 'X' if the user shows all items. The application must ensure that entries are not repeated in
the item table. RS_SELFIELD is initial in this case.

CALLER_EXIT USING RS_DATA


Is called at the beginning of the function module to make special settings. It is not usually used.

- List processing events

IMPORTANT: The application Callback routine 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

TOP_OF_LIST no USING parameter


Information output at the start of the list

END_OF_LIST no USING parameter


Information output at the end of the list

TOP_OF_PAGE no USING parameter


Equivalent to the list processing TOP-OF-PAGE event

END_OF_PAGE no USING parameter


Not available for hierarchical-sequential lists.
Information output at the end of a page. This is only called for printing.

TOP_OF_COVERPAGE no USING parameter


The selection information and list status are output together (if they exist) on a separate page by default. See also the
documentation of the parameters:
IS_PRINT-NO_COVERPAGE
IS_PRINT-NO_PRINT_SELINFOS
IS_PRINT-NO_PRINT_LISTINFOS
IS_LAYOUT-GET_SELINFOS
The user can format the header area of the 'cover page' himself or herself by specifying a Callback routine for this
event.

END_OF_COVERPAGE no USING parameter


Analogously to TOP_OF_COVERPAGE the user can add other information to the information output by ALV
(selection information, list status) at this event.

FOREIGN_TOP_OF_PAGE no USING parameter


The Top-of-page event is always processed in ALV and is only passed to the caller via the Callback mechanism. This
is still the case if the caller, e.g. by a user action, processes a branch list which was not formatted by ALV (e.g. a
popup with additional information about the list record selected and displayed by ALV).
In this case, top-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by
the caller. The event top-of-page still occurs in ALV. When ALV notices a top-of-page which was not caused by an
ALV output, the form routine in FOREIGN_TOP_OF_PAGE is called.

FOREIGN_END_OF_PAGE no USING parameter


The event end-of-page is always processed in ALV and only passed to the caller via callback. This is still the case,
e.g. when the caller processes a details list which was not formatted by ALV (e.g. a popup with further information
about selected list records
which were displayed by ALV).
In this case, end-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by
the caller. The event end-of-page still occurs in ALV. When ALV notices an end-of-page that was not caused by an
ALV output, the form routine in FOREIGN_END_OF_PAGE is called.

BEFORE_LINE_OUTPUT USING RS_LINEINFO TYPE SLIS_LINEINFO


Output information before each output line. Should only be used in justified cases because it costs a lot of
performance.

AFTER_LINE_OUTPUT USING RS_LINEINFO TYPE SLIS_LINEINFO


Output information after each output line. Should only be used in justified cases because it costs a lot of performance.

Internal use only


LIST_MODIFY USING R_TABNAME TYPE SLIS_TABNAME
R_INDEX LIKE SY-TABIX
R_INDEX_ITEM LIKE SY-TABIX
R_INDEX_SUM LIKE SY-TABIX

- 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.

See also the documentation of the IMPORTING parameter


I_CALLBACK_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 system
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.

The table fields are as follows:


o ucomm
Standard function code which is also passed in the callback event USER_COMMAND.
Example:
ucomm = '&OL0' means that the application also gets control at the display variant definition function code.

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 definition popup.
In the function code processing form 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 internal output table, if necessary.
If the application sets the SELFIELD-REFRESH flag (USER_COMMAND form
routine interface reference parameter) after the selection, the list is output again. Output fields added by the user
and reselected data
now appear.

IS_PRINT: -

PRINT CONTROL PARAMETER

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

Value set: SPACE, 'X'


'X' = do not print selection info (see LAYOUT-GET_SELINFOS)

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 be printed by the user in the footer area in the 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).

o NO_CHANGE_PRINT_PARAMS
Value set: SPACE, 'X'
SPACE = (default) The output format (number of columns) is dynamically
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: -

Only to be used if the list is output in a popup.


x coordinate of the top left-hand corner of the popup

I_SCREEN_START_LINE: -
Only to be used if the list is output 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 output 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.

E_EXIT_CAUSED_BY_CALLER: - delete list in the CALLBACK_USER_COMMAND


Parameter which states whether the caller left the list (SELFIELD-EXIT = 'X') in CALLBACK USER_COMMAND

ES_EXIT_CAUSED_BY_CALLER: - (HOW THE USER LEFT THE LIST)

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

o ES_EXIT_CAUSED_BY_USER-CANCEL = 'X' 'Cancel' occurred


o ES_EXIT_CAUSED_BY_USER-EXIT = 'X' 'Exit' occurred
T_OUTTAB: - (TABLE WITH DATA TO BE DISPLAYED)

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.

2. REUSE_ALV_HIERSEQ_LIST_DISPLAY: - (Used to display multilevel sequential list.)


IMPORTING
VALUE(I_INTERFACE_CHECK) DEFAULT SPACE
VALUE(I_CALLBACK_PROGRAM) LIKE SY-REPID OPTIONAL
VALUE(I_CALLBACK_PF_STATUS_SET) TYPE SLIS_FORMNAME
DEFAULT SPACE
VALUE(I_CALLBACK_USER_COMMAND) TYPE SLIS_FORMNAME
DEFAULT SPACE
VALUE(IS_LAYOUT) TYPE SLIS_LAYOUT_ALV OPTIONAL
VALUE(IT_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV OPTIONAL
VALUE(IT_EXCLUDING) TYPE SLIS_T_EXTAB OPTIONAL
VALUE(IT_SPECIAL_GROUPS) TYPE SLIS_T_SP_GROUP_ALV
OPTIONAL
VALUE(IT_SORT) TYPE SLIS_T_SORTINFO_ALV OPTIONAL
VALUE(IT_FILTER) TYPE SLIS_T_FILTER_ALV OPTIONAL
VALUE(IS_SEL_HIDE) TYPE SLIS_SEL_HIDE_ALV OPTIONAL
VALUE(I_SCREEN_START_COLUMN) DEFAULT 0
VALUE(I_SCREEN_START_LINE) DEFAULT 0
VALUE(I_SCREEN_END_COLUMN) DEFAULT 0
VALUE(I_SCREEN_END_LINE) DEFAULT 0
VALUE(I_DEFAULT) DEFAULT 'X'
VALUE(I_SAVE) DEFAULT SPACE
VALUE(IS_VARIANT) LIKE DISVARIANT
STRUCTURE DISVARIANT DEFAULT SPACE
VALUE(IT_EVENTS) TYPE SLIS_T_EVENT OPTIONAL
VALUE(IT_EVENT_EXIT) TYPE SLIS_T_EVENT_EXIT OPTIONAL
VALUE(I_TABNAME_HEADER) TYPE SLIS_TABNAME
VALUE(I_TABNAME_ITEM) TYPE SLIS_TABNAME
VALUE(I_STRUCTURE_NAME_HEADER) LIKE DD02L-TABNAME
OPTIONAL
VALUE(I_STRUCTURE_NAME_ITEM) LIKE DD02L-TABNAME
OPTIONAL
VALUE(IS_KEYINFO) TYPE SLIS_KEYINFO_ALV
VALUE(IS_PRINT) TYPE SLIS_PRINT_ALV OPTIONAL
VALUE(IS_REPREP_ID) TYPE SLIS_REPREP_ID OPTIONAL
EXPORTING
VALUE(E_EXIT_CAUSED_BY_CALLER)
VALUE(ES_EXIT_CAUSED_BY_USER) TYPE SLIS_EXIT_BY_USER

- 103 -
SAP –ABAP BOOK

TABLES
T_OUTTAB_HEADER
T_OUTTAB_ITEM
EXCEPTIONS
PROGRAM_ERROR

I_INTERFACE_CHECK: - (Interface consistency check log output.)


Same as in REUSE_ALV_LIST_DISPLAY
I_CALLBACK_PROGRAM: - (Name of the calling program.)
Same as in REUSE_ALV_LIST_DISPLAY
I_CALLBACK_PF_STATUS_SET: -
Same as in REUSE_ALV_LIST_DISPLAY
I_CALLBACK_USER_COMMAND: - (Exit routine for command handling.)
Same as in REUSE_ALV_LIST_DISPLAY
IS_LAYOUT: - (List layout specifications)
Same as in REUSE_ALV_LIST_DISPLAY
IT_FIELDCAT: - (Field catalog with field descriptions)
Same as in REUSE_ALV_LIST_DISPLAY
IT_EXCLUDING: - (Table of inactive function codes)
Same as in REUSE_ALV_LIST_DISPLAY
IT_SPECIAL_GROUPS: - (Grouping fields for column selection)
Same as in REUSE_ALV_LIST_DISPLAY

IT_SORT: -(Sort criteria for first list display)


Same as in REUSE_ALV_LIST_DISPLAY
IT_FILTER: -(Filter criteria for first list output)
Same as in REUSE_ALV_LIST_DISPLAY
IS_SEL_HIDE: - (Selection information modification)
Same as in REUSE_ALV_LIST_DISPLAY
I_SCREEN_START_COLUMN: -(Coordinates for list in dialog box)
Same as in REUSE_ALV_LIST_DISPLAY
I_SCREEN_START_LINE: - -(Coordinates for list in dialog box)
Same as in REUSE_ALV_LIST_DISPLAY
I_SCREEN_END_COLUMN: -(Coordinates for list in dialog box)
Same as in REUSE_ALV_LIST_DISPLAY
I_SCREEN_END_LINE: - -(Coordinates for list in dialog box)
Same as in REUSE_ALV_LIST_DISPLAY
I_DEFAULT: - (Initial variant active/inactive logic)
Same as in REUSE_ALV_LIST_DISPLAY
I_SAVE: -(Variants can be saved)
Same as in REUSE_ALV_LIST_DISPLAY
IS_VARIANT: -(Variant information)
Same as in REUSE_ALV_LIST_DISPLAY
IT_EVENTS: - (Table of events to perform)
Same as in REUSE_ALV_LIST_DISPLAY
IT_EVENT_EXIT: - (Standard fcode exit requests table)
Same as in REUSE_ALV_LIST_DISPLAY
I_TABNAME_HEADER: -(Header Table Name)
Name of the internal table in the program containing the output data of the highest hierarchy level.
I_TABNAME_ITEM: - (Item Table Name)
Name of the internal table in the program containing the output data of the lowest hierarchy level.
I_STRUCTURE_NAME_HEADER:- (Internal output table (header) structure name)
Same as I_STRUCTURE_NAME in REUSE_ALV_LIST_DISPLAY
I_STRUCTURE_NAME_ITEM: -(Internal output table (posit.) structure name)
Same as I_STRUCTURE_NAME in REUSE_ALV_LIST_DISPLAY
IS_KEYINFO: - (Header/posit. table field links)
This structure contains the header and item table field names which link the two tables (shared key).

- 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.

IS_PRINT: - (Print information)


Same as in REUSE_ALV_LIST_DISPLAY
IS_REPREP_ID: - (Initialization key for Re/Re interface)
E_EXIT_CAUSED_BY_CALLER: -(Delete list in CALLBACK_USER_COMMAND)
Same as in REUSE_ALV_LIST_DISPLAY
ES_EXIT_CAUSED_BY_USER: -(How the user left the list)
Same as in REUSE_ALV_LIST_DISPLAY
T_OUTTAB_HEADER: -(Header table with data to be output)
Same as T_OUTTAB in REUSE_ALV_LIST_DISPLAY
T_OUTTAB_ITEM: - (Position table with data to be output)
Same as T_OUTTAB in REUSE_ALV_LIST_DISPLAY

3. REUSE_ALV_FIELDCATALOG_MERGE: -(this module is used to create field catalog from dictionary


structure or internal table)
IMPORTING
VALUE(I_PROGRAM_NAME) LIKE SY-REPID OPTIONAL
VALUE(I_INTERNAL_TABNAME) TYPE SLIS_TABNAME OPTIONAL
VALUE(I_STRUCTURE_NAME) LIKE DD02L-TABNAME OPTIONAL
VALUE(I_CLIENT_NEVER_DISPLAY) TYPE SLIS_CHAR_1
DEFAULT 'X'
VALUE(I_INCLNAME) LIKE TRDIR-NAME OPTIONAL
CHANGING
VALUE(CT_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV
EXCEPTIONS
INCONSISTENT_INTERFACE
PROGRAM_ERROR
I_PROGRAM_NAME: - (Internal table declaration program)
Program from which the function module is called and which contains the exit routines. The program should always be

a Report, Function group, Module pool or Form routine pool (not an Include).

I_INTERNAL_TABNAME: -(Output table name)


Name of the internal output table in the CALLBACK_PROGRAM.
I_STRUCTURE_NAME: - (Structure name (structure, table, view))
Same as in REUSE_ALV_LIST_DISPLAY
I_CLIENT_NEVER_DISPLAY: - (Hide client fields)
Client field handling in the structure passed.

Value range

'X', SPACE

SPACE: client fields (type CLNT) in the structure passed are flagged as technical (=> no screen output) in the field
catalog.

I_INCLNAME: -(Data declaration include name)


If the list output structure data declaration is not in the assigned TOP Include, the Include name can be specified here
if no structure is specified.

CT_FIELDCAT: - (Field catalog with field descriptions)


Same as IT_FIELDCAT in REUSE_ALV_LIST_DISPLAY.

- 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

- (S)election: - Important header information, e.g. currency of amounts in the list


- display format:
KEY(bold) INFO(normal)
Ex.:
--- KEY----- ----INFO-------
Currency DEM Ctrl area curr.
Material FGS_TEST Test material
- Usually several entries (one entry per line)

Attributes: - left-justified
- Bold (KEY=on/INFO=off)
- Followed by empty line

- (A)ction: - Action info (see LIBS)


- Direct output via table
- Only the contents of INFO are
Output (KEY is ignored)
- Usually one entry
Attributes: - left-justified
- Normal intensity
o KEY: String with keyword character output in combination with TYP = 'S'.
o INFO: Information output in header, formatted by type.

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)

ET_EVENTS: - (Table of events to perform)

The event table is returned with all possible CALLBACK events for the specified 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

The function module REUSE_ALV_EVENT_NAMES_GET gets the names of these


constants (call in test mode).

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 : I_CALLBACK_PF_STATUS_SET: -

SAME AS IN REUSE_ALV_LIST_DISPLAY : I_CALLBACK_USER_COMMAND: -

SAME AS IN REUSE_ALV_LIST_DISPLAY : IT_EXCLUDING: -

SAME AS IN REUSE_ALV_LIST_DISPLAY

7.REUSE_ALV_BLOCK_LIST_APPEND: -(this behaves same as REUSE_ALV_LIST_DISPLAY)


IMPORTING
VALUE(IS_LAYOUT) TYPE SLIS_LAYOUT_ALV
VALUE(IT_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV
VALUE(I_TABNAME) TYPE SLIS_TABNAME
VALUE(IT_EVENTS) TYPE SLIS_T_EVENT
VALUE(IT_SORT) TYPE SLIS_T_SORTINFO_ALV OPTIONAL
VALUE(I_TEXT) TYPE SLIS_TEXT40 DEFAULT SPACE
TABLES
T_OUTTAB
EXCEPTIONS
PROGRAM_ERROR
MAXIMUM_OF_APPENDS_REACHED

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

8. REUSE_ALV_BLOCK_LIST_HS_APPEND: -(this behaves same as


REUSE_ALV_HIERSEQ_LIST_DISPLAY)
IMPORTING

- 107 -
SAP –ABAP BOOK

VALUE(IS_LAYOUT) TYPE SLIS_LAYOUT_ALV


VALUE(IT_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV
VALUE(IS_KEYINFO) TYPE SLIS_KEYINFO_ALV
VALUE(I_HEADER_TABNAME) TYPE SLIS_TABNAME
VALUE(I_ITEM_TABNAME) TYPE SLIS_TABNAME
VALUE(IT_EVENTS) TYPE SLIS_T_EVENT
VALUE(IT_SORT) TYPE SLIS_T_SORTINFO_ALV OPTIONAL
VALUE(I_TEXT) TYPE SLIS_TEXT40 DEFAULT SPACE
TABLES
T_OUTTAB_HEADER
T_OUTTAB_ITEM
EXCEPTIONS
PROGRAM_ERROR

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

9. REUSE_ALV_BLOCK_LIST_DISPLAY: - (This module is called display blocks after appending then.)


IMPORTING
VALUE(I_INTERFACE_CHECK) DEFAULT SPACE
VALUE(IS_PRINT) TYPE SLIS_PRINT_ALV OPTIONAL
VALUE(I_SCREEN_START_COLUMN) DEFAULT 0
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
EXCEPTIONS
PROGRAM_ERROR
I_INTERFACE_CHECK: -

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: -

SAME AS IT_LAYOUT IN REUSE_ALV_LIST_DISPLAY

ET_FIELDCAT: -
Same as IT_FIELDCAT in REUSE_ALV_LIST_DISPLAY
ET_SORT: -
Same as IT_SORT in REUSE_ALV_LIST_DISPLAY
ET_FILTER: -

SAME AS IT_FILTER IN REUSE_ALV_LIST_DISPLAY

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

11.REUSE_ALV_LIST_LAYOUT_INFO_SET: -(this module is used to set the current ALV list information)
IMPORTING
VALUE(IS_LAYOUT) TYPE SLIS_LAYOUT_ALV OPTIONAL
VALUE(IT_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV OPTIONAL
VALUE(IT_SORT) TYPE SLIS_T_SORTINFO_ALV OPTIONAL
VALUE(IT_FILTER) TYPE SLIS_T_FILTER_ALV OPTIONAL
VALUE(IS_LIST_SCROLL) TYPE SLIS_LIST_SCROLL OPTIONAL

IS_LAYOUT: -

SAME AS IN REUSE_ALV_LIST_DISPLAY

IT_FIELDCAT: -

SAME AS IN REUSE_ALV_LIST_DISPLAY IT_SORT: -

SAME AS IN REUSE_ALV_LIST_DISPLAY IT_FILTER: -

SAME AS IN REUSE_ALV_LIST_DISPLAY IS_LIST_SCROLL: -

SAME AS ES_LIST_SCROLL IN REUSE_ALV_LIST_LAYOUT_INFO_GET

12.REUSE_ALV_POPUP_TO_SELECT: -(This module is used to List in popup to choose one or more entries (or
display only))
IMPORTING
VALUE(I_TITLE) OPTIONAL

VALUE(I_SELECTION) DEFAULT 'X'

VALUE(I_ZEBRA) DEFAULT SPACE


VALUE(I_SCREEN_START_COLUMN) DEFAULT 0
VALUE(I_SCREEN_START_LINE) DEFAULT 0
VALUE(I_SCREEN_END_COLUMN) DEFAULT 0
VALUE(I_SCREEN_END_LINE) DEFAULT 0
VALUE(I_CHECKBOX_FIELDNAME) OPTIONAL
VALUE(I_LINEMARK_FIELDNAME) OPTIONAL

- 110 -
SAP –ABAP BOOK

VALUE(I_SCROLL_TO_SEL_LINE) DEFAULT 'X'


VALUE(I_TABNAME)
VALUE(I_STRUCTURE_NAME) LIKE DD02L-TABNAME OPTIONAL
VALUE(IT_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV OPTIONAL
VALUE(IT_EXCLUDING) TYPE SLIS_T_EXTAB OPTIONAL
VALUE(I_CALLBACK_PROGRAM) LIKE SY-REPID OPTIONAL
VALUE(I_CALLBACK_USER_COMMAND) TYPE SLIS_FORMNAME
OPTIONAL
EXPORTING
VALUE(ES_SELFIELD) TYPE SLIS_SELFIELD
VALUE(E_EXIT)
TABLES
T_OUTTAB
EXCEPTIONS
PROGRAM_ERROR
I_TITLE: - (Dialog box title)
Title to be displayed as the popup title.
I_SELECTION: - ((X) = Selection possible, ( ) = Display)
I_SELECTION = 'X' => the user can select entries in the displayed internal table.
I_ZEBRA: - (Line output with alternating color)
I_ZEBRA = 'X' => List rows are output in alternating colors for better readability. This option should be used when
the list is relatively wide.
I_SCREEN_START_COLUMN: -

Column coordinate of the top left-hand corner of the popup.


If no coordinates or only the coordinates of the top left-hand corner are specified in the interface, the module
calculates the optimal coordinates using the table information. The coordinates need not normally be specified in the
interface parameters.
You can position the popups by specifying the top left-hand corner, without specifying its size.
I_SCREEN_START_LINE: -

Row coordinate of the top left-hand corner of the popup.


I_SCREEN_END_COLUMN: -

Column coordinate of the bottom right-hand corner of the popup.


I_SCREEN_END_LINE: -

Row coordinate of the bottom right-hand corner of the popup.


I_CHECKBOX_FIELDNAME: - (Output table checkbox field name)
If the table output in the popup has checkboxes at the beginning of the rows (e.g. for multiple selection), the internal
table must contain a field containing the value of the checkbox.
Assign the name of this field to the parameter I_CHECKBOX_FIELDNAME.
I_LINEMARK_FIELDNAME: - (LINE SELECTION COLOR INFORMATION FIELD NAME)

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. The name of this
field is assigned to this parameter.

The internal output table field must be of type CHAR(3).

The coding must have the following syntax:

- 111 -
SAP –ABAP BOOK

'Cxy':
C = color (each code must begin with 'C')
x = color number ('1'-'9')
y = highlight ('0' = off, '1' = on)

Note: the color of the key columns is not affected.


I_SCROLL_TO_SEL_LINE: - (SCROLL TO DEFAULT SELECTION IF NECESSARY)

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.

When the popup is called, the cursor should be immediately positioned on, or scrolled to, this row.
Prerequisite: color code the highlighted row with 'C50'

See also the documentation of the importing parameter


I_LINEMARK_FIELDNAME

I_TABNAME: - (Table name with chosen values)


Name of the internal output table in the calling program
I_STRUCTURE_NAME: - (INTERNAL OUTPUT TABLE STRUCTURE NAME)

SAME AS I_STRUCTURE_NAME IN REUSE_ALV_LIST_DISPLAY

IT_FIELDCAT: -

SAME AS IN REUSE_ALV_LIST_DISPLAY

IT_EXCLUDING: -

The optional IMPORTING parameter IT_EXCLUDING is an internal table.


This is only used when the caller wants to deactivate standard functions.
The function codes of these standard functions are entered in this table.

At most the following functions are active in the standard and can be deactivated using IT_EXCLUDING:

o Function code: &ETA (Detail)


o Function code: &SC (Find)
o Function code: &SC+ (Find next)
o Function code: &OUP (Sort ascending)
o Function code: &ODN (Sort descending)
o Function code: &ILT (Filter)
o Function code: &OL0 (Display variant)
o Function code: &CRB (Horizontal scroll: First column)
o Function code: &CRL (Horizontal scroll: Previous column)
o Function code: &CRR (Horizontal scroll: Next column)
o Function code: &CRE (Horizontal scroll: Last column)
o Function code: &AC1 (Cancel)

Only for active checkboxes:


o Function code: &ALL (Select all)
o Function code: &SAL (Deselect all)

- 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 output table name
o tabindex : internal output table index
o fieldname: field name
o value : field contents

Multiple selection using checkboxes puts an 'X' in the


I_CHECKBOX_FIELDNAME field in the corresponding row in the internal
table.
E_EXIT: - ('X' = Cancel by user)
Flag is set when the user leaves the popup with the 'Cancel' function.
T_OUTTAB: -
Internal table of any structure which contains the data to be output in list form.

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.

13. REUSE_ALV_VARIANT_DEFAULT_GET: -(This module is used to read default display variant)


IMPORTING
VALUE(I_SAVE) DEFAULT SPACE
CHANGING
VALUE(CS_VARIANT) LIKE DISVARIANT
STRUCTURE DISVARIANT
EXCEPTIONS
WRONG_INPUT
NOT_FOUND
PROGRAM_ERROR
I_SAVE: - (VARIANT CAN BE SAVED)

SAME AS IN REUSE_ALV_LIST_DISPLAY

CS_VARIANT: - (Variant information)

SAME AS IN REUSE_ALV_LIST_DISPLAY

WRONG_INPUT: - Inconsistent input parameters


NOT_FOUND: - VARIANT NOT FOUND

PROGRAM_ERROR: - Program errors

14. REUSE_ALV_VARIANT_F4 : -(This module is used to display variant selection popup)


IMPORTING

- 113 -
SAP –ABAP BOOK

VALUE(IS_VARIANT) LIKE DISVARIANT


STRUCTURE DISVARIANT
VALUE(I_TABNAME_HEADER) TYPE SLIS_TABNAME OPTIONAL
VALUE(I_TABNAME_ITEM) TYPE SLIS_TABNAME OPTIONAL
VALUE(IT_DEFAULT_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV
OPTIONAL
VALUE(I_SAVE) DEFAULT SPACE
EXPORTING
VALUE(E_EXIT)
VALUE(ES_VARIANT) LIKE DISVARIANT
STRUCTURE DISVARIANT
EXCEPTIONS
NOT_FOUND
PROGRAM_ERROR
IS_VARIANT: -

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

E_EXIT: - DIALOG CANCELLED BY USER

ES_VARIANT: -
SAME AS IN REUSE_ALV_LIST_DISPLAY

15.REUSE_ALV_VARIANT_EXISTENCE: - (this module is used to check existence of a display variant)


IMPORTING
VALUE(I_SAVE) DEFAULT SPACE
CHANGING
VALUE(CS_VARIANT) LIKE DISVARIANT
STRUCTURE DISVARIANT
EXCEPTIONS
WRONG_INPUT
NOT_FOUND

- 114 -
SAP –ABAP BOOK

PROGRAM_ERROR
I_SAVE: -

SAME AS IN REUSE_ALV_LIST_DISPLAY

CS_VARIANT: -
SAME AS IN REUSE_ALV_LIST_DISPLAY

PROGRAM FOR ALV BASIC LIST

TYPE-POOLS: SLIS.
TABLES: VBAK.
*-----POPUATING STRUCTURE.

TYPES: BEGIN OF STR_1,


vbeln TYPE vbeln,
erdat TYPE erdat,
audat TYPE audat,
auart TYPE auart,
END OF STR_1.

*-----POPULATING INTERNALTABLE FOR STRUCTURE.

DATA: IT_1 TYPE TABLE OF STR_1 WITH HEADER LINE.

*----POPULATING INTERNALTABLE FOR FIELD CATALOG.

DATA: IT_SATH TYPE SLIS_T_FIELDCAT_ALV,


WA_SATH TYPE slis_fieldcat_alv.

*-----POPULATING SELECT-OPTIONS.

SELECT-OPTIONS: SO_SATH FOR VBAK-VBELN.

*-----RETRIEVE THE DATA INTO INTERNAL TABLE

START-OF-SELECTION.
SELECT VBELN
ERDAT
AUDAT
AUART FROM VBAK INTO TABLE IT_1
WHERE VBELN IN SO_SATH.

*-----CREATING FIELD CATALOG

WA_SATH-COL_POS = '1'. "POS OF THE FIELD


WA_SATH-FIELDNAME = 'VBELN'. " FIELD NAME
WA_SATH-SELTEXT_M = 'SD_NUM'. "DESC OF THE COLUMN
APPEND WA_SATH TO IT_SATH.

WA_SATH-COL_POS = '2'.
WA_SATH-FIELDNAME = 'ERDAT'.
WA_SATH-SELTEXT_M = 'ORDER_DATE'.

- 115 -
SAP –ABAP BOOK

APPEND WA_SATH TO IT_SATH.

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.

DATA: V_PROG_NAME TYPE SY-REPID.


V_PROG_NAME = 'Z_TRNG_ALVSAMPLE1_T009'.

*-----FUNCTION MODULE TO CALL ALV

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'


EXPORTING
IT_FIELDCAT = IT_SATH
I_CALLBACK_PROGRAM = V_PROG_NAME
TABLES
t_outtab = IT_1.

- 116 -
SAP –ABAP BOOK

Out Put

- 117 -
SAP –ABAP BOOK

PROGRAM FOR ALV BASIC INTRA LIST WITH LOGO

*-----TABLES------------------------------------------------*
TABLES: vbak, vbpa, kna1.

*-----TYPE-POOLS DECLAIRATION------------------------*
TYPE-POOLS: slis.

*-----TYPE 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---------------------------------*
DATA: it_vbak TYPE str_1 OCCURS 0,
wa_vbak TYPE str_1,

it_vbap TYPE str_2 OCCURS 0,


wa_vbap TYPE str_2,

it_fieldcat TYPE slis_t_fieldcat_alv,


wa_fieldcat TYPE slis_fieldcat_alv,

it_fieldcat1 TYPE slis_t_fieldcat_alv,


wa_fieldcat1 TYPE slis_fieldcat_alv,

it_events TYPE slis_t_event,


wa_events TYPE slis_alv_event,

it_page TYPE slis_t_listheader WITH HEADER LINE.

*-----SELECTION-SCREEN---------------------------------*
SELECT-OPTIONS: so_vbeln FOR vbak-vbeln OBLIGATORY.

*-----START-OF-SELECTION-----------------------------*
START-OF-SELECTION.

*-----RETRIEVE MATERIAL INFO FROM VBAK TABLE-----*


SELECT vbeln erdat ernam netwr
FROM vbak
INTO TABLE it_vbak
WHERE vbeln IN so_vbeln.

*-----CREATING FIELD CATALOG FOR BASIC LIST------*


wa_fieldcat-col_pos = '1'.
wa_fieldcat-fieldname = 'VBELN'.
wa_fieldcat-seltext_m = text-001.

- 118 -
SAP –ABAP BOOK

APPEND wa_fieldcat TO it_fieldcat.


CLEAR wa_fieldcat.

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.

*-----CREATING FIELD CATALOG FOR SECONDARY LIST-


wa_fieldcat1-col_pos = '1'.
wa_fieldcat1-fieldname = 'VBELN'.
wa_fieldcat1-seltext_m = text-001.
APPEND wa_fieldcat1 TO it_fieldcat1.
CLEAR wa_fieldcat1.

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.

DATA: a TYPE sy-repid.


a = 'Z_TRNG_ALVLOGO_T009'.
*
*APPEND wa_events TO it_events.

*-----CALLING FUNCTION MODULE FOR BASIC LIST------


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program =a
i_callback_user_command = 'B'
i_callback_top_of_page = 'H1'
it_fieldcat = it_fieldcat
it_events = it_events
TABLES
t_outtab = it_vbak.

*-----FORM HEADER--------------------------------------*

- 119 -
SAP –ABAP BOOK

*-----HEADER FOR SALES DOC DETAILS----------*


FORM h1.
it_page-typ = 'H'.
it_page-info = 'SALES ORDER DETAILS'.
APPEND it_page.
CLEAR it_page.

*-----FUNCTION MODULE TO DISPLAY LOGO--------*


CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_page[]
i_logo = 'ENJOYSAP_LOGO'.
FREE it_page.
ENDFORM.

*-----FORM IMPLEMENTATION FOR USER COMMAND----*


FORM b USING c LIKE sy-ucomm d TYPE
slis_selfield.
READ TABLE it_vbak INTO wa_vbak INDEX d-tabindex.

*-----RETRIEVE MATERIAL INFO FROM VBAP TABLE-------


SELECT vbeln posnr matnr
FROM vbap
INTO TABLE it_vbap
WHERE vbeln = wa_vbak-vbeln.
IF sy-subrc EQ 0.

*----CALLING FUNCTION MODU FOR SECONDARY LIST*


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = a
i_callback_top_of_page = 'H2'
it_fieldcat = it_fieldcat1
TABLES
t_outtab = it_vbap.
ENDIF.
ENDFORM.

*-----FORM HEADER--------------------------------------*
*-----HEADER FOR ITEM DETAILS------------------------*
FORM h2.
it_page-typ = 'H'.
it_page-info = 'SALES DOCUMENT DETAILS'.
APPEND it_page.
CLEAR it_page.

*-----FUNCTION MODULE TO DISPLAY LOGO-------------*


CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_page[]
i_logo = 'ENJOYSAP_LOGO'.
FREE it_page.
ENDFORM.

ALV FOR HIERARCHICAL METHOD

type-pools: slis.

- 120 -
SAP –ABAP BOOK

tables: vbak.

TYPES: BEGIN OF ty_header_data,


vbeln TYPE vbeln,
erdat TYPE erdat,
netwr TYPE netwr,
END OF ty_header_data,

BEGIN OF ty_item_data,
vbeln TYPE vbeln,
posnr TYPE posnr,
arktx TYPE arktx,
werKS TYPE werks,
END OF ty_item_data.

data: it_header_data type ty_header_data occurs 0,


wa_header_data type ty_header_data,

it_item_data type ty_item_data occurs 0,


wa_item_data type ty_item_data,

It_fcat type slis_t_fieldcat_alv,


wa_fcat type slis_fieldcat_alv,

v_tabname_header type slis_tabname,


v_tabname_item type slis_tabname,
is_keyinfo type SLIS_KEYINFO_ALV,
v_prog_name like sy-repid.

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

APPEND wa_fcat TO it_fcat.


CLEAR WA_FCAT.

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.

select-options: so_vbeln for vbak-vbeln.

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.

**--fn module to create hierarchical alv list


CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK =''
I_CALLBACK_PROGRAM = v_prog_name
* I_CALLBACK_PF_STATUS_SET =''
* I_CALLBACK_USER_COMMAND =''
* IS_LAYOUT =
IT_FIELDCAT = it_fcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_SCREEN_START_COLUMN =0
* I_SCREEN_START_LINE =0
* I_SCREEN_END_COLUMN =0
* I_SCREEN_END_LINE =0

- 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
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.

In this 7 article tutorial we will cover subjects such as:

• Main elements of SAPscript


• Commands that can be used in a layout set
• How to include a graphical image

- 123 -
SAP –ABAP BOOK

• Commands that can be used in SAPscript


• Step-by-step walkthrough of example
• Example layout set
• Example SAPscript code

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.

The various components of the header are explained below

• 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

1. Description - Brief description or title of the layout set


2. Default paragraph - The base paragraph that is globally applicable to the
document. This can be overridden at lower level of the layout set by using
other paragraphs
3. Tab Stop - The base tab-stop that is globally applicable to the document.
These can be overridden at lower level of the layout set by using other tab
stops
4. First Page - The start page of the layout set
5. Page Format
6. Orientation - The direction of printing the data on a page – P for portrait
(vertical) and L for landscape (horizontal)
7. Lines per inch
8. Characters/inch

• 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:

MAIN - A layout set can have only one MAIN window which is created by default. This
window can flow over multiple pages.

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.

It is advisable to group logically related data within one text element.

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

All the windows that form a page of the layout set.

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.

The various types of commands that can be used within a layout set are tabulated
below

Command Purpose

* Default paragraph

Blank Continuous text

= Extended Line

( Raw Line

/ Line Feed

/= Line feed and extended line

/( Line Feed and Raw Line

/: Command Line

/* Comment Line

/E Text Element

<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

• 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

• Use report RSTXLDMC to upload this file as a text module in SAP

• Execute the above program from the ABAP /4 editor

• Enter the location of the .TIFF file on the PC

• Specify BMON or BCOL as the raster image type

- 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

• The ID should be ‘ST’ and give the logon language

• 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

INCLUDE ZHEX-MACRO-LOGO OBJECT TEXT ID ST in the first line

The commands that are commonly used in a sap script are as follows -:

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 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.

Varying these parameters also helps to draw a line instead of


a box.

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

< LT Less than

> GT Greater than

<= LE Less than or equal to

>= GE greater than or equal to

<> NE not equal to

The logical operators that can be used are as follows

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.

1. Understand the structure of the document that needs to be generated page by


page.

2. Find out the different pages that form the document.

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

8. Create all CONSTANT the windows that have been uniquely identified in the
document

9. Identify the MAIN window of the every page of the document

10. Define the pages that form the parts of the document

11. Assign the windows to each page

- 128 -
SAP –ABAP BOOK

12. Define the text elements within each window

13. Use function module OPEN_FORM to open the layout set.

14. Use function module WRITE_FORM to write the text elements in various windows

15. Use function module CLOSE_FORM to close the layout set

Always remember to check and activate the layout set when any change is done to
it, otherwise the change will not appear on the output document that is printed!!!

Steps:

- 129 -
SAP –ABAP BOOK

Enter Description

Save ( Ctrl + S )

Click on Pages

- 130 -
SAP –ABAP BOOK

Page1

Save , then give Description – FIRST PAGE

Save

Click on Paragraph format

Enter P1

Enter Description

- 131 -
SAP –ABAP BOOK

Goto - Header

Click on Basic Settings

- 132 -
SAP –ABAP BOOK

Save – click on Windows

There will be a default Window called Main Window

- 133 -
SAP –ABAP BOOK

To create New window follow the Navigation As shown Above

Save and Activate

Select a window and then

- 134 -
SAP –ABAP BOOK

Write some text as shown below

MAIN window text

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&

Come Back,No need to Save.

Click on Page Windows.

- 135 -
SAP –ABAP BOOK

You get a pop-up as shown below

- 136 -
SAP –ABAP BOOK

Select one window.


Now give Width and Height

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.

DATA : BEGIN OF ZOPTION.


INCLUDE STRUCTURE ITCPO.
DATA : END OF ZOPTION.

PARAMETERS: P_EBELN LIKE EKKO-EBELN,


P_EBELP LIKE EKPO-EBELP.

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.

ZOPTION-TDDEST = USR01-SPLD. "Output device (printer)


ZOPTION-TDIMMED = 'X'. "Print immediately
ZOPTION-TDDELETE = 'X'. "Delete after printing
ZOPTION-TDPROGRAM = 'ZPQRPRNT'. "Program Name

CALL FUNCTION 'OPEN_FORM'


EXPORTING
APPLICATION = 'TX'
* ARCHIVE_INDEX = ' '
* ARCHIVE_PARAMS = ' '
DEVICE = 'PRINTER'
DIALOG = ' '
FORM = 'Z_TESTSCRIPT'
LANGUAGE = SY-LANGU
OPTIONS = ZOPTION
IMPORTING
LANGUAGE = SY-LANGU
EXCEPTIONS
OTHERS = 1.

CALL FUNCTION 'WRITE_FORM'


EXPORTING
ELEMENT = 'HEADER'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'HEADER'
EXCEPTIONS
ELEMENT = 1.

CALL FUNCTION 'WRITE_FORM'


EXPORTING
ELEMENT = 'MAIN'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'MAIN'
EXCEPTIONS
ELEMENT = 1.

CALL FUNCTION 'WRITE_FORM'


EXPORTING
ELEMENT = 'FOOTER'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'FOOTER'

- 139 -
SAP –ABAP BOOK

EXCEPTIONS
ELEMENT = 1.

CALL FUNCTION 'CLOSE_FORM'


EXCEPTIONS
UNOPENED = 1
OTHERS = 2.

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

Steps to be followed while creating Smart Forms:

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

3. Double click the Form interface Left Sub-tree.


4. Enter the Import Parameters (The values that passed from the Print Program into
the Form) (e.x. Company Code)
Parameter name Type assignment Reference type Default value
Pass value
COMPANY_CODE TYPE EKKO-BUKRS


5. Double click the Global definitions from the Left Sub-tree.


Assume that we are using two tables EKKO and EKPO in this example:
6. Click the “Types” Tab.
7. Enter the Code as following:

- 141 -
SAP –ABAP BOOK

TYPES: BEGIN OF WA_EKKO,


EBELN LIKE EKKO-EBELN,
BUKRS LIKE EKKO-BUKRS,
END OF WA_EKKO.

TYPES: BEGIN OF WA_EKPO,


EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MENGE LIKE EKPO-MENGE,
NETPR LIKE EKPO-NETPR,
END OF WA_EKPO.

TYPES: T_EKKO TYPE STANDARD TABLE OF WA_EKKO,


T_EKPO TYPE STANDARD TABLE OF WA_EKPO.

8. Click the “Global data” Tab.


Declare the Internal Tables and Work Areas as follows:
Variable name Type assignment Reference type Default value
Constant
I_EKKO TYPE T_EKKO
I_EKPO TYPE T_EKPO
WA_EKKO TYPE WA_EKKO
WA_EKPO TYPE WA_EKPO

- 142 -
SAP –ABAP BOOK

9. Double click the “%PAGE1 New Page” in the Left Sub-tree.

10. Change the %PAGE1 to “FIRST” or any name and Enter the Description (e.x. First
Page).
11. Select the Next Page as “FIRST”

- 143 -
SAP –ABAP BOOK

12. Select the “Output options” Tab and select the format of the page (Portrait or
Landscape) and all other print attributes.

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

22. Enter the Input Parameter as COMPANY_CODE and Export Parameter as


V_ADRNR in the “General attributes” Tab and write the select query as following:
SELECT SINGLE ADRNR INTO V_ADRNR
FROM T001 WHERE BUKRS EQ COMPANY_CODE.
(Note: Before writing the select query first declare the Variable V_ADRNR in the
Global definitions area as follows:
V_ADRNR TYPE T001-ADRNR.

23. Right click the “ADD_WIN Address Window” in the Left Sub-tree and from the
Menu option “Create”  select the “Address”.

- 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

25. Select the Type of the address in the “General attributes” Tab. (Since we are
retrieving the Organization address, we selected the first radio button) and in the
Address number text box pass the V_ADRNR Variable as &V_ADRNR&.

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

29. Enter the Input Parameter as COMPANY_CODE and Output Parameter as


I_EKKO and I_EKPO in the “General attributes” Tab and write the select query as
following:
SELECT EBELN BUKRS
INTO TABLE I_EKKO
FROM EKKO
UP TO 10 ROWS
WHERE BUKRS EQ COMPANY_CODE.
IF SY-SUBRC EQ 0.
SORT I_EKKO BY EBELN.
SELECT EBELN EBELP MENGE NETPR
INTO TABLE I_EKPO
FROM EKPO
FOR ALL ENTRIES IN I_EKKO
WHERE EBELN EQ I_EKKO-EBELN.
IF SY-SUBRC EQ 0.
SORT I_EKPO BY EBELN EBELP.
ENDIF.
ENDIF.
30. Right click “MAIN Main Window” in the Left Sub-tree and from the Menu option
“Create”  select the “Complex Section”.

- 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.

32. Select the “Data” Tab.


33. Enter the Internal Table Name as I_EKKO and Work area name as WA_EKKO and
sort by the BUKRS and EBELN fields.

- 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

Click the Text Editor

- 155 -
SAP –ABAP BOOK

Display the values of Company Code and Purchase Order Number as shown
below:

Press Back Button, then Press Save and Check Buttons

- 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 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 “Select
pattern” Button

- 159 -
SAP –ABAP BOOK

Selected table pattern


40. Inorder to Display the “Column Text“ for the table columns, insert the Text as
shown below:
41. Right click the “OI_HEAD ORDER ITEM HEADER” and from the Menu path
“Create”  Select the “Text” .

- 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 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 m
with OI_HEAD O
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.

51. Similary add one Text for the remaining columns.

- 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 4th Text for the 4th 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.

InputParameters: WA_EKPO-MENGE,WA_EKPO-NETPR & OutputParameters:


V_TOTAL,V_SUBTOTAL, V_GRDTOTAL.

- 171 -
SAP –ABAP BOOK

54. Now add the 4th Text to display the 4th column in the Form.

For the Fourth Column Text also You need only to select the “New cell” Check box.

- 172 -
SAP –ABAP BOOK

55. Inorder to display the Subtotals (which has been created earlier i.e. refer to step no
52) of all the Line Items for each Purchase Order, we have to Insert a separate
Text Under the Table OI_DISPLAY ORDER ITEM DISPLAY” by right clicking the
same.

- 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

Text = “GRD_TOT_DISP”, Description = “GRAND TOTAL DISPLAY” and Variable


V_GRDTOTAL has been populated to display the grand total in the form.

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

62. Inorder to display the page numbers we have to insert a “Text” by right clicking the
“PG_WIN PAGE NUMBER WINDOW”.

- 181 -
SAP –ABAP BOOK

Text “%TEXT1 New text 1” gets inserted and now enter the text name and

description.

Text = “PG_DISP”, Description = “PAGE NUMBER DISPLAY” and Page Number


gets displayed from the Transparent Table “SFSY”.

63. General Screen Shot of Entire Left Sub-tree:

- 182 -
SAP –ABAP BOOK

ENTIRE LEFT SUB-


TREE

64. Form output:

- 183 -
SAP –ABAP BOOK

65. SOME MORE FURTHER MODIFICATIONS / ADDITIONAL OPTIONS IN THE


ABOVE CREATED FORM:
Condition-1: Create second page and company logo should get printed only in the
first page and not in the second page. Similarly, company address window should
get printed only in the last page and not in other pages.
To create the second page right click the “FIRST First Page” in the left sub-tree.

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

71. Output showing the main window got printed only in the first page and not in the
second page and so on …. First Page: With LOGO

- 187 -
SAP –ABAP BOOK

Second Page: Without

LOGO

- 188 -
SAP –ABAP BOOK

72. Inorder to restrict the Company address to be printed only in the last 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

73. Output showing the address window got printed only in the last page and not in the
first page and so on ….
First Page: without company address

- 190 -
SAP –ABAP BOOK

Last page (second page): with company address window

- 191 -
SAP –ABAP BOOK

74. Condition-2: Purchase order’s whose value is more than 5000 only should get
displayed / printed.
Inorder to achieve the same, right click the “PO_LOOP PURCHASE ORDER
NUMBER LOOP” and select the “Loop”.

75. “%LOOP1 New loop 1” gets inserted

- 192 -
SAP –ABAP BOOK

76. Enter Loop name and description.

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.

79. “%CODE1 New program lines 1” gets inserted

- 194 -
SAP –ABAP BOOK

80. Enter the name and description for Program lines. Before calculating the subtotal
declare two variables one for total and another for subtotal in Global definitions.
Calculate the Subtotal as shown below:

Input parameters: “WA_EKPO-MENGE, WA_EKPO-NETPR, V_TOT”; Output


Parameters: “V_VALUE”.

- 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”.

82. “%CONDITION1 New alternate 1” gets inserted.

- 196 -
SAP –ABAP BOOK

83. Enter Alternate name and description. Select the “General attributes” Tab and
Enter the condition of subtotal > 5000 as shown:

84. Now, move “PO_NO_DISPLAY PURCHASE ORDER NUMBER DISPLAY,


OI_HEAD ORDER ITEM HEADER, OI_DISPLAY ORDER ITEM DISPLAY,
SUB_TOTAL_DISPLAY DISPLAY SUBTOTAL and CLR_VAR New program lines”
under the “TRUE” part.

- 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

Output parameters: V_COUNTER.

89. Inorder to avoid triggering “New page command” in the first 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

90. “%COMMAND1 New command 1” gets inserted.

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:

“%COMMAND1 New command 1” gets inserted

- 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

95. The new PROBLEM we faced when we create the smart form is page number.
Total Page Number got displayed as “*” as shown:

- 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.

Go to the menu path Insert  Symbols  New as shown

Which will result you in the following popup and fill the popup as shown.

- 210 -
SAP –ABAP BOOK

97. It will takes you to the following screen.

98. Now replace &SFSY-FORMPAGES+4(4CZ)& as &SFSY-FORMPAGES+0(4CZ)&

99. Press back and then check, activate and execute – You can observe that the
problem has resolved.

- 211 -
SAP –ABAP BOOK

100. Enjoy and try to create more smart forms……..

BUSINESS ADD-INS

CONTENTS

I. Basic concept

II. Basic skills required

III. BADI in detail


a. Different views

- 212 -
SAP –ABAP BOOK

b. 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

IV. Difference between different enhancement technique with BADI

V. Advantages of BADI’s

VI. Technical stuff

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 Objects. BADI is an exit point in
a 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.

BASIC SKILLS REQUIRED

• Work Experience/Knowledge on ABAP Objects (Object orientation of ABAP) is mandatory.


• Experience on SAP enhancement technique.

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.

Different Views
a) The different views of the BADI’s are:

i. Definition view, Application Programmer can predefine the exit points in


the source in which specific industry sector customers can attach additional

- 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 customize the logic
they need or use a standard logic if available.

Architecture
a) Architecture:

b) User defined BADI’s:

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 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.

- 214 -
SAP –ABAP BOOK

ii. Filtering, If the Add-in has to be executed under certain conditions, then the
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 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.

g) Business Add-in contains an interface and other additional components such as


function codes for menu enhancements. Business Add-ins also includes
enhancements for screens. The enhancement, interface and generated classes are all
located in the appropriate application development namespace. Business Add-in
implementations are created in the respective implementation namespace.

Defining a Business Add-in

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

add-in and implement it accordingly to their business needs.

a) From SAP menu, choose Tools -> ABAP Workbench -> Utilities -> Business Add-
ins or transaction code SE18. The example, which is illustrated, is the string
conversion in the program. And giving the provision to the users to determine
themselves how their strings are to be converted. Application developer define an
enhancement, consists of interface with a method with changing parameter used to
pass the string.

- 215 -
SAP –ABAP BOOK

b) Enter the Badi name and choose create.

c) Enter the short text, choose the interface tab.

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.

d) Enter the BAdi name

- 218 -
SAP –ABAP BOOK

e) Enter the short description for the BAdi implementation and implement the
interface in the class appearing in the BAdi implementation screen.

f) Double click on the implementation class and insert the desired source code for the
implementation between the method ZIF_EX_BUSINESSADDIN~CONVERSION. And Method. 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
Method ZIF_EX_BUSINESSADDIN~CONVERSION.

translate parameter to upper case.

endmethod.

Calling Badi in the Application

a) When we define BAdi, enhancement management generates a class that implements


the interface. The application developer uses a factory method to create an instance
of adapter class in the application program and calls corresponding method. The
adapter class method generated by the enhancement management decide by
checking the entries in the table whether one or several active implementations need
to be called. If required, the implementations are subsequently executed. The
application program ensures only the adapter class method is called. The
application program doesn’t know which implementations are called.
b) Call the string conversion Business Add-in, the program calling the Business Add-
in. Following is the ABAP source code

REPORT ZMPTEST_BADI.

* Declaring the handler


class: cl_exithandler definition load.

* Interface Reference
data: badi_interface type ref to ZIF_EX_BUSINESSADDIN.

* String
data: w_str(15) type c value 'baddi test'.

*************************************************
****Start of Selection Event.....................
************************************************
start-of-selection.
call method cl_exithandler=>get_instance
changing
instance = badi_interface.
write: / 'Please click here'.

*************************************************

- 220 -
SAP –ABAP BOOK

****At line-selection Event.....................


************************************************
at line-selection.

write: / 'original word', w_str.

if not badi_interface is initial.


call method badi_interface->conversion
changing parameter = w_str.

endif.
write: / 'Converted word', w_str.

Filter dependent Badi

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 enhancement. 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 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.

Multiple use Badi

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.

DIFFERENCE BETWEEN DIFFERENT ENHANCEMENT TECHNIQUE WITH BADI

a) Difference between Business Transaction Events and BADI’s.

- 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 cannot 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 levels i.e. SAP-
partners – customers, but in case of BAdi’s you can create 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

a) Following are the Tables which are relevant to BAdi’s


i. SXS_ATTRT - BAdi Definition list
ii. V_EXT_ACT - Active implementations of an exit
iii. V_EXT_ IMP - Implementation class for an interface+filter
iv. V_EXT_M - BAdi’s with filters

b) Transaction related to BAdi’s


i. SE18 - Business Add-in builder
ii. SE19 – Implementation of Badi
iii. SE24 – Class/Interface Builder

- 222 -

Вам также может понравиться