0% found this document useful (0 votes)
76 views

ABAP Development Cycle in Eclipse

Uploaded by

Jamila Hamdi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views

ABAP Development Cycle in Eclipse

Uploaded by

Jamila Hamdi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

ABAP Development Cycle in

Eclipse
Table of Contents

Table of Contents 2

Creating Repository Objects 3


Basic Editor Tasks 4
Create a Program 4
Eclipse and SAP GUI Editors 6
Transport 7
Create a Package 8

Editing a Repository Object 9


Write a Program Using Keyword and Code Completion 11

Debugging ABAP in Eclipse 13


Jump to Raised Exception Location 18
To Display Raised Exceptions in the ABAP Debugger 18
Debug a Program 19

Learning Assessment 25

2
Overview
In the creation Repository Objects part, you will learn how to create
repository objects and perform basic editor tasks.

Creating Repository Objects


ABAP Repository Objects
The repository consists of all ABAP development objects, such as programs,
function modules, definitions of database tables, and so on. It contains
objects delivered by SAP as well as those defined by the customer. (Note that
the terms repository object and development object are often used
interchangeably.) When a repository object is created, it must be assigned to
a package, unless it is a local object which will not be transported.

Figure 1: Creating a Repository Object


Some repository objects can have sub-objects that are themselves repository
objects. For example, function modules belong to function groups.
Furthermore, repository objects can reference other repository objects.
ABAP Development Tools (ADT) allows you to create and edit repository
objects. Here are some of the ABAP repository objects you can work with in
ADT:

● ABAP programs
● ABAP dictionary objects, such as database table definitions and data types

3
● Screens
● Web Dynpro components(Dynpro: is the SAP standard UI technology for
developing Web applications in the ABAP environment)
● Function groups and function modules
● ABAP classes and interfaces
Different tools are available for creating, editing and displaying ABAP
Repository Objects in ADT. Some of these tools are native to Eclipse but some
objects must be displayed and edited in the SAP GUI.

Basic Editor Tasks


There are two basic functions that all developers will need to use when
developing ABAP applications. The first is syntax checking and the second is
object activation.

Figure 2: Basic Editor Tasks

The keyboard commands used to perform these basic functions are exactly
the same as those of the SAP GUI-based editors (CTRL + F2 for syntax check,

4
and CTRL + F3 for activation). However, the buttons have slightly different
icons.

Figure 3: Activation Errors


As in the SAP GUI, a dialog box will appear if you attempt to activate an
object that has syntax errors. It is sensible to fix the errors at that point. Each
problematic line of code is marked with a red cross icon. If you hover your
cursor over the icon, the associated error message is displayed as a tooltip.
You can also find information about the errors in the Problems view.

Create a Program
Business Example: You are a programmer for an SAP customer and work
with the new ABAP Development Tools. You want to create an ABAP program
in Eclipse, then activate it and run it as an ABAP application.

1. In your temporary ABAP package (beginning $TMP-), create a new ABAP


program with the name ZBC404_##_HELLO, where ## is the group number
assigned to you by your instructor. Give the program the description My first
program. Use the WRITE statement to display the text 'This is my first
program' and save the program.

2. Activate the new program.

3. Run the new program as an ABAP application.

5
Solution

1. In your temporary ABAP package (beginning $TMP-), create a new ABAP


program with the name ZBC404_##_HELLO, where ## is the group number
assigned to you by your instructor. Give the program the description My first
program.

Use the WRITE statement to display the text 'This is my first program' and
save the program.

a) Choose File → New → ABAP Program.

b) In the New ABAP Program dialog box, ensure that your own project
appears in the Project field. If it does not, choose Browse and select your
project.

c) Ensure that your temporary ABAP package name appears in the


Package field. If it does not, choose Browse and select your package.

d) In the Name field, enter the program name.

e) In the Description field, enter the program description.

f) Choose Next.

g) As you are creating a local program, you do not need to specify a


Transport Request. Choose Finish. The new program ZBC404_##_HELLO
opens in the editor.

h) In the editor, enter WRITE 'This is my first program in Eclipse.'.

i) To save the program, choose Ctrl + S.

6
2. Activate the new program.

a) In the Project Explorer view, from the program's context menu choose
Activate (or press Ctrl + F3 - the same key combination used in the
traditional ABAP Editor).

3. Run the new program as an ABAP application.

a) In the Project Explorer view, from the program's context menu choose
Run As → 1 ABAP Application(or press F8 - the same key used in the
traditional ABAP Editor).
Eclipse and SAP GUI Editors
ABAP Development Tools integrates two different types of tools for ABAP
development - Eclipse-based tools and SAP GUI-based tools.

