0% found this document useful (0 votes)
35 views116 pages

Legacy Resource

Uploaded by

lanyosanunez
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)
35 views116 pages

Legacy Resource

Uploaded by

lanyosanunez
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/ 116

Basic ABAP

Student Guide

Rev. 11.31
HP Restricted
Basic ABAP

Student Guide

Rev. 11.31
Use of this material to deliver training without
HP Restricted prior written permission from HP is prohibited.
Copyright 2011 Hewlett-Packard Development Company, L.P.
The information contained herein is subject to change without notice. The only warranties for HP
products and services are set forth in the express warranty statements accompanying such products
and services. Nothing herein should be construed as constituting an additional warranty. HP shall
not be liable for technical or editorial errors or omissions contained herein.
This is an HP copyrighted work that may not be reproduced without the written permission of HP.
You may not use these materials to deliver training to any person outside of your organization
without the written permission of HP.
Printed in the US
Basic ABAP
Student guide
July 2011
HP Restricted — Contact HP Education for customer training materials.
ABAP Basics

HP Restricted 1 Rev. 11.31


ABAP Basics

HP Restricted 2 Rev. 11.31


ABAP Basics

HP Restricted 3 Rev. 11.31


ABAP Basics

HP Restricted 4 Rev. 11.31


ABAP Basics

HP Restricted 5 Rev. 11.31


ABAP Basics

HP Restricted 6 Rev. 11.31


ABAP Basics

HP Restricted 7 Rev. 11.31


ABAP Basics

Database Layer
The database layer, which is accessed by SAP Application Server, consists of a central database
system which in turn is made up of the database management system (DBMS) and the database itself.
The database not only contains the master data and transaction data from your ABAP application
programs, but also contains the programs and metadata that the SAP system requires for self-
management.

Application Layer
The software components of the Application Layer consist of one or more ABAP application servers and
a Message Server. Each application server contains a set of services used to run the SAP System.
Theoretically, you only need one application server to run an SAP System. In practice, the services are
distributed across more than one application server. This means that not all application servers will
provide the full range of services. The message server is responsible for communication between the
application servers. It passes requests from one application server to another within an SAP System. It
also contains information about application server groups and the current load balancing within them. It
uses this information to choose an appropriate server when a user logs onto the system.

Presentation Layer
The presentation layer is the interface between the SAP System and its users. Using its software
components referred to as SAP GUI (Graphical User Interface) this layer provides an intuitive graphical
interface for entering and displaying data. The presentation layer sends the user‟s input to the
application server, and receives data for display from it. While an SAP GUI component is running, it
remains linked to a user‟s terminal session in the SAP System.

HP Restricted 8 Rev. 11.31


ABAP Basics

Work Process
Work Processes are components that are able to execute an application (that is, one dialog step* each). Each
work process is linked to a memory area containing the context of the application being run. The context
contains the current data for the application program. This needs to be available in each dialog step.

Dispatcher
The Dispatcher is the link between the work processes and the users logged onto the SAP application server
(that is, the SAP GUIs of these users). Its task is to receive requests for dialog steps from the SAP GUI and
direct them to a free work process. In the same way, it directs screen output resulting from the dialog step back
to the appropriate user.

Gateway
This is the interface for the communication protocols of SAP System (RFC, CPI/C). It can communicate with
other SAP application servers of the same SAP system, with other SAP systems, or with external non-SAP
systems.

Shared Memory
All of the work processes on an SAP application server use a common main memory area called Shared
Memory to save contexts or to buffer constant data locally.

The resources that all work processes use (such as programs and table contents) are contained in shared
memory. Memory management in the SAP application server ensures that the work processes always address
the correct context, which is the data relevant to the current state of the program that is running. A mapping
process projects the required context for a dialog step from shared memory into the address of the relevant
work process. This reduces the actual copying to a minimum.

*A Dialog Step is the processing needed to get from one screen to the next. It includes all processing that
occurs after the user issues a request, up to and including the processing needed to display the next screen.

HP Restricted 9 Rev. 11.31


ABAP Basics

