Quantcast
Channel: SCN : All Content - SAP NetWeaver Technology Platform
Viewing all articles
Browse latest Browse all 1967

SAP NetWeaver - Implementing an ABAP Program

$
0
0

ABAP

 

 

ABAP is a programming language developed by SAP. Most of the business applications of an SAP system are written in ABAP. An ABAP program consists of individual statements beginning with a keyword and ending with a period.

 

Example program:

 

REPORT first report.
WRITE 'My first ABAP report!'.

 

The example program contains two statements, one on each line. The keywords are REPORT and WRITE. The program displays a list. In this case, the list contains the line: My first ABAP report!

The figure shows an excerpt from an ABAP program. You can use special commands or keywords in ABAP programs to create selection screens (keyword PARAMETERS), to print lists (keyword WRITE), and to access table content (for example, using the keyword SELECT). The ABAP statement CALL SCREEN calls a screen (consisting of a screen image and its flow logic) defined in the Screen Painter screen.

ABAP uses Open Structured Query Language (SQL) commands to access the database. Open SQL consists of a set of ABAP statements that execute operations on the central database of the SAP system. Open SQL is used in an identical way for all supported database platforms on SAP systems, based on AS ABAP, meaning that the type of database used has no effect on the development of a program.

 

ScreenHunter_24 Apr. 11 14.34.jpg

image provided by SAP

 

The characteristics of ABAP are as follows:

  • Multilingual capability (text elements, such as list headers and input field texts, are stored separately for each supported language)
  • Simple and effective development of graphical user interfaces
  • Object-oriented programming (ABAP Objects)
  • Platform independence (using Open SQL and the database interface)
  • Efficient access to data structures, such as tables, data elements, and so on

 

 

 

ABAP Workbench Tools

 

 

In AS ABAP, you use the ABAP Workbench, a graphical programming environment, to write application programs. The ABAP Workbench enables you to use programming tools, pushbuttons, the context menu (right mouse click), and forward navigation (double-click an object name). An ABAP application is, for example, a transaction or a report.

You can access a range of tools, including the following tools:

  • ABAP Editor (transaction SE38 or SE80) to write ABAP programs
  • ABAP Dictionary (transaction SE11) to define and describe tables, data elements, lock objects, and so on
  • Screen Painter (transaction SE51 in the User Interfacesubdirectory) to create interactive user interfaces
  • Function Builder (transaction SE37) to create and manage function modules (these are independent modules of ABAP code with defined input and output interfaces)


The individual Workbench tools combine to form an integrated system. If, for example, you are working with program objects in the ABAP Editor, then the editor also recognizes objects created using other tools. A specific tool for editing an object starts when you select the object and double-click it.

 

You can find the ABAP Workbench tools on the SAP Easy Access screen by choosingToolsABAP WorkbenchDevelopment. When working in the Workbench, you come across development objects and packages. Development objects, such as reports, transactions, or screen definitions, are objects that you can edit using the ABAP Workbench. A package contains logically-related development objects, such as all objects for a specific application.

SAP provides the Object Navigator to help you organize your development processes using the ABAP Workbench. This enables simple, uniform access to repository objects and their corresponding development tools. You can access Object Navigator by using transaction SE80, or you can also chooseToolsABAP WorkbenchOverview Object Navigator.

 

ScreenHunter_25 Apr. 11 14.37.jpg

image provided by SAP


 

 

Access to ABAP Source Code

 

 

SAP delivers the source code for all ABAP programs. You can view the code and use it as a template for your programs, among other things.

In any application, you can choose SystemStatus and double-click to navigate to the relevant ABAP Workbench tool. The Workbench displays the selected object in the appropriate tool, provided you have the necessary access rights.

 

ScreenHunter_26 Apr. 11 14.39.jpg

image provided by SAP


 

 

Creation of ABAP Programs by Using the ABAP Editor

 

 

You can use the ABAP Editor (transaction SE38 or link in the Object Navigator, transaction SE80) to create and edit programs. ABAP programs are stored in the SAP system as entries in database tables.

When you want to create a new program, enter both a program title and attributes for the program. These attributes include the program type (for example, executable program), status (for example, test program), and application component. When saving a program, you also need to assign it to a package.

Once you complete these activities, you can write your own program by using the ABAP Editor.

 

ScreenHunter_27 Apr. 11 14.40.jpg

image provided by SAP


 

 

ABAP Editor

 

 

The ABAP Editor provides a range of functions, including a syntax check and an option for the capitalization of ABAP keywords. You can also display syntax help for an ABAP keyword by positioning the cursor on the keyword and pressing F1. SAP recommends that you develop ABAP programs by using only the ABAP Editor. Using the ABAP Editor, you can navigate to other tools in the development environment, such as theABAP Dictionary, the Screen Painter, and the Menu Painter, by double-clicking the repository objects in the coding.