Eclipse-based tools integrate seamlessly into the Eclipse environment.


They share the same look-and-feel, as well as the same navigation
functionality. Among the Eclipse-based tools are the different types of
ABAP Source Code editors, and the Outline, Tasks, and Problems views.

The SAP GUI is installed locally together with the Eclipse-based client. SAP
GUI-based tools represent, in the broadest sense, the tools and utilities of
the traditional ABAP Workbench. Typical examples are the Package
Builder, parts of the ABAP Dictionary, and the utilities for maintaining text
elements for ABAP programs.

When you try to open a development object in the Project Explorer view,
an Eclipse-based editor will open if one is available. If not, a SAP-GUI based
tool will open in the editor area. Any additional objects that require a SAP
GUI-based tool open in separate tabs in the editor area.

7
With GUI-based tools, you have complete access to the functionality of the
traditional ABAP Workbench. You can, for example, start any applications
you need by entering a transaction code or OK code.

You may occasionally want to start the SAP GUI independently of the
selection of any development object – for example, you may want to
change user settings. To do so choose Ctrl + 6 or choose the Open SAP GUI
button on the Workbench toolbar . Select the relevant ABAP project and
choose OK. The SAP GUI will be launched in the editor area of the ABAP
Perspective.
Transport
Development projects are carried out in a development system. Upon
completion, the development objects associated with that project must be
transported to other systems for testing or to the production system. This
happens via a change request. Change requests are often referred to as
transport requests.

Figure 4: Transport Between a Development System and a Production


System

8
Change requests are created by the project manager at the start of the
development process. Each developer working on the project is assigned a
‘task’ in the change request.

When a development object is edited or created, the developer


responsible assigns the change to the change request. The object is
entered into the developer’s task. This means that every repository object
that a developer works on during the lifetime of a development project is
collected within his or her individual task.

When a repository object is created, it must be assigned to a change


request (unless it has been created as a local object, that is, it belongs to
$TMP).

The Transport Organizer view in ABAP Development Tools offers the basic
transport functionality of the SAP GUI- based Transport Organizer. You
can use it to perform the following functions:

● View the transport requests, tasks, and object lists of any user.

● Filter for requests, tasks, and objects.

● Create, change, and delete transport requests.

● Change ownership of transport requests.

● Run consistency checks.

● Release transport requests and tasks. To access additional transport


functionality, you can double-click a transport request or a task to launch
the SAP GUI-based Transport Organizer within Eclipse.

9
Create a Package
Business Example: You are a programmer for an SAP customer and work
with the new ABAP Development Tools. Your current task is to create a
new ABAP package.

1. Create a package ZBC404_##, where ## is the group number assigned


to you by your instructor. Provide the short description My package. Assign
the package to the Application Component CA and Software Component
HOME. When prompted for a transport request, use the one created by
your instructor.

Solution

.a) Choose File → New → Other...

b) In the New window, expand the ABAP node and choose ABAP
Repository Object.

c) Choose Next.

d) In the Project field of the New ABAP Repository Object window, enter
the name of your project.

e) Expand the Package node and choose Package.

f) Choose Next.

g) In the Object name field, enter the package name ZBC404_##, then
choose Finish.

h) In the Create Package window, enter the short description in the Short
Description field. Note that this field has a tick, meaning its completion is
mandatory.

10
i) Ensure that the appropriate values are entered in the Application
Component and Software Component fields — CA and HOME, respectively.

j) Choose Continue.

k) In the Prompt for transportable Workbench request dialog box, choose


Own Requests, then choose the only one available, and choose Continue.

Editing a Repository Object


Keyword Completion

ADT's keyword completion feature allows you to reduce the time spent on
pure code editing by proposing valid ABAP keywords and identifiers that may
be inserted at any given position within the source code. To use keyword
completion, you simply begin typing the first few characters of a keyword or
identifier - suggestions appear automatically.

Figure 5: Using Keyword Completion

If the initial suggestion is correct, simply choose the TAB key to accept it. To
see more options, choose Ctrl + Space, and then choose the desired ABAP
keyword or identifier from the list of suggested entries. Note that keyword
completion can be turned off in Preferences but it is enabled by default.

11
Code Completion

The keyboard shortcut Ctrl + Space is not used solely for keyword
completion. You can also use it to access code completion suggestions for
the following:

● Data objects declared within the application

● Methods, attributes, and events

● Function modules

● Class names

Figure 6: Using Code Completion

When you choose Ctrl + Space, a full list of objects matching what you have
already typed appears. As you continue to type, the list is narrowed down. To
insert the name of a variable, function module, or method into your code,
select the entry and choose Enter or double-click the name. For function
modules and methods, you will often want to insert not just the name but
also the full interface or signature. To do this, highlight the function module
or method and choose Shift + Enter.

12
Write a Program Using Keyword and Code
Completion
Business Example

You are a programmer for an SAP customer and work with the new ABAP
Development Tools. You want to create a program using keyword and code
completion.

1. In the ABAP package ZBC404_##, where ## is the user name assigned to


you by your instructor, create an ABAP program called
ZBC404_##_CODE_COMPLETION. Give it the description Code completion
program and use the transport request created by your instructor.

2. Declare a standard internal table with line type sflight. Remember that as
ABAP keywords are suggested, you can insert them by pressing the Tab key.

3. Fill the internal table with data from table sflight. Use the array fetch
technique (SELECT ... INTO TABLE).

4. Use the ALV object model to display the data. Declare a reference variable
with TYPE REF TO cl_salv_table.

5. Use the factory method of cl_salv_table to obtain a valid instance of the


class. Use code completion to help you.

6. Use code completion to find the appropriate method to display the data on
the screen.

7. Save, activate, and run your program.

Solution

13
1. In the ABAP package ZBC404_##, where ## is the user name assigned to
you by your instructor, create an ABAP program called
ZBC404_##_CODE_COMPLETION. Give it the description Code completion
program and use the transport request created by your instructor.

a) Choose File → New → ABAP Program.

b) In the New ABAP Program dialog box, ensure that your own project
appears in the Project field. If it does not, choose Browse and select your
project.

c) Ensure that ZBC404_## appears in the Package field.

d) In the Name field, enter ZBC404_##_CODE_COMPLETION.

e) In the Description field, enter the program's description.

f) Choose Next.

g) Choose the transport request created by your instructor.

h) Choose Finish. The new program ZBC404_##_CODE_COMPLETION opens


in the editor.

2. Declare a standard internal table with line type sflight. Remember that as
ABAP keywords are suggested, you can insert them by pressing the Tab key.

a) Enter DATA gt_sflight TYPE STANDARD TABLE OF SFLIGHT.

3. Fill the internal table with data from table sflight. Use the array fetch
technique (SELECT ... INTO TABLE).

a) Enter SELECT * FROM sflight INTO TABLE gt_sflight.

14
4. Use the ALV object model to display the data. Declare a reference variable
with TYPE REF TO cl_salv_table.

a) Enter DATA go_alv TYPE REF TO cl_salv_table.

5. Use the factory method of cl_salv_table to obtain a valid instance of the


class. Use code completion to help you.

a) Enter cl_salv_table=>then press Ctrl + Space. Highlight factory, then choose


Shift + Enter. The code that is added contains some statements that are
commented out. Amend as necessary and add the appropriate variables.

6. Use code completion to find the appropriate method to display the data on
the screen.

a) Enter go_alv-> then press Ctrl + Space. Place the cursor on display, then
choose Shift + Enter.

7. Save, activate, and run your program.

a) See code block below.

Debugging ABAP in Eclipse

15
The Debug Perspective
ABAP Development Tools includes a native debugger.

Note: ADT's native debugger is only available if your AS ABAP system has SAP
Kernel 7.21 or higher. If you do not have this release, you have to use the
GUI-based debugger.

Figure 7: The Default Arrangement of the Debug Perspective

Its key capabilities are as follows:

● Navigation via step functions and the call stack

● Flexible variable display and modification

● Internal table display

● Breakpoints

● Debugging after a runtime error

16
● Display the attributes of an exception object

● Jump to the location of an exception that occurred during a debugger step

● Direct editing in the debugger This last feature - the ability to correct a
mistake as soon as you find it - is very useful and is not available in the SAP
GUI-based debugger. Other features are available in the SAP GUI debugger
but not the ADT debugger. Some are available in both.

The following table summarizes the situation regarding feature availability:

17
Table 1: Debugger Feature Availability

When ABAP encounters an active breakpoint, ADT switches from the ABAP
perspective to the Debug perspective. The first time this happens, you will be
asked to confirm the change. When you do, you can also tell ADT to switch
automatically in future.

Figure 8: The Debug Perspective

The main areas of the Debug perspective are as follows:

● The navigation toolbar of the Debug view lets you control execution in the
debugger, stepping through your code, resuming or canceling execution.

18
● The Debug view also shows you the active call stack. You can click on
entries in the call stack to open the code at that level of the stack. You can
then inspect active variables, set breakpoints, or edit your code.

● Variables and Breakpoints are on tabs and share a view. A double-click on a


variable in the code view shows you the value and attributes of the variable
in the Variables view. In the Breakpoints view, you can see the list of active
and inactive breakpoints. Double-click on a breakpoint to jump to its location
in the code. Mark or unmark a breakpoint to activate or deactivate it. Any
such changes are effective in the current debugging session.

● The editor view shows the code you are debugging. You can follow
debugger execution in the code, show the values of variables by hovering
with the cursor over them, and open them in the Variables view by clicking on
them. You can correct mistakes in your coding directly in the editor; there's
no need to switch to the ABAP perspective to edit your code.

● The ABAP Internal Table view opens at the bottom of the Debug
perspective. Double clicking on an internal table opens the table not only in
the Variables view but also in the

ABAP Internal Table view. You can also type an internal table name directly
into the view or find a table in the code that you are debugging. You can view
and edit the rows of the table, rearrange table columns for better display
using drag-and-drop, and so on.

Debugger Settings

You can change how the ABAP debugger behaves using the General Settings
(choose Window → Preferences and then choose Debug under the ABAP

19
Development node). The choices you make here apply to all of your ABAP
projects. The options are presented in the following table:

Table 2: ABAP Debugger Options

20
Jump to Raised Exception Location

When an exception occurs during a step in the ABAP debugger, you are
notified by the display of a red '!' exclamation point in the left hand gutter of
the editor window.

Figure 9: A Raised Exception

You can use the context menu of the line where the exception has been
raised to access the Go to Exception Raise Location and Show Exception
Variable functions. To return to the CATCH statement, use the keyboard
shortcut Alt + Left Arrow.

Display Raised Exceptions in the ABAP Debugger

When an exception is raised during the debugging process, a red


exclamation mark appears in the left-hand margin of the editor window.

21
1. To jump to a raised exception, choose the context menu of the line
marked with a red exclamation mark in the source code and choose Go to
Exception Raise Location.

2. To display the attributes of the exception object, choose the context menu
of the line marked with a red exclamation mark in the source code and
choose Show Exception Variable.
Debug a Program
Business Example

You are a programmer for an SAP customer and work with the new ABAP
Development Tools. You have been asked to debug an ABAP program.

1. Create a duplicate of the program BC404_FLIGHT_APP called


ZBC404_##_FLIGHT_APP, where ## is the group number assigned to you by
your instructor. Assign it to your package and to an appropriate transport
request.

2. Activate your program.

3. Set a breakpoint at the first statement of the INITIALIZATION event and


run the program as normal.

What are the five views that are immediately visible in the Debug
perspective?

4. Check that the fields on the selection screen have been populated and
execute the program, at which point the Debug perspective opens.

5. Set a statement breakpoint for all SELECT statements and continue


running the program.

22
6. When the program stops again, return to the Debug perspective and enter
the name of the target structure of the SELECT statement in the Variables
view. Expand the display to show all components of the structure and
execute the next single step to ensure that the structure is filled.

7. Continue running the program until you reach the statement SELECT
bookid customid class loccuram loccurkey forcuram forcurkey FROM sbook …
Then use the ABAP Internal Table (Debugger)view to display the internal
table.

8. How many columns does the Table view contain? Choose the correct
answer.

A3
B5
C7
D9

9. Execute the SELECT statement using the single step function.

How many records were selected?

10. Resume the program. As soon as you reach a SELECT statement that is
not part of a program, class, or function module beginning with BC404 or
CL_BC404, disable the statement breakpoint. Terminate the debugger and
return to the ABAP perspective.

11. Delete the breakpoint in the INITIALIZATION event, set a new breakpoint
on the CREATE OBJECT statement in the AT SELECTION-SCREEN event, and
run the program.

23
12. On the selection screen, enter invalid data. Execute the CREATE OBJECT
statement and go to the raised exception.

What is the name of the class in which the exception was raised?

13. Switch to the SAP GUI window containing the selection screen and verify
that the application has behaved correctly.

Then terminate the debugging session.

Solution

1. Create a duplicate of the program BC404_FLIGHT_APP called


ZBC404_##_FLIGHT_APP, where ## is the group number assigned to you by
your instructor. Assign it to your package and to an appropriate transport
request.

a) In the context menu of program BC404_FLIGHT_APP, choose Duplicate.

