ABAP training: Function Modules: Function Groups

Function modules are grouped together in Function Groups. This can be grouping around a similar business object. For example a module to create, update, read data of a business object.

Creation of a Function Group

To create a function group start transaction SE37, and select menu Goto / Function Groups / Create Group:

Fill out the name and description, and press Save.

The function group is not useful yet, since it is not active. To activate go to the Change Function Group in the same menu and select the Master Program button to jump to the master program:

Now you can activate the Function Group.

Function group content

Once you have created one or more function modules, the modules can be seen in the Mater program by double clicking on the function module include ending with XX.

ABAP training: Data Dictionary: Search Help

A search help can be created to speed up input data field for the end user. It can be used to quickly narrow down possible entries based on input criteria. Search helps can be assigned to data elements or database table fields.

Creation of search help

Start transaction SE11 and selection the option Search help and press Create:

In the selection screen choose Elementary search help:

The main search help screen opens:

Enter a description. And assign in the Selection method field your table. If you split the main table from the text table, you can assign the text table in the Text table field. In the dialog behavior the most common is to Display values immediately.

Always set a hotkey by assigning it a letter. When you create a Collective search help the search helps are sorted by this letter assignment.

In the parameters set your fields. IMP means it is input. EXP is there on the output. The LPos field determines the seqeuence on the output.

Now check and activate your search help.

Test the search help with the test button:

Assigning search help to table

The search help is not automatically used. You can assign it to the data element in SE11:

Or you can assign is specifically in SE11 in a table defintion:

Select the row, press the Srch Help button and assign the search help.

Most common is to assign it to a data element.

ABAP training: Data Dictionary: Database table

The database table is the object to store data in the database. It is built of data elements.

Database table creation

To create a database table start transaction and choose the option Database table, enter your name, and press create:

Set delivery class

On the delivery and maintenance tab you have to choose the type and maintenance mode:

For Delivery Class there are 2 main options:

  • A for application data (most used)
  • C for customizing data

Customizing data is meant for tables that are maintained by IT and are setup in the development system and transported to production. New entries in these tables will ask for a transport request. Maintenance on production is normally not possible, since production systems are closed for customizing changes.

For Data Browser/Table View Editing, you can set how the system should respond when your table is using in SE16 (table content display) and SM30 (table maintenance). Choose the option that meets your business needs.

Add the field list

In the table field list add the fields for your table:

Important here: the first field is always the key field MANDT with type MANDT. MANDT is the field for the client.

In the example above we have taken a second field and marked it as key field (in the Key column).

Per field you create, you have to gave a table name and a reference to a Data element. You can refer to a standard SAP data element or an own created data element.

Set technical settings

Finally you need to set the technical properties of the table by clicking the Technical Settings button:

The data class indicates the intended use of the table (master data, transactional data, configuration data, etc.).

The size category indicates the amount of anticipated records in a productive system.

Buffering can be set if needed (see this blog for details on table buffering). Only switch this on when you know what you are doing.

If the flag Log Changes is ticked, all table changes are stored in table logging. For all details on table logging, read this blog.

Only switch on when really needed and only for small configuration tables. If done on large application data tables, the basis administrator will be cross at you for blowing up the application logging table volume.

Assign authorization group

This is technically an optional step, but highly advisable to avoid security issues and rework.

Choose menu option Utilities/Assign Authorization Group to come to this screen:

Select the correct authorization group from the list in the field New Authorization Group. There is no execute button, but you have to press Save now to assign it.

Final activation

Now Save the table, check and Activate. Table is ready for use.

Table maintenance generator

If you want to maintain data in your table in SM30, you need to use the table maintenance generator. In SE11 go to change mode of your table and select the menu option Utilities and then Table Maintenance Generator to reach this screen:

Assign the function group in which the table maintenance is stored.

For simple tables assign one step simple procedure and for screen use screen number 9000.

If your table is a master data table, keep the no recording routine. For new Z customizing tables do choose the Standard recording routine (basically the system will now force the entry to be saved in a transport).

Then use the Create button to generate the maintenance objects.