Whenever a user logs on to the system, a screen (SAP Menu, or User Menu …) is displayed. From this
screen, the user can start an ABAP program through the menu path.

The sample program has a selection screen as the user dialog, a variable and a structure as data
objects, and one ABAP processing block. The list used to display the data is created dynamically at
runtime.

1. The system first loads the program context onto the application server. The program context
contains memory areas for variables and complex data objects, information on the screens for
user dialogs, and ABAP processing blocks. The runtime system gets all this program information
from the Repository, which is a special part of the database.
2. Since the program contains a selection screen, the ABAP runtime system sends it to the
presentation server. The presentation server controls the program flow for as long as the user has
not finished entering data in the input fields.
3. Selection screens allow users to enter selection criteria required by the program for it to continue.
As soon as the user has finished entering data on the selection screen, they can trigger further
processing of the program by choosing Execute. The entered data is automatically placed in its
corresponding data objects in the program and the ABAP runtime system resumes control of
processing. In our simple program example there is only one ABAP processing block. The ABAP
runtime system triggers sequential processing of this ABAP processing block.
4. The program sends data retrieving request to the database, information about the database table
to be accessed and the row in the table to be read is passed on to the database.
5. The database returns the requested data record to the program and the runtime system ensures
that this data is placed in the appropriate data objects.
6. After the data retrieval, the ABAP processing block receives statements for structuring the list with
which the result is to be displayed. After the processing block finishes, the runtime system sends
the list as a screen to the presentation server.

HP Restricted 10 Rev. 11.31


ABAP Basics

HP Restricted 11 Rev. 11.31


ABAP Basics

HP Restricted 12 Rev. 11.31


ABAP Basics

HP Restricted 13 Rev. 11.31


ABAP Basics

HP Restricted 14 Rev. 11.31


ABAP Basics

• ABAP Workbench is the integrated development environment for ABAP development. All the basic
ABAP objects, mime objects, transport requests can be found, displayed, and changed in this
workbench.

• Input “se80” in T-code box and press Enter.

• Menu provides all the basic functionalities for the user to control the logon session, it varies
according to the development object currently displayed in the Object Content Area.

• The buttons within Tool Area include all the most-used and basic functionalities that are related
closely to the development object currently displayed in the Object Content Area, such as
display/edit switch, syntax check button, breakpoint quickset and so on.

• In the navigation area, a hierarchy of all the repositories enables you to search and find the
objects you need.

• Object Content Area displays the detailed information of the current object, not only source code,
but also the details of DDIC objects, classes.

HP Restricted 15 Rev. 11.31


ABAP Basics

HP Restricted 16 Rev. 11.31


ABAP Basics

In this navigation area, you can directly select the object type and input the object name to navigate to
it. It is also supported to search the object by its name with a fuzzy pattern like “*SAP*”.

HP Restricted 17 Rev. 11.31


ABAP Basics

HP Restricted 18 Rev. 11.31


ABAP Basics

HP Restricted 19 Rev. 11.31


ABAP Basics

HP Restricted 20 Rev. 11.31


ABAP Basics

HP Restricted 21 Rev. 11.31


ABAP Basics

F1 Help is a very useful tool when using ABAP workbench, it provides information that covers all the
topics related to ABAP development. Complete help documents in various areas are available for
reference.

For example:
If you are not quite clear about the syntax of keyword “Parameters,” Search it in F1 Help and the help
document contains all the information about the syntax and how to use it with a simple example code
piece.

There are two ways of opening F1 help:


 Press the highlighted blue button, input the keywords you are looking for and press Enter.
 Put your cursor on the screen field or the keywords in the ABAP editor and press F1, the help tool
will automatically navigate to the help document.

HP Restricted 22 Rev. 11.31


ABAP Basics

HP Restricted 23 Rev. 11.31


ABAP Basics

HP Restricted 24 Rev. 11.31


ABAP Basics

HP Restricted 25 Rev. 11.31


ABAP Basics

HP Restricted 26 Rev. 11.31


ABAP Basics

