This is a test message to test the length of the message box.
ABAP Quick Creation of test data
Created by Software-Heroes

ABAP Quick - Creation of test data


What challenges do you have when setting up test tables and test data and how can machine processing help you?

Today's tip is about creating test data easily, migrating the test application to other systems, and quickly restoring the data in the system. We take a closer look at the various options in detail.


Provide data

Are you currently setting up a new table and want to fill it directly with data? There are two ways of getting the data into the table:

  • Creation of a view
  • Insertion by program


Let's first set up a table. The quick and easy way is to create it using the ABAP Development Tools (ADT), since the table is defined in a simple form here. You save yourself the need to set the technical details and jump to the extension category. Our test table looks like this:


Table Maintanance view

A table maintenance view is created after the table has been created. With this you can then insert, edit and delete new data records. A function group and maintenance modules are generated, so a relatively large number of objects are required.

  • Function group with modules
  • Dynpros
  • Includes with events



Here you create an executable class or a report and fill in the data at the push of a button. Only a simple object (class, report) is required. So what could such an executable class look like?

    INTERFACES if_oo_adt_classrun.


CLASS zcl_bs_demo_fill_account IMPLEMENTATION.
  METHOD if_oo_adt_classrun~main.
      lt_account TYPE STANDARD TABLE OF zbs_dy_account WITH EMPTY KEY.

    lt_account = VALUE #(
      ( identifier = '1000000010' amount = '12.34' currency = 'EUR' account_active = abap_true )
      ( identifier = '1000000011' amount = '200.00' currency = 'USD' account_active = abap_true )
      ( identifier = '1000000012' amount = '55.50' currency = 'EUR' account_active = abap_false )
      ( identifier = '2000000010' amount = '13.37' currency = 'CHF' account_active = abap_false )

    DELETE FROM zbs_dy_account.
    INSERT zbs_dy_account FROM TABLE @lt_account.

    out->write( |Datasets inserted { sy-dbcnt }| ).



Hint: So that the class remains executable, you should first clean up the table before inserting the data. Don't forget to call a clean commit at the end.



When comparing the two variants, the maintenance view is the most flexible, you can adapt the entries directly and copy them from Excel directly into the table. The only negative point is the large number of objects created to maintain the table. If you want to move the objects to another system, this is not possible, unless you would export the data to Excel. But here you are far from an automatic process.

  • + Flexible
  • - Number of objects
  • - No data migration


In addition, the construct with an executable class is relatively flexible, as you can always adjust the data in the class. Here, however, you always work with the full data package when you change the data. When the objects are migrated, data content is also moved and is available again in the target system at any time.

  • - Relative flexible
  • + Number of objects
  • + Data migration



You want to quickly show your colleague a small application and need test data for this, then the executable class is a quick and easy way to make data available and to be able to adapt it again and again without disrupting your actual development process. The creation of test data is also a popular example where you have to adjust the data again and again when you adapt your test cases. If you have written a comprehensive application, then you might want to roll it out in other systems and need the corresponding data for your ABAP unit test cases.

There are many cases in which you will need the data over and over again. The maintenance via the maintenance view will always be effective and the simplest, but rolling out the maintenance view via abapGit, for example, will put more stumbling blocks in your way than you actually need. The deinstallation of such maintenance views is currently not properly supported and in the end you will be missing the data for maintenance.

With this in mind, we recommend using the executable object if you have no other requirements, as it is the most flexible variant when transferring objects, migrating and providing data in an empty system.


Hint: Creating test data is also made more difficult in the cloud environment (steampunk), as there is no GUI and no table maintenance generator. The easiest way here is to create the data via the executable class.



Of course, you should specifically secure such data creation objects so that no one can simply execute them in the productive system accidentally. The easiest way here is probably to check the authorizations against Debug & Change, since debugging is possible in any clean production system, but Debug & Change is not. At least you should keep this point in mind when transporting such objects into production.



What is the easiest way to get test data into the system and transfer it to the next system? There are different approaches here and you should decide what suits you best depending on the situation.

Included topics:
QuickTest dataCreation of test data
Comments (0)

And further ...

Are you satisfied with the content of the article? We post new content in the ABAP area every Friday and irregularly in all other areas. Take a look at our tools and apps, we provide them free of charge.

ABAP Quick - RFC Error handling

Category - ABAP

How do you actually handle errors when communicating via a destination in the function module? More about this in our tip.


ABAP Quick - CLEAR right

Category - ABAP

Delete correctly? In this article we want to take a look at when it makes sense to delete and how you can do it effectively.


ABAP Quick - Performance chained statements

Category - ABAP

Let's take a look at the performance when creating chained statements with DATA and FIELD-SYMBOL. Which variant will be ahead in terms of performance?


ABAP - ALV still relevant in 2022?

Category - ABAP

Today the joking question, do we still need reports that generate ALV outputs in 2022? In this article, we want to look into this question.


ABAP in Change

Category - ABAP

The programming language ABAP has been changing for years and is being modernized in various concepts. In this article, we'll look at it in detail.