SM30 can now be used to maintain the content of the table.

ABAP training: Data Dictionary: Data type

There are 3 types of Data Types:

  1. Data element
  2. Structure
  3. Table type

Data elements are used to be built tables with content. Structures are help structures with single data lines that can be used in ABAP programs. Table types are help tables with multiple lines that can be used in ABAP programs. Only tables store data in the database. Structures and table types not.

Date elements and types are mainly based on domains and are the building blocks for tables.

Creation of Data element

Start transaction SE11. Select Data type and enter the name of the data element you want to create:

On the next screen select Data element:

On the main screen enter the description:

For the types that the data element will use, you can choose from pointing it to a domain, or to a built in type. The data element will take over the characteristics from the domain or built in type.

The 3rd tab is for further characteristics:

Here a data element can be linked to a Search Help, a parameter ID can be set and the data element can be marked for functional Change Documents.

By default the SAP GUI will remember the user input. This normally helps the end user. If you select the No Input History tick box the GUI will not store the input history for those fields using this data element.

In the last tab, you set the field labels for the data element:

There are 3 labels with different length and a heading description.

Save the data element, check it and activate it.

Creation of a Structure

To create a Structure, start transaction SE11 and select Data type, enter your structure name and press create. In the popup screen now select Structure:

In the next screen give the Structure a name and fill out the fields of the structure:

The build up of the Structure is similar to building a table. Differences: structures are used in ABAP as helper structures and don’t store data in the database. Therefore also as structure will not have key fields as well.

For components you can use both your custom created data elements as well as standard SAP data elements. You can use the button “Built-In Type” to switch the entry to direct types.

If you are done, Save the Structure, check and activate it.

Creation of a Table Type

To create a Table Type, start transaction SE11 and select Data type, enter your structure name and press create. In the popup screen now select Table Type:

Enter the description of the table type:

The most used option is to refer the Table Type to a Structure.

In the initialization the table access can be set differently from Standard. In the Primary Key tab, you can define the keys for the table if wanted.

Re-use and transparency considerations

Both structures and table types can also be defined locally in ABAP programs. If a second program needs similar or the same structures and table types, it does already make sense to define these elements in SE11 data types. This will stimulate re-use and consistency. Also the where-used options of the data dictionary can be used to quickly find the uses of the data types.

ABAP training: Data Dictionary: Domains

In the SAP data dictionary the lowest level re-usable element is the Domain. The Domain is used to build a Data Element in a database table.

Create a domain

To create a domain start transaction SE11, and choose the option Domain, enter your name and press Create:

In the next screen give the Domain a proper name and set the Date Type:

In this case we have chosen for a CHAR data type with length 50:

Note here that for text you can choose to make it case sensitive or not.

If you are happy, press the Save button and store the Domain in the proper package.

Then press the Check button to see if all is ok, and Activate button to activate the domain.

Possible data domains

The characteristics of a domain depend on the chosen Data Type.

For example a number will show different options:

There are domains for date, time, currency, quantity, etc…

Domain with own defined value set

The nicest feature of a domain is that you can define a value set. This value set can be used to restrict field choices to a limited set.

Example: first define a Domain;

Now go to the tab Value Range to set the restrictions:

In this case only the values FUTURE, PAST and PRESENT are allowed for this domain (and the Data Elements using it in tables).

Expert information

Be careful updating a domain later on (this includes adding a value in the value range). Any domain change will trigger a recompilation of:

  • The domain itself
  • Every Data Type using it (data type can be data element, structure and/or table type)
  • Every table using the data type
  • Every program using the table

This can be a lot!

Use the Where-Used button to see which tables are impacted. When it is a lot, check with your basis team when to import your transport in subsequent systems. Choose a time if possible where no users are working.

Domain Field length reduction and extension

Reducing domain field length can lead to data loss. Check and double check twice before executing a domain field length reduction.

Domain field length extensions are possible, but will trigger database table adjustments for the tables in which the data elements are using the impacted domain.

Use the Where-Used button to see which tables are impacted. Check with your basis team when to import your transport in subsequent systems. Choose a time if possible where no users are working.