When developing business application software, real world must be concretely represented by data
models. A data model is always originated from the units in the real world, each business unit in data
models corresponds to an entity or a concept in human society.

With real world being abstracted as data models, an ABAP dictionary is formed by these data models
and the units within the models. Simply put, ABAP dictionary is a repository that provides all the data
types used in ABAP programs.

Based on the database tables and the connections among them in the ABAP dictionary, a relational
database that carries business meanings is automatically generated.

HP Restricted 27 Rev. 11.31


ABAP Basics

Other Options:
(Note: please refer to advanced topics of SAP Data Dictionary for further details.)
• Create documentation: With Documentation, create a text that describes the contents of the data
element. This text is displayed for the F1 help in all screen fields that refer to this data element. You
should therefore only leave out this step if the data element does not appear on a screen.
• Assign a search help: You can assign the data element a search help. This search help is offered
on all the screen fields referring to this data element when the input help (F4 help) is called. To
assign the search help, you must specify its Name in the data element maintenance screen and an
export parameter of the search help in the Parameter field.
• Assign a parameter ID: A field can be filled with default values from SAP memory using a
parameter ID. A screen field is only filled automatically with the value stored under the parameter
ID of the data element if this was explicitly permitted in the Screen Painter.
• Assign a default component name: You can store a proposal for the name of the table fields or
structure components that refer to a data element. If possible, use an English language default
name. Always use this default name for components in BAPI structures (structures with a fixed
interface). This results in a more unified assignment of field and component names.
• Mark data element as relevant for change documents: The data of a business-oriented object is
often distributed on several tables. To be able to trace changes to this business object, these tables
can be combined in a Change document object. Function modules that can be integrated in the
corresponding application programs and that log the changes are generated from such a change
document object. Changed field contents are only logged if the Change document flag is set for
the data element of the field.

HP Restricted 28 Rev. 11.31


ABAP Basics

Other Options:
(Note: please refer to advanced topics of SAP Data Dictionary for further details.)
• Create documentation: You can create technical documentation about the domain with Goto ->
Documentation.
• Restrict output length: The value for the output length (maximum field length including editing
characters such as comma and period) is automatically computed from the definitions for the data
type, number of places and number of decimal places. If fields that refer to this domain should be
output on the screen or in lists with only a certain length, you can reduce this size.
• Distinguish uppercase/lowercase: If you want to distinguish uppercase and lowercase for the fields
referring to this domain, you have to select Lowercase. Otherwise, all the entered letters are
converted to uppercase in the database. Entries can only be made for this field in data types
CHAR and LCHR.
• Assign conversion routine: If field values have to be converted during input or output, you can
define a conversion routine.
• Output with sign: If fields that refer to this domain can contain negative values, the Sign flag must
be set. When the field contents are output to the screen, the first output location is reserved for a
sign. If the flag is not set but the field contains negative values, problems could occur when
outputting to the screen. Entries can only be made in this field for data types DEC, FLTP, QUAN
and CURR.

HP Restricted 29 Rev. 11.31


ABAP Basics

HP Restricted 30 Rev. 11.31


ABAP Basics

HP Restricted 31 Rev. 11.31


ABAP Basics

Pooled and Cluster Tables


In addition to transparent tables, where the definition in the ABAP Dictionary and in the database are
identical, there are Pooled and Cluster tables in the R/3 system. Pooled and cluster tables are
characterized by the fact that several tables logically defined in the ABAP Dictionary are combined in a
physical database table (table pool or cluster). For details of the pooled and cluster tables, please refer
to “Pooled and Cluster Tables” at online SAP library at the following link:
-
http://help.sap.com/saphelp_nw70/helpdata/en/cf/21f083446011d189700000e8322d00/conte
nt.htm

HP Restricted 32 Rev. 11.31


ABAP Basics

In Flight Model, travel agency must design a database table to store all the airline information. Above
this table, a Graphic User Interface must be developed for their customers to check and find the airlines.

The table at the bottom shows the design of table SCARR, which stores airline information of a travel
agency. The combination of airline code, name, local currency and URL gives the basic information of
an airline. Airline code is the unique key of an airline, so it‟s the key field of table SCARR, while the
other 3 fields are defined as non-key fields.

