9 Creating Instances of a Class
Learning
/Browse/Courses/Learning Basic ABAP Programming/Creating Instances of a Class
Creating Instances of a Class
Objective
After completing this lesson, you will be able to create Instances of an ABAP Class.
Instance Creation
You work with attributes like normal variables of the same type. Outside the class, however, the attribute name is not sufficient to identify the attribute unambiguously. To address a static attribute outside the class, first type the class name, then the static component selector (=>), and only then the attribute name. The static component selector is a double arrow made up of an equals sign and the greater than sign.
Hint
No blanks are allowed before or after the component selector.
For instance attributes the situation is even more complicated: In order to access an instance component, you need a reference variable.
A reference variable is a special kind of variable that you use to create, address, and manage an object. A reference variable is used to point at the instance of a class in the program memory. You declare reference variables using the DATA statement with the addition TYPE REF TO followed by the name of a class.
The initial value of a reference variable is called the NULL reference; the reference does not yet point anywhere.
To create a new instance of a class, you use the NEW operator. The example above, uses a NEW #( ) expression on the right hand side of a value assignment. The result of the expression is the memory address of the newly created instance. This reference is then stored in the reference variable on the left-hand side of the assignment.
You may have noticed that the name of the class that you want to instantiate does not appear anywhere in the expression. However, from the location of the NEW #( ) expression, the system already knows that the target variable connection has the type REF TO lcl_connection, and consequently it knows that it should create an instance of the class lcl_connection. The pound sign after the NEW operator means "use the type of the variable before the equals sign". (In more advanced scenarios, you can actually specify the name of the class in place of the pound sign).
Hint
There must be at least one blank between the brackets.
When you address a class for the first time (which could be accessing a static component or creating an instance of the class), the runtime system also loads the class definition into the program memory. This class definition contains all of the static attributes, which only exist once in the class instead of once for each instance.
You address static components using the class name and the static component selector. This does not work for instance components because you have to specify the instance you want to access.
To address an instance attribute outside the class, first type the reference variable, then the instance component selector (->), and only then the attribute name. The instance component selector is an arrow made up of a dash and the greater than sign.
Note
Unlike many other programming languages, ABAP uses different characters for instance component selector and static component selector.
One of the main characteristics of object oriented programming is the fact that you can create multiple instances of the same class. Each instance is created in a different place in the program memory and the values of instance attributes in one instance are independent from the values in other instances. But as the graphic illustrates, instances of the same class share the value for the static attributes.
If you assign one reference variable to another, the system copies the address of the object to which the first variable is pointing into the second reference variable. The result of this is that you have two reference variables that point to the same object.
You can use the same reference variable to create more than one instance of a class. Each time you use the NEW #( ) expression, the system creates a new instance of the class and places the address of the new instance into the reference variable. However, the address of the new instance overwrites the address of the previous instance.
In the example above, the address of lcl_connection (2) overwrites the address of lcl_connection (1). Consequently, there is no longer a reference variable in the program pointing to lcl_connection (1). When this happens to an instance, it can no longer be addressed from the program.
To prevent the program memory from becoming filled with objects that can no longer be addressed and eventually overflowing, the runtime system has a component called the garbage collector. The garbage collector is a program that runs periodically to look for and destroy objects to which no more references point. If during a program you delete the last reference to an object by overwriting it or using the CLEAR statement, the garbage collector will destroy the object on its next pass.
Note
At the end of a program, when all of the reference variables are freed, the garbage collector will destroy all of the instances to which they had pointed. You do not have to worry about resource management in the program yourself.
How to Create Instances of an ABAP Class
Demo
Start Demo
Instance Management in an Internal Table
One way in which you can keep objects alive is to place the references into an internal table. This is a technique that you may well want to use if you are creating a whole series of objects. It enables you to use a single reference variable to create lots of objects. Although the reference variable is overwritten with the address of the next object, the existing objects are safe because the internal table contains a reference to them. You therefore never delete the "last" reference to the objects.
How To Manage Instances in an Internal Table
Demo
Start Demo
Create and Manage Instances
In this exercise, you create and manage instances of your local class.
Template:
/LRN/CL_S4D400_CLS_LOCAL_CLASS (global Class)
Solution:
/LRN/CL_S4D400_CLS_INSTANCES (global Class)
Task 1: Copy Template (Optional)
Copy the template class. If you finished the previous exercise you can skip this task and continue editing your class ZCL_##_LOCAL_CLASS.
Steps
Open the source code of global class/LRN/CL_S4D400_CLS_LOCAL_CLASS in the ABAP editor.
In the Eclipse toolbar, choose Open ABAP Development Object. Alternatively, press Ctrl + Shift + A.
Enter /LRN/CL_S4D400_CLS as search string.
From the list of development objects choose /LRN/CL_S4D400_CLS_LOCAL_CLASS, then choose OK.
Link the Project Explorer view with the editor.
In the Project Explorer toolbar, find the Link with Editor button. If it is not yet pressed, choose it. As a result, the development object, that is open in the editor, should be highlighted in the Project Explorer.
Copy class /LRN/CL_S4D400_CLS_LOCAL_CLASS to a class in your own package (suggested name: ZCL_##_INSTANCES, where ## stands for your group number).
In the Project Explorer view, right-click class /LRN/CL_S4D400_CLS_LOCAL_CLASS to open the content menu.
From the context menu, choose Duplicate ....
Enter the name of your package in the Package field. In the Name field, enter the name ZCL_##_INSTANCES, where ## stands for your group number.
Adjust the description and choose Next.
Confirm the transport request and choose Finish.
Task 2: Create an Instance
In the main method of your global class, declare a reference variable and create an instance of your local class.
Steps
In method if_oo_adt_classrun~main of your global class, declare a reference variable (suggested name: connection) and type it with your local class lcl_connection.
Switch to the Global Class tab.
Adjust the code as follows:
Code Snippet
Copy code
Switch to dark mode
METHOD if_oo_adt_classrun~main.
DATA connection TYPE REF TO lcl_connection.
ENDMETHOD.
Create an instance of the class and set the attributes carrier_id and connection_id (Suggested values: "LH" for attribute carrier_id and "0400" for attribute connection_id.
Adjust the code as follows:
Code Snippet
Copy code
Switch to dark mode
DATA connection TYPE REF TO lcl_connection.
connection = new #( ).
connection->carrier_id = 'LH'.
connection->connection_id = '0400'.
Hint
After typing the component selector (->), press Strg + Space to choose the attribute names from a suggestion list.
Activate the class and use the debugger to analyze step by step what happens.
Press Ctrl + F3 to activate the class.
Double-click the left-hand margin of the editor next to the line connection = new #( ).to set a break point.
Press F9 to run the class.
Double-click the word connection to display the content of reference variable connection.
Press F5 to go one step further in the debugger. Check that the value of connection has changed.
In the Variablesview, expand the branch connection to display the initial attributes of the class.
Press F5 to go one step further in the debugger. Check that the value of carrier_id has changed.
Press F5 again. Check that the value of Connection_ID has changed.
Task 3: Manage Several Instances
Create more instances of your local class and store the references to these instances in an internal table.
Steps
In method if_oo_adt_classrun~main( ) of your global class, declare an internal table with the line type TYPE REF TO lcl_connection (suggested name: connections).
Adjust the code as follows:
Code Snippet
Copy code
Switch to dark mode
DATA connection TYPE REF TO lcl_connection.
DATA connections TYPE TABLE OF REF TO lcl_connection.
connection = new #( ).
connection->carrier_id = 'LH'.
connection->connection_id = '0400'.
After instantiating the class and setting the attributes, append the object reference to the internal table.
Adjust the code as follows:
Code Snippet
Copy code
Switch to dark mode
connection = NEW #( ).
connection->carrier_id = 'LH'.
connection->connection_id = '0400'.
APPEND connection TO connections.
Create two more instances of class lcl_connection, set their instance attributes to different values than in the first instance and append the references to the new instances to internal table connections. Use the same reference variable connection for all three instances.
Adjust the code as follows:
Code Snippet
Copy code
Switch to dark mode
connection = NEW #( ).
connection->carrier_id = 'LH'.
connection->connection_id = '0400'.
APPEND connection TO connections.
connection = NEW #( ).
connection->carrier_id = 'AA'.
connection->connection_id = '0017'.
APPEND connection TO connections.
connection = NEW #( ).
connection->carrier_id = 'SQ'.
connection->connection_id = '0001'.
APPEND connection TO connections.
Activate the class and use the debugger to analyze step by step what happens.
Press Ctrl + F3 to activate the class.
Double-click the left-hand margin of the editor next to the first line connection = new #( ).to remove the break point.
Double-click the left-hand margin of the editor next to the first line APPEND connection TO connections.to set a new break point.
Press F9 to run the class.
Double-click the word connection to display the content of reference variable connection.
Double-click the word connections to display the content of internal table connections.
Press F5 to go one step further in the debugger. Check that the content of connections has changed.
In the Variables view, expand the branch connections to display content of the internal table.
Press F5 several times until you reach the end of the program. While you do so, check the content of the internal table.
Compare your code on tab Global Class to the following extract from the model solution:
Code Snippet
Copy code
Switch to dark mode
METHOD if_oo_adt_classrun~main.
DATA connection TYPE REF TO lcl_connection.
DATA connections TYPE TABLE OF REF TO lcl_connection.
* First Instance
**********************************************************************
connection = NEW #( ).
connection->carrier_id = 'LH'.
connection->connection_id = '0400'.
APPEND connection TO connections.
* Second Instance
**********************************************************************
connection = NEW #( ).
connection->carrier_id = 'AA'.
connection->connection_id = '0017'.
APPEND connection TO connections.
* Third Instance
**********************************************************************
connection = NEW #( ).
connection->carrier_id = 'SQ'.
connection->connection_id = '0001'.
APPEND connection TO connections.
ENDMETHOD.
Log in to track your progress & complete quizzes
Log in
Register
Was this lesson helpful?
Yes
No
Next lesson
Learning
Quick links
Learning Support
About SAP
Site Information
Creating Instances of a Class
Objective
After completing this lesson, you will be able to create Instances of an ABAP Class.
Instance Creation
You work with attributes like normal variables of the same type. Outside the class, however, the attribute name is not sufficient to identify the attribute unambiguously.
To address a static attribute outside the class, first type the class name, then the static component selector (
=>), and only then the attribute name.The static component selector is a double arrow made up of an equals sign and the greater than sign.
Hint: No blanks are allowed before or after the component selector.
For instance attributes the situation is even more complicated: In order to access an instance component, you need a reference variable.
A reference variable is a special kind of variable that you use to create, address, and manage an object. It is used to point at the instance of a class in the program memory.
You declare reference variables using the DATA statement with the addition
TYPE REF TOfollowed by the name of a class.The initial value of a reference variable is called the NULL reference; the reference does not yet point anywhere.
To create a new instance of a class, you use the NEW operator.
The example above, uses a
NEW #( )expression on the right hand side of a value assignment. The result of the expression is the memory address of the newly created instance. This reference is then stored in the reference variable on the left-hand side of the assignment.The pound sign
#( )after theNEWoperator means "use the type of the variable before the equals sign". (In more advanced scenarios, you can actually specify the name of the class in place of the pound sign, e.g.,NEW lcl_connection( )).Hint: There must be at least one blank between the brackets.
When you address a class for the first time (which could be accessing a static component or creating an instance of the class), the runtime system also loads the class definition into the program memory.
This class definition contains all of the static attributes, which only exist once in the class instead of once for each instance.
You address static components using the class name and the static component selector (
=>).This does not work for instance components because you have to specify the instance you want to access.
To address an instance attribute outside the class, first type the reference variable, then the instance component selector (
->), and only then the attribute name.The instance component selector is an arrow made up of a dash and the greater than sign.
Note: Unlike many other programming languages, ABAP uses different characters for instance component selector and static component selector.
One of the main characteristics of object oriented programming is the fact that you can create multiple instances of the same class. Each instance is created in a different place in the program memory and the values of instance attributes in one instance are independent from the values in other instances. But as the graphic illustrates, instances of the same class share the value for the static attributes.
If you assign one reference variable to another, the system copies the address of the object to which the first variable is pointing into the second reference variable. The result of this is that you have two reference variables that point to the same object.
You can use the same reference variable to create more than one instance of a class. Each time you use the
NEW #( )expression, the system creates a new instance of the class and places the address of the new instance into the reference variable. However, the address of the new instance overwrites the address of the previous instance. In the example above, the address oflcl_connection (2)overwrites the address oflcl_connection (1). Consequently, there is no longer a reference variable in the program pointing tolcl_connection (1). When this happens to an instance, it can no longer be addressed from the program.To prevent the program memory from becoming filled with objects that can no longer be addressed and eventually overflowing, the runtime system has a component called the garbage collector.
The garbage collector is a program that runs periodically to look for and destroy objects to which no more references point. If during a program you delete the last reference to an object by overwriting it or using the
CLEARstatement, the garbage collector will destroy the object on its next pass.Note: At the end of a program, when all of the reference variables are freed, the garbage collector will destroy all of the instances to which they had pointed. You do not have to worry about resource management in the program yourself.
How to Create Instances of an ABAP Class Demo
Start Demo
Instance Management in an Internal Table
One way in which you can keep objects alive is to place the references into an internal table.
This is a technique that you may well want to use if you are creating a whole series of objects. It enables you to use a single reference variable to create lots of objects.
Although the reference variable is overwritten with the address of the next object, the existing objects are safe because the internal table contains a reference to them. You therefore never delete the "last" reference to the objects.
How To Manage Instances in an Internal Table Demo
Start Demo
Create and Manage Instances
In this exercise, you create and manage instances of your local class.
Template:
/LRN/CL_S4D400_CLS_LOCAL_CLASS(global Class)Solution:
/LRN/CL_S4D400_CLS_INSTANCES(global Class)
Task 1: Copy Template (Optional)
Copy the template class. If you finished the previous exercise you can skip this task and continue editing your class
ZCL_##_LOCAL_CLASS.Steps
Open the source code of global class
/LRN/CL_S4D400_CLS_LOCAL_CLASSin the ABAP editor. In the Eclipse toolbar, chooseOpen ABAP Development Object. Alternatively, pressCtrl + Shift + A.Enter
/LRN/CL_S4D400_CLSas search string. From the list of development objects choose/LRN/CL_S4D400_CLS_LOCAL_CLASS, then chooseOK.Link the Project Explorer view with the editor. In the Project Explorer toolbar, find the
Link with Editorbutton. If it is not yet pressed, choose it. As a result, the development object, that is open in the editor, should be highlighted in the Project Explorer.Copy class
/LRN/CL_S4D400_CLS_LOCAL_CLASSto a class in your own package (suggested name:ZCL_##_INSTANCES, where##stands for your group number). In the Project Explorer view, right-click class/LRN/CL_S4D400_CLS_LOCAL_CLASSto open the content menu. From the context menu, chooseDuplicate ....Enter the name of your package in the
Packagefield. In theNamefield, enter the nameZCL_##_INSTANCES, where##stands for your group number. Adjust the description and chooseNext.Confirm the transport request and choose
Finish.
Task 2: Create an Instance
In the main method of your global class, declare a reference variable and create an instance of your local class
lcl_connection.Steps
In method
if_oo_adt_classrun~mainof your global class, declare a reference variable (suggested name:connection) and type it with your local classlcl_connection. Switch to the Global Class tab. Adjust the code as follows:ABAP METHOD if_oo_adt_classrun~main. DATA connection TYPE REF TO lcl_connection. ENDMETHOD.Create an instance of the class and set the attributes
carrier_idandconnection_id. (Suggested values: "LH" for attributecarrier_idand "0400" for attributeconnection_id). Adjust the code as follows:ABAP DATA connection TYPE REF TO lcl_connection. connection = NEW #( ). connection->carrier_id = 'LH'. connection->connection_id = '0400'.
Hint: After typing the component selector (
->), pressStrg + Spaceto choose the attribute names from a suggestion list.
Activate the class (
Ctrl + F3) and use the debugger to analyze step by step what happens.
Double-click the left-hand margin of the editor next to the line
connection = NEW #( ). to set a break point.Press
F9to run the class.Double-click the word
connectionto display the content of reference variableconnection. Note how its value changes fromNULLto a memory address after instance creation.Press
F5to go one step further in the debugger. Check that the value ofconnectionhas changed.In the Variables view, expand the branch
connectionto display the initial attributes of the class.Press
F5to go one step further in the debugger. Check that the value ofcarrier_idhas changed.Press
F5again. Check that the value ofconnection_idhas changed.
Task 3: Manage Several Instances
Create more instances of your local class and store the references to these instances in an internal table.
Steps
In method
if_oo_adt_classrun~main( )of your global class, declare an internal table with the line typeTYPE TABLE OF REF TO lcl_connection(suggested name:connections). Adjust the code as follows:ABAP DATA connection TYPE REF TO lcl_connection. DATA connections TYPE TABLE OF REF TO lcl_connection. connection = NEW #( ). connection->carrier_id = 'LH'. connection->connection_id = '0400'.After instantiating the class and setting the attributes, append the object reference to the internal table. Adjust the code as follows:
ABAP connection = NEW #( ). connection->carrier_id = 'LH'. connection->connection_id = '0400'. APPEND connection TO connections.Create two more instances of class
lcl_connection, set their instance attributes to different values than in the first instance and append the references to the new instances to internal tableconnections. Use the same reference variableconnectionfor all three instances. Adjust the code as follows:ABAP connection = NEW #( ). connection->carrier_id = 'LH'. connection->connection_id = '0400'. APPEND connection TO connections. connection = NEW #( ). connection->carrier_id = 'AA'. connection->connection_id = '0017'. APPEND connection TO connections. connection = NEW #( ). connection->carrier_id = 'SQ'. connection->connection_id = '0001'. APPEND connection TO connections.Activate the class (
Ctrl + F3) and use the debugger to analyze step by step what happens.
Double-click the left-hand margin of the editor next to the first line
connection = NEW #( ). to remove the break point.Double-click the left-hand margin of the editor next to the first line
APPEND connection TO connections. to set a new break point.Press
F9to run the class.Double-click the word
connectionto display the content of reference variableconnection.Double-click the word
connectionsto display the content of internal tableconnections.Press
F5to go one step further in the debugger. Check that the content ofconnectionshas changed. In the Variables view, expand the branchconnectionsto display content of the internal table. Note how new entries are added and the references point to distinct objects.Press
F5several times until you reach the end of the program. While you do so, check the content of the internal table, observing the distinct instances.
Compare your code on tab Global Class to the following extract from the model solution: ```ABAP METHOD ifooadtclassrun~main. DATA connection TYPE REF TO lclconnection. DATA connections TYPE TABLE OF REF TO lcl_connection.
First Instance ****
connection = NEW #( ).
connection->carrierid = 'LH'. connection->connectionid = '0400'.
APPEND connection TO connections.Second Instance ***
connection = NEW #( ).
connection->carrierid = 'AA'. connection->connectionid = '0017'.
APPEND connection TO connections.
*
Here are 30 keywords extracted from the notes, along with their definitions and use cases:
ABAP Class
Definition: A blueprint that defines the structure and behavior of objects, comprising attributes and methods.
Use Cases: Central to object-oriented programming in ABAP; used to encapsulate data and operations, for example,
lcl_connection.
Instance (Object)
Definition: A concrete realization of a class, existing in program memory with its own set of instance attributes.
Use Cases: To create multiple independent data structures based on a single class definition, each object managing its own unique data, such as
lcl_connection (1)orlcl_connection (2).
Static Attribute
Definition: An attribute that belongs to the class itself, not to any specific instance. It exists only once for the entire class.
Use Cases: Storing data that is shared across all instances of a class or for class-level configuration parameters. Accessed using the static component selector (
=>).
Instance Attribute
Definition: An attribute that belongs to a specific instance (object) of a class. Each object maintains its own unique value for these attributes.
Use Cases: Storing data unique to each object created from a class, such as
carrier_idandconnection_idfor individual connection objects.
Reference Variable
Definition: A special type of variable that stores the memory address of an object, allowing the program to point to and interact with an instance of a class.
Use Cases: To create, address, and manage objects in ABAP. Declared using
DATA connection TYPE REF TO lcl_connection.
NULL Reference
Definition: The initial state of a reference variable, indicating that it does not currently point to any object in memory.
Use Cases: Represents an unassigned or empty reference, useful for initializations or checking if an object has been assigned to a reference variable.
NEW Operator
Definition: An ABAP operator used to dynamically create a new instance of a class in the program memory.
Use Cases: To instantiate a class, for example,
connection = NEW #( ), which allocates memory for a new object and makes its address available.
Static Component Selector (
=>)Definition: The operator used in ABAP to access static components (attributes or methods) of a class directly, without requiring an instance.
Use Cases:
ClassName=>StaticAttributeNameto uniquely identify and access static attributes from outside the class definition.
Instance Component Selector (
->)Definition: The operator used in ABAP to access instance components (attributes or methods) of an object via its reference variable.
Use Cases:
ReferenceVariable->InstanceAttributeNameto access attributes belonging to a specific object, such asconnection->carrier_id.
DATA Statement
Definition: A fundamental ABAP statement used to declare variables, including reference variables.
Use Cases:
DATA connection TYPE REF TO lcl_connectionto declare a variableconnectionthat can store a reference to an object of typelcl_connection.
TYPE REF TO
Definition: An addition to the
DATAstatement that specifies the type of a variable as a reference to a class.Use Cases: Used to define the type of a reference variable (
DATA connection TYPE REF TO lcl_connection), indicating it will hold references to instances oflcl_connection.
NEW #( ) Expression
Definition: A shorthand syntax for the
NEWoperator where#( )signifies that the system should derive the class type to be instantiated from the type of the reference variable on the left side of the assignment.Use Cases:
connection = NEW #( )provides a concise way to create an instance when the target reference variable's type clearly indicates the class to be instantiated.
Class Definition (in memory)
Definition: The detailed blueprint of a class, including all its attributes and methods, loaded into program memory by the runtime system.
Use Cases: Loaded automatically when a class is first accessed (e.g., when creating its first instance or accessing a static component), making the class structure available during execution.
Program Memory
Definition: The designated area within a computer's memory where an executing program and its associated data, including created objects, reside.
Use Cases: This is where instances of classes are physically created and managed; the garbage collector operates within this space to manage unreferenced objects.
Garbage Collector
Definition: A component of the ABAP runtime system that automatically reclaims memory by destroying objects to which no active reference variables point.
Use Cases: Prevents memory leaks and overflows by ensuring that unaddressable objects are automatically removed, simplifying resource management for developers.
Internal Table
Definition: A dynamic data structure in ABAP that can store multiple lines of data, often used to manage collections of records or object references.
Use Cases: To retain references to multiple objects, thereby keeping them alive and accessible even if the original reference variable used to create them is overwritten, e.g.,
DATA connections TYPE TABLE OF REF TO lcl_connection.
APPEND Statement
Definition: An ABAP statement used to add an item (a data line or an object reference) to the end of an internal table.
Use Cases:
APPEND connection TO connectionsis used to store the memory address of a newly created object in an internal table, thus maintaining a reference to it.
CLEAR Statement
Definition: An ABAP statement used to reset variables to their initial values. For reference variables, it sets the reference to
NULL.Use Cases: To explicitly nullify a reference variable, making the object it pointed to eligible for garbage collection if it was the last existing reference.
Debugger
Definition: An interactive tool used to analyze the execution of an ABAP program step by step, inspect variable values, and diagnose errors.
Use Cases: Used to observe the state of reference variables and internal tables before and after instance creation, and to understand the flow of data and object lifecycle.
Breakpoint
Definition: A marker placed in the source code that, when encountered during program execution in the debugger, pauses the program at that specific line.
Use Cases: To temporarily halt program execution at a point of interest (e.g.,
connection = NEW #( )) to examine the values of variables likeconnectionandconnections.
Eclipse Toolbar
Definition: The set of icons and menus located at the top of the Eclipse IDE, providing quick access to common functionalities.
Use Cases: Contains options such as
Open ABAP Development Objectfor navigating and opening ABAP code artifacts.
Project Explorer View
Definition: A hierarchical view in the Eclipse IDE that displays all development objects (e.g., packages, classes, programs) within the current ABAP project.
Use Cases: Navigating through existing classes, selecting objects for editing, and performing actions like
Duplicateon development objects.
Ctrl + Shift + ADefinition: A keyboard shortcut in Eclipse ADT (ABAP Development Tools) to open the
Open ABAP Development Objectdialog.Use Cases: Provides a quick way to find and open any ABAP development object by typing its name in a search field.
Duplicate(Context Menu Option)Definition: A command available when right-clicking a development object (e.g., a class) in the Project Explorer, allowing creation of an exact copy.
Use Cases: Used to copy template classes, such as
/LRN/CL_S4D400_CLS_LOCAL_CLASS, into a user's own development package for modification through exercise tasks.
if_oo_adt_classrun~mainMethodDefinition: A standard interface method often implemented in global classes within Eclipse ADT, serving as the main entry point for executing program logic.
Use Cases: This method is where test code is typically written to declare reference variables, create instances, and manage object collections (e.g., within an internal table).
Ctrl + F3Definition: A keyboard shortcut in the ABAP editor within Eclipse ADT to activate a class or other development object.
Use Cases: Compiles and saves changes to a class, making it executable and ensuring syntax consistency before running or debugging.
F9(Run in Debugger)Definition: A keyboard shortcut in Eclipse ADT to start program execution in debug mode, running until a breakpoint is hit or the program finishes.
Use Cases: Initiating a debugging session to begin executing the ABAP code and observing its behavior.
F5(Step in Debugger)Definition: A keyboard shortcut in the Eclipse ADT debugger that executes the current line of code and then pauses execution at the next executable line.
Use Cases: Allows for line-by-line analysis of program flow, crucial for understanding how variables (like
connection) change during processing.
Variables View
Definition: A dedicated window within the Eclipse ADT debugger that displays the current values of all accessible variables at the point of a breakpoint or during stepping.
Use Cases: Essential for inspecting the content of reference variables, expanding branches to see object attributes, and checking the contents of internal tables (
connections) during debugging.
Strg + Space(Content Assist)Definition: A keyboard shortcut in the ABAP editor to invoke content assist (code completion), suggesting relevant code elements based on the current context.
Use Cases: Used after typing a component selector (
->or=>) to quickly select attribute or method names from a suggestion list, improving coding speed and accuracy.