SAP ABAP BOOK-01 SAP ABAP I N D E X 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. SAP in IBM/SAP-ERP
Views 165 Downloads 2 File size 50MB
SAP ABAP BOOK-01
SAP ABAP
I N D E X
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17.
SAP in IBM/SAP-ERP Overview ABAP Data Dictionary Introduction to ABAP ALV Reporting OOPS ABAP Module Pool Programming (Online) Data Interface ALE LSMW SAP Scripts Smart Forms ADOBE PDF Form ABAP WDA Enhancement Production Quality ABAP Workshop Upgrade Overview Functional Overview
Service Line Track Name Category Target Audience Delivery Mode Duration JRSS
Table of Content for Technical Tracks_SAP ABAP (SAP) SAP SAP ABAP Graduate Hire Graduate Hire Classroom 40 days Application Developer-SAP.ABAP
Agenda: Day 1: SAP in IBM/SAP-ERP Overview
ABAP Guhire overview SAP NW overview SAP in IBM
Day 2 and 3: ABAP Data Dictionary
ABAP DDIC basics,Overview of ABAP Dictionary ABAP Dictionary Objects,Foreign Key Relationships ABAP Dictionary Tables in Relational Databases Adding Structures,ABAP Repository Information System ABAP Dictionary Changes,Overview of Search Helps ABAP Dictionary Objects-Views Type Groups,Online Help & Documentation Table Maintenance Generator
Day 4 to 6: Introduction to ABAP
Intro to ABAP, Adv Into to ABAP, Interactive reporting
Day 7 to 9: Case study1: Data Dictionary and classical report
Day 10: Classical ALV reporting: Overview of ALV
Day 11 to 12: Introduction of OOPS ABAP - Day 1
Fundamentals of ABAP Objects
ABAP Objects –Inheritance ABAP Objects –Interfaces ABAP Objects - Events Handling ABAP Objects - Global Classes and Interfaces ABAP Objects - Class Based Exceptions
Day 13: Advanced ALV Report with OOPS
ABAP Objects - Advanced ALV with ABAP Objects and RTTS
Day 14 and 15: Case study2: Detailed ALV Report with OOPS + Internal Assessment 1 (DDIC + OOPs)
Day 16: Online Programming Introduction to Online Programming:
Online Programming Example Screen Painter ABAP Dictionary Automatic Screen Field Checks Issuing Messages UserDefinedChecks Default Values and Cursor Position Graphical User Interface Dynamic Screen Sequence Conditional Execution of PAI Modules Sub-screens Database Operations Logical Locking Tabstrip Control Table Control andScreen Modifications and Screen Flow Events
Day 17 to 18: Data Interface/Conversion/BAPI - Day 1
Background Processing Application Server Files Presentation Server Files Batch Input Methods Batch Input Session Processing Batch Input Sessions
Call Transaction Method Batch Input Recorder Use of BAPIs for Data Interfacing
Day 19 to 20: Case Study3: End to End Interface Concepts uploading file from PS/AS and then BDC
Application Developer-SAP.ABAP
Day 22: LSMW: LSMW
Day 23: SAP Scripts
SAPScript Overview SAPScript Forms Coding in the SAPScript editor SAPScript - Output Program SAPScript – Configuration Printing SAPScript Forms Debugging SAPScripts
Day 24: Smart Forms
Introduction to SmartForms Global Settings Pages and Windows Basic Nodes Auxiliary Nodes Debugging SmartForm User Defined Exceptions
Day 25: Case Study 4 : Smart Forms + Internal Assessment 2 -[ Online programming + BDC+ Scripts] Day 26 to 27: ADOBE PDF For
Adobe - PDF based Print Form – Architechture Adobe - PDF based Print Form – Interface Adobe - PDF based Print Form – Context Adobe - PDF based Print Form – Designer Adobe - PDF based Print Form - Form Layout Adobe - PDF based Print Form - Scripting in the Form Adobe - PDF based Print Form - Integration into ABAP Programs Adobe - PDF based Print Form - Tips and Tricks
Day 28: Case Study5: ADOBE PDF Form
Day 29: Introduction to ABAP WDA
Web Dynpro For ABAP-Introduction Web Dynpro Controllers Web Dynpro for ABAP-Navigation Web Dynpro for ABAP-Context at Design Time Web Dynpro for ABAP-Controller and Context Mapping Web Dynpro for ABAP-Designing User Interface Web Dynpro for ABAP-Messages Web Dynpro for ABAP-Component Usage Web Dynpro for ABAP-ALV
Day 30: User Exit/Badi/Enhancement Spot
Day 31: Case Study6: Enhancement
Day 32: Production Quality ABAP Workshop (Performance tuning)
Day 33: Production Quality ABAP Workshop (Testing/Adv Debugging/Troubleshooting Concepts)
Day 34: Upgrade Overview: ABAP Upgrade Training
Day 35: Funcational Overview Concepts + Internal Assessment 3 -[ WDA+User exit+enhancement ]
SAPFunctionalOverview SAP MM overview for technical SD Overview for SAP Technicals SAP FICO Overview - Asset master & Transactions SAP FICO _AP_user manual Overview;SD Overview for SAP Technicals
Day 36: IBM Methods & Tools [FS/TS/UTP Templates and Checklists and Programming Standards + Overview - Delivery Management Tool - RTC + DE Case Study (Config. Mgmnt + SDLC)
Day 37: IBM Methods and Tools, Accelerators - RIC Generator, Code Snippet Generator, Auto TS Generator + Code Optimizer and RIC Generator + DE Case Study (Metrics and Reviews/Inspection )
Day 38: Case Study7: Project Simulation CS with Documentation Day 39: Practical exam - (On L&K SAP Server) + Assessment Day 40: Assessment
Day 1 SAP in IBM_SAP-ERP Overview
1
SAP NetWeaver is an ambitious undertaking with so many dimensions that it is hard even for experienced IT professionals to quickly understand its structure and potential. Think of SAP NetWeaver as essentially an orchestra of technologies with many programs and toolkits, each adding its own voice to the composition to allow you to do things that could never be done before. SAP Netweaver is Designed to Enable change through increased business flexibility and adaptability. Increase usability by making it easier for end users to work with all their systems. This increases user adoption, cost savings, and productivity. Enhance integration by making it possible for a collection of enterprise applications to work together. Enable innovation by allowing new applications to be constructed on top of existing applications. Save money by reducing the expense of owning and maintaining your existing systems.
2
Net weaver can help users and groups improve their productivity through enhanced collaboration, optimized knowledge management and intuitive search in business
objects as well as unstructured content. Personalized access to mission-critical applications and data is accomplished using portals, desktop clients and mobile interfaces. Flexible UI technology enables IT organizations and partners to build their own state-of-the-art applications. Key Terminologies Explained: Custom UI Development Web Dynpro ABAP , Java. Motivation Behind Webdynpro is : -UI definition independent of client technology. -Abstract declaration. -Different rendering engines for different (future) UI technologies without adapting application coding SAP EP At its most basic level, the purpose of a portal is simple: to organize complex assortments of information and tools in an accessible way. As the name indicates, a portal is a kind of doorway. SAP EP is both a doorway to SAP’s underlying applications and a doorway to all the business information — in all its many forms and from all types of sources — contained within your company. SAP EP is the layer that interacts with the user, coordinates that interaction, and channels it to SAP NetWeaver components, mySAP Business Suite solutions, and other applications. Then it displays the results. Example ESS , MSS Applications. Search Service in SAP The search services in the SAP Net Weaver Application Server (AS) ABAP provide a framework for indexing and searching SAP business objects in SAP applications. They comprise the following components: Embedded Search Embedded Search serves SAP Business Suite applications as a basic search technology platform for searching business objects using the TREX engine (starting with SAP Business Suite 2008). Embedded Search is the Enterprise Search component in the AS ABAP. It may be referred to as Enterprise Search (ABAP) in the documentation of SAP Business Suite applications. Search Engine Service Search Engine Service serves SAP applications to use the TREX search engine to search for business objects (starting with ERP 6.0). TREX The SAP NetWeaver standalone engine Search and Classification TREX provides SAP applications with numerous services for searching, classification, and text-mining in large collections of documents (unstructured data) as well as for searching in and aggregating across business objects (structured data). As a back-end engine, TREX provides search application such as SAP NetWeaver Enterprise Search and search services such as Search Engine Service and Embedded Search with indexing and search technologies. TREX as an SAP NetWeaver standalone engine is a significant part of most search features in SAP applications. TREX cannot be licensed as a separate product. Mobile: SAP Solutions for Mobile Business has one purpose: To bring business processes to mobile devices in a seamless computing environment, a kind of universal mobile adapter. To provide a complete solution, SAP created mobile applications that work across multiple platforms and systems and developed an infrastructure for these applications using (surprise!) SAP NetWeaver as the foundation. An important aspect of SAP MI is that it’s based on open standards such as Java, XML, and SOAP. This means that the platform can run on all kinds of devices and networks, from laptops to smart phones, and from wireless LANs to Bluetooth.
3
SAP BI as a whole is like the cockpit of a super airplane. The enterprise is the plane and SAP BI is the onboard computer, collecting data like speed, gas airflow, fuel level, and weather conditions. That data is promptly sorted, analyzed, and displayed so that both the pilot and navigator have the information they need in the form they need — whether a diagnostic readout or a speedometer — to make the right decision in real time. Knowing your speed is useful. Realizing you’re about to hit a major storm pattern is critical. The role that SAP BI plays in SAP NetWeaver is that of a central, integrated repository for information from distributed and heterogeneous sources. In more lucid language,just as in your home, data is stored all over the place, from the box of tax papers in the basement to the recipe file in the kitchen. In your enterprise, the good old Enterprise Resource Planning (ERP) system has its data, the friendly Customer Relationship Management (CRM) system has its data, and a grandfatherly legacy system that has been running for 20 years on a mainframe has even more data. Add to that your Web site data, your co-workers’ spreadsheets of data, and even that department down the hall that nobody’s quite sure what it does might have some data. To find out about the big picture, say customer or sales activity, the data from all these applications must be brought together. SAP BI is analogous to an airplane cockpit in a box, Business Content is a sample set of blueprints to get your flight analysis and reporting started. If Business Content can be likened to the airplane cockpit blueprint, the SAP BI preloaded Analytical Applications can be likened to an automatic computer that can build that cockpit for you based on the blueprint. It can’t fly the plane for you but it has already calculated every successful take off and landing and has a few strategies that it wants to recommend. The Analytical Applications are similar: They’re preloaded applications containing best practice analytical models. One application might contain all the common calculations that are needed for a company in the retail industry. Another application might contain best analytical techniques common to any business — calculating the lifetime value of a customer, for example.
4
5
Enterprise Information Management (EIM) is the business activity of creating, cleansing, integrating, managing, governing, and archiving structured and unstructured data used by an organization. EIM can help organizations integrate data and reconcile business information in heterogeneous IT landscapes and cross-company business networks to create a trusted data foundation for operational, analytical, and governance initiatives. SAP delivers solutions from different product families (SAP NetWeaver, SAP Business Objects IM, and SAP solution extensions) that support EIM activities such as enterprise data warehouse (EDW) management, master data management, data integration and data quality management, metadata management, information lifecycle management, and enterprise content management. By managing information assets effectively, organizations can minimize data integration efforts, streamline end-to-end business process execution, and gain well-founded business insight. MDM: The role of SAP MDM in SAP NetWeaver is way more than just that of a special purpose repository. You see, this product not only helps collect master data from all over the place, but with the soul of a data janitor it also helps clean up that data. It finds duplicate data and stores relationships between master data in records across systems. It also distributes master data back to source systems. Best way to Understand MDM is by below example: When company A buys company B, one of the first tasks facing company A is to figure out where the overlap is. For example, three groups of customers exist: customers who do business with company A only; customers who do business with company B only; and customers who do business with both companies. After a merger has been announced, the faster you sort out which part of which company goes with which customer, the better. Otherwise, you may have sales staff from company A and company B calling on the same customer or even competing for the same business without anyone catching on. Also, be sure that you quickly introduce company A’s products to company B’s customers, and vice versa. One way to handle this is to wait until both companies are running on the same systems. However, in most mergers of any size, that usually takes years. SAP MDM provides a much better solution that goes like this: -SAP MDM performs a consolidation so that all customers are identified in all the systems at company A and company B. -SAP MDM harmonizes the data in all the systems.
6
Service-oriented architecture (SOA) middleware facilitates communication between disparate applications and systems based on the exchange of XML messages. Most Commonly used Middleware tool is SAP PI. SAP PI, like other software, is simply a set of tools. But SAP PI acts like a superhighway: Whenever an application needs to send or receive a message, SAP PI is the road that carries it. SAP PI has on-ramps and off-ramps, and rules that make sure every message is received and read correctly when it reaches its destination. Now on to brass tacks. The purpose of SAP PI is to connect applications with each other. The problem is that frequently each application has its own format for data. So SAP PI is also like a translator in that it specializes in converting formats between applications from SAP or any other vendors so that they can successfully exchange messages.
7
8
9
10
11
Organizations face a difficult challenge in today’s security-conscious world having to support transparent enterprise boundaries, location-independent users, and the growing demands for regulatory compliance. With SAP NetWeaver, IT organizations can enable safeguards that protect their business, while helping users -- and the business processes they rely on – proceed unhindered by security operations.
12
Application Life-cycle Management provides processes, tools, services, and an organizational model to manage SAP and non-SAP solutions throughout the complete application life cycle. Instead of just focusing on the individual phases, SAP provides a holistic approach. Results of the different phases can be leveraged by other phases due to the integration provided by SAP Solution Manager This helps you to implement your IT solutions faster and operate them at lower cost.
13
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
SAP Overview ECC 6.0
The evolution of ERP solutions Materials Requirement Planning (MRP-I) began as a technique for developing enterprise-wide business solutions by providing automated tools for forecasting demands and planning according to the forecast
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
SAP Overview ECC 6.0
An integrated suite of business applications, which..
Closely links, monitors, and controls primary enterprise resources like manpower, machine, material, methods, market and money
Enables corporate firms to readily change their processes to adapt to the ever changing business scenario
Provides expertise in industry specific business processes
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
SAP Overview ECC 6.0
ERP - What It’s Not ……
ERP facilitates the decision making but does not decide.
ERP provides comprehensive information to optimize but does not optimize dynamically.
It automates and integrates transactions but does not target the cycle time.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
ECC 6.0
ERP will impact
Communication and information domain
Leadership and authority
Company policies
Jobs and rewards
Company structure and culture
Skills and knowledge of employees
Information is available online generally to a much broader audience
ERP can alter how work gets done and thus how people work together
ERP alters the level of decision-making authority
ERP can alter organizational structure
©IBM Global Services
SAP Overview
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
ECC 6.0
Recipe for a successful ERP application
Comprehensive functionality
Integration among modules and functions
Best Business Practices
Global support
©IBM Global Services
SAP Overview
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
SAP Overview ECC 6.0
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. SAP is now the recognized leader in providing collaborative business solutions for all types of industries and for every major market. Serving more than 36,200 customers worldwide, SAP is the world's largest business software company and the world's third-largest independent software provider overall. Today, SAP employs more than 38,400 people in more than 50 countries.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
SAP Overview ECC 6.0
In 1990s SAP R/3 was released. With SAP R/3, SAP ushers in a new generation of enterprise software -- from mainframe computing (client-server architecture) to the three-tier architecture of database, application, and user interface.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
ECC 6.0
Heterogeneous Platforms
©IBM Global Services
SAP Overview
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
SAP Overview ECC 6.0
With the Internet, the user becomes the focus of software applications. SAP develops mySAP Workplace and paves the way for the idea of an enterprise portal and role-specific access to information. As mentioned earlier, with the introduction of mySAP Business Suite, SAP is now organized into a service-based architecture, which has the following: mySAP Customer Relationship Management (CRM) mySAP ERP mySAP Product Lifecycle Management (PLM) mySAP Supply Chain Management (SCM) mySAP Supplier Relationship Management (SRM) mySAP ERP addresses the core business software requirements of the most demanding midsize and large organizations -- in all industries and sectors. mySAP ERP includes four individual solutions that support key areas of Enterprise Resource Planning: mySAP ERP Human Capital Management (HCM) -- Maximize workforce potential. mySAP ERP Financials -- Turn finance into a strategic business partner. mySAP ERP Operations -- Free up resources; budget for innovation. mySAP ERP Corporate Services -- Streamline business processes and costs.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
SAP Overview ECC 6.0
SAP has since broadened the integration vision of mySAP Technology into a blueprint they call the Enterprise Services Architecture (ESA). SAP NetWeaver is a comprehensive integration and application platform”, mySAP Technology is now renamed SAP NetWeaver™; NetWeaver delivers the ESA blueprint. SAP NetWeaver is a vision, or paradigm, of total integration of : People Information Business Processes Applications SAP has a team of over 2000 developers in a single organization, working on NetWeaver.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
ECC 6.0
Quick Facts about SAP ERP6.0: •Launched in June 2006 •Built on SAP NetWeaver 7.0 •Approximately 7000 systems (12/2007) •Platform upon which SAP will deliver future software innovations •Software innovation delivered via “SAP enhancement packages”
©IBM Global Services
SAP Overview
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
SAP Overview ECC 6.0
Because configuration is captured in data, as opposed to code, it survives software upgrades and other changes.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
SAP Overview ECC 6.0
R/3 applications are written in the ABAP programming language, and run within the application layer of the R/3 System.
ABAP programs communicate with the database management system of the central relational database (RDBMS), and with the graphical user interface (SAPGUI) at presentation level.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
SAP Overview ECC 6.0
ABAP programs are objects of the R/3 Repository. Like all other Repository objects, you maintain them using an ABAP Workbench Tool.
To open ABAP programs directly from the tool ABAP Editor, select the menu path Tools -> ABAP Workbench ->Development -> User Interface -> ABAP Editor from the SAP menu of SAP Easy Access (or start Transaction SE38). If you want to change a program using this method, you must already know its name and environment.
This procedure is only suited for maintaining or creating relatively simple or short programs, which have few or no additional components. It is better to access ABAP programs through Tools -> ABAP Workbench -> Overview -> Object Navigator from the SAP menu of SAP Easy Access (or start Transaction SE80).
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ERP / SAP Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Client Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Client Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Client Overview
SAP Overview ECC 6.0
A client is a logical portion of an SAP R/3 physical database. From a business standpoint, a client can be interpreted as a logical group of companies. All customizing (configuration) and development (ABAP) work in SAP R/3 is performed in a client. However, the data from both customizing and development work may be stored within an individual client (client dependent data) or among all clients (client independent data) in the system.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
SAP Overview
SAP Client Overview
ECC 6.0
The data in each client may be separate from that of the other clients. There are basically two types of data in an SAP R/3 System. Client-dependent and client-independent data. Client-dependent data is defined as data specific to an individual client. Client-independent data can be defined as data contained across all clients in the system. Some examples of client-dependent data include number ranges, ABAP variants, and user masters as well as the data that is created or updated through SAP R/3 transactions transaction data). Examples of client-independent data include data dictionary objects (tables, views), ABAP source code, screens, and menus. All data resides in tables. To determine if a particular table is client-dependent or client-independent, the table structure needs to be reviewed. The table structure can be viewed by the data dictionary (SE11). If MANDT (client in German) is the first key field of the table, then the table is clientdependent; otherwise, the table is client-independent. For example, the TSTC table is client-independent; however, the USR01 table is client-dependent. As shown in the above diagram, every SAP R/3 system contains the three clients 000, 001, and 066. Let’s review these clients and examine what they contain.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Client Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Client Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training
SAP Overview
SAP Client Overview
ECC 6.0
During a standard install of the SAP R/3 system, clients 000, 001, and 066 are set-up and provided. These clients provide different features and must not be deleted. Client 000 performs special functions. In particular, it is given extended functionality during upgrades. Client 001 is basically a copy of 000 and can be used as a basis for a new customizing client. Client 066 is a special client which is provided for operational system monitoring. It is used by SAP R/3’s Early Watch Service to provide performance recommendations. In releases prior to 3.0, client 000 contained a model company. As of Release 4.0 clients, 000 and 001 are identical. Client 000 no longer contains a model company. Either client can be used as the basis for configuration through a client copy. Typically, most projects start with a copy of client 000 to begin building configuration. Customer work should never take place in the three delivered clients.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Client Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Client Overview
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
SAP Overview ECC 6.0
Saplogon is used to create icons to logon to SAP R/3. However, the icons created with Saplogon are not placed in the SAP R/3 Windows group, they are instead shown via the Saplogon Menu (shown in the slide). The SAP logon pad is available once the SAP GUI is installed at the workstation. The Saplogon Menu can be thought of as a one-stop shopping store, where end-users can choose from logon icons, logon groups, or create new logon icons. Logon icons will log a user onto one specific application server. A logon group will log the user onto one of several applications servers depending on which one has the best performance statistics.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
SAP Overview ECC 6.0
To create a shortcut for connecting to a new SAP application server, follow the procedure below: 1. Click the ‘New Item’ button and enter the following details :
Description: Give a meaningful short text for identifying the Server. The Server will be available in the SAP Logon pad with this name. Nor
Application Server: Give the IP/Address of the Application Server, provided by the basis administrator.
System number: Give the system number provided by the basis administrator. It should be kept as 00, if nothing is specified.
System ID given as per the mail
2. Click ‘OK’. 3. The newly created SAP application server will now be available in the SAP logon pad.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training
SAP Overview
SAP Navigation
ECC 6.0
Follow the procedure below to Log on to the SAP Server: 1. Launch the SAP Logon pad (
).
2. Double click on the Application Server (which you need to connect), from the SAP Logon pad. The SAP Logon screen appears. 3. In the SAP Logon screen, the value of the default client appears automatically, if you want to logon to a different client, then change it with the new client number. 4. Next, enter the User ID and password, which have been assigned to you. 5. Enter ‘EN’ in language to logon to English settings. Generally the language is defaulted to ‘EN’ or any other language depending on the country/users. So, you may not need to enter it in the SAP logon screen and it takes its values from the default settings. 6. After filling up the 4 fields, hit enter to logon to the SAP system. 7. During the first time logon to the system with your ID, you will be prompted to change your initial password. 8. However, to change your password later, click on the New Password push-button and set the password. 1. Select a new password and then confirm it by typing it again. The asterisk will remain in the password field. 2. Click on the
icon once you are satisfied with your password selection.
The Password must contain at least 3 characters and no more than eight.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training
SAP Overview
SAP Navigation
ECC 6.0
Once you have logged on to the application, the initial menu screen will appear. All menus are displayed in the menu bar. The menus that appear in the menu bar varies according to the task you are doing in the R/3 System. Therefore, you will see different menus as you work on different tasks. Menus that are always available from every screen in the R/3 System:
System: This menu contains functions that affect the system as a whole, such as the Create Session, End Session, User Profile, or Log Off options.
Help: The Help menu contains functions for accessing various forms of online support.
Those icons which are available for use will be enabled (they will not be shaded gray). In order to determine what each icon represents on the tool bar, place the cursor on the icon (if it is enabled) and a floating box will appear with text and a unique Function key used to identify the icon.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
SAP Overview ECC 6.0
Using the Layout menu: 1. Click on the Layout menu located in the standard toolbar to activate the customization option. 2. Then select the Options menu item. This will lead you to a screen where you can select the following customization options:
Options
Cursor
Local Data
I18N
Expert
Trace
Scripting
With these options you can configure settings like:
Whether to sound ‘Beep’ at message
Whether to display dialog box for success message
Whether to show keys in dropdown lists etc.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
SAP Overview ECC 6.0
To view only an icon specific function key: Place the cursor on top of an icon to view the floating help reference.
In order to view all available function keys while on any screen: Click on the right mouse button (see above) and then use the left mouse button to select a function.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
SAP Overview ECC 6.0
Use the menu path System User Profile Own data to change user specific settings such as:
Output Device
Print controller
Date Format
Decimal Notation
Logon Language (interface and documentation)
The user profile is connected to the user ID. It will be applied to each logon session for that user, irrespective of which PC is used or which SAP system the user connects to.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
SAP Overview ECC 6.0
1. Change the Default settings for the User.
Change your output device to print to your Windows default printer. 1. Place your cursor in the output device field and then hit F4 to view the list of available output devices. 2. You may also want to select the checkbox which would allow for immediate printing capabilities, otherwise the default is to output the spool file.
Change the date format to be MM/DD/YYYY.
Change the Decimal notation to be a Decimal Point.
2. Once changes have been made, save your work, and then exit the window by using the icon.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
SAP Overview ECC 6.0
The R/3 System displays warning and error messages in the status bar. A system message consists of one line; however, you can get more information about a message by doing the following: 1. On the status bar, click anywhere on the message, or position the cursor directly on the message and click the icon or hit F1. 2. A dialogue box will appear with help on the message. 3. If more detailed information is required, you have the option to select the Technical info push-button. Depending on the complexity of the error message, different information will be displayed in this dialogue box. Sometimes you will be presented with Message Data and Program Data and sometimes you will only see Message Data.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
SAP Overview
SAP Navigation
ECC 6.0
You can create a session at any time and from any screen in the system; you will not lose any data in sessions that are already open. You can create up to 6 sessions. Each session you create is as if you logged on to the system again. Therefore, the system has more work to do which can affect how fast it responds to your requests. To create a new session from anywhere in the system, proceed as follows: 1. Choose System Create Session from the menu bar. 2. The system opens an additional window with the new session running in it. 3. The new session becomes the active session and remains the active session unless you move to a different (open or new) session. This can be done by using the ALT + TAB keys. 4. The new session number is shown in parentheses on the status bar. For example, one session may be AD3 (1) and the other may be AD3 (2). AD3 is the SAP system being used and the numbers (1) and (2) are the sessions being used by the user. To end a session, choose the following menu path: 1. System End Session. The remaining sessions are not re-numbered.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
SAP Overview
SAP Navigation
ECC 6.0
Before you can use a transaction code, you have to find the right transaction code for the task you want to start. To display transaction codes in the SAP main menu screen (the initial SAP Screen displayed after logon) do the following : 1. Go to Extras Settings (Shift + F9) 2. Click checkbox for Show technical names 3. The Transaction codes are now displayed along with the Transaction short text in the SAP menu. Once a transaction is selected, you can start the task associated with it by double-clicking it. Otherwise, you can use this transaction code to start this task from any screen in the R/3 System. When you are in a transaction, you can find its transaction code by using the menu path: 1. System Status
Note: In order to return to the SAP main menu screen, type /N in the command field and click the button in the screen displayed.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
SAP Overview ECC 6.0
In the R/3 System, you can create a session and start a task in one step by using a transaction code. When you open a session with a transaction code, the system displays the initial screen of the task in a new session. To use this method, you must know which transaction code to use for the task you want to perform.
To create a new session and a task at once from anywhere in the system, do the following: 1. In the command field enter a /o followed by the transaction code for the task you want to start. /o allows you to keep the current session and create a session without losing the original session /i = Kills session you are working on. 2. For example, to create a customer master record in the Accounts Receivable application, you would use the transaction code FD01. To open a session and start this task at the same time, then you would enter /ofd01 in the command field. 3. Hit Enter for execution or click on the green arrow.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
SAP Overview ECC 6.0
To exit the application use the menu path: 1. System Log Off 2. A popup screen will be displayed ‘Unsaved data will be lost. Do you want to log off ?’ (This message will appear even if you have saved your data.) Select YES to log off the system without saving any changes or updates. Select NO to cancel the log off request.
Warning: If you have several sessions open and you log off with this method instead of end session, it will kill all your sessions.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training SAP Navigation
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
SAP Overview ECC 6.0
The CTS is the central tool for managing changes to Customizing and Repository data that you make in the IMG or ABAP Workbench. The CTS records all changes in change requests. The changes in change requests can be linked together logically, or can be completely independent of each other. Developers in a team can use a common request. You can create documentation for a change request, where you can describe your changes in more detail. This makes it easier to see which data was changed by which user, and to what purpose. When you have finished your work in the IMG or ABAP Workbench, or have reached a certain stage, you can release the request. The change request is then used to copy the changes from this client to other clients or systems. This automatic procedure is known as a transport. Transports of changes by the CTS allow you to develop in one environment, test your development work in a test environment, and then, if the tests are successful, use it productively. This makes sure that productive operations are not placed at risk by faulty settings or program errors. Transports of changes between clients and systems are subject to rules that are set in the CTS configuration in the system landscape. One rule may be that changes are transported into a test environment before they can be copied to the production environment. All transports are logged, so that you can see when a change request was imported into a client or system, and whether there were any errors.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training
SAP Overview
Change and Transport System
ECC 6.0
Transport Organizer is the set of utilities which provide for the development change management and customization (configuration) change management.
All development changes (ABAP/4, DDIC) and Customizing are tracked through the Transport Organizer.
The Transport Organizer is accessed via transaction SE09 or SE10.
The Development Workbench is now fully integrated with the Transport Organizer.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
SAP Overview ECC 6.0
The initial screen provides various selection criteria for locating an individual Request. Select the ‘Workbench Requests’ checkbox to locate Development change requests and select the ‘Customizing Requests’ checkbox to display the list of change requests used to organize Customizing objects.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
SAP Overview ECC 6.0
The Transport Organizer displays all of the Requests which meet the selection criteria in a graphical tree format.
“Drill down” features are available to allow the user to display the desired level of detail for a Request or Task.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
SAP Overview ECC 6.0
By drilling down to the detail level on an individual task, from within the Transport Organizer, the user can display the list of all objects contained within the task. The object list displays all objects, development or customizing, for which changes are recorded in the selected task. Information on these objects include: Desc: Category of the object. Prg_type : Program type Obj: Element object type. Obj. name: Name of the object to be transported. Funct.: Correction function for the object. Possible values are: “M” Delete and recreate in the target database. “ ” Delete the specified object in the target database, and insert the value from the source database. “K” The object contains key values. Individual entries from the object have been specified for transport. “D” Delete the object from the target database.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
SAP Overview ECC 6.0
ObjStatus: Object lock indicator. Possible values are: LOCKED Object locked. NOT_IMP Object not imported. ERR_IMP Error importing object. OK_IMP Object imported. OK_GEN Object imported and generated. From within the Display Object List, you can drill down further on objects which have key values associated with them (Function “K”). Details regarding the table records specified by the key values are displayed on this screen. They include: Obj: Element object type. TabName: Table name. Key (beginning): Table key (abbreviated) for the object in the request/task. F: Function for the key entry. Possible values include: “ ” If the key exists in the source system, it is transported to the target system. If the key does not exist in the source system, it is deleted from the target system.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
SAP Overview ECC 6.0
1. When entering a configuration/creating a development object, the SAP will prompt the user for a Change Request (assuming that the client has been set to automatically record customizing changes). 2. If the user already has an outstanding Change Request that he/she would like to place the customizing/development change in, the “Own Requests” button can be selected. This will provide the user with a tree structure view of all requests with which that user is associated. From there, the user may select the appropriate request in which to include the customizing/development change. 3. By selecting the “Create Request” button, a new Change Request will be generated, and a Task within the new request will be generated.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
SAP Overview ECC 6.0
4. Having selected “Create Request” on the previous screen, the user is prompted to enter a short description for the new request. 5. The user’s id is automatically assigned to this request, and a task is generated within the Change Request. 6. If the user is authorized, he/she may also add additional users to this request, each one receiving their own task within it.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
SAP Overview ECC 6.0
7. After providing a short description for the Change Request and selecting the Save button, the SAP system returns the number of the new request. 8. As long as this request remains open, future customizing/development changes can continue to be added to it.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
SAP Overview ECC 6.0
All users who will be editing development objects on the R/3 system must be registered with SAP and assigned a development key.
If a user has not been assigned a development key, the message shown above will be displayed.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
SAP Overview ECC 6.0
By selecting the ‘Information’ button from the previous screen, the user can obtain the R/3 system’s installation number. This number is required for the registration process.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
ECC 6.0
A list of all registered developers can be found in table DEVACCESS.
This table displays the registered user ID and associated developer key.
©IBM Global Services
SAP Overview
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
SAP Overview ECC 6.0
A Package is a group of logically related development objects. A Package contains all the development objects which must be developed, maintained, and sometimes transported together. The objects that make up a transaction usually belong to one Package. Before 4.7 Package was called Development Class.
When creating a new object in the R/3 system, the developer will be prompted to supply a Package. By selecting a valid Package and then a CTS, changes to the object will be recorded in the Transport Organizer.
If the “Local Object” button is selected, the object is classified as a local private object, and changes are not recorded by the Workbench Organizer. Local private objects may not be transported.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
SAP Overview ECC 6.0
To add a new Task to an existing Request, place the cursor on the Request in the Request tree diagram. 1. Select the “Add User” button. 2. Select the user ID of the individual to whom this new Task will be assigned. 3. Multiple Tasks may be created for a single user in a Request.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Change and Transport System
©IBM Global Services
SAP Overview ECC 6.0
Dec-2008
Day 2 and 3 ABAP Data Dictionary
IBM Global Business Services
Apr 2007
1
IBM Global Business Services
Apr 2007
2
IBM Global Business Services
Apr 2007
3
IBM Global Business Services
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; or
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; or
Use transaction code SE11
The ABAP Workbench was known as the ABAP/4 Development Workbench in past releases.
The Object Navigator used to be called the Object Browser and the Repository Browser.
Apr 2007
4
IBM Global Business Services
Apr 2007
5
IBM Global Business Services
Apr 2007
6
IBM Global Business Services
Apr 2007
7
IBM Global Business Services
DATA CLASS : The data class defines the physical area of the database (for ORACLE the TABLESPACE) in which your table is logically stored. If you choose a data class correctly, your table will automatically be assigned to the correct area when it is created on the database.
The most important data classes are (other than the system data):
APPL0
Master data : Master data is data which is frequently read, but rarely updated.
APPL1
Transaction data : Transaction data is data which is frequently updated
APPL2 Organizational and customizing data : Organizational und customizing data is data which is defined when the system is initialized and then rarely changed.
There are two more data classes available, USR and USR1. These are reserved for user developments. The tables assigned to these data classes are stored in a tablespace for user developments.
Apr 2007
8
IBM Global Business Services
Apr 2007
9
IBM Global Business Services
Buffering Database Tables
Buffering a table improves the performance when accessing the data records contained in the table. The table buffers reside locally on each application server in the system. The data of buffered tables can thus be accessed directly from the buffer of the application server. This avoids the time-consuming process of accessing the database.
Buffering is particularly important in client/server environments, as it takes considerably longer to access a table with the network than it does to access a table that is buffered locally.
Apr 2007
10
IBM Global Business Services
You must define whether and how a table is buffered in the technical settings for the table. There are three possibilities here:
Buffering not permitted: We must not buffer a table if the table data is frequently modified. In this case the cost of synchronization could be greater than the gain in performance resulting from buffering.
We also do not buffer time critical data.
Buffering permitted but not activated:
Buffering activated: Generally custom data are buffered with full buffering or generic buffering.
Apr 2007
11
IBM Global Business Services
Apr 2007
12
IBM Global Business Services
Apr 2007
13
IBM Global Business Services
Apr 2007
14
IBM Global Business Services
Follow menu path Utilities - Table maintenance generator from transaction SE11.
Specify the Authorization Group. (E.g. &NC& for skipping any Authority Check)
Click ‘one step’ maintenance type.
Give the Overview Screen as ‘9000’. (You can specify any Screen Number beginning with 9)
Now, hit the Create Button to create the maintenance view for the table. Specify the Development Class and CTS when prompted for.
Specify a Function group. (If you don’t have a Function Group already, then open transaction SE80 in another session and create a Function Group)
Also remember to set the ‘Display/Maintenance allowed’ value in the table attributes.
Apr 2007
15
IBM Global Business Services
If we check one step maintenance then we can create edit delete in the same overview screen
Apr 2007
16
IBM Global Business Services
Only one maintenance screen is processed during extended table maintenance. The entries are displayed in list form on this screen.
Apr 2007
17
IBM Global Business Services
Two maintenance screens are processed during the extended table maintenance:
On the Overview screen the entries are displayed in list form.
On the Single screen one entry is displayed. The single screen can be called from the overview screen, by function key, for every entry.
Apr 2007
18
IBM Global Business Services
*** IF we select two step maintenance then put the overview screen as 9000 and single screen 9001 for detail view
Go to transaction SM30 (Maintain Table Views: Initial Screen) and specify the table name.
You can Display and Maintain Table entries by clicking the ‘Display’ and ‘Maintain’ pushbuttons.
Click the ‘Maintain’ pushbutton to maintain the entries for the table.
Apr 2007
19
IBM Global Business Services
Apr 2007
20
IBM Global Business Services
Logically A delivery class is not meant for transporting the data but technically if we choose Standard recording
routine then it is possible to transport the data .
Apr 2007
21
IBM Global Business Services
Apr 2007
22
IBM Global Business Services
We should create a customize transaction for the TMG this is because of the fact that if someone has the authorization of SM 30 they can modify any table so to prevent that we create the customizing Transaction for our TMG .
Apr 2007
23
IBM Global Business Services
The first radio-button is for dialog or for online programming transaction
The second one is for Report transaction
The third one is for Class (oops) transaction
The fourth one is for variant
Apr 2007
24
IBM Global Business Services
First go to se93 give a transaction code begin with z press create .
Choose the 5th radio button i.e. Transactions with parameters .
In the transaction we should give SM 30 to maintain the table .
Give the appropriate screen no .
Name of the screen field 1> viewname ----------- table name (eg. Ztestlk)
2> update -------------- X Now we are able to acces the table using this Tcode .
Apr 2007
25
IBM Global Business Services
Apr 2007
26
IBM Global Business Services
Apr 2007
27
IBM Global Business Services
Apr 2007
28
IBM Global Business Services
Apr 2007
29
IBM Global Business Services
We can initialize the variable by just clearing it.
Eg. clear .
Apr 2007
30
IBM Global Business Services
Apr 2007
31
IBM Global Business Services
Apr 2007
32
IBM Global Business Services
Apr 2007
33
IBM Global Business Services
To set the default values of parameters or select options.
Eg. Suppose we have a parameter p_date where we want the default value as 30 days after the current date.
In this case if we use the following code:
parameters: p_date type sy-datum default sy-datum + 30.
We will get syntactical error here since the default offset should be only string.
Hence in this case we can solve our problem in the following way:
parameters: p_date type sy-datum.
initialization.
p_date = sy-datum + 30.
This is one situation when the initialization event becomes necessary.
Apr 2007
34
IBM Global Business Services
Steps for declaring an internal table/work area. Type declaration. First method types: begin of ty_cepc, bukrs type bukrs, "company code prctr type prctr, "profit centre datbi type datbi, "valid to date kokrs type kokrs, "controlling area end of ty_cepc. OR Second method types: begin of ty_cepc, bukrs type cepc~bukrs, "company code prctr type cepc~prctr, "profit centre datbi type cepc~datbi, "valid to date kokrs type cepc~kokrs, "controlling area end of ty_cepc. Here the second method is preferable since in this case the data element refers to the nature of the data element in that particular table (eg. cepc~bukrs). In the first case search help for the field kokrs will not come automatically where as in the second case it will come automatically. This is because in table CEPC for field kokrs the input help is implemented with check table and when we use the second method we refer to the data element in the table CEPC where as since there is no search help implemented for the data element kokrs so when we use the first method it refers to this data element which ha no input help implemented.
Apr 2007
35
IBM Global Business Services
Note: It's a good practice to declare all the internal tables, all the work areas, all the variables and all the constants together.
Apr 2007
36
IBM Global Business Services
Apr 2007
37
IBM Global Business Services
Apr 2007
38
IBM Global Business Services
**** Validation on input field can be checked in AT SELECTION-SCREEN EVENT as well as AT SELECTION-SCREEN ON EVENT .
If we want to validate a single input field then we should always validate in AT SELECTIONSCREEN ON event if we validate it in AT SELECTION-SCREEN then all the other field which is not meant for validation will also get validated so performance issue will get decreased .
Apr 2007
39
IBM Global Business Services
Apr 2007
40
IBM Global Business Services
Apr 2007
41
IBM Global Business Services
Suppose for example we have a select option as following:
SELECT-OPTIONS: so_matnr FOR v_matnr.
Then in the multiple selections option button at the selection screen if we enter the values as follows:
In the Select Single Values tab we enter a value say 1301.
In the Select Ranges tab we enter 1301 in the lower limit and 1400 in the upper limit.
In the Exclude Single Values tab we enter a value say 1304.
In the Exclude Ranges tab we enter 1310 in the lower limit and 1320 in the upper limit.
We can view this table through the debugging mode.
Apr 2007
42
IBM Global Business Services
A search help describes the flow of an input help. The search help can only take effect using a mechanism that assigns the search help to this field. This mechanism is called the search help attachment to the field.
Attaching a search help to a field has an effect on the field's behavior. It is therefore considered to be part of the field definition.
The input help (F4 help) is a standard function of the R/3 System. It permits the user to display a list of possible values for a screen field. A value can be directly copied to an input field by list selection. The fields having an input help are shown in the R/3 System by the input help key to the right of the field. This key appears as soon as the cursor is positioned on the corresponding screen field. The help can be started either by clicking on this screen element or with function key F4. If the number of possible entries for a field is very large, you can limit the set of displayed values by entering further restrictions.
Apr 2007
43
IBM Global Business Services
A search help can be attached directly to a field of a structure or table. The definition of this attachment is analogous to that of a foreign key. You have to define an assignment (between the interface parameters of the search help and the fields of the structure) for which the system makes a proposal.
If a field has a check table, its contents are automatically offered as possible values in the input help. The key fields of the check table are displayed. If a check table has a text table, its first character-like non-key field is displayed.
If you are not satisfied with the described standard display of the data of the check table, you can attach a search help to the check table. This search help is used for all the fields that have this table as check table. You have to define an assignment between the interface of the search help and the key of the check table when you define the attachment
Attaching a search help to a check table (or a data element) can result in a high degree of reusability. However, there are restrictions on passing further values via the interface of the search help .
With the screen event POV you can program the input help of a field by yourself. You can adjust the design of the help to the standard help using the function modules F4IF_FIELD_VALUE_REQUEST or F4IF_INT_TABLE_VALUE_REQUEST.
Apr 2007
44
IBM Global Business Services
Apr 2007
45
IBM Global Business Services
Apr 2007
46
IBM Global Business Services
Apr 2007
47
IBM Global Business Services
Apr 2007
48
IBM Global Business Services
Apr 2007
49
IBM Global Business Services
Apr 2007
50
IBM Global Business Services
Apr 2007
51
IBM Global Business Services
Apr 2007
52
IBM Global Business Services
Apr 2007
53
IBM Global Business Services
Apr 2007
54
IBM Global Business Services
Apr 2007
55
IBM Global Business Services
Apr 2007
56
IBM Global Business Services
Apr 2007
57
IBM Global Business Services
Apr 2007
58
IBM Global Business Services
Apr 2007
59
IBM Global Business Services
Apr 2007
60
IBM Global Business Services
Apr 2007
61
IBM Global Business Services
Apr 2007
62
IBM Global Business Services
The message type determines where the message is displayed and what action the user can or must take on the current screen .
Apr 2007
63
IBM Global Business Services
Apr 2007
64
IBM Global Business Services
Apr 2007
65
IBM Global Business Services
Apr 2007
66
IBM Global Business Services
Apr 2007
67
IBM Global Business Services
Apr 2007
68
IBM Global Business Services
Documentation helps in further use and helps the user to understand the purpose of the object.
Document Should be maintain for future reference .
Documentation can be maintain GO->Documentation->Click ‘Edit Documentation’ in Documentation pop-Up ->Document->Upload.
Or by change Editor instead of upload
Apr 2007
69
IBM Global Business Services
Apr 2007
70
IBM Global Business Services
Apr 2007
71
IBM Global Business Services
Apr 2007
72
IBM Global Business Services
Apr 2007
73
IBM Global Business Services
Apr 2007
74
IBM Global Business Services
Apr 2007
75
IBM Global Business Services
Apr 2007
76
IBM Global Business Services
The debugger stops only if the watchpoint variable (SY-SUBRC) changes and the additional condition (SY-SUBRC = 4) is met.
Apr 2007
77
IBM Global Business Services
Apr 2007
78
IBM Global Business Services
Similarly we can set dynamic breakpoints at any other ABAP Commands, Methods, Functions, forms etc.
Apr 2007
79
IBM Global Business Services
Apr 2007
80
IBM Global Business Services
Apr 2007
81
IBM Global Business Services
Apr 2007
82
IBM Global Business Services
Apr 2007
83
IBM Global Business Services
Apr 2007
84
IBM Global Business Services
Apr 2007
85
IBM Global Business Services
Apr 2007
86
IBM Global Business Services
Apr 2007
87
IBM Global Business Services
Apr 2007
88
IBM Global Business Services
Tips:
Never use local objects in a client program.
Consult your TL before using, creating a transport request.
Apr 2007
89
IBM Global Business Services
Apr 2007
90
IBM Global Business Services
Apr 2007
91
IBM Global Business Services
Apr 2007
92
IBM Global Business Services
Apr 2007
93
IBM Global Business Services
Apr 2007
94
IBM Global Business Services
Apr 2007
95
IBM Global Business Services
Note1: The test conditions should be given in proper business terms and not in technical terms. For instance we cannot write "validate plant from table t001w".
Note2: The UTP (Test Condition, Step Description, and Expected Result) is usually prepared before we actually start coding. The UTP is prepared depending on the object requirement
Apr 2007
96
IBM Global Business Services
Apr 2007
97
IBM Global Business Services
Apr 2007
98
IBM Global Business Services
Apr 2007
99
IBM Global Business Services
Now in order to confirm whether the data in this internal table is proper or not we can verify the data from the database table but this is not a proper method. Hence we go the standard transactions like MM03,VA01 etc depending on the project requirement and verify the data.
After that if alv report we check whether the fieldcatalog internal table is populated and lastly we check whether the subroutine for displaying the reports/uploading/downloading file is working properly or not.
Apr 2007
100
IBM Global Business Services
Apr 2007
101
IBM Global Business Services
Client-dependent data is defined as data specific to an individual client. Client-independent data can be defined as data contained across all clients in the system.
In SAP all data resides in tables. To determine if a particular table is client-dependent or clientindependent, the table structure needs to be reviewed. The table structure can be viewed by the data dictionary (SE11). If MANDT (client in German) is the first key field of the table, then the table is client-dependent; otherwise, the table is client-independent.
Apr 2007
102
IBM Global Business Services
Apr 2007
103
IBM Global Business Services
Apr 2007
104
IBM Global Services - SAP Development ABAP Training Overview of the ABAP Dictionary
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Overview of the ABAP Dictionary
ABAP Dictionary ECC 6.0
ABAP also known as ABAP/4, and /4 represents that it is a 4th Generation language.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Overview of the ABAP Dictionary
ABAP Dictionary ECC 6.0
A data dictionary is a centralized storage location for information about the data that is stored in a database. This information is often called “metadata” (data about data). A data dictionary provides answers to questions such as: What data is contained in the database? What are the attributes of this data: name, length, format, etc.? What relationships exist among different data objects? SAP’s data dictionary is called the ABAP Dictionary. As an ABAP developer, it is unlikely that you will be responsible for creating and maintaining objects within the ABAP Dictionary. ABAP Dictionary is accessed via transaction code SE11.
The purpose of this chapter is to familiarise you with how objects are created, stored, and used by the ABAP Dictionary.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Overview of the ABAP Dictionary
ECC 6.0
The ABAP Dictionary: Enforces data integrity Manages data definitions without redundancy Is tightly integrated with the rest of the ABAP Workbench
©IBM Global Services
ABAP Dictionary
Dec-2008
IBM Global Services - SAP Development ABAP Training Overview of the ABAP Dictionary
ABAP Dictionary ECC 6.0
Enforcing data integrity is the process of ensuring that data entered into the system is logical, complete, and consistent. When data integrity rules are defined in the ABAP Dictionary, the system automatically prevents the entry of invalid data. Defining the data integrity rules at the dictionary level means they only have to be defined once, rather than in each program that accesses that data. The following are examples of data lacking integrity: A date field with a month value of 13 An order assigned to a customer number that doesn’t exist An order not assigned to a customer
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Overview of the ABAP Dictionary
ABAP Dictionary ECC 6.0
Managing data definitions without redundancy is the process of linking similar information to the same data definition.
For example, a legacy customer database is likely to contain a customer’s ID number in several places. The ABAP Dictionary provides the capability of defining the characteristics of a customer ID number in only one place. That central definition then can be used for each instance of a customer ID number.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Overview of the ABAP Dictionary
ABAP Dictionary ECC 6.0
The ABAP Dictionary’s integration with the rest of the development environment enables ABAP programs to automatically recognize the names and characteristics of dictionary objects. Additionally, the system provides easy navigation between development objects and dictionary definitions. For example, as a programmer, you can double-click on the name of a dictionary object in your program code, and the system will take you directly to the definition of that object in the ABAP Dictionary. When a dictionary object is changed, a program that references the changed object will automatically reference the new version the next time the program runs. Because ABAP is interpreted, it is not necessary to recompile programs that reference changed dictionary objects.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Overview of the ABAP Dictionary
ABAP Dictionary ECC 6.0
The basic objects of the ABAP Dictionary are tables, data elements and domains. Tables are the structures that actually store the information that is in the database (i.e., customer information). Tables are composed of rows (called records) and columns (called fields). Data elements and domains are used to describe the characteristics of fields. More information about these objects will be covered in future chapters.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Overview of the ABAP Dictionary
ABAP Dictionary ECC 6.0
The database utility provides the interface between the ABAP Dictionary and the underlying database management system (DBMS). It supports the creation of tables and secondary indices in the database both online and in the background. You can access the database utility using transaction code ‘SE14’. Whenever you make a change to a dictionary object that affects the underlying database, the database utility is activated. Usually it works silently behind the scenes, but occasionally the database utility will prompt you for information. This occurs when an error is encountered or when existing data must be converted. The database utility provides the interface to the DBMS by automatically generating the Data Definition Language (DDL) that the DBMS understands.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Overview of the ABAP Dictionary
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Overview of the ABAP Dictionary
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Overview of the ABAP Dictionary
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Overview of the ABAP Dictionary
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
ABAP Dictionary ECC 6.0
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; or Use the menu path: Tools ABAP Workbench Overview Object Navigator Pull down the Workbench menu and select Edit objects… Select the Dictionary tab from the pop up screen and enter the appropriate table name in the Database table field. or Use transaction code SE11 The ABAP Workbench was known as the ABAP/4 Development Workbench in past releases. The Object Navigator used to be called the Object Browser and the Repository Browser.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
ABAP Dictionary ECC 6.0
The basic objects of the ABAP Dictionary are tables, data elements, and domains. These form the active part of the ABAP Dictionary and contain all the field-related metadata of the R/3 System. A field is not a dictionary object, but rather is a component of a table. A field cannot exist without a table and only has meaning within that particular table. Data elements and domains are dictionary objects. Therefore, they can be used by many tables. They specify the characteristics of fields. Table name is limited to 16 characters. Data element and domain names are limited to 30 characters. These concepts will be explained more fully in future pages. Table, data element and domain names were limited to 10 characters in previous releases.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
ABAP Dictionary ECC 6.0
Tables are the objects that actually hold the information in a database. They consist of rows (records) and columns (fields). For example, table KNA1 stores information about customers. Some of the columns in KNA1 are KUNNR (customer ID number), NAME1 (customer name), and ORT02 (customer city). Each row in KNA1 stores this information for a different customer. Certain fields in a table are specified as the primary key of that table. The primary key is that field or combination of fields that uniquely identifies a row in the table. In table KNA1, the SAP R/3 client (MANDT) and the customer number (KUNNR) form the primary key. Custom tables must start with a Y or a Z and can be 16 characters in length.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
ABAP Dictionary ECC 6.0
The Object Navigator is used to organize your programming in an integrated development environment. It can be used to create, change, and manage objects. It is the center point of entry into the ABAP Workbench. You can get to the Object Navigator by way of transaction SE80 or the menu path: Tools ABAP Workbench Overview Object Navigator
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
ABAP Dictionary ECC 6.0
Now, let’s take a look at creating a table in the ABAP Dictionary. We will create a table called ZXXFIRSTTABLE (where XX stands for the last two digits of your logon id). This table will hold information about your ABAP class. Follow the menu path: 1. Tools ABAP Workbench Overview Object Navigator 2. Pull down the Workbench menu and select Edit object. Select the Dictionary tab from the pop up screen and enter the appropriate table name in the Database table field. 3. Click the Create button (F5). 4. You can also use Transaction Code SE11, and select radio button for Database table. 5. Remember, custom table names must begin with a Y or Z and are restricted to 16 characters. Enter a description (short text) and a delivery class. 6. If the table is to be maintained via SAP R/3-provided table maintenance screens, select the table maintenance attribute (Tab.Maint.Allowed). 7. Click the Fields tab to begin adding Fields to the new table. We will learn how to add Fields later in this chapter.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
ABAP Dictionary Objects
ECC 6.0
Table fields are defined in SAP R/3 by data elements and domains. This is a key difference between SAP R/3 and many other systems. In many other systems, a field is defined only by its type (i.e., character, numeric) and length. These characteristics are assigned directly to each field. In SAP R/3, a field is defined by being assigned to a data element, which is in turn assigned to a domain. These assignments determine the field’s type and length in addition to other characteristics. SAP R/3 refers to this method of field definition as the “Two-Level Domain Concept”. In addition, you can assign the field type (data type) characteristics in different ways: You can directly assign the field a data type, length, and short text when defining the table. You can assign a data element to a field so that the field will inherit the data element’s characteristics.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
ABAP Dictionary ECC 6.0
The meaning of a field name is not always obvious. For example, KUNNR may not immediately bring the image of a customer to your mind. Data elements help resolve this problem. A data element provides a meaningful description for a field. You will hear it called a semantic domain. The data element description appears beside a field in a table definition. These descriptions are language-dependent (unlike field names). Even more importantly, the data element provides field headings for use on screens. When you “paint” a dictionary field on a screen, you can automatically have the data element field headings appear. This permits the end user to see meaningful field descriptions. Also in a data element, parameter id is provided. Using a Parameter ID, a screen field that can be filled with proposed values from SAP memory. A Search help can be assigned to a data element. A search help is an object of the ABAP Dictionary with which input helps (F4 helps) can be defined. The advantage of using a data element to describe fields and provide field headers is that the data element can be used more than once. For example, SAP R/3 contains many tables that have the field KUNNR. In cases like this, it is not necessary to enter the description for KUNNR many times. Each instance of KUNNR can be assigned to the same data element, and the field description only needs to be specified once. Additionally, if the description needs to be changed, it must be changed only once, and all fields referring to that data element automatically use the new description.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
ABAP Dictionary ECC 6.0
SAP R/3 comes delivered with many pre-defined data elements. Whenever the semantic description of a field you are creating matches with an existing SAP R/3- supplied data element, use the one that SAP R/3 provides. Otherwise, you must create your own data element. When using a SAP R/3-supplied data element, however, you must also use the corresponding SAP R/3-supplied domain. If you wish to use a different domain, you must create your own data element.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
ABAP Dictionary ECC 6.0
Now, let’s take a look at creating a data element in the ABAP Dictionary. We will create a data element called ZXXFIRSTNAME (where XX stands for the last two digits of your logon id). This data element will be used in the table ZXXFIRSTTABLE which we just created. 1.
To create a data element within the ABAP Dictionary use transaction SE80 or the menu path: Tools ABAP Workbench Overview Object Navigator. You can also use Transaction Code SE11, and select radio button for Database Type and then Data Element.
2.
Pull down the Workbench menu and select Edit object. Select the Dictionary tab from the pop up screen and enter the appropriate Data Element name in the Data Element field.
3.
Click the Create button (F5).
4.
Enter a description (short text) and a Domain.
5.
Enter ZXXNAME as the Domain (where XX stands for the last two digits of your logon id).
6.
We will create this Domain later in the chapter. Click the SAVE icon (Ctrl+S).
7.
Type in your development class, YXXA (where XX stands for the last two digits of your logon id).
Note : As of 4.0, a Data Element cannot have the same name as an existing table or Structure.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
ABAP Dictionary ECC 6.0
Next, click the Field label tab. Provide a descriptive text for each of the following labels; Short, Medium, Long, and Heading. These labels are used as templates in the Screen Painter as a choice between the different label lengths. The Heading field is used as the column heading for tabular record entries and its length should correspond with the length of the field. Click the SAVE icon (Ctrl+S).
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
ABAP Dictionary ECC 6.0
In addition to providing field descriptions and headers, data elements can provide detailed field documentation. This documentation is maintained at the data element level and is available to a user who hits F1 when the cursor is on a field assigned to the data element. To maintain this documentation, navigate to the Change Data Element screen within the ABAP Dictionary and click the Documentation push-button.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
ABAP Dictionary ECC 6.0
A domain specifies the technical characteristics and the allowed values of a field. Domains are linked to fields via data elements. In other words, fields are assigned to data elements, and data elements are assigned to domains. You cannot directly assign fields to domains. The technical characteristics of a field are the field’s type and length. These are also referred to as the field’s format. The allowed values of a field define what is acceptable input for that field. These may be listed explicitly or may be specified by reference to a value table. The concept of allowed values is explained more fully on later pages.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
ABAP Dictionary ECC 6.0
Domains can exist independently in the ABAP Dictionary. Just as multiple fields may be assigned to the same data element, multiple data elements may be assigned to the same domain. As with data elements, pre-defined domains exist in the system and are available for your use. If a SAP R/3-supplied domain matches the characteristics you require, use the pre-defined domain. If you wish to change the domain’s allowed values, however, you must create your own domain. In addition to the characteristics listed previously, domains can also specify a field’s output characteristics, such as output length and whether or not lowercase letters are permitted for that domain.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
ABAP Dictionary ECC 6.0
Valid values for a domain can be explicitly listed. To create or maintain an explicit list of valid values, use the menu path Goto Fixed Values on the Change Domain screen in the ABAP Dictionary. Explicit values are used when the list of valid values are not likely to change over time. For example, if a domain was meant to contain the names of the months of the year, it would be possible to explicitly list “JANUARY” through “DECEMBER” as the allowed values (note that this would not work well in a multi-language environment) Valid values for a domain can also be specified by reference to a value table. When this is done, the records in the value table specify the valid values for the domain. In order to specify a value table for a domain, one of the key fields of that table must point to that domain. That field is the one that determines the valid values for the domain. A value table is used when the list of valid values may change over time. For example, a car maker may want to use a value table to list the valid colors for certain car models. As new colors are developed, the value table can be updated without changing the domain itself.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
ABAP Dictionary ECC 6.0
By defining valid values for a domain, automatic validation is provided for any fields that point to that domain. This includes validation at the ABAP Dictionary level (if a program tries to insert invalid data, an error will occur) as well as at the screen level (users will not be permitted to enter invalid data). Whereas in a report, suppose we have a parameter that references a domain with fixed values then still user can give invalid data & sap ignores this validation if the addition VALUE CHECK is not provided with the parameter declaration Additionally, users can obtain a list of possible entries (for fields pointing to domains with allowed values) by hitting function key F4.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
ABAP Dictionary ECC 6.0
Now, let’s take a look at creating a Domain in the ABAP Dictionary. We will create a Domain called ZXXNAME (where XX stands for the last two digits of your logon id). This Domain will be attached to the Data Element ZXXFIRSTNAME which we just created. 1.
To create a Domain within the ABAP Dictionary use transaction SE80 or the menu path: Tools ABAP Workbench Overview Object Navigator.
2.
Pull down the Workbench menu and select Edit objects… Select the Dictionary tab from the pop up screen and enter the appropriate Domain name in the Domain field.
3.
You can also use Transaction Code SE11, and select radio button for Domain.
4.
Enter ZXXNAME as the Domain name (where XX stands for the last two digits of your logon id).
5.
Click the Create button (F5).
6.
Enter a description (short text), a data type, and the appropriate number of characters for this Domain.
7.
Click the
8.
Type in your development class, YXXA (where XX stands for the last two digits of your logon id)
icon (Ctrl+S).
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
ABAP Dictionary ECC 6.0
A domain can define a value range containing the valid values for fields that refer to that domain.
Explicit values or a value table can be defined for the Domain ZXXNAME. 1. Click the Value range tab. Under both sections of this screen, we can assign valid values to the Domain ZXXNAME. This means that SAP will only allow the values specified on this screen to be entered into any field that references the Domain ZXXNAME. 2. A Value Table can also be assigned to the Domain ZXXNAME. If a Value Table is assigned to ZXXNAME, SAP will only allow the values contained within the Value Table to be entered into any field that references the Domain ZXXNAME if a foreign key is defined. 3. Once valid values are assigned, click the icon (Ctrl+F3). 4. Navigate back to the Data Element ZXXFIRSTNAME. Click the icon (Ctrl+F3). 5. Navigate back to the Table ZXXFIRSTTABLE. We will now add a custom field to our table.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
ABAP Dictionary ECC 6.0
Now you are able to add custom fields to the table ZXXFIRSTTABLE. •
Enter FIRSTNAME as the first field in the field list.
•
Enter ZXXFIRSTNAME as FIRSTNAME’s Field Type (Data Element).
•
Assigning the Data Element to the field FIRSTNAME means that the field FIRSTNAME will inherit the same data type and characteristics that we previously assigned to its Data Element, ZXXFIRSTNAME. The field FIRSTNAME will be a Character based field with a length of 30.
•
Check the Primary Key checkbox next to the field FIRSTNAME. (This will be discussed in later chapters)
•
Continue to add relevant fields (such as LASTNAME, HOMETOWN, POSTBOX, etc.) to this table. Remember to create your own Data Elements and Domains when SAP does not provide fields that meet your exact specifications.
•
Click the
icon (Ctrl+F3) to activate the new table when you are done.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
ABAP Dictionary Objects
ECC 6.0
Maintain the table’s Technical Settings by entering a Data Class and a Size Category. Both of these fields will depend on what the table will be used for and how much data you expect the table to hold. For this example, ZXXFIRSTTABLE will hold a small amount of Master Data. 1.
Select APPL0 for the Data Class.
2.
Select 0 for the Size Category.
3.
Click the
4.
The table ZXXFIRSTTABLE should now be in an active status and it should contain one field FIRSTNAME.
©IBM Global Services
icon (Shift+F8) and then the
Dec-2008
button (F3).
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
ABAP Dictionary ECC 6.0
The Data statement: The statement DATA declares a variable of any data type . The SELECT – ENDSELECT statement retrieves records one at a time from the database and puts them into the work area. The SELECT-ENDSELECT syntax creates a looping structure. In other words, all statements between SELECT and ENDSELECT are executed once for each record retrieved from the database. The WRITE statement writes data to the screen.
SELECT-ENDSELECT is the Elementary statement for selecting record within an ABAP code, so this is used here to explain the basic concept of database select. But, you should firmly remember that this statement should not be used inside programs that you do during project work. For SELECT-ENDSELECT the database is hit everytime a new record is found. There are efficient ways of retrieving multiple records from a database table at one shot and storing them in Internal tables. You will learn the technique in a future slide. Dec-2008 ©IBM Global Services
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Foreign Key Relationships
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Foreign Key Relationships
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
Foreign Key Relationships
ECC 6.0
Relationships between tables are represented in the ABAP Dictionary by foreign keys. A foreign key is a field (or combination of fields) that represents the primary key of another table. For example, if table YORDERS has a field CUSTID indicating which customer placed the order, that field could be established as a foreign key (assuming that CUSTID was the primary key of the YCUSTOMERS table). Note that CUSTID is not necessarily part of the primary key of the table YORDERS. The table that is referenced by the foreign key (in our example, YCUSTOMERS) is called the check table. The check table is also known as the “referenced” or “parent” table. The table that contains the foreign key fields (in our example, YORDERS) is called the foreign key table. The foreign key table is also known as the “dependent” or “child” table.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Foreign Key Relationships
ABAP Dictionary ECC 6.0
Foreign keys are used for: 1. Maintaining data integrity 2. Providing additional texts in the online help system 3. Creating other dictionary objects that are defined over multiple tables (such as views)
Maintaining data integrity is probably the most important reason to use foreign keys. With foreign keys, it is possible to prevent values from being entered into one table that do not already exist in another table. For example, it becomes impossible to enter orders that do not have valid customer numbers.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Foreign Key Relationships
ABAP Dictionary ECC 6.0
In order to establish a foreign key relationship in SAP, the fields involved must share the same domain. Therefore, foreign keys provide an additional data integrity check beyond that which is provided by the value table. Prior SAP versions required that Foreign Keys must have a Value Table specified.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Foreign Key Relationships
ABAP Dictionary ECC 6.0
Let’s review some of the key terminology relating to foreign keys. Value table: The table containing the set of allowed values attached to a domain. Check table: The table that is referenced by a foreign key. A check table is either identical to a value table, or is another table containing a subset of the records in a value table. Foreign key table: The table containing fields that are the primary key of the other table. The foreign key table is also known own as the “dependent” or “child” table.
Using Foreign Keys, you can 1. Create value checks for input fields. 2. Link several tables in a view or in a lock object.
To see a full list of the allowed values for a screen field, place the cursor inside the field and hit the F4 key.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Foreign Key Relationships
ABAP Dictionary ECC 6.0
For example, suppose a foreign key relationship was established between an ORDERS table and a PRODUCTS table in order to ensure that orders contained valid product numbers. In this case, it is likely that the value table and the check table would both be the PRODUCTS table. In many cases, the value table and the check table will be the same. However, it is important to understand the distinction between the two. The Value Table is optional in the foreign key definition. Foreign Key definitions must always have a Check Table assigned.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
Foreign Key Relationships
ECC 6.0
For example, suppose a telephone company stores general customer information in the CUSTOMERS table and stores specialised information about business customers in the BUSINESS_CUSTOMERS table. Suppose that there was also a BUSINESS_OWNERS table that listed the owners of all business customers. The BUSINESS_OWNERS table might consist of two fields: Customer ID and the name of each individual owner. In this case, we would establish a foreign key relationship between the BUSINESS_OWNERS table and the BUSINESS_CUSTOMERS table. The value table for the customer ID field in the BUSINESS_OWNERS table would be the CUSTOMERS table, but the check table would be the BUSINESS_CUSTOMERS table. The foreign key table would be the BUSINESS_OWNERS table.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Foreign Key Relationships
ABAP Dictionary ECC 6.0
To establish a Foreign Key in the ABAP Dictionary, begin by navigating to the field definition of the Foreign Key Table and entering change mode. The Foreign Key can then be established by placing the cursor on the Foreign Key Field, and then by clicking the icon in the Application Toolbar. Based on the Value Table for the domain of the field you selected, the system will suggest a Foreign Key Relationship for you.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
Foreign Key Relationships
ECC 6.0
When creating foreign key relationships, you should always specify the cardinality of that relationship. Here is a reminder of the possible values for each side of the n : m notation that SAP uses to specify cardinality. For the left side: n=1 Each record in the foreign key table refers to exactly one record in the check table. n = C Each record in the foreign key table refers to zero or one records in the check table. For the right side: m=1 Each record in the check table has exactly one dependent record. m=C Each record in the check table has a zero or one dependent records. m=N Each record in the check table has at least one dependent record. m = CN Each record in the check table has zero, one, or many dependent entities.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
Foreign Key Relationships
ECC 6.0
Using the Object Navigator edit the Table ZXXFIRSTTABLE which we created in Chapter 2. Place the cursor on the field for which you wish to create a Foreign Key Relationship. In this example, we will add the Check Table T005S as a Foreign Key for the STATE field so that users will be forced to enter a valid state into the Table ZXXFIRSTTABLE. Click the icon to create the Foreign Key Relationship for the STATE field. Remember the criteria for establishing a Foreign Key Relationship: the Foreign Key Field and Check Table Field must share the same domain. Since the field STATE’s domain (REGIO) has a Value Table (T005S), SAP will propose T005S as the Check Table for the field STATE when we click the Foreign Key pushbutton. Click Yes when the Create Foreign Key window appears. You can see a graphical representation of the foreign key relationships in a table by clicking on this icon or from application toolbar (Ctrl+Shift+F11).
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Foreign Key Relationships
ABAP Dictionary ECC 6.0
Enter a description (short text). Maintain the semantic attributes (see Data Dictionary Appendix for information on setting up the Cardinality) Cardinality n : m n = 1 or C m = 1, C, N, CN Foreign Key Field Type (see Data Dictionary Appendix for information on setting up the Foreign Key Field Type) 1. Not Specified 2. Non-Key Field Candidates 3. Key Field / Key Field Candidates 4. Key Fields of a Text Table Click the Copy button at the bottom of the screen.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Foreign Key Relationships
ABAP Dictionary ECC 6.0
If the primary key of a check table has multiple fields (i.e. it has a composite primary key), some type of assignment must be made for each field when creating a foreign key relationship. The options include: Creating a field-by-field assignment. Every primary key field in the check table is matched with a field in the foreign key table. Using a partial foreign key. Some fields will not be a determining factor in deciding what check table records provide acceptable values for the foreign key field being checked. Using a constant foreign key. Only check table records with a particular constant (literal) value in a particular field provide acceptable values for the foreign key field being checked.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Foreign Key Relationships
ABAP Dictionary ECC 6.0
When performing a field-by-field assignment, all key fields in the check table are used to determine valid entries in the foreign key table. For example, suppose there was a YCOURSES table with the key fields faculty (academic department) and course number. This table would provide the master list of courses that an academic institution offers. Suppose also that there was a YOFFERINGS table with the key fields faculty, course number, and section number. This table would list the times and dates that different sections of each course were offered. In this case, we would establish a foreign key relationship from YOFFERINGS to YCOURSES using field-by-field assignment. In other words, the faculty and course number fields for each record in the YOFFERINGS table would have to match the faculty and course number fields for some record in the YCOURSES table.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Foreign Key Relationships
ABAP Dictionary ECC 6.0
When creating a partial foreign key, certain fields are flagged as generic. These fields are ignored by the system when validating records that are inserted into the foreign key table. For example, suppose that we were tracking information about new courses that were under development in a YNEWCRS table. This table would have faculty and course number as the primary key. However, in this table, we would not want to validate the course number against the YCOURSES table, because by definition the new courses are not yet in the YCOURSES table. In this case, we might use a partial foreign key from YNEWCRS to YCOURSES and flag the course number field as generic. In other words, the table YNEWCRS would be forced to have valid values in the faculty field, but we could enter any course number we wanted. This example is for illustration purposes. In a real-world application, there would probably be a separate YFACULTY table that would list valid faculties, and the YNEWCRS table would probably be validated against that table. Note: If additional fields are added to the primary key of a check table, the new fields are automatically flagged as generic in any previously existing foreign keys.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Foreign Key Relationships
ABAP Dictionary ECC 6.0
When creating a constant foreign key, certain fields are assigned a literal value. Only records in the check table with that value in the corresponding field are used to determine whether records in the foreign key table are valid. For example, suppose there was a table YBIOCRS that contained specific information about biology courses. The primary key of this table would be course number only (it would already be understood that the courses were biology courses). In this case, we would want to validate the course number against the YCOURSES table, but we would only want biology course numbers to be valid. That is, if there was a course “English 402” but no course “Biology 402”, we would not want 402 to be a valid entry in table YBIOCRS. To accomplish this, we could establish a foreign key from YBIOCRS to YCOURSES with the constant value “BIO” in the faculty field.
Note: Assigning a constant value to a field has the effect of restricting the values that are permissible for the other foreign key fields in the foreign key table. Validation is actually turned off for the field that is assigned the constant value. For example, if we changed the above example so that the table YBIOCRS did have a faculty field, it would be possible to enter any value in that field.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
Foreign Key Relationships
ECC 6.0
Click on the checkbox provided to flag a foreign key field as generic. Enter a constant value in quotes to define a foreign key relationship with a constant. It is possible to combine the use of partial and constant foreign keys within the same foreign key relationship.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Foreign Key Relationships
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Foreign Key Relationships
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Foreign Key Relationships
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Foreign Key Relationships
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
©IBM Global Services
Dec-2008
ABAP Dictionary ECC 6.0
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
©IBM Global Services
Dec-2008
ABAP Dictionary ECC 6.0
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
ABAP Dictionary ECC 6.0
There are 3 different table types in the SAP ABAP Dictionary: 1. Transparent tables 2. Pool tables 3. Cluster tables
Data in the SAP R/3 system is stored in a relational database management system (RDBMS). All tables in the SAP R/3 system are created using the ABAP Dictionary and are stored in the relational database.
The ABAP Dictionary is SAP’s tool for developers to maintain any type of table that exist in the physical database.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
ABAP Dictionary ECC 6.0
SAP uses the term master data to refer to control tables and the traditional files that are necessary to run a business such as personnel files, general ledger accounts, customer files, etc. There is a 1:1 correlation between the master data tables in the Dictionary and the tables in the physical database. For each master data table in the Dictionary, the same master data table exists in the physical database. Commercial data or transaction data is another SAP term used to refer to data created as a result of performing SAP business transactions such as creating: invoices, orders, production schedules, purchase requisitions, stock transfers, etc. SAP stores both master data and transaction data in transparent tables (TRANSP).
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
ABAP Dictionary ECC 6.0
Transparent (TRANSP) tables have a 1:1 correlation between the ABAP Dictionary and the physical database. For each TRANSP table in the Dictionary, the same table name exists in the physical database. Since TRANSP tables exist in the physical database, you can use either Open SQL or Native SQL to access them. Transparent tables are created automatically in the database after you specify the table’s technical settings and activate the table using the Database Utility. The Database Utility gets invoked automatically when you activate the table by clicking the icon.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
ABAP Dictionary Tables in Relational Databases
ECC 6.0
Pooled tables can be used to store control data (e.g. screen sequences, program parameters or temporary data). Several pooled tables can be combined to form a table pool. The table pool corresponds to a physical table in the database in which all the records of the allocated pooled tables are stored. Cluster tables may contain continuous text, for example, documentation. Several cluster tables can be combined to form a table cluster. Several logical lines of different tables are combined to form a physical record in this table type. This permits object-by-object storage or object-by-object access. In order to combine tables in clusters, at least parts of the primary keys must agree. Several cluster tables are stored in one corresponding table on the database. We will not be working with these two type of tables in the exercises for this course.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
ABAP Dictionary ECC 6.0
Technical settings allow you to optimize the storage requirements and table access behavior of database tables. The Technical Settings screen appears when you click the icon on the ABAP Table Maintenance screen. Data class - Designates the table to an area in the physical database where similar tables are grouped (in ORACLEä and INFORMIXä only). Size Category - Identifies the amount of disk space that will be required to hold the data records for a table in the database (in ORACLEä and INFORMIXä only). Buffering - Determines whether table records will be accessed directly from the database server or from global memory. Logging - Creates before and after images of changes to the table of contents. Logging must be activated by the profile when the system is started.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
ABAP Dictionary ECC 6.0
Tables in the ABAP Dictionary must be assigned to one of the following classes of data: Master Data: Large amounts of data which do not change often. It is often read, but rarely updated. An example of master data is the data contained in an address file, such as the name, address and telephone number. (APPL0) Transaction Data: Data with temporary lifecycle, not stored long. Frequently updated. An example of transaction data is the goods in a warehouse, which change after each purchase order. (APPL1) Organization and Customizing Data: Specified when the system is configured and then not often changed. An example is the table with country codes. (APPL2) Two further data classes, USER and USER1, are provided for the customer. These are used to define user developments. Defining a data class has the effect of storing the table in a defined area of the database when the table is created.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
ABAP Dictionary ECC 6.0
A table’s size category identifies the amount of disk space on the database that is allocated to the table. This amount is translated to a number of data records if you hit F4 for help, depending on the underlying database. If the number of records in a table exceeds the original size category, then more space will automatically be allocated in the database. The storage space will be incremented by the amount of the original size category.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
ABAP Dictionary ECC 6.0
Buffering is only recommended for tables with data that typically does not change or get updated. Buffering types: Single record: Only a single record actually being processed is moved into the buffer. This type of buffering preserves buffer space but requires more database hits in order to load the table. Recommended for large tables when only a few records need to be accessed. Generic: A subset of the table records are loaded based on part of the primary key. Recommended if only certain “generic” areas of the table will be needed. Full: Results in either all of the table or none of it being loaded into the buffer. Recommended for a) tables up to 30 K in size, b) larger tables where access is needed to many records, and c) tables against which attempts to access data will frequently yield a “no record found” result.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
ABAP Dictionary ECC 6.0
On the technical settings screen you can specify “Log data changes” to automatically generate a log file of details on the structure of a table, a list of the data changes made during a certain period, and statistics. In addition to clicking the checkbox “Log data changes” on the technical settings screen, you must ensure that the System Administrator has also specified the switch or entry to allow “Table Logging On”. Log files do not rely on successful database updates to be completed before they are written. The existing logs can be displayed with Transaction code SCU3.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
ABAP Dictionary ECC 6.0
Activating tables causes the Technical Settings screen to display. Choose an appropriate data class and size category. Use the F4 help to list the possible entries. The Buffering and Logging settings can also be set on this screen. When the settings are saved, SAP automatically runs the Database Utility. A table’s Technical Settings can be changed at any time. For successful activation of tables, we need to specify the enhancement category using the menu path Extras Enhancement Category in ECC 6.0.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
©IBM Global Services
Dec-2008
ABAP Dictionary ECC 6.0
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
©IBM Global Services
Dec-2008
ABAP Dictionary ECC 6.0
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
ABAP Dictionary ECC 6.0
The Database (DB) Utility is a tool used in SAP to serve as a interface between the database management software (i.e., ORACLE, INFORMIX, DB2, INGRES, etc.) and the ABAP Dictionary. It is used to: Convert data (i.e., change field lengths and data types, etc.) Activate objects in the ABAP Dictionary Create tables and indices Perform all standard table operations in the database that were entered in the ABAP Dictionary The DB Utility automatically writes the SQL commands necessary to create, change and delete tables and indexes in the physical database, and records the tables in the ABAP Dictionary. As the DB Utility is operating, a log file gets created which contains information on whether or not the conversion was successful and the point of failure during the conversion if it was not successful. The DB Utility can be run either online or in the background. You can also manually run the DB Utility from any ABAP Dictionary screen under the UTILITIES Database Object Database Utility menu or transaction SE14.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
ABAP Dictionary Tables in Relational Databases
ECC 6.0
To improve performance, SAP automatically creates a primary index (id 0) for transparent tables based on the primary key. You can also define your own secondary indexes for transparent tables. Indexes accelerate the reading of tables when the system looks for records satisfying specific search criteria. The system determines the most efficient index by which to select data for the specific request. An index serves as a sorted copy of the table reduced to specific fields, with a pointer to the remaining fields. Database indexes are defined in ABAP Dictionary and stored in the physical database. From the ABAP table maintenance screen use the menu path GoTo Indexes. A pop-up window appears. In pop up window press the create button and select the entry ‘Create Index’ from the dropdown. Assign a 3-character id to your index. Provide a short text and select the field(s) by which the table needs to be indexed. Sometimes the presence of an index causes a performance problem. You can indicate the optionality of the index with different databases. Secondary index is used for the tables which are not frequently changed (Eg: Master tables) Creating an index on an SAP table requires a repair, but it will not get overwritten with an upgrade.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
ABAP Dictionary ECC 6.0
In the cases where database accesses are necessary and appropriate, it is imperative to perform those accesses as efficiently as possible. The single most important method of optimizing a database access is by using an index. An index is a set of fields from a table that is sorted and then stored in a location separate from the table itself. Each record in the index contains a pointer to matching record(s) in the actual database table.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
ABAP Dictionary ECC 6.0
This analogy is probably as old as computer science itself, but it still works well. Think of an index like a telephone book. If you want to find someone’s phone number, the first thing you might do is decide where you want to look for that number. One thing you probably won’t do is start calling all possible telephone number combinations until you hit upon the right one! You might ask a friend, or call directory assistance, or look up the information in a phone book. Let’s suppose you decide to use a phone book. The next thing you do is to begin searching for that person’s name in the book. Once you find the name, you then look across from the name to find the number. A DBMS goes through a similar process when performing a query. It first must decide how it is going to look for the information that has been requested, just as you did when looking for a telephone number. One option is to look at each record in the table, one at a time, until all the matching records have been found. This would be analogous to trying all possible combinations of telephone numbers until you found the right one. As ridiculous as that sounds, sometimes DBMS’s have to do just that. This is called performing a full table scan.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
ABAP Dictionary ECC 6.0
Another option the DBMS has is to perform an index scan. In this case, the DBMS looks in a separate file, searching for the information by a particular key field (or fields). This is like using the phone book, searching for the correct name. Once the matching record(s) have been found in the index, the DBMS follows a pointer from the index to retrieve the actual record in the table. This pointer consists of a disk address that tells the system exactly where to find the desired record(s). In our telephone book example, the analogous process is pretty simple: you simply look across the line from the name to the telephone number.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
ABAP Dictionary ECC 6.0
This process is analogous to an index range scan that might be performed by a DBMS. Sometimes an index doesn’t point to a single record. If you have an index of customers by their last names, this will probably be the case - you will probably have many customers with the same last name. In this case, once the database finds matching record(s) in the index, its job isn’t over. It now must retrieve all the records that matched the selected index records, and examine each one to see if they meet the final selection criteria for the query.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
ABAP Dictionary ECC 6.0
In contrast, if each index record matches exactly one record in the table, and if all the fields of the index are specified in the query, a unique index scan can be performed. Queries based on a table’s full primary key always fulfil this criterion - such as by client (implicit if using Open SQL) and customer number in table KNA1. In this case, once the DBMS finds the matching record in the index, its work is almost done. All it must do is follow the pointer from the index to the solitary table record that it knows will satisfy the query.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
ABAP Dictionary Tables in Relational Databases
ECC 6.0
In general, indexed reads are much quicker than normal table reads, and some types of indexed reads are quicker than others. A unique index scan is generally faster than an index range scan, because it has less data to sort through and retrieve. The smaller the amount of data being processed by a query, the faster it will run. Here are some guidelines: Always make your queries as selective as possible. Use indexed reads over full table scans. Use unique index scans when possible.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
©IBM Global Services
Dec-2008
ABAP Dictionary ECC 6.0
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Tables in Relational Databases
©IBM Global Services
Dec-2008
ABAP Dictionary ECC 6.0
IBM Global Services - SAP Development ABAP Training Adding Structures
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Adding Structures
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Adding Structures
ABAP Dictionary ECC 6.0
Structure - A group of internal fields that logically belong together. A Structure consists of components (fields) whose types are defined. A component can have an elementary type, a structured type, a table type or a reference type. In ABAP, you reference a Structure by its name. To access the individual fields within a Structure, you must specify the name of the Structure followed by component selector(-) followed by the relevant field name. A Structure’s components can have an elementary type, a structured type, a table type, or a reference type. Structures are used especially to define the data at the interface of module pools and screens and to define the types of function module parameters.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Adding Structures
ABAP Dictionary ECC 6.0
Groups of fields can be added to customer tables using substructures. Groups of fields or individual fields can be added to SAP delivered tables using append structures, or customizing includes: Substructures allow you to include fields from another table or structure in the table you are creating. Customizing includes are provided in SAP tables and structures to allow you to add fields to these structures/tables without modifying the tables themselves. Append structures allow you to add fields to SAP-provided structures and transparent tables that were not provided for in the standard version.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Adding Structures
ABAP Dictionary ECC 6.0
Rather than listing all the fields you want a table or structure to contain, you can choose to include fields from another table or structure as a substructure. This allows you to avoid redundant field definitions in structures/tables as well as maintain changes for these common fields in one structure/table. Substructures can be nested. A structure can include another structure, which in turn includes another structure, etc. Up to nine nesting levels are allowed. TRANSP table types can only exist once in a nested chain. To include a substructure in a table: Type “.INCLUDE” for the Field Name field on the Table Change screen, then type in the name of the structure/table in the “Data elem.” field. You can expand and collapse substructures in the table/structure definition screens they are used. This is an alternative way to see what fields the substructure holds, rather than double-clicking on the substructure name to navigate to its definition.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Adding Structures
ABAP Dictionary ECC 6.0
If it is expected customers will need to add their own fields to SAP tables or structures, some of the standard version SAP tables and structures are supplied with customizing includes. Customizing includes are supplied empty by SAP and are filled in by the customer with the help of special customizing transactions. These includes make it possible to extend (add fields to) tables without modifying the tables themselves and without the risk of additions being overwritten during a Release Upgrade. Names of customizing includes start with ‘CI_’. If a table does not contain a customizing include, you can still make additions by creating an Append structure. You cannot add your own ‘.INCLUDE CI_’ to an SAP table.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Adding Structures
ABAP Dictionary ECC 6.0
Append structures are intended for additions not provided for in the standard version of SAP tables via customizing includes. They are to be used with SAP transparent tables or structures, not with customer tables. An Append structure is a structure assigned to exactly one table. However, a single table can have a number of append structures. It is recommended to use only one append structure in a table. When an append structure is activated, its assigned table is also activated with all of the append structure fields. When a table including an append structure is activated, the append structure fields are found and added to the table. Append structures cannot be deleted. Append structures cannot be used with tables containing fields of data type VARC, LCHR, or LRAW because these data types must be the last field in a table. Use the Append structures … push-button in the table display screen to add fields to SAP tables. Fields contained in an Append structure are added to the SAP tables when an upgrade is performed and the appropriate tables are activated.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Adding Structures
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Adding Structures
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Adding Structures
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Adding Structures
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Repository Information System
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Repository Information System
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Repository Information System
ABAP Dictionary ECC 6.0
The ABAP Repository Information System is a tool which allows you to perform quick searches for information on all ABAP development objects. The two basic functions available in the Repository Info System are the Find and Where-used list functions. The Find function allows you to search for objects from a specific object class meeting selection criteria. The Where-used list function allows you to determine the use of an object in other objects. Both functions produce a list of results which met the specified search criteria. Typical queries made to the Repository Info System include: Find (Object searches, e.g.:) List all domains with a specific data type (char) and length (10) List all tables changed by user ABAPXXX since 01/01/96 List all data elements that refer to a particular domain (UPENUM) List all tables containing a specific field (EUNR) List all indexes for a specific table (UPERS) Where-used list (e.g.:) List all views containing a particular base table (UPERS) List all tables using a particular table (UPERS) as a check table
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
ABAP Repository Information System
ECC 6.0
To access the ABAP Repository from the initial SAP screen, use the following menu path: Tools ABAP Workbench Overview Information System. Expand any subitems in order to perform a search on a particular object (i.e., perform a search on Tables). The ABAP Repository Information System can also be accessed via transaction code SE84. In previous SAP releases, the menu path was: Overview Repository Infosys.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Repository Information System
ABAP Dictionary ECC 6.0
To search for objects via specific attributes by providing the relevant entries in the available search fields. Additional search fields can be used to limit search criteria by using the All Selections icon (Shift-F9) . When the All Selections icon is used, an Additional Selections group box with more object attributes is displayed beneath the standard selections. Enter a single value in the search attributes, or use the arrow pushbuttons for Multiple-Selections. The * and + wildcards are available for input in search fields. * represents any field string. + represents one character.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Repository Information System
ABAP Dictionary ECC 6.0
It is possible to list single values as search criteria using the Selection Options screen. Use the Selection Options icon to obtain the list of possible Selection Options. Use the SELECT and EXCLUDE FROM SELECTION pushbuttons to perform inclusive or exclusive range searches.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Repository Information System
ABAP Dictionary ECC 6.0
On all hit lists, you should see the following common options under the first menu path: CHANGE: Changes to object's maintenance screen, assuming it is yours to edit. DISPLAY: Changes to object’s display screen. CHECK: Checks object for syntax errors. GENERATE/ACTIVATE: Allows you to activate an object. TEST/EXECUTE: Lets you run the object. PRINT: Sends list to printer. COPY: Allows copying of selected objects . RENAME: Changes the name of an object, assuming it is yours and doing so will not cause cascading negative effects. REASSIGN: Change the Package to which an object is assigned. DELETE: Allows deletion of selected objects in list. TRANSPORT: Include selected object in a transport request. EXIT: Return to the Repository Information System.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Repository Information System
ABAP Dictionary ECC 6.0
To create where-used list searches for the table name, check the table name for which search is required and click on where-used list icon which generates the where-used list for the tablename selected. Check programs to find out the programs where table: ‘MARA’ is used. ( refer above screen ). The output lists of where-used searches are similar to basic output lists of Find object searches. Where-used searches can also be performed outside the Repository, such as in an ABAP program (i.e., to find the use of variables throughout a program), or in the ABAP Dictionary (i.e., to determine if a particular type group was used in other ABAP programs), or in the Repository Browser, or any of the other Workbench Tools.
The ABAP Repository Information System supports both where-used and sub-objects searches for Dictionary objects. These searches can occur from within lists. Therefore, it is possible to navigate both up and down as well as back and forth through the hierarchy of related objects.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Repository Information System
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Repository Information System
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
ABAP Repository Information System
ECC 6.0
The Repository can also be used to perform searches on other ABAP Workbench objects: Business Engineering Data modeling Process modeling Business Object Browser Program Library Function builder Program library Program sub-objects… Development co-ordination (Packages) Requests/Tasks…. Test Objects Authorizations (authority objects) Automatic tests (CATT procedures)…
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Repository Information System
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Repository Information System
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Changes
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Changes
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Changes
ABAP Dictionary ECC 6.0
An object must be fully activated in the SAP system in order to be used by other objects (e.g., a domain must be activated prior to being used by a data element, tables must be activated prior to being used in an ABAP program, etc.). ABAP Dictionary objects are activated either: Individually (immediately after each object is saved with the activation icon) or Mass (several objects grouped together for later activation after each one has been saved) Two steps are required to perform a mass activation: 1. Enter the object types and names in a table named TACOB. Use the menu path: System Services Table Maintenance Extended Table Maintenance or transaction SM30 to access this table. Enter TACOB for the table name and click the maintain pushbutton. Some of the object types are: DOMA (domains) DATA ELEMENTS (data elements) TABL (tables) 2. Execute the mass activation program RADMASG0 via transaction SE38, or use the menu path: System Services Reporting (transaction SA38). Enter TACOB for the external table name and click the Execute pushbutton.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Changes
ABAP Dictionary ECC 6.0
The mass activation program RADMASG0 can either be run online or scheduled as a background job. Greater efficiency is gained when objects are activated online due to the links that can occur between subcomponents of objects. (i.e., links between data elements and various tables). For example, if several tables attempt to use the same data elements, failures can occur when the tables are activated because the data elements are waiting on a background job to run in order to be activated.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Changes
ABAP Dictionary ECC 6.0
ABAP programs and Screen Painter screens always use the current version of a table activated in the Dictionary. When an object is changed and re-activated, all other objects currently linked to the changed object are automatically updated, (i.e., when a domain is changed and activated, all data elements, tables, report programs, module pool programs reflect the change, they do not need to be reactivated as well). As you can see, changing and reactivating objects can greatly affect a large number of associated objects. If appropriate, a data object is automatically checked for consistency (among data types) when the object has been changed.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Changes
ABAP Dictionary ECC 6.0
Changing the primary key of a value table that is being used by a domain, requires a lengthy process because of the embedded links between the domain and the value table. It is not a simple process to change and reactivate a value table. The below 8 steps should be followed to do this. The 8 steps are: 1. Delete “old” value table from domain 2. Activate domain without value table 3. Change primary key 4. Maintain all dependent tables (remove check table) 5. Activate dependent tables 6. Reactivate value table 7. Type value table in affected domain: Activate domain 8. Maintain dependent tables if required: (Define foreign keys)
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Changes
ABAP Dictionary ECC 6.0
An object in the ABAP Dictionary can exist in various versions and a listing of them can be viewed within the object’s dictionary maintenance screen via the menu path Utilities Version management. There are two VERSIONS of an object that can exist in the ABAP Dictionary: Active: valid in the dictionary and in any development objects (i.e., programs) in which it is used. Revised: a modified version. You can switch between the two versions. Once an object is activated, you can change it and save a modified (revised) version. This can be viewed from Utilities Version management. If you activate this new revised version, it overwrites the original activated object. In the Version Manager, objects which are saved appear with the notation “modif.” Objects which are activated appear with the notation “activ.” (Continued on next page)
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Changes
ABAP Dictionary ECC 6.0
Versions (continued): Temporary versions (under the heading “Version(s) in the version database”): During the development process while a change request is open, several temporary versions of an active object can be stored. Even after the object has been activated, it can be reset to the previous status. Store versions in the maintenance screen of objects via the leftmost menu (i.e., Table, Data Element, Program)®Store version. Temporary versions act as backup versions prior to the change request being released. When a change request is released, all temporary versions are deleted. Historical versions: If an object has been changed and activated, when the corresponding change request for the object is released for transport, the active version is stored as an historical version in a versions database. These versions are created every time a change request is released after an object has been changed. From the object maintenance screen, use the menu path Utilities Version management to see an overview of all versions that exist for an object. Versions of non-dictionary objects (i.e., programs) can be stored. However, only active, temporary and historical versions are possible (modified versions).
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Changes
ABAP Dictionary ECC 6.0
Display: List all defined attributes of object. Compare: Differences between this version and previous versions are highlighted. Retrieve: Retrieve stored version of object. Version is located in the ABAP Dictionary and takes the form of a revised version. Remote compare: Comparison with versions from other systems.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Changes
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Changes
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
ABAP Dictionary Changes
ECC 6.0
When you activate an object any locks on the object are automatically released. Other users can see the revised version in the Dictionary but can only access the active version.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Changes
ABAP Dictionary ECC 6.0
Versions of modified (repaired) SAP standard objects can be compared with new SAP standard objects by using the transaction SPDD. SPDD compares an inactive SAP standard version with the active modified (repaired) version and displays the results of the comparison in tabular form. All modifications to SAP objects made by clients are incorporated for review and considered by SAP during a system upgrade for a new release of SAP.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Changes
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Changes
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
ABAP Dictionary ECC 6.0
A view is an object, like the telescope, that provides a picture of something. We can construct a view with special “lenses” or “filters” to allow us to look at one or more dictionary tables. We can look at parts of one table (selected records and/or fields) or combinations of tables and parts of tables. A view is an ABAP Dictionary object. In many cases, you reference a view in an ABAP program just as you would a table. For example, you can select data from a view. However, a view does not contain data of its own – rather, the view provides specialised access to the data that exists in other tables. For this reason, views are often called virtual tables.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
ABAP Dictionary ECC 6.0
In its most basic form, a view simply mirrors an entire database table. It looks just like the table and it acts just like the table – but it isn’t actually the table. Of course, if this is all that views could do, they wouldn’t be very useful. Let’s take a look at some of the other capabilities of views. The view name cannot be the same as an existing table name.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
ECC 6.0
We can use views to: Join several tables Project (or choose) certain fields from one or more tables Select (or choose) certain records from one or more tables Join, projection, and selection are called relational operations.
©IBM Global Services
ABAP Dictionary
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
ABAP Dictionary ECC 6.0
The projection operation is used to narrow a view’s focus to certain fields in a table. For example, we might have a view of an employee table that does not contain the salary field. Employees authorised to view salary data would be given authorisation to view the actual table, while other employees might only have authorisation to use the view without the salary data.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
ABAP Dictionary ECC 6.0
When designing a view, view fields need to be given names. The view field names should be the same as the regular table fields they are reflecting, unless the view is a database view. Only in that situation are you permitted to use different names. When referencing the view field in code, you would refer to VIEW_NAME-VIEW_FIELD_NAME.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
ABAP Dictionary Objects: Views
ECC 6.0
The selection operation is used to narrow a view’s focus to certain records in a table. For example, we might sometimes wish to view only the information about employees belonging to a certain staff classification. This might mean creating one view containing partners and principals one view containing principal consultants, and another view containing consultants. Each view would be built using selection criteria that indicated which records to include in that view. As an example of why such a view might be used, staff members might be permitted to view the billing rates of employees in the same staff classification or lower, but not of employees in a higher classification.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
ABAP Dictionary ECC 6.0
You specify selection criteria by building logical expressions that compare specific fields of a table to hard-coded literal values. (1 & 2) Specify the table and field on which the restricted selection should take place. Any fields, including unprojected ones, can be indicated. (3) Specify the relational operator used to compare the field to the value. You may use EQ, NE, LE, LT, GE, GT, LIKE, and NOT LIKE. (4) Specify the comparison value. Comparison values must be text or numeric literals. Text literals must be enclosed in single quotes. (5) You can specify multiple selection criteria (one per line) and link them using the logical operators AND and OR. Unlike elsewhere in SAP (and most other systems), OR takes priority over AND. Also, OR operations are only permitted between lines which refer to the same field. If the projection and selection operations are both used within the same view, it is possible to specify selection criteria for fields that are not included within the view. For example, it would be possible to create a view that contained only employees making over $100,000 per year even if the view did not contain the salary field.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
ABAP Dictionary Objects: Views
ECC 6.0
The join operation is used to combine information from multiple tables into a single view. For example, we might wish to create a report listing employees by name, along with their salary history. Database design considerations would probably result in the salary history being stored in one table and basic employee information (such as the name) being stored in another. Thus, we might create a view that would combine the data from both tables. We could write our report program using this view, and it would seem to our program as if the data was stored in a single table. Using the join operation within a view is generally the most efficient way to access data from multiple tables. We’ll examine some other methods later on.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
ABAP Dictionary ECC 6.0
Database design principles often require related data to be stored in separate tables. This is necessary to provide flexibility in one-to-many and many-to-many relationships, and also to prevent data redundancy. For example, if employee name and salary history were stored in the same table, we would encounter one of the following situations: If we stored salary history on the employee record, we would have to create a fixed number of “previous salary” fields in the employee table. For many employees, most of those fields would be blank, and for long-term employees, we might eventually run out of fields. If we stored employee name on the salary history record, we would have many copies of the employee’s name. If the employee’s name changed, that change would have to be made many times. Additionally, we would run the risk of not updating all the data correctly, and the employee and the salary table could get “out of sync.” Whenever possible, redundant copies of the same information should be avoided. As a result, data is often “broken apart” into several tables. This is called normalising the database. The join operation essentially reverses this process. The result of a join is a view that looks like a table with redundant data.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
ABAP Dictionary ECC 6.0
When data is broken apart into separate tables, it is still necessary to duplicate some data – namely the key fields of the tables involved. For example, the salary history table would contain a field for employee ID number, so that we knew which employee each salary record belonged to. In this case, the employee ID number becomes a foreign key in the salary history table. The key to understanding the join operation is to understand that different tables are joined together using foreign keys. We don’t want every employee’s name associated with every salary history record. Rather, we want each employee’s name to be associated with only those salary records belonging to that employee.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
ABAP Dictionary ECC 6.0
Therefore, in order to use the join operation in SAP, you must first ensure that the appropriate foreign key relationships exist among the tables to be joined. Also, you must ensure that the semantic attributes of those foreign keys have been maintained (see Chapter 4 for a discussion of semantic attributes and foreign keys). Other notes on the join operation: Views are created with a primary table and up to 10 secondary tables. The primary table can be either a check table or a foreign key table with respect to the other tables in the view (i.e., the primary table does not have to be the check table). Note : When a join operation is employed, only those primary table records that have a match in all secondary tables are retrieved. For example, in a join between employees and salary history, employees with no salary history records would not appear at all.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
ABAP Dictionary ECC 6.0
You can hard code all the tables you need all at once. Then you would have to hard code the foreign key relationships between them as well. It might be simpler to input the first base table, and from there hit the Relationships pushbutton. Then you can select a related table and the join conditions will be filled in automatically for you.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
ABAP Dictionary ECC 6.0
The database view is the only type of view in SAP that is physically created at the database level. In other words, the underlying database system also directly recognises the view, apart from SAP. Therefore, database views must be created over transparent tables. With the database view, all three of the relational operations (projection, selection, and join) can be used. Database views can be buffered just like transparent tables. In the technical settings you can decide whether to have buffering off, or on with type single record, generic, or full.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
ABAP Dictionary ECC 6.0
The projection view is a logical view. In this context, the word “logical” means that the view exists within the ABAP Dictionary but is not recognised by the underlying database system. Projection views must be defined over a single transparent table. The only relational operation that is valid for a projection view is projection.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
ABAP Dictionary Objects: Views
ECC 6.0
Projection Views
Database Views
Must be built over a single table
Can be built over many tables
Data can be updated
Data can be updated if the view is built over a single table
Data updates must use open SQL
Data updates can use open SQL or Native SQL
Updates are less efficient than using a Database View
Updates are more efficient than using a Projection View
Fields in the view must be named the same as the fields in the underlying table
Fields in the view can be named differently from the fields in the underlying table(s)
Can’t be buffered
Can be buffered
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
ABAP Dictionary ECC 6.0
Help Views: Help views can be used as selection methods for Search Helps. It might be necessary to create a Help View if you are trying to accomplish an outer join, since database views only create inner joins. Maintenance Views: These views permit maintenance of base table data. Transactions SM30 and SE54 are provided for working with maintenance views. In previous releases, Help Views used to play a major role in matchcodes. However, matchcodes have been replaced by Search Helps, and therefore, Help Views no longer have as big a presence.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
ABAP Dictionary ECC 6.0
In the code above, we select data from the view YXXEMP_V to write the id, last name, and first name fields to the screen. The syntax to reference a view in an ABAP program is the same as that used to reference a table.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Dictionary Objects: Views
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Search Helps
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Search Helps
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Search Helps
ABAP Dictionary ECC 6.0
Search helps are dictionary objects those we develop to compile a set of valid values for users (Search helps replace the functionality of matchcodes in the previous releases of SAP R/3. Matchcodes are obsolete now and we should therefore only learn about Search Helps) All throughout SAP, users must enter values into screen fields. These requested inputs often are numerical codes and ID’s, or abbreviations. Acceptable values might not be immediately evident, or the user might have forgotten the necessary input. The user has 2 paths of help available, hitting the F1 function key (which displays documentation,), and hitting the F4 function key, which displays valid values. Sometimes a list of valid values will appear when you hit F4, even if a search help was not defined for that field. These valid values come from the domain that is attached to the field. If we invoke a search help, we will see its results, not those from the domain valid values. Whether a search help is available or not depends on whether the programmer has attached one to the field. Search helps can return more than just the original search field to the screen.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Search Helps
ABAP Dictionary ECC 6.0
An elementary search help is exactly one combination of fields that will be used to determine the needed value. A collective search help is a combination of elementary search helps, so that the user has the option to pick any path to get to the answer. Adding an elementary search help to an SAP table is considered a modification, and you would have to register your change. Adding an elementary search help to an existing collective search help on an SAP table is allowed without registering. To get an idea about the use of Search Help, you can go to transaction XD01(Create Customer: Initial Screen) and hit F4 after placing the cursor on the Customer Number field. The collective Search Help DEBI is displayed, which in turn is the combination of multiple elementary search helps(each in a different tab). The Selection Screen for the first elementary Search Help “Customers (general)” is displayed.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Search Helps
ABAP Dictionary ECC 6.0
In the Selection Screen for the first Elementary Search Help “Customers (general)”, Specify “S*” against the field “Customer” to view all the Customers that start with “S”. You can specify any other selection criteria and also a combination of selection criteria. After this hit ‘ENTER’ or click the Green arrow to display the list of Customer’s that starts with “S”. Now you can select the particular Customer you want to be copied to the Customer field in XD01. In this way you get assistance in the form of set of valid value, while specifying a value for an input field. You can select any tab of the collective Search Help to go to any of it’s elementary Search Helps and perform similar kind of Search.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Search Helps
ABAP Dictionary ECC 6.0
To create a search help: 1. Go to the ABAP Dictionary: Initial Screen from the ABAP Development Workbench (Transaction Code SE11). 2. Select the “Search helps” radio button. 3. Enter a name for your search help. It must begin with the letter Y or Z, and can be up to 30 characters. 4. Hit the Create pushbutton. 5. Select Elementary or Collective search help in the next screen. Like with most objects in the Dictionary, you can also decide to make a search help at any point while in the Repository Browser. It will assume you want to save your object under the development class you are browsing at the time.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Search Helps
ABAP Dictionary ECC 6.0
The following are new terms you will see when you define your search help: Hot key (optional) - Use this number to code values for the complex dialog box all in the original search field. Selection method - The name of the table or view that holds the data that will form your help hit list. The fields from this table/view will be used in the interface parameters. Text table - If there is a text table available for your main Selection Method table, it will appear here. You can then use its fields as well in defining your search help path. Search help exit (optional) - A function module that enhances the typical processing of the search help. Not commonly used. Dialog Type - Controls how you see your results. The options are: D - immediate hit list of valid values C - dialog box where you can narrow down your search, followed by the hit list A - if there are less than 100 matches, acts like D, if more than 100 matches, acts like C The interface parameters are covered in more detail on the next slide.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Search Helps
ABAP Dictionary ECC 6.0
Search help parameters - Indicate all the values you will be passing to and from the search help. When you click in the cell, a drop down arrow will appear. This will give you a list of fields from your selection method table. If you type in your parameters manually, be sure that they have the same name as the fields in the table. IMP - Indicate parameters as import if you want to pass them from the initial screen to the search help to be used as search criteria. EXP - Indicate parameters as export if you want them to be passed back to the screen from the search help. LPos - Indicate which order on the hit list you want this parameter to be displayed at. For example, value 3 means the parameter will be the third column of information in the hit list. SPos - Indicate which order on the dialog box you want the data associated with this parameter to be displayed at. If you leave this empty, the parameter will not be displayed on the dialog box. SDis - If checked, this sets the parameter to display only. That means the user will be able to see the value, but it will be grayed out, and the user cannot enter anything in the field. Default value - Set literal in quotes, system field, or parameter ID as default.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Search Helps
ABAP Dictionary ECC 6.0
There are three different points where you can attach a search help. You can assign a search help to all of them if you choose. When the user hits F4, the system checks to see if there is a search help attached to the: Field - To attach a search help to a field, click on the field in the table (or structure) definition, and go to Goto Search help For field. This is the first type of search help that is checked for, if one is not found, the system checks if a search help is attached to the... Table - To attach a search help to a table, go to Goto Search help For table. This is the second type of search help that is checked for, if one is not found, the system checks if a search help is attached to the... Data element - To attach a search help to a data element, double click on the data element to get to its definition. Here you will find fields for specifying the name of the Search Help and the Search Help Parameter. This is the third type of search help that is checked for, if one is not found, the system does not use a search help, but will check the domain for valid values. If none exist, then no help is provided.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
Search Helps
ECC 6.0
You will be painting fields that respond with search helps in reports and transactions you will learn about throughout the course. For now, to test your search help, you can use the selection screen that appears when you view your table contents (Utilities Table Contents Display from the table definition screen). Upon hitting F4, the attached search help will begin processing. It will check to see if the field you are in, the search field, is identified as an export parameter. If it is, then the way the search help continues depends on how the dialog behavior was defined. Dialog type C presents a complex dialog box, where you build the context data. Dialog type D bypasses the dialog box, and immediately displays a hit list of acceptable values. The green fields in your hit list represent the values that can be exported back to the screen. Double-click on a green field in the hit list to return the value to the original selection screen.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Search Helps
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Search Helps
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Search Helps
ABAP Dictionary ECC 6.0
Creating a collective search help begins in the same way as creating an elementary search help. Simply choose “collective” instead of “elementary”. There are two parts to maintain in the collective search help definition, the Interface section, and the Search helps section. Since the collective search help is meant to be a collection of elementary search helps, you should use the parameters section to declare all export parameters from all of the individual elementary search helps. Typically, the elementary search helps are returning the same export parameter, so you would indicate just that one export parameter in the interface here.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Search Helps
ABAP Dictionary ECC 6.0
The second section of the definition screen is the Search helps section. All you have to do here is enter the names of the elementary search helps you will include in your collective search help. Do not forget to create parameter assignments. You need to create the link from an elementary search help back to the collective search help. Select each elementary search help entry and hit “Param. assignment”. The system will generate a suggested assignment.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Search Helps
ABAP Dictionary ECC 6.0
Collective search helps get invoked by the user the same way elementary search helps get invoked, by hitting F4 in the questionable field. The only visual difference is that there is now an icon that will let you switch between elementary search helps. Advanced users can take advantage of hot keys to enter values for a search help dialog box all in the original search field. This works with both kinds of search helps. For example, the following two techniques would achieve the same result: 1. - User hits F4 in FIRST_FIELD. - User selects toggle button, and chooses elementary search help with hot key ‘B’. - User enters the value “Philadelphia” for field second, and “Vanilla” for field third. - User hits the check mark. - User gets a hit list of all values for FIRST_FIELD that are Philadelphia and Vanilla. 2. - User enters B.Philadelphia.Vanilla in FIRST_FIELD. - User hits F4. - User gets a hit list of all values for FIRST_FIELD that are Philadelphia and Vanilla.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Search Helps
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Search Helps
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
Search Helps
ECC 6.0
A search help exit is a function module. Basically, it is extra code that can be included in the processing of the search help at specific times. When designing your own search help exits, use function module F41F_SHLP_EXIT_EXAMPLE as a template. You have the option to include a search help exit with your elementary and collective search helps. A call is made to the search help exit at several times during the regular processing of the search help. By adding code to the search help exit, you can change the appearance and functionality of how the search help appears to the user. Existing SAP search help exits can be found in the Information System as function modules beginning with F4UT_. An example is F4UT_OPTIMIZE_COLWIDTH, which fits the columns of a hit list to be as wide as the widest piece of data. Search help exits are not recommended to be overused, to preserve the integrity of the regular search help process.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Search Helps
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Search Helps
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Online Help & Documentation
©IBM Global Services
ABAP Dictionary
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Online Help & Documentation
©IBM Global Services
ABAP Dictionary
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary ECC 6.0
Online Help & Documentation
Documentation can be created for the following ABAP Dictionary objects: Tables/structures (used as technical information, available in a Table manual if program RSSDOCTB is run) Domains (used as technical information, not displayed in online help) Data elements (used in online help - F1)
Data element documentation and supplemental documentation is called when using F1 help on an input field.
Allowed input values are revealed with F4 help. These values are derived from: Domain values Foreign keys Search Helps
Since matchcodes used earlier (in SAP Ver. 3.0) instead of Search Helps, matchcodes were the first line of F4 help offered to the user. ©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary ECC 6.0
Online Help & Documentation
Documentation for tables/structures and domains can be created within the ABAP Dictionary maintenance screen for the object. Use menu path Goto Documentation. In this chapter, we will focus on data element documentation and supplemental documentation. Data element documentation is field-specific and is displayed for all fields which refer to the data element. Data element supplemental documentation reflects screen-specific information for an input field. When the user hits the F1 key, both data element documentation and data element supplemental documentation is displayed (if each is maintained).
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary ECC 6.0
Online Help & Documentation
Data element documentation and data element supplemental documentation can be created in several ways: Transaction SE61 Within the ABAP Dictionary ( Transaction SE11): Change Data Element maintenance screen Through F1 help Through the Screen Painter (Transaction code SE51) To create data element documentation and/or supplemental documentation from a screen: Place the cursor on the screen field for which you want to create documentation. Click the F1 key. Click the ‘Edit Documentation’ button and you will be prompted to create data element documentation or supplemental documentation. To create documentation and/or supplemental documentation from the screen painter (tcode: SE51): Position the cursor on the appropriate input field and use the following menu path: Goto Documentation Data element doc., or Goto Documentation DE supplement doc.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary ECC 6.0
Online Help & Documentation
To create data element documentation from ABAP Dictionary : Goto transaction “SE11”,Select radio-button – “Data Type", Give the data element name ,click on “ Change” button, click on documentation button present on the application toolbar. To create documentation and/or supplementary documentation from transaction : SE61 – Goto transaction SE61, enter the data element name, click on “create", Enter the appropriate documentation and click on “Save” button.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary ECC 6.0
Online Help & Documentation
Supplemental documentation entered from the screen or screen painter is maintained automatically in table THLPF. To view this, do the following: On the screen for which supplemental documentation has been created, go to System Status and find the program (GUI) and screen number. Go to System Services Maintenance Extended table maintenance. Type THLPF in the Table input field and click Display. Scroll to the bottom of the table display. Click the ‘Position’ button at the bottom and type the Program (GUI) and Screen Number and hit enter. This will search for the entry which the system created in the table for your supplemental documentation. The system will scroll through the table entries to display those entries matching your search criteria. Data element supplements, along with their program, screen, and table/field references, are contained in table THLPF. Entries in this table are created automatically if the data element supplement was created through the Screen Painter or through F1 help. Entries in this table must be made manually if the data element supplement was created through the ABAP Dictionary or through transaction SE61 (System Services Maintenance Expended table maintenance). If these entries are not made, the data element documentation will not be displayed when the user hits F1 on the input field.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary ECC 6.0
Online Help & Documentation
Data element documentation and supplementary documentation can be created in the ABAP Dictionary: Change Data Element screen. Navigate through the ABAP Dictionary to the Data Element you want to create documentation for Click the Documentation button to create or maintain Data Element Documentation Click the Supplementary documentation button to create or maintain Data Element Supplementary Documentation
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Online Help & Documentation
©IBM Global Services
ABAP Dictionary
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Online Help & Documentation
©IBM Global Services
ABAP Dictionary
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Online Help & Documentation
©IBM Global Services
ABAP Dictionary
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Online Help & Documentation
©IBM Global Services
ABAP Dictionary
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Type Groups
©IBM Global Services
ABAP Dictionary
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Type Groups
©IBM Global Services
ABAP Dictionary
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary ECC 6.0
Type Groups
Type groups are used for creating customer-defined data types. These type groups are created in the ABAP Dictionary and are available for use in all ABAP programs. The main purpose is efficiency of coding. If there is a certain non-standard SAP type that the programmers find themselves using often in code, it would save coding and maintenance time to have them centrally defined. Reusability is another reason for using these type groups
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary ECC 6.0
Type Groups
Type groups are ABAP Dictionary Objects They are defined with the keyword TYPE-POOLS followed by the name of the type group (this statement is created automatically in the first line of the dictionary editor). Type group names are limited to five characters. (To display a type pool, go to R3 Repository Information System (Tcode: SE84) ->ABAP Dictionary-> Other Objects-> Type groups. To create a type pool, go to Object Navigator (Tcode: SE80) ->Click the ‘Edit Object’ button in the Application toolbar and Select the tab ‘Dictionary’-> Check the radio button for Type group-> Type a name in the corresponding field-> Finally hit the create button) Type groups can be Created/Changed/Displayed from SE11 as well Types of a type group must begin with the type group name and an underscore (i.e., YTYP1_ for all types in the above example). Type groups also contain constants so this statement is also valid for constant as well Variables can be declared in ABAP programs using the customer defined types. Type groups are referenced in programs by using the TYPE-POOLS statement. In the example above, the data type (character, integer, packed number, etc.) and length for each data variable is defined by using a type from the YTYP1 type group.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Type Groups
©IBM Global Services
ABAP Dictionary
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Type Groups
©IBM Global Services
ABAP Dictionary
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Type Groups
©IBM Global Services
ABAP Dictionary
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Type Groups
©IBM Global Services
ABAP Dictionary
Dec-2008
IBM Global Services - SAP Development ABAP Training Table Maintenance Generator
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Table Maintenance Generator
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
Table Maintenance Generator
ECC 6.0
Table entries can be displayed and created directly from SE11 following the menu path Utilities-> Table Contents-> Display or Create Entries. This is only possible when the ‘Data Browser/Table View Maint’ field has got a value “Display/Maintenance Allowed”. For using table maintenance generator also, this option should be set as “Display/Maintenance Allowed”.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Table Maintenance Generator
ABAP Dictionary ECC 6.0
Maintaining table entries through SE11 using menu path (Utilities Table Contents Create entries) is not advisable for the following reasons: You cannot enter multiple records in the same screen. You cannot put custom checks and validations when a table entry is being created or modified. So, table entries are generally maintained by creating a Maintenance view for the table, using the Table Maintenance Generator. Another reason is in production Server users does not have authorizations to access SE11 or SE16 transactions, at that time users can maintain the table through transaction created for table maintenance generator.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
Table Maintenance Generator
ECC 6.0
Follow menu path Utilities Table maintenance generator from transaction SE11.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
Table Maintenance Generator
ECC 6.0
1. Specify the Authorization Group. (E.g. &NC& for skipping any Authority Check) 2. Specify a Function group. (If you don’t have a Function Group already, then open transaction SE80 in another session and create a Function Group) 3. Click ‘one step’ maintenance type. 4. Give the Overview Screen as ‘9000’. (You can specify any Screen Number beginning with 9) 5. Now, hit the Create Button to create the maintenance view for the table. Specify the Development Class and CTS when prompted for. Also remember to set the ‘Display/Maintenance allowed’ value in the table attributes.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ABAP Dictionary
Table Maintenance Generator
ECC 6.0
Go to transaction SM30 (Maintain Table Views: Initial Screen) and specify the table name. You can Display and Maintain Table entries by clicking the ‘Display’ and ‘Maintain’ pushbuttons. Click the ‘Maintain’ pushbutton to maintain the entries for the table.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Table Maintenance Generator
ABAP Dictionary ECC 6.0
You will notice that the table entries are displayed in a table control. The key fields of the table will not be editable, but you can edit the non-key fields, which are open for input. Use the “New Entry” pushbutton to insert new entries into the table. Use the “Copy” button to copy one record to create another. Use the “Delete” button to delete selected records. Click on the “Save” button to save the new entries or the modifications.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Table Maintenance Generator
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Table Maintenance Generator
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Table Maintenance Generator
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Table Maintenance Generator
©IBM Global Services
ABAP Dictionary ECC 6.0
Dec-2008
Day 4 to 6 Introduction to ABAP
IBM Global Services - SAP Development ABAP Training ABAP Programming Language
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Programming Language
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Programming Language
Intro to ABAP ECC 6.0
ABAP is a programming language created and used by SAP for the development of application programs, including: Reports Module Pool Programming Interfaces Data conversions User Exits & BADI All of R/3s applications and even parts of its basis system were developed in ABAP. ABAP is an event-driven programming language. User actions and system events control the execution of an application. ABAP is also called ABAP/4. The “4” stands for “fourth generation language”.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP
ABAP Programming Language
ECC 6.0
The ABAP Workbench is used by SAP for the development of standard and custom application software. The ABAP Workbench is also used to create dictionary objects. It consists of the following components: ABAP Editor is used to maintain programs. ABAP Dictionary is used to maintain Dictionary objects. Repository Browser is used to display a hierarchical structure of the components in a package. Menu Painter is used to develop graphical user interfaces, including menubars and toolbars. Screen Painter is used to maintain screen components for an online program. Repository Information System contains information about development and runtime objects, such as data models, dictionary types and table structures, programs, and functions. Test and Analysis Tools, such as the Syntax Check and the Debugger. Function Builder, which allows you to create and maintain function groups and function modules. Data Modeler, a tool which supports graphical modeling. Workbench Organizer, which maintains multiple development projects and manages their distribution.
TheServices ABAP Workbench used to beDec-2008 known as the ABAP/4 Development Workbench. ©IBMNote: Global
IBM Global Services - SAP Development ABAP Training ABAP Programming Language
Intro to ABAP ECC 6.0
Report programs produce lists and can be divided into classical reports and interactive reports. Classical reports do not allow interaction by the user; therefore, the basic list contains extensive information that the user must often sort through to find the relevant data. Interactive reports allow interaction by the user; therefore, the user can produce secondary, detailed lists off of the basic list by choosing the relevant data and requesting more information.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Programming Language
Intro to ABAP ECC 6.0
Module pool programming (or online programming) involves the creation of a module pool (a collection of ABAP modules) and one or more screens. The modules are called by the screen processor during program execution. Batch input processing is used to ensure the safe transfer of data into the SAP system. This process is an automatic, protected data transfer to the SAP system which uses SAP transactions to validate data as it populates the SAP database. ABAP contains statements which conform to CPI-C standards (Common Program Interface Communications). These are used for programming communications programs. ABAP can read and write sequential data sets.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Programming Language
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Programming Language
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Programming Language
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Programming Language
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Introduction to ABAP Programming
©IBM Global Services
Intro to ABAP
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Introduction to ABAP Programming
©IBM Global Services
Intro to ABAP
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Introduction to ABAP Programming
Below is a list of common ABAP program terms. Program A series of ABAP statements Report An ABAP program whose output is a list Module Pool A dialog program which is a collection of screens List The output generated by an ABAP report program
©IBM Global Services
Intro to ABAP
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP ECC 6.0
Introduction to ABAP Programming
The ABAP Editor is used to create, maintain, and execute ABAP programs. Some methods for executing ABAP programs include: The ABAP Editor : Tools->ABAP Workbench Overview->Object Navigator Or use transaction SE80 The Reporting function: System Services Reporting Or use transaction SE38 ABAP programs that you create must start with a “Y” or a “Z” and can be up to 40 characters in length.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP ECC 6.0
Introduction to ABAP Programming
The editor combines a character based text entry capability with graphical icons and menu options to perform many of the functions necessary to build complex ABAP applications. Move to a specific line by double-clicking on the line number.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Introduction to ABAP Programming
©IBM Global Services
Intro to ABAP
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Introduction to ABAP Programming
©IBM Global Services
Intro to ABAP
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP ECC 6.0
Introduction to ABAP Programming
The ABAP development environment provides a wide variety of tools required by the programmer for the development and testing of applications. Pictured above is the online debugging tool which enables the programmer to watch the program execute line by line. The online debugging tool provides the programmer with the capability to designate watch variables. These variables, once chosen, can be viewed as their values change from statement to statement while the program executes. The programmer can even change their values to simulate different processing scenarios.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Introduction to ABAP Programming
©IBM Global Services
Intro to ABAP
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Introduction to ABAP Programming
©IBM Global Services
Intro to ABAP
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP ECC 6.0
Introduction to ABAP Programming
The ABAP program editor provides many functions through the use of graphical push-buttons. Among these functions are: Toggle from display mode to edit mode Undo/Redo, cut, copy and paste by right-clicking on Mouse Find and repeat find Syntax check - with limited auto correction Activate Execute Where-used list Pretty Printer Save program as local file Upload program from local file ABAP help
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP ECC 6.0
Introduction to ABAP Programming
Some of the functions under the PROGRAM Menu include:
Other Object Enables the programmer to immediately load another object without going back to the ABAP Editor: Initial Screen.
Check
The programmer can make their program syntax error free and can also improve the performance of the program.
Syntax
Extended program check
Code Inspector
Test
The programmer can execute or process the program in debugging mode or in direct mode .
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP ECC 6.0
Introduction to ABAP Programming
The more important functions under the EDIT menu include: Insert Statement This option brings up a dialog box in which the user can choose a statement structure to insert. Once chosen, the editor will insert a statement format at the location of the cursor with all of the options and requirements set. The programmer has only to fill in the blanks. Note: If the statement structure required is not listed, use the drop down box in the ‘Other pattern’ option, where many more ABAP keywords are listed (eg IF, SELECT, CASE, WINDOW) as well as comment box templates. Use the menu path Edit Pattern or Utilities More utilities Edit pattern to set user defined statement structures Edit Line This option brings up a second submenu which gives the programmer a list of line commands. These include: Delete line (deletes the line the cursor is on). Split line (places all information to the right of the cursor on the line directly below the line the cursor is on). Insert line (inserts a line above the line the cursor is on). Others …
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP ECC 6.0
Introduction to ABAP Programming
Pretty Printer This option formats the contents of the editor in terms of indentation and spacing. Helps with the readability of the program.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP ECC 6.0
Introduction to ABAP Programming
The GOTO menu gives the programmer the ability to immediately navigate to any one of the following functions: Attributes (displays the particular attributes of that program). Text elements (an editor for titles and headers, selection texts and text symbols used for formatting reports). Variants (an editor for the creation, change or display of variants). Messages (an editor for message classes). Others.. All of these options will be covered in later chapters.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP ECC 6.0
Introduction to ABAP Programming
Under the UTILITIES menu the programmer can access the following utilities: Help This function is a repeat of the light blue ‘i’ push-button Breakpoints The programmer can set or remove break-points that are used by the online debugging tool (the red ‘stop’ pushbutton also provides this function) Program upload and download utilities (in More utilities) Allows the programmer to transfer ABAP code to/from a local file Edit Locally Allows the programmer to edit the program in NotePad when not online. See Settings menu to choose path. Path for local editing. Edit Pattern Sets regularly used user defined patterns for inserting using menu path Edit Pattern.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP ECC 6.0
Introduction to ABAP Programming
Using the BLOCK/BUFFER menu, the programmer can: Copy program code to any one of three (X, Y, Z) separately maintained clipboards (buffers). Program code can then be inserted into another program from these clipboards (buffers). To copy code to the windows clipboard, select the “Copy to clipboard” menu option. Comments can be inserted or removed from the code using the “Insert Comment *”(or using hotkey CTRL+) menu options.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP ECC 6.0
Introduction to ABAP Programming
Using the Settings-> user can set the settings of various parameters e.g. Workbench, ABAP Editor, Class Builder, Screen Painter, Menu Painter, Function Builder, Repository Infosystem, Data Browser, Internet Transaction Server, Business Server Pages, Transport Organizer, SAP script. In the ABAP Editor and in Pretty Printer tab choose the case in which the code is displayed from either: 1. Lower case 2. Upper case 3. Key word Uppercase (only ABAP key words are in Upper case) 4. Key word Lowercase (only ABAP key words are in Lower case) Set the path for local editing in Notepad
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Introduction to ABAP Programming
©IBM Global Services
Intro to ABAP
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Introduction to ABAP Programming
©IBM Global Services
Intro to ABAP
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Introduction to ABAP Programming
An ABAP program is comprised of a series of individual ABAP statements Each statement must end with a period. (full-stop) Key words are always the first word in a statement. Words must be separated by at least one blank. ABAP statements can be indented and extend over several lines.
©IBM Global Services
Intro to ABAP
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP ECC 6.0
Introduction to ABAP Programming
To avoid repeating key words, ABAP allows you to “chain” statements together if these statements begin with the same key word. The key word is followed by a colon. Each chained statement component is separated by a comma. Blanks can be inserted before and after the separators (which may be colons, commas, or periods).
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP ECC 6.0
Introduction to ABAP Programming
Comments are inserted into the program in two ways: 1. By placing an asterisk (*) in column 1, the complete line is designated as a comment line. 2. By placing a double quotation mark (") within a line, the remainder of the line is considered a comment.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP ECC 6.0
Introduction to ABAP Programming
ABAP programs must start with either the PROGRAM or REPORT statement. This statement is produced automatically when the program is created through the Repository Browser. The REPORT statement is used for ABAP reports programs. The PROGRAM statement is used for general ABAP programs (for example, module pool programs). All global data declarations must be grouped together at the beginning of the program in a declaration section. The statement section can consist of various processing blocks. This subject is dealt with in the remaining chapters of this course. Adhere to program naming standards dictated by the client.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP ECC 6.0
Introduction to ABAP Programming
One way to create a new program is: 1. Go into the Program menu from the ABAP Editor: Initial Screen 2. Select the Create menu option or use the Create function key. You can also create, maintain, and execute programs from the Repository Browser (this is the recommended method for creating programs transaction SE80). The program attributes must be maintained before proceeding. ABAP programs must be assigned to a package or, if applicable, identified as a local, private object. (This is a requirement of SAP’s Correction and Transport System.) The application, class, and type attributes are used for the management of ABAP programs. The application, title, and type attributes are required. Other attributes are optional, and only needed for specific read accesses or when you have additional requirements. F1 and F4 are help keys which allow you to search for the significance of the attributes or a list of allowable input values.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP ECC 6.0
Introduction to ABAP Programming
The ABAP editor's Execute function is used to start an ABAP program directly from the editor. An ABAP module pool program is executed using transaction codes.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Introduction to ABAP Programming
©IBM Global Services
Intro to ABAP
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Introduction to ABAP Programming
©IBM Global Services
Intro to ABAP
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Introduction to ABAP Programming
©IBM Global Services
Intro to ABAP
Dec-2008
IBM Global Services - SAP Development ABAP Training
ECC 6.0
Introduction to ABAP Programming
©IBM Global Services
Intro to ABAP
Dec-2008
IBM Global Services - SAP Development ABAP Training Simple Output Statements
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Simple Output Statements
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Simple Output Statements
Intro to ABAP ECC 6.0
The “WRITE” statement outputs the contents of a field or constant in a format consistent with the data type. Successive WRITE statements output data on the same output line. When the line is full, output continues on the next line. The “SKIP “ statement creates blank lines. Normally, ABAP produces two standard header lines for each page. The date and page number are displayed on the first header line along with the program title. The second header line is an underline. Many system fields are available in an ABAP program. These system fields are defined as the ABAP Dictionary structure SYST. To reference system fields in a program, use SY-. For example, SY-DATUM indicates the current date and SY-UZEIT indicates the current time. You can use many methods to view the system ABAP Dictionary structure:
ABAP Dictionary
Repository Information System
ABAP Help in a program (use help pushbutton or “F1”)
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP
Simple Output Statements
ECC 6.0
ABAP provides many methods for formatting data. You can specify when to start a new line of output, start columns, and/or output length with the following statement: WRITE /. . . . The forward slash (“/”) in the “WRITE” statement indicates to start the output on a new line. The “ULINE” statement creates an underline. You can specify the exact location for an underline by referencing a line feed, position, and/or length with the following statement: ULINE /.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Simple Output Statements
Intro to ABAP ECC 6.0
The “UNDER” addition to the “WRITE” statement allows you to specify a field be printed in the same start column (left justified) directly beneath a field which has already been output. You must still code an explicit line feed (with a forward slash) to move to the next line. The “UNDER” addition does not act as a line feed.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Simple Output Statements
Intro to ABAP ECC 6.0
The sequence for the format specification of the “WRITE” statement must be followed precisely if more than one specification is used. Formatting options include:
LEFT-JUSTIFIED
RIGHT-JUSTIFIED
CENTERED
NO-GAP (deletes the gaps between consecutively displayed fields).
USING EDIT MASK (specifies a format template).
USING NO EDIT MASK (switched off any format template specified in the ABAP Dictionary).
NO-ZERO (replaces leading zeros with blanks; if the contents of a field are equal to zero, the output consist entirely of blanks).
There are many other formatting options. Consult the Extended Help text.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Simple Output Statements
Intro to ABAP ECC 6.0
The “NEW-PAGE” statement starts a new page. This statement will not create an empty page. There are many interesting extensions to NEW-PAGE, such as PRINT ON. Look in Online Help for more information.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Simple Output Statements
Intro to ABAP ECC 6.0
Certain symbols and icons can be written on a report. You must load the include programs and/or (the angle brackets are part of the name) with the “INCLUDE ” statement. You can also directly use TYPE-POOLS: icon for icon and TYPE-POOLS: sym for symbols. To write an icon to the report, use the following syntax: WRITE AS ICON. To write a symbol to the report, use the following syntax: WRITE AS SYMBOL. To display the complete list of icons, execute the program “SHOWICON”. For symbols, execute the program “SHOWSYMB”. You can go to the initial screen of the ABAP Editor (transaction code “SE38”) to execute these programs. The INCLUDE statement can also be used to include separate data declarations that are used by many programs. For example: commonly used function export/import parameters, constants for TRUE/FALSE YES/NO flags, BDC_TAB, etc.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Simple Output Statements
Intro to ABAP ECC 6.0
Text elements can be used to maintain a program’s title and column headings, selection texts, and text symbols. These text elements can be maintained in multiple languages, so the display to the user will depend on the user’s specified logon language. We will cover text symbols on the next page. Selection texts will be covered in the next chapter when we learn the “PARAMETERS” statement. Maintain a list heading and up to four lines of column headings for a report by using the “GoTo Text elements Titles/headings” menu path). The text placed in the “List header” field will replace the default title (short text of the program) on the program’s standard heading output.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Simple Output Statements
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Simple Output Statements
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP
Simple Output Statements
ECC 6.0
Numbered texts (text symbols) are used most often for writing text to the screen that is language dependent. Maintain numbered texts using the “GoTo Text elements Text Symbols” menu path). It is possible to maintain numbered texts separately for different languages. Consult the SAP’s online help for information on maintaining text elements in multiple languages The two methods of using numbered texts (text symbols) are: TEXT-xxx [where “xxx” is a unique three-character code] “”(xxx) [where “xxx” is a unique three-character code] The TEXT-xxx method allows you to assign text to a text symbol for easier maintainability and coding. Therefore, you can refer to a long sentence as TEXT-xxx instead of writing in code the sentence every time it needs to be written to a list. The text contained in the text symbol will be written out in the user’s current logon language as long as it is maintained in that language. Otherwise nothing will be written out. The (xxx) method also allows for easier language maintenance. In case the text symbol (xxx) is not maintained in the user’s logon language then the is used. However, this method loses the benefit of not having to code the same sentence many times.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Simple Output Statements
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Simple Output Statements
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Simple Output Statements
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Simple Output Statements
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
Intro to ABAP ECC 6.0
In an ABAP program, you can use ten system-defined, elementary data types to declare data objects: Character Text (standard length = 1; allowed length = no maximum) Numeric Text (standard length = 1; allowed length = no maximum) This data type should be used for numeric fields that will not be calculated (i.e., social security number and telephone number). Integer (standard length is machine specific and cannot be changed) This data type stores a binary number with a range of values from -21477483648 to +2147483647. Packed Number (standard length = 8; allowed length = 1 to 16) With this data type, two digits are stored in a single byte and the last half byte is used to store the sign. This data type is recommended for commercial calculations. Floating Point Number (standard length is machine specific and cannot be changed) With this data type, two digits are stored in a single byte and the last half byte is used to store the sign. This data type is recommended for mathematical/scientific calculations.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
Intro to ABAP ECC 6.0
Date (standard length = 8 and cannot be changed) This data type stores data in the ‘YYYYMMDD’ format Time (standard length = 6 and cannot be changed) This data type stores data in the ‘HHMMSS’ format HeXadecimal (standard length = 1; allowed length = no maximum) String (similar to data type C and refers to a variable-length string ). XString (similar to data type X and refers to a variable-length byte sequence. Strings can have any length). It is not yet possible to use strings in screens. However, strings can be stored in database tables as clusters using EXPORT and transferred using IMPORT.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
Intro to ABAP ECC 6.0
To declare a variable (or field) in an ABAP program, use the “DATA” statement: DATA () TYPE VALUE . The only required parameter in this statement is the of the variable. A variable’s name can be up to 30 characters in length. This name should begin with a letter and the remainder of the name should consist of letters, numbers, or an underscore. “SPACE” is a reserved word in ABAP. The variable’s is specified in parentheses immediately after the (no spaces in between the name and the length). If no length is specified, the variable will be the standard length for the data type (see previous page). The variable’s is specified after the “TYPE” addition. If no data type is specified, the variable will be type ‘C’. To define a default value for the variable, use the “VALUE” addition. This default value is different than the initial value automatically assigned to a data object (see next page).
In the example code above, what is the data type and length of the “STARTER” variable? The function, STRLEN, can be used to find the length of a character string ©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
Intro to ABAP ECC 6.0
All data objects declared have an associated initial value. This initial value depends on the data type: C,STRING:
blank
N: 0…0 (the number of zeroes depends on the defined length) I: 0 P: 0 F: 0…0E+00 (the number of zeroes depends on the system length) D: 00000000 T: 000000 X,XSTRING:
00
The “CLEAR ” statement sets a field back to its initial value, not its default value.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
Intro to ABAP ECC 6.0
Use the following rules when assigning default values to data objects: Default values for the character-based data types (C and N) must be a text literals (i.e. enclosed in single quotes. ). For example, see the “NICKNAME” variable above illustrates this rule. Default integer values for the numeric data types (I, P, and F) may or may not be enclosed in single quotes. For example, the “POINTS” variable above uses single quotes, but the “GAMES” variable does not. Default fractional values for the numeric data types (P and F) must be a text literals (i.e. enclosed in single quotes); otherwise, the decimal point would indicate the end of the statement. For example, the “AVERAGE” variable above illustrates this rule. For a packed or floating point number to be stored with a decimal, it must be defined with the “DECIMALS” addition. For example, AVERAGE(5) TYPE P DECIMALS 2 VALUE ‘25.5’. Default values for date (D) and time (T) variables must be enclosed in single quotes. For example, the “ACQUIRED” variable above illustrates this rule. In the example code above, what is the value of the “STARTER” variable?
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP
ABAP Data Declarations
ECC 6.0
To declare fields with the same format (i.e. data type and length), use the “LIKE ” addition instead of the “TYPE” addition to the data declaration. Defining fields in this manner makes it easy to change the format of several fields because you only need to make a change to the data type or length once in the program. In the “LIKE “ addition, the can be: A previously-defined program field or field string (we will cover field strings in a future chapter) For example, the “NICKNAME” field above is defined “LIKE PLAYER”. An ABAP dictionary field For example, the “ACQUIRED” field above is defined “LIKE SY-DATUM”. The “LIKE” addition only applies to the data type and length, not a default value assigned to the referenced field. For example, the “NICKNAME” field above defined “LIKE PLAYER” will be a 35-length character field. However, the “NICKNAME” field will not have the “Julius Erving” default value assigned to it. This type of Declaration is OBSOLETE in Newer Versions of ABAP
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP
ABAP Data Declarations
ECC 6.0
To declare a constant in an ABAP program, use the “CONSTANTS” statement. The basic syntax of this statement is: CONSTANTS () TYPE VALUE . A constant’s can be up to 30 characters in length. This name should begin with a letter and the remainder of the name should consist of letters, numbers, or an underscore. “SPACE” is a reserved word in ABAP. Like the constant’s , the “VALUE” addition is required because a constant must have a value.
The constant’s is specified in parentheses immediately after the (no spaces in between the name and the length). If no length is specified, the constant will be the standard length for the data type.
The constant’s is specified after the “TYPE” addition. If no data type is specified, the constant will be type “C”. You cannot change the value of a constant in an ABAP program (syntax error). Hard-coded literals should be avoided. Use CONSTANTS if this clarifies the code.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP
ABAP Data Declarations
ECC 6.0
To declare a user-defined data type in an ABAP program, use the “TYPES” statement. The basic syntax of this statement is: TYPES () TYPE . A user-defined data type’s can be up to 30 characters in length. This name should begin with a letter and the remainder of the name should consist of letters, numbers, or an underscore. “SPACE” is a reserved word in ABAP. The “VALUE” addition cannot be used because this statement only defines a data type. This statement does not allocate any memory for a field and, therefore, cannot have a value.
The user-defined data type’s is specified in parentheses immediately after the (no spaces in between the name and the length). If no length is specified, the user-defined data type will be the standard length for the data type.
The user-defined data type’s is specified after the “TYPE” addition. If no data type is specified, the user-defined data type will be type “C”. You can use the “LIKE” addition instead of the “TYPE” addition.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
Intro to ABAP ECC 6.0
With the “WRITE” statement, a data object written to the list will have the standard output length associated to its data type (see above slide). If you want to change the output length of a field written to the report, you must specify the length in parentheses before the field name. For example, to write out a length 20 character field named “VAR1” in only 10 spaces, use the following “WRITE” statement: WRITE: /5 “The value is”, (10) VAR1. For packed and integer fields, leading zeros are converted to blanks. For packed and integer fields, commas are inserted between thousands. With the “WRITE” statement, a data object written to the list will be justified within its field length according to the standard justification associated to its data type (see above slide). If you want to change a field’s justification, you must use the “LEFT-JUSTIFIED”, “RIGHT-JUSTIFIED”, or “CENTERED” additions after the field name. For example, to make an integer field left justified, use the following “WRITE” statement: WRITE: /5 “The total count is”, COUNT LEFT-JUSTIFIED.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
Intro to ABAP ECC 6.0
You can determine the number of decimal places to display in all numeric fields (i.e., integer, packed, and floating point fields) with the “DECIMALS” addition to the “WRITE” statement: WRITE DECIMALS . ABAP performs automatic rounding of numeric fields. You can explicitly round numeric fields with the “ROUND” statement. You can determine the value of the exponent to display in floating point fields with the “EXPONENT” addition to the “WRITE” statement: WRITE EXPONENT . If you want a packed field to store a decimal value, the “DECIMAL” addition must be used when defining the field. For example: DATA DECIMALS . The “DECIMALS” addition can also be used when defining parameters, constants, or userdefined data types. Coding Recommendations: A common cause of error occurs using the WRITE command with prices/values. Ensure to always use the CURRENCY option. Ex: WRITE: nnnnnnn CURRENCY nnn.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP
ABAP Data Declarations
ECC 6.0
You have numerous alternatives to assign values to fields: MOVE TO . [COMPUTE] = . The key word “COMPUTE” is optional. ADD TO . SUBTRACT FROM . MULTIPLY BY . DIVIDE BY . There are other alternatives that we will cover in later chapters. The system carries out automatic type conversion if variables are not of the same type. If a character field is to be converted to a packed field, only numbers, the plus/minus sign, and the decimal point are allowed. The plus/minus sign will be placed at the end of the packed field. If a packed field is to be converted to a character field, the numerical value is formatted (decimal point, sign) and the leading zeros are converted to blanks. For information for all conversions between variables of different types, see the ABAP editor documentation for MOVE (type MOVE and hit F1). UNPACK is a specific conversion keyword moving values from a packed variable (type P) to a character one (type C).
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
Intro to ABAP ECC 6.0
The valid operators for arithmetic expressions are: +, -, *, /, **, DIV and MOD. ** indicates exponentiation (i.e., 3 ** 2 means 3 to the power of 2). DIV indicates the quotient (i.e., 10 DIV 3 evaluates to 3). MOD indicates the remainder (i.e., 10 MOD 3 evaluates to 1). Arithmetic functions also exist in ABAP. Some of these functions include: SQRT, EXP, LOG, SIN, COS, and STRLEN. The order of operation in arithmetic expressions is: Parentheses Functions Exponentiation *, /, DIV, and MOD + and All operators and parenthesis in an arithmetic expression must be separated by at least one space. Functions must be followed immediately by an opening parentheses: Incorrect:
ANSWER=(10+SQRT(NUM1))/(NUM2 - 10).
Correct:
ANSWER = ( 10 + SQRT( NUM1 ) ) / ( NUM2 - 10 ).
Before calculations are performed, field values of non-numeric fields are automatically converted to numerical values. There is no limit to the nesting levels for parentheses in arithmetic expressions.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training
Intro to ABAP
ABAP Data Declarations
ECC 6.0
ABAP allows you to display and change portions of a field by specifying an offset and length. To display a portion of a field, use the following “WRITE” statement: WRITE +(). For example, to write the third, fourth, and fifth characters of a field named “CUSTOMER”, the “WRITE” statement would be:
WRITE CUSTOMER+2(3).
To change a portion of a field, use the following statement: +() = . For example, to change the month of a date field named “BIRTHDAY”, the statement would be: BIRTHDAY+4(2) = “11”. The offset and length can be used together (as the previous examples illustrate) or separately.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
Intro to ABAP ECC 6.0
Remember that date fields are stored in “YYYYMMDD” format. You can perform calculations on dates, but you must keep in mind that the system can only work in terms of a number of days. For example: You can add seven days to a date field. You cannot add two weeks to a date field. This value would have to be converted into a number of days. If you perform calculations on a date field, the date field is converted to a packed number that represents the number of days since the beginning of 01/01/0001. Coding Recommendations: There are numerous SAP function modules that will perform date calculations. Ex: DATE_COMPUTE_DAY, DATE_GET_WEEK, DATE_CHECK_PLAUSIBILITY, POPUP_TO_SELECT_MONTH, EASTER_GET_DATE. Conversion function modules usually have the word CONVERT or CONVERSION in their name. Ex: CONVERSION_EXIT_PERI_INPUT converts dates from the format MMYYYY to YYYYMM (if passed in as MMYY, it is passed out as YYYYMM), CONVERSION_EXIT_INVDT_INPUT converts date in format DDMMYYYY to SAP inverted date format - plus many other variations.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
Intro to ABAP ECC 6.0
To declare a variable (or field) in an ABAP program that can be given a value at runtime, use the “PARAMETERS” statement. The basic syntax is: PARAMETERS () TYPE DEFAULT . The only required addition in this statement is the of the parameter. A parameter’s name can be up to 8 characters in length.This name should begin with a letter and the remainder of the name should consist of letters, numbers, or an underscore. “SPACE” is a reserved word in ABAP.
The parameter’s is specified in parentheses immediately after the (no spaces in between the name and the length). If no length is specified, the variable will be the standard length for the data type (see page 1).
The parameter’s is specified after the “TYPE” addition. If no data type is specified, the variable will be type ‘C’. To define a default value for the parameter, use the “DEFAULT” addition. This default value is different from the initial value automatically assigned to a data object (see page 3). When you execute a program using the “PARAMETERS” statement, a “selection screen” is displayed for you to enter values into the parameters. To continue program execution from the selection screen, click on the “Execute” pushbutton (or click the “F8” key).
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
Intro to ABAP ECC 6.0
Text elements can be used to maintain a program’s title and column headings, selection texts, and text symbols. These text elements can be maintained in multiple languages, so the display to the user will depend on the user’s specified logon language. Maintain the selection texts by selecting the “Selection texts” option in the Text Elements function (“GoTo Text elements” menu path). The text placed in the “Text” field for a parameter will be used on the selection screen instead of the name of the parameter. Using selection texts allows you to create meaningful text on the selection screen.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
Intro to ABAP ECC 6.0
A field symbol is a place holder for a field (i.e. a pointer). A field symbol does not reserve space for the field, but points to the field (i.e., a field symbol assumes the address of the field, not the value). A field symbol can point to single fields or field strings (structures). Remember that the “TABLES” statement creates a field string with the appropriate ABAP Dictionary structure. When working with field symbols, angle brackets (< >) must be used. The “FIELD-SYMBOLS” statement is used to declare a field symbol. A field symbol’s name can be up to 30 characters in length including angle brakets(). This name should begin with a letter and the remainder of the name should consist of letters, numbers, or an underscore. If a field symbol is defined without attributes, it takes on the attributes of the field assigned to it. If a field symbol is given a data type and length (either explicitly or with the “LIKE” addition), the system verifies that the field symbol has the same attributes as the field assigned to it. The “ASSIGN” statement associates a field to a field symbol at runtime (i.e., when the program is executed). If you change the value to a field symbol, you are really changing the value of the field assigned to the field symbol. If you write the value of the field symbol, you are really writing the value of the field assigned to the field symbol.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
Intro to ABAP ECC 6.0
With the “ASSIGN” statement, you can assign a portion of a field to a field symbol by specifying the field’s offset and length. In the example above, the field symbol “FSYMBOL” is assigned to five characters of the variable “TEXT_LINE” starting with the third character. If a change is made to the field symbol, only these five characters of the variable will be changed. The output from the code above would be: Text Line =ABCDEFGHIJK Field Symbol = CDEFG Field Symbol = 12345 Text Line = AB12345HIJK
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
Intro to ABAP ECC 6.0
With the “ASSIGN” statement, you can assign a field to a field symbol where the name of the field is not known until the program is executed. This is called dynamic field assignment. For example, in the code above a field name is being entered as a parameter. The field entered will be assigned to a field symbol. To perform a dynamic field assignment, you must enclose in parentheses the variable that contains the appropriate field name. For example: ASSIGN (FIELD) TO . After a dynamic field assignment, the value of SY-SUBRC indicates whether a field was assigned to the field symbol. If the assignment was successful (i.e., the variable in parentheses contained a valid field name), SY-SUBRC will be set to zero. If the assignment was not successful (i.e., the variable in parentheses did not contain a valid field name), SY-SUBRC will be set to a non-zero number. If you are going to assign a field string created with the “TABLES” statement to a field symbol, execution time is minimised if you use the “ASSIGN TABLE FIELD” option. Note: in ECC 6.0 TABLES statement is obsolete
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training ABAP Data Declarations
©IBM Global Services
Intro to ABAP ECC 6.0
Dec-2008
IBM Global Services - SAP Development ABAP Training Retrieving Data with SELECT Statements
©IBM Global Services
Dec-2008
Intro to ABAP ECC 6.0
IBM Global Services - SAP Development ABAP Training Retrieving Data with SELECT Statements
©IBM Global Services
Dec-2008
Intro to ABAP ECC 6.0
IBM Global Services - SAP Development ABAP Training Retrieving Data with SELECT Statements
Intro to ABAP ECC 6.0
Information is retrieved from the database for use in our programs via a special language known as Structured Query Language, or SQL. SQL is a language specifically designed for use with relational database systems. It is used in many systems, not just SAP. However, ABAP has certain SQL commands “built-in”, so the connection between ABAP and SQL is fairly seamless. SQL has three main components, which are used for different purposes: Data Manipulation Language (DML): For retrieving and updating information in the database. Data Definition Language (DDL): For defining database objects and specifying the structure of the data in the database. In SAP, these functions are handled primarily by the ABAP Dictionary and the Database Utility. Data Control Language (DCL): For controlling access to DML and DDL functions. This course covers the first category only: Data Manipulation Language The DML provides the four basic data operations: 1. Select (retrieve) 2. Insert 3. Update 4. Delete
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Retrieving Data with SELECT Statements
Intro to ABAP ECC 6.0
As noted on the previous page, SQL is a standard language used across many different systems. The majority of the functionality provided by SQL remains the same across all systems, but some database manufacturers have added their own proprietary extensions to SQL. Additionally, the syntax of SQL has minor variations across systems. SAP had to ensure that SQL statements in ABAP programs would be compatible with each of the underlying database systems supported by SAP. This was accomplished through the development of Open SQL (also called SAP SQL). Open SQL is a subset of standard SQL with a specific syntax recognised by ABAP. The run-time environment of the R/3 System automatically translates Open SQL statements to the appropriate syntax for the underlying database system. Therefore, code written in Open SQL will run on any database system supported by SAP. Note: Sometimes, for technical reasons, it is advantageous to know which database system an application is intended for. However, if Open SQL is used, it is not necessary to know this. SAP itself was written using Open SQL because it was intended to run on multiple systems.
©IBM Global Services
Dec-2008
IBM Global Services - SAP Development ABAP Training Retrieving Data with SELECT Statements
Intro to ABAP ECC 6.0
In all versions of SQL, the SELECT statement is used to read records from a database table. The most basic form of the SELECT statement is: SELECT * FROM