If you create or change a program (or a development object) and then save it, an inactive version of the program (or development object) is always saved in the ABAP repository, making it possible to continue developing the program without changing the active system. Until you activate the inactive version of the program (or object), all calls to the program (or object) use the last active version instead of the version on which you are working.

You can execute your program in the ABAP Editor by using Direct processing (F8 key). This action executes the inactive version of your program for testing purposes.

 

 

ABAP Dictionary

 

 

The ABAP Dictionary is a central component of the ABAP Workbench, containing both business and technical definitions and descriptions of SAP data. The ABAP runtime environment, such as the ABAP interpreter and screen processor, accesses the information of the ABAP Dictionary.

The ABAP Dictionary enables all data definitions that the SAP system uses to be described and managed centrally. The ABAP Dictionary is an active dictionary that is completely integrated in the SAP development and runtime environment. The dictionary information is created only once, but is available throughout the system at all times. The ABAP Dictionary (transaction SE11) automatically provides all the information that has been created or modified, ensuring that runtime objects are up-to-date and data is consistent and secure.

The objects of the ABAP Dictionary can be subdivided as follows:

  • Database object definitions (tables, views, and so on)
  • Type definitions (structures, table types, and so on)
  • Service definitions (F1 help, F4 help, lock objects, and so on)

 

 

Object Types in the ABAP Dictionary

 

 

The different object types are explained as follows:

  • TablesThe definition of tables in the ABAP Dictionary is database independent. This definition serves as the basis for the creation of a table with the same structure in the underlying database.
  • ViewsThese are logical views of one or more tables. View structures are defined in the ABAP Dictionary. This structure is the basis for the creation of a view on a database.
  • Lock objectsLock objects coordinate attempts by several users to access the same dataset. Function modules are generated from the lock object definition in the ABAP Dictionary. Users can use the function modules in application programs.
  • DomainsDomains are used to group fields that have similar technical or business purposes. A domain defines the range of values for all table fields and structure components that refer to the domain.

 

Significance of the ABAP Dictionary

 

 

The integration of the ABAP Dictionary into the program flow is based on the interpretative method of the AS ABAP runtime environment. Instead of working with the original version of an ABAP program, the ABAP processor interprets a runtime object generated from the program text before its first execution. Runtime objects are also automatically generated before the execution of a program if a time stamp comparison of the runtime objects reveals that they are no longer consistent with the current status of the ABAP Dictionary.

In the SAP system, the ABAP Dictionary also allows you to manage the database tables that are relevant to the SAP system. You do not need detailed, product-specific database knowledge for application development. The ABAP Dictionary transfers the runtime table definitions to the database level.

The interaction between the ABAP Dictionary and the development or runtime environment is outlined in the figure.

 

ScreenHunter_28 Apr. 11 14.45.jpg

image provided by SAP

 

 

 

Table Definition and the Two-Level Domain Concept

 

 

You can define tables in a database independently in the ABAP Dictionary. When you activate the table, a system creates a physical table definition in the database, based on the table definition stored in the ABAP Dictionary. The table definition in the ABAP Dictionary is converted into a definition for the database that is used.

A field is not an independent object because it depends on a table and can only be maintained within the table.

You can use domains and data elements to define fields in a table. A domain is used to technically define a table field. For example, the field length and type, output attributes, and restrictions of possible values (fixed values) are defined in the domain.

Data elements are used to describe the semantic attributes of a field in the context of a table. For example, in a data element, you can define a short description of a table field that is displayed on the screen when you call the F1 help. Using the data element, you can also specify the input field screen text (for example, field label – Destination Airport).

The figure showing a table definition and domain concept uses table SPFLI from the flight data model as an example. This table maintains flights (for example, flight XY from A to B). The table contains fields for the departure airport (AIRPFROM) and the destination airport (AIRPTO) because the departure and destination airports are different things in a business context. Two data elements, S_FROMAIRP and S_TOAIRP, are defined. However, because both columns contain the names of airports, both data elements refer to the same domain, S_AIRPID. The domain has the technical type CHAR and is three characters long.

ScreenHunter_29 Apr. 11 14.48.jpg

image provided by SAP




Modeling in the ABAP Dictionary



The figure shows data modeling (entity/relationship between tables) in the ABAP Dictionary. SAP provides data models for some of their applications. These models can be displayed using SD11. The models show entities and their relationships. Entities are tables in the ABAP Dictionary.



ScreenHunter_30 Apr. 11 14.50.jpg

image provided by SAP




Viewing all articles
Browse latest Browse all 1967

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>