Some software products marketed by SAP AG and its distributors contain .. 1 Unit 1: Flow of an ABAP Program BC Lesson: System Architecture and ABAP . Register Login. Tutorials Forum PDF Books Interview Question Courses & Institutes Sample Resume Articles SAP Career Guidence. Logo ☰. Some software products marketed by SAP AG and its distributors contain SAP AG. BC ABAP Workbench Tutorial. April 3. Icons. Icon.
|Language:||English, Spanish, Japanese|
|Genre:||Politics & Laws|
|ePub File Size:||28.45 MB|
|PDF File Size:||10.83 MB|
|Distribution:||Free* [*Regsitration Required]|
An SAP Compass course - use it to learn, reference it for work. SAP NetWeaver .. following packages BC, BC, BC and DNW7AW. The following. BC ABAP Workbench Concepts and Tools in the ABAP Dictionary, see the SAP. This book is not affiliated with, sponsored by, or approved by SAP AG. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an SAP affiliate.
In the SAP Web Application Server, presentations, application logic, and data storage can be assigned to different systems. Reference Parameters Using translatable text elements, you can develop multi-language applications. Selection Screen Exercise Objectives After completing this exercise, you will be able to: Icons in Body Text The following icons are used in this handbook.
Message Types ABAP Dictionary Reading Multiple Database Tables Available Reuse Techniques Event Blocks Flow Chart Encapsulating Output in a Subroutine Calling the Subroutine Reference Parameters Subroutine with Interface Reference Parameters A Simple Detail List Detail lists Selection Screens Creating a Screen Screen Attributes The Attribute Window Displaying Data Example Program with Data Transport Defining Pushbuttons Functions in Screens Setting a Status before Displaying a Screen Program and selection screen report transaction.
Execute your program by entering the new transaction code. Add to favorites. Execute your program by double-clicking the new favorite entry. Transaction Codes Task 1: Refer to the online documentation for each tool. Unit Contents Lesson: Transparent Tables and Views Transparent Tables and Views Lesson Overview In this lesson, you will become familiar with the description and the structure of transparent tables.
In addition, the distinction between structures and transparent tables will be explained. Data Modeling In the development of business application software, parts of the real world must be represented in data form.
A business unit then represents an entity. These entities relate to each other. The entities and relationships are visible from the data model.
Based on this data model, you can find the conversion of the table definitions and their relationships in the ABAP Dictionary. The actual application data is then on the database itself physically. In the context of this training course, it is sufficient to show one simple excerpt from this data model; this can be modified to suit your own needs, if necessary: If a customer of a travel agency wants to travel from one place to another, then he or she requests the following information from the travel agency: This view is different to that of a travel agency: In the data model, which is tailored for managing the necessary data, the data is stored in tables in a central database, organized according to technical criteria.
The amount of data stored far exceeds the demands of a customer. You must be able to compile the data to suit the demands of the customer using application programs.
Transparent Tables and Views Figure Relational Data Model The flight data model contains entities for all business information that is logically connected, such as: These entities all relate to each other in certain ways: You can manage all necessary data, without redundancies, using these relationships.
At the same time, the travel agency is able to obtain all data requested by the customer. A transparent table contains different columns to allow structured management of the data records. In this context, the term table key is of particular importance. The table key is the combination of key fields. The values in the key fields allow the system to uniquely identify all data records.
Key fields that link to other tables are called foreign key fields. Using these foreign key relationships, you can manage the data in a hierarchy and in a consistent fashion. In any other case we refer to primary key fields.
Technical Structure of a Transparent Table You normally use a data element to type a table field. Semantic properties, such as field labels, are stored in the data element. You normally use a domain for the technical properties. This is where the data type, amongst other things, is stored. The Key indicator marks a field as a key field. You normally type a field using a data element Field Type. The short description stored for the data element is displayed here once again. The same applies for the technical attributes of the field Data Type, Length, and Dec.
A data element normally uses a domain! This provides us with a logical view of the table. It is a purely technical description.
As soon as it is physically converted, the table is in the database. The table content, that is, the actual application data is also there. Structures in the ABAP Dictionary The definition of a flat structure is constructed in almost the same way as that of a transparent table. Only the property of being a key field is not appropriate for structures in accordance with a data model. They do not serve to represent a database table in the ABAP Dictionary, but are a pure type definition instead.
The DB Properties in the menu Extras have nothing to do with this topic, but are provided for other implementation options. However, we refer to component and component type as opposed to field and field type, because, in contrast to transparent tables, it is possible to define complex structures.
This means that, for example, it is possible to store a sub structure component under a component name. Using Global Structures for Data Objects A structure normally serves the purpose of centrally providing a data type in which fields from different tables are compiled.
In the ABAP program, you can then define data objects using the Dictionary structure structured data type. Therefore you can use it as a central data type definition, as is the case with a structure. This means that the following syntax variants are also possible, similar to the data object definitions listed above,: Using Global Structures for Dialogs If you use an elementary structure component to define an input field for a selection screen, you can use the semantic attributes as well as the technical attributes: On request, the system automatically generates a documentation dialog and an input help dialog for the user.
The same applies to fields of transparent tables. If you have defined a foreign key relationship, the resulting value combinations will appear in the input help on the screen. If there is an error, the system also processes an automatic error dialog.
For this you must define the data object for the data transport between the screen and the program using the TABLES statement. Transparent Tables and Views Exercise 4: Business Example You have to examine a specified ABAP program to see whether global data types are used in it, and if so, which ones. Executing a Program 1. Display the object list for package BC Throughout the exercise, make sure that you remain in display mode. Run the program to find out how it works. There is an input field on the selection screen.
What information must you pass to the program? Use the field help. What values can you enter? Use input help. What information does the program provide?
What is the technical name of the input field? Use the Technical Information for the field help. Task 3: Two output fields appear on the screen. Find out the screen number.
Choose Status from the System menu. What information is displayed? Transparent Tables and Views 2. What are the technical names of the display fields?
Do the fields belong to a structure with a globally defined type? Task 4: Use the object list to analyze the source code of the program. What data objects are there? Where in the program are they defined? Where in the program are they used? What data object corresponds to the input field on the selection screen? Search the object list for a data object with the same name as the field that you found out in step 2.
Short description of an airline 2. You see a list of airline descriptions: AA, AB, and so on. Description and local currency of the selected airline 4. Open the node Fields and display the respective statements in edit mode, as described in the training material. After you have selected a data object and executed the where-used list in programs, the system displays a list of the locations found.
Open the node Fields. Related Information Working with Elementary Data Objects Working with Structures Working with Internal Tables Working with Elementary Data Objects Lesson Overview In this lesson you will become familiar with the difference between data types and data objects first only the elementary ones and you will learn how to define these in a program.
Also, you will learn basic ABAP statements. Data Types and Data Objects Figure Working with Elementary Data Objects The type of a data object defines its technical attributes. The type of an interface parameter defines the type of the values actual parameters that are passed when the modularization unit is called.
As well as the technical attributes, the type of an input or output field can provide further information; for example, you can use it to control the field or input help.
Using global data types has several advantages: This increases the consistency of the system and significantly reduces the maintenance effort. You can then also use them to design screens. Therefore, when searching for global types, make sure that you take both the technical and semantic attributes into account. Only then you will be able to make full use of the user-friendly maintenance functions and robust nature of your program.
The following predefined ABAP types are completely specified: D Date , Format: You can use the LIKE addition to refer to the type of a data object already defined.
This means you can define an elementary data object of these types in the following way: This means that you should first define an elementary type: Using this, you then define the data object: For compatibility reasons, you can define data objects using the DATA statement, without having defined the type beforehand locally in the program using a TYPES statement.
In the case of incompletely predefined ABAP types, the system adds standard values to replace the missing type information. If there is no type specification at all, the system defines an elementary data object of type C with length one.
The same syntax applies to global types as does to user-defined types: Working with Elementary Data Objects You assign a value to each fixed data object in the source code. Therefore, it cannot be changed at runtime. You can use literals to pass fixed values to ABAP statements. There are numeric literals and text literals.
The latter are always enclosed in inverted commas: The system then maps them onto the data type I, if they are within the value range of 4-byte integers. Higher numeric literals are mapped onto data type p. They are mapped onto data type C and converted later, if necessary. If you want to include an inverted comma in a text literal, you must enter it twice.
Their type is defined similarly to the definition of elementary data objects. This is how you define the value of the constants. If possible, avoid literals completely when using statements. Instead, define constants. This significantly improves program maintenance.
Value Assignments When a program is started, the program context is loaded into a storage area of the application server and made available for all the data objects. Every elementary data object is pre-assigned the type-related initial value, except if a different value was pre-assigned using the VALUE addition.
You can use the MOVE statement to copy the contents of data objects. Two syntax variants are available for this purpose: If the two data objects source and target have different types, the type is automatically converted if there is a conversion rule. For detailed information about copying and the conversion rules, refer to the keyword documentation for the MOVE statement.
For detailed information about the initial values for a particular type, refer to the keyword documentation on the CLEAR statement. Working with Elementary Data Objects Figure Valid operations include: Parentheses and operators are keywords and must therefore be enclosed between at least one blank. Several functions for different data types are predefined in the ABAP runtime environment. For example, the following statement supplies the current length of the content of a character string.
In the case of functions, the opening parenthesis is part of the ID. The rest must again be separated by at least one space. Except for the first WHEN branch, all further additions are optional. If the condition is met, the system executes the relevant statement sequence.
If no comparison is successful, then the system executes the ELSE branch, if it is available. Except for the first query, all further branches are optional. Working with Elementary Data Objects For both constructions the system only ever executes one statement sequence, and this always for the first valid case. It is more clearly arranged and less runtime-intensive. This query places the execution of all statements up to the end of the current processing block under one condition.
If this is unsuccessful, the system continues with the first statement in the next processing block. In the first two types of loop, the system stores the number of the current loop pass in the SY-INDEX field; in the case of nested loops, this always refers to the current loop. You also have the option of specifying the maximum number of loop passes; otherwise you may get an endless loop. For example, you can construct a footer-controlled loop.
You must specify the three-digit message number and the message class. Furthermore, you can use the WITH addition to include up to four parameters. The system, depending on the message text, inserts these values into the message text. You control the dialog behavior using the type abbreviation t. There are six different dialog types for messages: A Abort The program is ended after a dialog box. X Exit The program is exited and a short dump analysis is issued.
W Warning The runtime behavior is context-dependent. I Information The program is continued after a dialog box.
S Success The message appears in the status line on the subsequent screen. There you will find executable examples, even for many other keywords and programming techniques. Executing a program in debugging mode There are several ways to start a program in debugging mode from the Object Navigator without having to change the program: Afterwards, start the program by choosing Execute Direct Processing or F8.
You have two ways of doing this: Debugging Mode: Single Step and Field Contents In debugging mode, you can choose Single step to execute the program statement by statement. You can display the contents of up to eight data objects. Breakpoints You can set a breakpoint by double-clicking in front of a line of source code. You can also set breakpoints for a specific ABAP statement: If you choose Continue, the program is executed up to the next breakpoint.
If you save the breakpoints, they remain intact while you are logged on to the system. With breakpoints, the ABAP Workbench only switches to debugging mode for the developer who set the breakpoints. All other users can execute the program directly or set their own breakpoints. Tracing Data Changes Watchpoints are breakpoints that depend on the field content. You can create the following types of watchpoints: Field Name The program is executed until the content of the field has changed.
Field Name, Relational Operator, Comparison Value The program is executed until the content of the field has changed so that the defined logical condition, relative to a value, is met. Working with Elementary Data Objects Exercise 5: You must be able to enter the values and the arithmetic operator on a selection screen. Display the result in a list.
Design the selection screen. Define the input parameters for two integers name suggestion: Execute calculations and set up the list output. Additionally, define an elementary data object for the result; type: Packed number with two decimal places name suggestion: Execute the calculation in connection with the specified arithmetic operator.
Use the CASE statement to do this. Catch errors. Display an error message on the list if the user has specified an invalid arithmetic operator. Use the IF statement to do this.
Display an error message on the list if the user tries to divide by zero. Working with Elementary Data Objects Solution 5: Result Source code extract: You can omit them here. Working with Structures Lesson: Also, this chapter will teach you how to use basic ABAP statements in structured data objects. Working with Structures Figure This allows you to combine values that belong together logically into one object.
Structures can be nested. This means that components can be made up of more structures or even tables. There are two ways to define structures: Working with Structures You define the data object itself in the usual way.
For reasons of compatibility, you can also define a structured data object directly. Access to Structure Components Components of a structure are always addressed using a hyphen -: For this reason, you should not use hyphens in names.
The value assignment only works if the components have identical names. All other components remain unchanged.
The individual value assignments can be executed using MOVE. Structures in Debugging Mode You can trace the field contents of a structure by entering the name of the structure in the left column using double-click. Double-click this entry again and you will see the component display of the structure. Working with Structures Exercise 6: Working with Structures Exercise Objectives After completing this exercise, you will be able to: Business Example You have to examine a specified ABAP program to ascertain when and how specific data is transported between certain structured data objects.
Executing a program in debugging mode 1. On the selection screen, give the field Airline the value LH. You are now in debugging mode. Check that all of the data objects are initial.
Transfer all of the data objects defined in the program into the field view. Find out about the structure and type of the individual components. Step through the program using the single-step function. Analyzing field contents 1. Which field values are copied? On the screen, enter appropriate values for the user name, date, and time, and continue with the program. Following up the list structure 1.
After the first WRITE statement, an extra button appears in the application toolbar, which allows you to display the current contents of the list buffer at any time.
Working with Structures Task 4: Setting breakpoints and changing field contents 1. Restart the program in Debugging mode. Repeat the exercise 1. Continue the program by selecting Continue, and check why the debugging of the program is stopped in each case.
Working with Structures Task 1: Working with Structures Task 3: Working with Internal Tables Lesson: Working with Internal Tables Figure In principle, the number of data records is unlimited. It is only restricted by the capacity limits of specific system installations. The ABAP runtime system dynamically manages the length of internal tables. This removes the necessity for you to carry out any work concerning working memory management. The individual data records in an internal table are known as table rows or table entries.
For this reason, the individual components in a row are referred to as columns of the internal table. The line type of an internal table can be any ABAP data type - elementary, structured, or another internal table.
Internal tables are therefore a simple way of processing large data sets in a structured manner. Typical uses include: Attributes of Internal Tables The data type of an internal table is completely specified by the following attributes: Line type This is the source of the attributes of the individual columns.
You normally specify a structure type but any data types are possible. Working with Internal Tables Key definition The key columns and their sequence define the criteria by which the table rows are identified. Depending on the access type, the key can be defined as unique or non-unique. In the case of unique keys, there are no multiple entries in internal tables with identical keys. Unlike database tables, the system may number the rows for an internal table.
It is therefore possible to access table rows using this index. A read access to a data record with index 5 returns the fifth data record of the internal table. Internal tables can be divided into three table kinds according to the access types that are possible in each case: Both index and key accesses are possible.
Here too, the index is maintained internally. A unique key is required. With hashed tables only key accesses are possible. Which table type you should use in each case depends on how that table's entries are generally going to be accessed: In this course, we only deal with standard tables; however - with the exception of a few special cases - the syntax is identical for all three table kinds.
The key fields are listed after the WITH addition. Note that the order of the key fields plays a part here. For detailed information about defining local table types, refer to the keyword documentation for the TYPES statement. You define the data object itself in the usual way. For compatibility reasons you can also define an internal table directly: Typing Structured Data Objects Figure Single Record Accesses The following single record operations are available for internal tables: In each case, wa represents a structure that must have the same type as the line type of the internal table itab.
This operation can only be used with standard tables. In a standard table these contents are appended, in a sorted table they are inserted in the right place, and in a hashed table they are inserted according to the hash algorithm. READ Copies the contents of an internal table row into a structure.
This statement can only be used for tables whose non-key fields are all numeric. If the keys are identical, the numeric values are added. For detailed information about the ABAP statements described here, refer to the relevant keyword documentation. Processing Sets of Records The following set operations are available for internal tables: All single record operations can be executed within the LOOP.
In this case, for the single record operations, the system identifies the row to be processed. Syntax Example: Filling Line by Line You can insert rows into an internal table by first filling a structure with the required values and then inserting it into the internal table using the INSERT statement. In the case of standard tables, the row is appended to the table.
For sorted tables and hashed tables, the system inserts the row by referring to the key. Reading Contents Using a Loop You can use a LOOP to read and process the contents of an internal table by accessing the structure components within the loop. If you want to change the contents of the internal table, you must first change the value of the components within the loop and then overwrite the internal table row using the MODIFY statement.
Index operations can only be performed on index tables. Therefore, these operations are only supported for standard and sorted tables. In the above example, the system only runs through the first five rows in the internal table. In the example below, the system reads the third row of the internal table. Key operations are supported for all table kinds.
With a fully specified key, key accesses to sorted and hashed tables are generally less runtime-intensive than key accesses to standard tables. With regards to runtime requirements, the sorted table is most suitable for this type of processing. The second example shows the syntax for reading a line in the internal table with a fully specified key. With regards to runtime requirements, the hashed table is most suited to this type of single record access if the number of contained data records is sufficiently high.
Operations on the Whole Internal Table The following operations affect the whole internal table: SORT You can use this to sort any number of columns in a standard or hashed table in ascending or descending order. Culture-specific sorting rules can be taken into account, if necessary. A part of the previously used working memory remains available for future insertions.
FREE This deletes the entire contents of the internal table and releases the previously used working memory. Sorting a Standard Table You can sort standard tables by the table key or by any column, simply by entering the column name after the BY addition to the SORT statement. Ascending sorting is the default. If you use the AS TEXT addition, the system will take the culture-specific sorting rule into account when sorting by character-type fields.
Only if you use the STABLE addition will the relative order of data records, which have identical sort keys, remain intact during sorting. In this example, the data records of the internal table are sorted descendingly by the percentage occupancy of flights. For more details, refer to the keyword documentation for the SORT statement.
Internal Tables in Debugging Mode You can trace the row contents of an internal table by entering the name in the left column. To see the table display, double-click this entry. An internal table with a header line consists of a work area the header line and the actual table body.
Both objects are addressed with the same name. How this name is interpreted depends on the context. To avoid confusion, it is recommended that you use internal tables without header lines. This is especially apparent in the case of nested tables.
Furthermore, within object-oriented contexts of ABAP Objects, you can now syntactically only use internal tables without a header. You can always uniquely address the body of an internal table itab by using the following syntax: This is irrespective of whether the internal table has a header or not.
Only the header is copied. The actual table content is copied.
Working with Internal Tables Exercise 7: Working with Internal Tables Exercise Objectives After completing this exercise, you will be able to: Define internal table 1. You should therefore define an internal table with a line type that is compatible with the line structure of SPFLI. Define an internal table name suggestion: Define a suitable work area for the internal table name suggestion: Phone Email. Course Number Duration 5 Days. Request Team Training.
Important Course Information Prerequisites: Exclusive Private Team Training Course Enhance your team's effectiveness and boost productivity with this course, delivered privately to your organization or to any preferred location or online. Login to My Learning Tree. Incorrect username or password.