To define the 4 fields mentioned above, 4 corresponding data elements are needed as their types. For
example, airline code is a 3-digit character string, a data element, with type = CHAR and length = 3,
should be defined as its type, this is why data element S_CARRID and domain S_CARRID are created
(data element S_CARRID uses domain S_CARRID as its elementary type).

In order to manipulate the airline data on a graphic user interface, a variable that contains information
of multiple airlines is needed in the implementation of the user interface. A table type, with table SCARR
being its line type, is required to serve as the data type of this variable. Here, table SCARR is reused
as a structure.

HP Restricted 33 Rev. 11.31


ABAP Basics

• Execute transaction code “SE11.”


• Select radio button “Domain,” and enter the name of your domain. (Please note that all objects
should be in customer namespace and thus their names should start with “Z” or “Y.”)
• Press “Create” button.
• Enter a short description of the domain.
• At “Definition” tab, select a “data type” from its value help (F4 help), enter the length of it. If the
value of this domain is case-sensitive, you should check the “Lower Case” checkbox.
• At “Value Range” tab, if the domain has fixed values, specify these values and their description
here.
• Press “Save” button to save the new domain as local object.
• Press “Check” toolbar button to validate the syntax and sanity of the new domain.
• Press “Activate” toolbar button to activate the new domain (Inactive objects cannot be used in
design time or runtime).

HP Restricted 34 Rev. 11.31


ABAP Basics

• Execute transaction code “SE11.”


• Select radio button “Data type” and then enter the name of your data element.
• In the prompt dialog, select “Data element” and press OK button.
• Enter a short description of the data element.
• At “Data Type” tab, put domain in “Domain” editbox or some predefined type in the “Predefined
Type” area as its technical definition.
• At “Field Label” tab, specify some field labels under different lengths.
• Press “Save” button to save the new data element as local object.
• Press “Check” toolbar button to validate the syntax and sanity of the new data element.
• Press “Activate” toolbar button to activate the new data element (Inactive objects cannot be used in
design time or runtime).

HP Restricted 35 Rev. 11.31


ABAP Basics

• Execute transaction code “SE11.”


• Select radio button “Data type” and then enter the name of your structure.
• In the prompt dialog, select “Structure” and press OK button.
• Enter a short description of the structure.
• At “Components” tab, specify the name and type of the components for your structure. If you need
to use predefined types (such as string, xstring) as the type of your component, press button
“Predefined Type” and put your type in column “Data Type.”
• Press “Save” button to save the new structure as local object.
• (Optional) Select menu item Extra -> Enhancement Category, and then specify enhancement
category for the structure, e.g. “Cannot Be Enhanced.”
• Press “Check” toolbar button to validate the syntax and sanity of the new structure
• Press “Activate” toolbar button to activate the new structure (Inactive objects cannot be used in
design time or runtime).

HP Restricted 36 Rev. 11.31


ABAP Basics

• Execute transaction code “SE11.”


• Select radio button “Data type” and then enter the name of your table type
• In the prompt dialog, select “Table type” and press “OK” button.
• Enter a short description of the table type.
• At “Line Type” tab, put a data element or structure in “Line Type” editbox of your table type, or
some predefined type in the “Predefined Type” area, or some reference type in the “Reference
Type” area.
• Press “Save” button to save the new table type as local object.
• Press “Check” toolbar button to validate the syntax and sanity of the new table type.
• Press “Activate” toolbar button to activate the new table type (Inactive objects cannot be used in
design time or runtime).

HP Restricted 37 Rev. 11.31


ABAP Basics

• Execute transaction code “SE11.”


• Select radio button “Database table” and then enter the name of your transparent table.

HP Restricted 38 Rev. 11.31


ABAP Basics

• Enter a short description of the table type.


• At “Delivery Maintenance” tab, specify Delivery Class and Data Browser/Table View Maint. Using
F4 help.

