Tài liệu Chapter 2: ABAP Query pdf

34 442 1
Tài liệu Chapter 2: ABAP Query pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Report Development Tools 2–1 Chapter 2: ABAP Query Contents Learning the Basics of ABAP Query 2–2 Creating a Report with ABAP Query .2–7 Running the Query .2–26 Understanding the Report List 2–27 Getting the Most from ABAP Query: Tips & Tricks .2–27 Review .2–33 Where to Learn More 2–33 2 In this chapter you will learn how to:  Create a functional report in ABAP Query  Build a basic functional area using a logical database  Maintain a user group  Create a report using a functional area and a user group Chapter 2: ABAP Query Learning the Basics of ABAP Query Reporting Made Easy 2–2 Learning the Basics of ABAP Query In this chapter, you will learn about ABAP Query, a tool that lets you present data from database tables in report lists. Before getting into how you can use ABAP Query to create reports, it is important to understand its features and basic organization. What Is ABAP Query? ABAP Query is an easy-to-use reporting tool that lets you query data from one or more database tables and funnel it into a list. With this tool, you can extract data from virtually any application or database table in the R/3 System. ABAP Query enables you to create lists by moving through menus. The output of ABAP Query can be: < Displayed on the screen in a table format < Displayed on the screen using SAP graphics < Downloaded to a spreadsheet (for example, Microsoft Excel) < Downloaded to a flat file < Saved as an extract that can be viewed later. Who Uses ABAP Query? ABAP Query is used by two different groups of people. Each group works with different ABAP Query components. < Departmental users: These are end users who create new queries and generate lists. Non-technical users find ABAP Query particularly useful because it does not require any programming knowledge. < System administrators: System administrators set up the necessary environment for end users and carry out transports. ABAP Query can be used to access just about any data in the database, making it very desirable for users in many areas of a business. Several R/3 application areas provide a predefined logical database for easier information retrieval. How Is ABAP Query Organized? As shown in the graphic, ABAP Query has three main components: < Functional areas < Queries < User groups Chapter 2: ABAP Query Learning the Basics of ABAP Query Report Development Tools 2–3 Basic List Basic List Ranked List Ranked List Statistical List Statistical List Functional Areas Functional Areas ABAP Query User Groups User Groups Queries Queries Functional Areas You need functional areas to offer a preselected set of data to the user, depending on the task to be accomplished. A functional area defines the tables—and the fields within those tables—which can be queried. Functional areas use a logical database, a direct read from a table, or a series of table joins to determine the available tables. Why create functional areas ABAP Query allows you to evaluate data in the R/3 System. However, since the system contains several hundred thousand fields in logical databases, in tables, and sequential datasets, it is simply not practical to offer all these fields to a user for selection when creating queries. Therefore, before starting to create queries (using the component Maintain Queries), you create functional areas (using the component Maintain Functional Areas). Functional areas provide the user with a framework for defining a query quickly and easily. Functional groups When you create a functional area, you select a logical database from an application system. However, since one logical database can contain a vast number of fields, you combine fields together in logical units known as functional groups (see page 2–5). A functional area not only allows you to restrict the number of fields and group them together in meaningful units, but it also allows you to define auxiliary fields and process them like database fields. You can also read the long texts in additional tables (for example, the long text of an airline carrier in the table SCARR) and perform any necessary preliminary work. This means that you can evaluate sequential datasets just as easily as SAP databases. Starting with Release 4.0, a functional area can have a name of up to 24-characters. Previous releases were limited to four-character names. SAP now delivers functional areas in various applications. Chapter 2: ABAP Query Learning the Basics of ABAP Query Reporting Made Easy 2–4 User Groups User groups link users to functional areas and queries and control the functional areas and queries a user can access. Each functional area is assigned to one or more user groups. For access to ABAP Query, a user must be a member of at least one user group. All members of a user group can access the same data as well as the same programs (queries) to create lists. What is a user group? A user group is a collection of users that work with comparable data and accomplish similar tasks. Changes to functional areas and queries are immediately visible to all users. The users assigned to a user group can only access the functional areas assigned to their user group. When creating a query, the user group controls which functional areas can be used. (However, user groups are irrelevant if a user has full authorization to all R/3 data.) Starting with Release 4.0, user groups can have 12-character names. Prior releases were limited to two-character names. Queries When you create different lists using ABAP Query, you can save the layout for each list. The element created is called a query. A query is specific to a user group and functional area. When creating a query, you may only select one functional area. Within a query, you must also specify functional groups in the selected functional area. This means the selected area (and the groups) must contain all the fields you wish to include in the query. Using queries If appropriate authorizations are in place, you can execute, modify, copy, and delete queries. Any modifications to queries affect all users of a user group. That is, if one user deletes a query, it is lost for all other users as well. All changes or new creations are at once visible to all users. Starting with Release 4.0, queries can have 12-character names. Prior releases were limited to two-character names. Queries have three different types of reports or lists: < Basic list: Sorts and totals selected fields as specified by the user in the query. This is the most common kind of report. < Statistical list: Totals, calculates averages, and allocates percentages based on the fields in the query. < Ranked list: Ranks fields based on numeric fields, including currency or quantity. A single query may have multiple statistical and ranked lists but only one basic list. Chapter 2: ABAP Query Learning the Basics of ABAP Query Report Development Tools 2–5 Related Terminology < Logical database: A series of tables that are linked together via a logical database program. < Functional groups: Part of a functional area. You create functional groups within a functional area and then assign the fields you want to query to the functional group. Logical database To retrieve data, ABAP provides an extra read program called a logical database. This program reads the required data and provides it to you in the correct order. You only write the statements that process the data. To take advantage of this functionality for your report program, you must declare the logical database in the report attributes. SAP delivers several logical databases in the application areas and gives a user the capability of creating their own. We strongly recommend that a basis/tools expert be involved in the creation of a logical database. To view the delivered SAP logical databases, follow the menu path: Tools → ABAP Workbench → Development → Programming Environment → Logical Databases, or use transaction code SE36. Functional groups If a field is not assigned to a functional group, it cannot be included in a query. Functional groups have two-character names and are functional-area dependent. There are no naming restrictions for functional groups. How to Access ABAP Query Components? From the SAP main menu, choose System → Services → ABAP Query to access ABAP Query. To access the components of ABAP Query, use the menu paths shown in the following table: ABAP Query Component Menu Path Maintain Queries Tools → ABAP Workbench → Utilities → ABAP Query → Queries Maintain Functional Areas Tools → ABAP Workbench → Utilities → ABAP Query → Functional Areas Maintain User Groups Tools → ABAP Workbench → Utilities → ABAP Query → User Groups Chapter 2: ABAP Query Learning the Basics of ABAP Query Reporting Made Easy 2–6 How Does ABAP Query Differ from Other Reporting Tools? There are several differences between ABAP Query and other reporting tools: < ABAP Query can access data from any table within SAP. Most other reporting tools can access only certain tables. < ABAP Query is ideal for listing data from any application in the system. It can calculate additional fields such as purchase price variance (PPV) in procurement or “aging buckets” in accounts receivable (A/R), and total and sort on any field. These fields are calculated on each line of a detail report and then totaled by the specified fields (for example, material or customer). < ABAP Query reports are typically simple listing and totaling reports, unlike a balance sheet or an income statement that requires complex groupings (for example, a cash or revenue line made up of several accounts on a financial statement). Such complex groupings would require the query to read tables multiple times to appropriately total and sort the accounts. Other tools (such as Report Painter/ Report Writer which uses sets for these groupings) are better suited for reports with complex groupings. What Are the Prerequisites? < An understanding of the data dictionary and perhaps some basic programming: While an ABAP programming background is not critical to use this tool, knowledge of the data dictionary and some basic programming is helpful. If you are not familiar with the data dictionary or do not possess basic programming skills, you may want to enlist the help of a basis/tools expert at some point. These skills will come in handy when the functional area you are building needs additional tables, additional fields, or table joins. < Know required database tables and fields: Before starting a query, you should know the required tables and fields. To execute a query, data must be present in the tables you are accessing. A general understanding of the fields and how they are stored in the database is also helpful. For example, the posted dollar amount in an FI document is stored as an absolute number. The system uses the posting key to determine if the actual value is positive or negative. To show the correct amount in your query you will need to create an additional field in the functional area that checks the posting key to determine the correct amount. The correct amount is then stored in the additional field for your queries. < System settings: An administrator must first make the required settings to allow a user to work with ABAP Query. < Authorizations: End users and system administrators must have the appropriate authorizations to use ABAP Query. Chapter 2: ABAP Query Creating a Report with ABAP Query Report Development Tools 2–7 Creating a Report with ABAP Query In this section a guided tour shows you how to create a report using ABAP Query. This step-by-step approach is built around a sample report (see the graphic below). We suggest you take a few minutes to familiarize yourself with the scenario and the desired report. Example: Bungee Corporation wants to view the account history for several G/L accounts at a time—in a specified format. While they like many of the standard reports provided in R/3, they would prefer to change the order of the columns. Bungee Corporation believes that in the future they will include fields from internal tables, and thus would like to begin creating custom reports. Additionally, the company wants to be able to print the General Ledger history. Shown below is a preview of the General Ledger History report with all the desired functionality. For this query, we will create a functional area using a logical database. This is an easy and effective way to start creating queries. Note: In the example we use Release 4.0B. While this release has a different look-and- feel than prior releases, the underlying concepts and terminology remain the same. Chapter 2: ABAP Query Creating a Report with ABAP Query Reporting Made Easy 2–8 The main steps in creating a query are shown in the graphic below. Create the query Create the query Trained Employee Available? Assign the functional area to the user group Assign the functional area to the user group Create a user group Create a user group Generate the functional area Generate the functional area Assign required fields to functional groups Assign required fields to functional groups Create a functional area Create a functional area 1 2 3 4 5 6 Guided Tour Step 1: Create a Functional Area 1. To access the initial screen of ABAP Query, choose System → Services → ABAP Query. 2. Choose Environment → Functional Areas. 2 Chapter 2: ABAP Query Creating a Report with ABAP Query Report Development Tools 2–9 3. In Functional area, enter a name for the functional area (for example, ZZ_GL_DETAIL) you want to create. 4. Choose Create. 5. In the Name field enter a description for the functional area. 6. Leave Fixed point arithmetic selected to ensure that the decimal places are correctly set for the calculations. 7. In Logical data base, enter the name of the logical database you want to use for the functional area (for example, SDF). 8. To display the tables and fields available in the logical database, choose Display. 9. Select Table join. Note: If you prefer to directly read a specific table or use a table join for multiple tables, then enter the name of the main table in the Table field and select either Direct read or Table join. Only one of two areas (steps 6 and 7 for logical databases or step 8 for specific tables) should be selected. 10. Choose Enter. 4 3 5 6 7 8 10 9 Chapter 2: ABAP Query Creating a Report with ABAP Query Reporting Made Easy 2–10 11. Choose the Create button (next to the Functional groups folder) to add two functional groups to the newly created functional area ZZ_GL_DETAIL. 12. Create the following two functional groups, A1 and A2 in the Create Functional Groups window: < A1 for Account Master Info < A2 for Account Transactions 13. Choose Enter. 11 12 13 [...]... on the white line 43 44 43 Choose Save 44 Congratulations! Your query is now ready to run Choose Execute to run the query Report Development Tools 2–25 Chapter 2: ABAP Query Running the Query Running the Query To run a query, choose System → Services → ABAP Query 1 Select the query from the list In this example, user group X1 has only one query (A1) 2 2 Choose Execute 1 3 Enter the variables In this... Chapter 2: ABAP Query Creating a Report with ABAP Query 12 Select the line BSEG 13 Choose the Extras button to add an additional field 13 12 14 Choose Create 14 15 In the Name field, enter Correct_Amount, the name of the additional field to be added to the functional area 15 16 16 Select Additional field 17 Choose Enter 2–14 17 Reporting Made Easy Chapter 2: ABAP Query Creating a Report with ABAP Query. .. only < Highlighted < Set defaults Report Development Tools 2–27 Chapter 2: ABAP Query Getting the Most from ABAP Query: Tips & Tricks The following example explains how to customize the variables from within the functional area 1 From the SAP main menu choose System → Services → ABAP Query, then Tools → ABAP Workbench → Utilities → ABAP Query → Functional Areas 2 In the Functional area field, enter... area, see page 2–11 1 From the SAP main menu choose System → Services → ABAP Query, then Tools → ABAP Workbench → Utilities → ABAP Query → Functional Areas 2 In the Functional area field, enter the name of the functional area to be created and choose Create Report Development Tools 2–29 Chapter 2: ABAP Query Getting the Most from ABAP Query: Tips & Tricks 3 In the Name field, enter a description for the... with ABAP Query: 1 Create a functional area 2 Assign required fields to functional groups 3 Generate the functional area 4 Create a user group 5 Assign the functional area to the user group 6 Create the query Where to Learn More < R/3 Library (Online help): In Release 4.0B, you will find more information on ABAP Query Go to R/3 Library → BC → Basis Components → ABAP Workbench → BC ABAP Query | BC ABAP. .. twice because both the logical database and the query use these fields as selection criteria Be sure to remove this duplication from the query 5 Dynamic selections are also available because of the logical database These selections should also be used instead of query selections 3 3 4 6 Choose Execute to run the query 2–26 Reporting Made Easy Chapter 2: ABAP Query Understanding the Report List Understanding... the query 5 Step 6: Create the Query To go to query maintenance from the User Group screen, choose Environment → Queries 1 Make sure you are working in the appropriate user group 2 If not, choose the Other User Group button and switch to the correct user group 3 In the Query field, enter a name for the new query In this example, enter A1 2 3 4 1 4 Choose Create 2–18 Reporting Made Easy Chapter 2: ABAP. .. do not appear in the 8 query 7 In Columns, enter the column size (in characters) In Lines enter the desired number of lines In this example, the number of lines and columns is 65 and 132 respectively This should match a print format if the query is to be printed 5 6 7 8 Choose Next Screen to continue Report Development Tools 2–19 Chapter 2: ABAP Query Creating a Report with ABAP Query 9 Select the functional... creating queries Multiple appearances can be extremely confusing The next two steps involve ABAP programming statements You may want to ask a Basis/Tools expert to help you if you are not familiar with SELECT statements and basic ABAP code Report Development Tools 2–11 Chapter 2: ABAP Query Creating a Report with ABAP Query The next step is to add an additional table that does not exist in the logical database... ABAP Query | BC ABAP Reporting Tutorial < ABAP/ 4 Query, a comprehensive book from the ABAP/ 4 Development Workbench documentation published by SAP AG To order printed copies use product number 50014371 < BC405: ABAP/ 4 Development Workbench—Reporting, a five-day training course offered by SAP Education and Training Report Development Tools 2–33 Chapter 2: ABAP Query Where to Learn More 2–34 Reporting . of ABAP Query, choose System → Services → ABAP Query. 2. Choose Environment → Functional Areas. 2 Chapter 2: ABAP Query Creating a Report with ABAP Query. Utilities → ABAP Query → Functional Areas Maintain User Groups Tools → ABAP Workbench → Utilities → ABAP Query → User Groups Chapter 2: ABAP Query Learning

Ngày đăng: 11/12/2013, 14:15

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan