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 Ware House Transportation Material Mgmt.
Production
Manpower
QA Materials
PPC Maintenance
Machinery
Purchasing
Corporate Marketing
Distribution Sales
Admin. Methods
R&D SCM
Marketing
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) (2) (3) (4) (5)
Single integrated software program Single database Information shared and communicated Automates customer orders, order fulfilment , billing, shipping, etc. 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 Accpac Agresso Business World
1C Company The Sage Group Unit 4 Agresso CGI Group (formerly American Management Systems) Infor Global Solutions Made2Manage Systems Epicor SuperNova Solutions Infor Global Solutions Industrial & Financial Systems Oracle Oracle SIV.AG Lawson Software QAD Microsoft Intentia NetSuite Inc. Oracle Oracle Ramco Systems The Sage Group SAP SAP iSystems, Inc Infor Global Solutions
AMS Advantage ERP LX (aka BPCS) Enterprise Business System Epicor Enterprise ERManager ERP LN (aka Baan) IFS Applications JD Edwards EnterpriseOne JD Edwards World kVASy4 Lawson Financials MFG/PRO Microsoft Dynamics Movex NetERP Oracle e-Business Suite PeopleSoft Ramco e.Applications Sage MAS 500 SAP R/3 mySAP TQT Visual Enterprise
80 70 60 50 40 30 20 10 0
SAP ORACLE SIEBEL PEOPLESOFT JDEDWARDS
1( '0 4) 2( '0 Q 4) 3( '0 Q 4) 4( '0 Q 4) 1( '0 Q 5) 2( '0 Q 5) 3( '0 Q 5) 4( '0 5)
Percentage
Big 5 Market Share Evolution (%)
Q
Q
The above graph shows the percentage of Market share of various ERP packages. 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
Tier 2
ABAP-Program
Layer
Application
-
ServerLayer
client-independent Database
Repository (all Dev.Objects)
client-dependent
Tier 1
Customizing -Tables Application -Tables
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 Service Revenue
€8,457 million (FY 2008)
Operating Income
€2,840 million (FY 2008)
Employees
51,500 (FTE at Dec. 31, 2008)
Customers
More than 86,000 in over 120 countries
Partners
More than 2,400 certified partners
R & D Investment
€1,631 million / 14% of total revenue (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 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.., • o
There are many more modules. SAP CRM (Customer Relationship Management ) 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 ) • o
- 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 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. • o
On-demand solutions SAP Business ByDesign 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 • o
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) (2) (3) (4) (5) (6)
Exchange Infrastructure (XI) Business Intelligence (BI) Mobile Infrastructure (MI) Web Application Server (Web As) Enterprise Portal (EP) 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 Covers demands of midsize companies with in-depth industry requirements 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. • o o
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, preproduction 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 on screen as below.
- 17 -
Button. You will get the Log
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 realworld 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
- 20 -
Button
SAP –ABAP BOOK
You will enter the ABAP Editor screen. There type a line command. WRITE: ‘MY FIRST PROGRAM’.
Save the program :Click on Check Syntax : Cick on
Button (or) type Ctrl + S 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
Data Element 1
Table C
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 LIFNR NAME1 ORT01 STRAS LAND1
Data Type CHAR CHAR CHAR CHAR CHAR
Length 10 35 35 35 35
Description Vendor Acc No Name of Vendor City District 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
- 27 -
Enter Button
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
[LENGTH ] [TYPE] [COMPONENTS] [OUTPUT-LENGTH ] [DECIMALS] [EDIT MASK <m>] [HELP-ID ].
- 33 -
SAP –ABAP BOOK
The following table shows the different ways of expressing basic arithmetic operations in ABAP: Operation
Statement using
Statement using
Addition Subtraction Multiplication Division Integer division Remainder of division Powers
mathematical expression = + <m>. = <m> - . = <m> * . = <m> / . = <m> DIV . = <m> MOD . = <m> ** .
Keyword ADD TO <m>. SUBTRACT FROM <m>. MULTIPLY <m> BY . DIVIDE <m> BY . -------
• 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 [|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 TO .
- 34 -
SAP –ABAP BOOK When you assign the data object, the system checks whether the technical attributes of the data object correspond to any type specifications for the field symbol . The field symbol adopts any generic attributes of that are not contained in its own type specification. Following the assignment, it points to 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 . This statement defines a field group . 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 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 ... INTO . This statement defines the fields of field group . Before you can assign fields to a field group, you must define the field group 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 in the field group , 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 . 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: CO CN CA NA CS NS CP NP
Meaning Contains Only Contains Not only Contains Any contains Not Any Contains String contains No String Contains Pattern 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
- 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 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 ([]). 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 TO . or the equivalent statement = . Like all data objects, you can initialize internal tables with the CLEAR . 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 []. To ensure that the table itself has been initialized, you can use the REFRESH . 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 . 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 [ASCENDING|DESCENDING] [AS TEXT] [STABLE]. The statement sorts the internal table 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 ... 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 [LINES ] [OCCURS ] [KIND ]. Operations on internal table 1) To add a line to an internal table, use the statement: INSERT INTO TABLE . 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 [FROM ] [TO ] INTO TABLE . 2) The following statement allows you to summate entries in an internal table: COLLECT <wa> INTO . 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 . 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 FROM <wa> [TRANSPORTING ...]. 5) The AT statement introduces a statement block that you end with the ENDAT statement. AT . <statement block> ENDAT. You can react to the following control level changes: FIRST LAST NEW END Of
Meaning First line of the internal table Last line of the internal table Beginning of a group of lines with the same contents in the field and in the fields left of End of a group of lines with the same contents in the field and in the fields left of
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 , , ...., 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 .
INSERT TABLE ITAB.
COLLECT <wa> INTO .
COLLECT .
READ TABLE ... INTO <wa>.
READ TABLE ...
MODIFY TABLE FROM <wa> ...
MODIFY TABLE ...
MODIFY FROM <wa> ...WHERE ...
MODIFY ... WHERE ...
DELETE TABLE FROM <wa>.
DELETE TABLE .
LOOP AT ITAB INTO <wa> ...
LOOP AT ITAB ... Operations for Index Tables
APPEND <wa> TO .
APPEND .
INSERT <wa> INTO ...
INSERT ...
MODIFY FROM <wa> ...
MODIFY ...
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 [Additions]. - 42 -
SAP –ABAP BOOK To open a file for reading, use the FOR INPUT addition to the OPEN DATASET statement. OPEN DATASET FOR INPUT. To open a file for writing, use the FOR OUTPUT addition to the OPEN DATASET statement. OPEN DATASET 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 FOR APPENDING. To open a file at a particular position, use the AT POSITION addition in the OPEN DATASET statement. OPEN DATASET [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 FILTER . The operating system command in the field is processed when the file 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 MESSAGE <msg>. To write data to a file on the application server, use the TRANSFER statement: TRANSFER to [LENGTH ]. To read data from a file on the application server, use the READ DATASET statement: READ DATASET INTO [LENGTH ]. 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 [TITLE ] [AS WINDOW]. ... SELECTION-SCREEN END OF SCREEN . 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 ...... MEMORY ID ...... 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 ... VISIBLE LENGTH ... If is smaller than the field length of , the input field is displayed in the length . To define the input field of a parameter as a required field, you use the following syntax: PARAMETERS ...... OBLIGATORY ...... To check a user entry against a check table or against fixed values in the ABAP Dictionary, you use the following syntax: PARAMETERS
TYPE ... VALUE CHECK ... To suppress the display of the input field on the selection screen, you use the following syntax: PARAMETERS ...... 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
...... MODIF ID ...... 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 FOR . This statement is simply a shortened form of the following statements: DATA: BEGIN OF OCCURS 0, SIGN(1), OPTION(2) LOW LIKE , HIGH LIKE , END OF . 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 IN . - 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 ... MEMORY ID .......... •
Upper and lower case for selection criteria:
(2) SELECT-OPTIONS <seltab> FOR ... LOWER CASE .............. •
To make the From field a required field on the selection screen, use:
(3) SELECT-OPTIONS <selcrit> FOR ... OBLIGATORY .............. •
To hide input fields on the selection screen, use:
(4) SELECT-OPTIONS <selcrit> FOR ... NO DISPLAY .............. •
To modify input fields on the selection screen, use:
(5) SELECT-OPTIONS <selcrit> FOR ... MODIF ID ...........
To place comments on the selection screen, and if you want write anything in selection-screen, you use: SELECTION-SCREEN COMMENT [/]<pos(len)> [FOR FIELD ] [MODIF ID ]. To create a logical block of elements on the selection screen, you use: (1) SELECTION-SCREEN BEGIN OF BLOCK [WITH FRAME [TITLE ]] [NO INTERVALS]. ... (2) SELECTION-SCREEN END OF 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 [STARTING AT ]. To create a pushbutton on the selection screen, you use:
- 48 -
<x1> ] [ENDING AT <x2>
SAP –ABAP BOOK (4) SELECTION SCREEN PUSHBUTTON [/]<pos(len)> [MODIF ID ].
USER-COMMAND
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 . 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 is triggered when the contents of each individual input field are passed from the selection screen to the ABAP program. The input 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 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 The event is triggered when the user calls the F1 help for the 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 The event is triggered when the user calls the F4 help for the 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 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 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 LINES. This statement triggers a page break if less than free lines are left on the current list page between the last output and the page footer. 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 ]. 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 ]. 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 UNDER . The system starts outputting in the same column from which field started. This statement is not limited to the current page, that is, 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 INITIALIZATION AT SELECTION-SCREEN START-OF-SELECTION GET GET LATE END-OF-SELECTION
Occurs Before the standard selection screen is displayed After user input on a selection screen has been processed, but while the selection screen is still active After the standard selection screen has been processed, before data is read from the logical database After the logical database has read an entry from the node After all of the nodes of the logical database have been processed that are below in the database hierarchy After all data has been read by the logical database - 52 -
SAP –ABAP BOOK List processor events: Event TOP-OF-PAGE END-OF-PAGE AT LINE-SELECTION AT PF AT USER-COMMAND
Occurs In list processing when a new page starts In list processing when a page ends When the user triggers the predefined function code PICK When the user triggers the predefined function code PF 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-OFSELECTION. 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-OFSELECTION 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 (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 SY-LSIND SY-LISTI SY-LILLI SY-LISEL SY-CUROW
Information Index of the list created during the current event (basic list = 0) Index of the list level from which the event was triggered Absolute number of the line from which the event was triggered Contents of the line from which the event was triggered 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) SYFunction 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, the system automatically assigns extra functions to other function keys that provide additional functions. AT PF (obsolete) All function keys of the keyboard F that are not used for predefined system functions, are set to the function codes PF, where is a number between 01 and 24. During list processing, the function codes PF are linked to the events AT PF. Choosing PF always triggers AT PF. You should no longer use event blocks for PF.
•
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 |] [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 PFSTATUS 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 to deactivate the function code stored in field . Specify to deactivate all function codes stored in the internal table . Field and the lines of table 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 SYLISTI). Without this option, the system changes the status of the current secondary list (SYLSIND) 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 [WITH ... ] [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 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 .... . The system also
- 58 -
SAP –ABAP BOOK replaces '&' placeholders in succession by the contents of the corresponding 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, 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 .
- 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 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 [ENDING AT ]. 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 . This statement places the contents of the variable for the current output line (system field SYLINNO) into the HIDE area. The variable 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 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 [INDEX ] [FIELD VALUE [INTO ] ... [INTO ]] [OF CURRENT PAGE|OF PAGE ]. The statement without any options stores the contents of line 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 exists, the system sets SY-SUBRC to 0, otherwise to 4. The options have the following effects: •
INDEX - 61 -
SAP –ABAP BOOK The system reads the information for line from the list of level . •
FIELD VALUE [INTO ] ... [INTO ]
The system interprets the output values of the variables in line as character strings and places them either into the same fields or, when using INTO, into the fields .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, 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
With this option, is not the number of the line of the entire list, but the number of a line on page 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 [INTO ] ...]. 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