Delivery Class: The delivery class controls the transport of table data for installation, upgrade, client
copy and when transporting between customer systems. The delivery class is also used in the extended
table maintenance. The most used delivery classes are A (Application Table), C (Customizing Table)
and S (System Table). This course will only involve A and C. Application tables store data which is
dependent on different applications, so normally an application table should contain a component with
type MANDT (client number) as applications may be located in different clients of the system. System
tables store data that are used within the whole system by different applications in the same way, so
“client” field is not needed in a system table.

“Data Browser/Table View Maint.” means how the table contents are displayed and whether they are
editable.
 “Not Allowed” means the table contents cannot be directly seen in ABAP workbench.
 “Allowed with Restrictions” means the table contents can be displayed in ABAP workbench but are
not editable
 “Allowed” means the table contents can be both displayed and edited directly in ABAP
workbench.

HP Restricted 39 Rev. 11.31


ABAP Basics

• At the “Fields” tab, specify the fields of your table and mark the key fields, using the client number
as the unique key of each table entry. The “Initialization” checkbox indicates whether the value of
this field is automatically given. For example, for the “CLIENT” field, this checkbox should be
checked; then, every time an entry is inserted into the table, the client value will automatically be
set as the current client number.
• (Optional) Select menu item Extra -> Enhancement Category, and then specify enhancement
category for the table, e.g. “Cannot Be Enhanced.”
• Press “Save” button to save the new table as local object.

HP Restricted 40 Rev. 11.31


ABAP Basics

• Press toolbar button “Technical Settings” to maintain technical settings.


• Specify data class, size category, and buffering setting.
• Click “Save” button to save the technical setting of the table, then click “Back” button to navigate
back to table maintenance screen.

The technical settings of a table define how the table will be handled when it is created in the
database, that is whether the table will be buffered and whether changes to data records of the table
will be logged.
 Data class: The data class defines the physical area of the database (tablespace) in which the
table should be created.
 Size category: The size category defines the size of the extents created for the table.
 Buffering status: The buffering status defines whether the table may be buffered.
 Buffering type: If the table may be buffered, you must define a buffering type (full, single-record,
generic). The buffering type defines how many table records are loaded into the buffer when a
table entry is accessed.
 Logging: This parameter defines whether changes to the table entries should be logged. If logging
is switched on, each change to a table record is recorded in a log table.

HP Restricted 41 Rev. 11.31


ABAP Basics

• Press “Check” toolbar button to validate the syntax and sanity of the new table.
• Press “Activate” toolbar button to activate the new table (Inactive objects cannot be used in design
time or runtime).

HP Restricted 42 Rev. 11.31


ABAP Basics

HP Restricted 43 Rev. 11.31


ABAP Basics

HP Restricted 44 Rev. 11.31


ABAP Basics

HP Restricted 45 Rev. 11.31


ABAP Basics

HP Restricted 46 Rev. 11.31


ABAP Basics

HP Restricted 47 Rev. 11.31


ABAP Basics

HP Restricted 48 Rev. 11.31


ABAP Basics

HP Restricted 49 Rev. 11.31


ABAP Basics

HP Restricted 50 Rev. 11.31


ABAP Basics

HP Restricted 51 Rev. 11.31


ABAP Basics

HP Restricted 52 Rev. 11.31


ABAP Basics

HP Restricted 53 Rev. 11.31


ABAP Basics

HP Restricted 54 Rev. 11.31


ABAP Basics

HP Restricted 55 Rev. 11.31


ABAP Basics

HP Restricted 56 Rev. 11.31


ABAP Basics

HP Restricted 57 Rev. 11.31


ABAP Basics

HP Restricted 58 Rev. 11.31


ABAP Basics

HP Restricted 59 Rev. 11.31


ABAP Basics

• Transaction Code “se38”


• Enter the program name in editbox “Program”
• Press “Create” button

HP Restricted 60 Rev. 11.31


ABAP Basics

• Enter a title for the program in the prompt dialog


• Select “Executable program” for “Type”
• Press “Save” button

HP Restricted 61 Rev. 11.31


ABAP Basics