b) In the Copy ABAP Program window, in the Name field, enter


ZBC404_##_FLIGHT_APP and choose Next.

c) Choose the only transport request that is available to you and choose
Finish. The duplicate program ZBC404_##_FLIGHT_APP opens in Eclipse.

2. Activate your program.

a) Choose Activate.

3. Set a breakpoint at the first statement of the INITIALIZATION event and


run the program as normal.

What are the five views that are immediately visible in the Debug
perspective? Debug, Variables, Source Code, Outline, and Console.

24
a) Choose the context menu in the left margin next to the first statement of
the INITIALIZATION event (line 16) and choose Toggle Breakpoint.

b) To run the program, choose F8. The program will stop at the breakpoint
and the Debug perspective will open.

4. Check that the fields on the selection screen have been populated and
execute the program, at which point the Debug perspective opens.

a) Choose the ABAP perspective.

b) Verify that the fields have been populated.

c) Choose Execute. The Debug perspective opens.

5. Set a statement breakpoint for all SELECT statements and continue


running the program.

a) Choose the Breakpoints view.

b) Choose Add ABAP Breakpoint→ Add Statement Breakpoint…

c) In the Select ABAP statement field of the Select Breakpoint Statement


window, enter SELECT and choose OK.

d) To continue running the program, choose F8.

6. When the program stops again, return to the Debug perspective and enter
the name of the target structure of the SELECT statement in the Variables
view. Expand the display to show all components of the structure and
execute the next single step to ensure that the structure is filled.

a) When the program stops running, choose the Debug perspective, then
choose the Variables view.

25
b) Select the field.

c) Enter the name of the target structure of the SELECT statement, ls_flight.

d) Expand the ls_flight node to show all components of the structure.

e) Choose F5 to execute the next single step to ensure that the structure is
filled.

7. Continue running the program until you reach the statement SELECT
bookid customid class loccuram loccurkey forcuram forcurkey FROM sbook …
Then use the ABAP Internal Table (Debugger)view to display the internal
table.

a) Continue running the program by choosing F8 until the statement bookid


customid class loccuram loccurkey forcuram forcurkey FROM sbook is
highlighted.

b) If it does not appear automatically, double-click the name of the table


mt_bookings in the SELECT statement to open the ABAP Internal Table
(Debugger)view.

8. How many columns does the Table view contain? Choose the correct
answer.

A3
B5
C7
D9

9. Execute the SELECT statement using the single step function.

26
How many records were selected?

The answer depends on data entered by the student. It is the number n


displayed in MT_BOOKINGS - [n x 7(70)] at the top of the Table display.

a) Choose F5

10. Resume the program. As soon as you reach a SELECT statement that is
not part of a program, class, or function module beginning with BC404 or
CL_BC404, disable the statement breakpoint. Terminate the debugger and
return to the ABAP perspective.

a) Continue running the program by choosing F8.

b) When you reach the appropriate SELECT statement, position the cursor on
the breakpoint definition in the Breakpoints view and choose Alt+Enter.

c) In the properties dialog, deselect the Enabled checkbox, then choose Enter.

d) Close the Debug perspective.

e) If it doesn't automatically become active, choose the ABAP perspective in


the Perspective bar.

11. Delete the breakpoint in the INITIALIZATION event, set a new breakpoint
on the CREATE OBJECT statement in the AT SELECTION-SCREEN event, and
run the program.

a) Choose the context menu of the breakpoint at line 16 in the Breakpoints


view and choose Toggle Breakpoint.

b) Choose the context menu in the margin by the CREATE OBJECT statement
in the AT SELECTION-SCREEN event (line 25) and choose Toggle Breakpoint.

27
c) To run the program, choose F8.

12. On the selection screen, enter invalid data. Execute the CREATE OBJECT
statement and go to the raised exception.

What is the name of the class in which the exception was raised?

➔ CL_BC404_FLIGHT_3.

a) Enter invalid data, such as LH in the PA_CAR field and 999 in the PA_CON
field.

b) In the Debug perspective, choose F6 to use the Step Over function to


execute the CREATE OBJECT statement.

c) Choose the context menu of the exclamation mark next to the CATCH
statement and choose Go To Exception Raise Location.

13. Switch to the SAP GUI window containing the selection screen and verify
that the application has behaved correctly. Then terminate the debugging
session.

a) Choose the SAP GUI view. The selection screen should still be displayed
with the message 'Flight Does Not Exist' in the status bar.

b) Close the Debug perspective.

28
Learning Assessment

29

You might also like