• The next prompt dialog is asking where to put the program, just press “Local Object” button to
store it as a local object.

HP Restricted 62 Rev. 11.31


ABAP Basics

• The ABAP editor is now shown, line “REPORT ZHPVL_PROGRAM1” is automatically generated as
the declaration statement of the program as the very beginning, as well as some commented
description lines above.
If you see ABAP Editor with a different look here, it‟s probably because the old ABAP editor is
being used. Apply the following steps to change it to the new ABAP editor:
1. Click “Utilities” in the top menu of your SAPGUI
2. Select “Settings”
3. Navigate to “ABAP Editor” tab
4. Navigate to “Editor” tab
5. Choose “Front-End Editor (New)”
6. Press “OK” button

HP Restricted 63 Rev. 11.31


ABAP Basics

• Enter your code after report declaration statement (ABAP Code is not case sensitive).
• Click syntax check button to check if there is any syntax error.
• Click “Save” button.
• Click “Activate” button to activate your program. (A program cannot be executed before its status
is active.

HP Restricted 64 Rev. 11.31


ABAP Basics

There are usually two channels to execute your program in ABAP workbench:
• Execute it directly in the ABAP editor, either with the execute button (highlighted one) or press “F8”
• Execute it from transaction code “se38”, either with the execute button (highlighted one) or press
“F8”

HP Restricted 65 Rev. 11.31


ABAP Basics

HP Restricted 66 Rev. 11.31


ABAP Basics

HP Restricted 67 Rev. 11.31


ABAP Basics

HP Restricted 68 Rev. 11.31


ABAP Basics

HP Restricted 69 Rev. 11.31


ABAP Basics

If an internal table is defined on a DDIC table type, the table type stores the 3 properties settings of
this internal table.

HP Restricted 70 Rev. 11.31


ABAP Basics

When declaring a standard table, keyword “standard” is optional.

HP Restricted 71 Rev. 11.31


ABAP Basics

HP Restricted 72 Rev. 11.31


ABAP Basics

• APPEND
Appends the contents of a structure to an internal table. This operation can only be used
with standard tables.
• INSERT
Inserts the content of a structure into an internal table. In the case of a standard table,
this content is appended, in a sorted table it is inserted in the right place according to
the key, and in a hashed table it is inserted according to the hash algorithm.
• READ
Copies the content of a table row to a structure.
• MODIFY
Overwrites an internal table row with the contents of a structure.
• DELETE
Deletes a row of an internal table.

HP Restricted 73 Rev. 11.31


ABAP Basics

LOOP AT. . . ENDLOOP


The LOOP places the rows of an internal table one by one into the structure specified in
the INTO clause. Within the LOOP, the current content of the structure can be output or
changed and written back to the table.
INSERT
Copies the contents of several rows of an internal table to another internal table.
APPEND
Appends the contents of several rows of an internal table to another standard table.
DELETE
Deletes the rows of the internal table that satisfy the condition <condition>.

HP Restricted 74 Rev. 11.31


ABAP Basics

HP Restricted 75 Rev. 11.31


ABAP Basics

HP Restricted 76 Rev. 11.31


ABAP Basics

HP Restricted 77 Rev. 11.31


ABAP Basics

HP Restricted 78 Rev. 11.31


ABAP Basics

HP Restricted 79 Rev. 11.31


ABAP Basics

HP Restricted 80 Rev. 11.31


ABAP Basics

HP Restricted 81 Rev. 11.31


ABAP Basics

HP Restricted 82 Rev. 11.31


ABAP Basics

HP Restricted 83 Rev. 11.31


ABAP Basics

HP Restricted 84 Rev. 11.31


ABAP Basics

HP Restricted 85 Rev. 11.31


ABAP Basics

HP Restricted 86 Rev. 11.31


ABAP Basics

HP Restricted 87 Rev. 11.31


ABAP Basics

HP Restricted 88 Rev. 11.31


ABAP Basics

HP Restricted 89 Rev. 11.31


ABAP Basics

HP Restricted 90 Rev. 11.31


ABAP Basics

HP Restricted 91 Rev. 11.31


ABAP Basics

HP Restricted 92 Rev. 11.31


ABAP Basics

HP Restricted 93 Rev. 11.31


ABAP Basics

HP Restricted 94 Rev. 11.31


ABAP Basics

HP Restricted 95 Rev. 11.31


ABAP Basics

HP Restricted 96 Rev. 11.31


ABAP Basics

HP Restricted 97 Rev. 11.31


ABAP Basics

HP Restricted 98 Rev. 11.31


ABAP Basics

HP Restricted 99 Rev. 11.31


ABAP Basics

HP Restricted 100 Rev. 11.31


ABAP Basics

HP Restricted 101 Rev. 11.31


ABAP Basics

HP Restricted 102 Rev. 11.31


ABAP Basics

Before developing a function module, you must have a function group that wraps the function module.
• Transaction Code “se80” to navigate to ABAP Workbench
• Select “Function Group” in the drop-down list
• Enter the name of your function group in the editbox below, and press Enter
• A prompt dialog will show up, click “Yes”
• Enter a short text for the function group in the next prompt dialog and press “Save”
• In the next prompt dialog, press “Local Object” to save the function group as a local object

HP Restricted 103 Rev. 11.31


ABAP Basics

• Transaction Code “se37”


• Enter the name of your function module in the editbox and press “Create”
• A prompt dialog will show up, enter the function group name that you want to wrap this function
module and a short text, press “Save,” function builder will show up

HP Restricted 104 Rev. 11.31


ABAP Basics

•In Function Builder, specify your importing parameters under tab “Import”
•Parameter name is the name of the parameter
•Typing is how the type is used for the parameter (type, type ref to)
•Associated Type is the type of the parameter, it could be a global DDIC type or a standard ABAP type
•Check “Optional” checkbox if you want to set any parameter to be an optional one

HP Restricted 105 Rev. 11.31


ABAP Basics

•In Function Builder, specify your exporting and changing parameters under the “Export” and
“Changing” tabs respectively
•“Tables” is obsolete for function module, so it is not introduced here

HP Restricted 106 Rev. 11.31


ABAP Basics

•In Function Builder, specify your exceptions under the tab “Exceptions”
•Put all the possible exceptions that could occur during the runtime of the function module
•The exceptions can be raised from your source code according to your logics

HP Restricted 107 Rev. 11.31


ABAP Basics

•In Function Builder, put your implementation source code after the automatically generated comment in
the ABAP Editor under the tab “Source Code.”
•At line 26 and line 28, keyword “raise” is used to raise the exceptions defined in “Exceptions” tab
according to your program logic.
•At line 22, “sy-subrc” is a system variable that indicates the result status of many standard procedures
which are normally triggered from keywords. Here, “concatenate” is a keyword, and you may use F1
help to check how “sy-subrc” is set according to the result of the concatenating procedure.

HP Restricted 108 Rev. 11.31


ABAP Basics

HP Restricted 109 Rev. 11.31


ABAP Basics

When calling a function module, keywords “CALL FUNCTION” are used, followed by the function
module name within a pair of “ „ “.

Importing parameters are specified through keywords “exporting” with formal parameters at the left
side of the “=” and the actual parameters at the right side.

Exporting parameters are specified through keywords “importing” with formal parameters at the left
side of the “=” and the actual parameters at the right side.

Changing parameters are specified through keywords “changing” with formal parameters at the left
side of the “=” and the actual parameters at the right side.

Exceptions are specified through keywords “exceptions” with defined exceptions at the left side of the
“=”, and you should specify a positive integer for each exception (“others” means the ones beyond the
exception definition). If no exception is raised during the runtime of the function module, system
variable “sy-subrc” would be set to 0. If an exception is raised, “sy-subrc” would be set to the positive
integer at the right side of that exception. Therefore, you should always put a “sy-subrc” checking logic
after calling the function module to handle the exceptions.

HP Restricted 110 Rev. 11.31


ABAP Basics

HP Restricted 111 Rev. 11.31


ABAP Basics

HP Restricted 112 Rev. 11.31

You might also like