Skip to Content
Technical Articles
Author's profile photo Sandra Rossi

API to Read and Write function module Test Data (SE37)

I propose here an API which permits to create test data in transaction code SE37 very easily, and also execute and load them. There are 3 demo programs: one to demonstrate the API, one to export test data to an XML file and another one to restore.

The API is in my github repository (https://github.com/sandraros/FM-Test-Data). Feedback welcome! You may create Issues for bugs, requests or propose fixes (Pull Requests) directly at github. Note that it requires 3 little other APIs to be installed (see below Installation steps).

Note that the API doesn’t allow to do things which are not permitted by SE37 like updating existing test data, you can only load and create (copy), and delete.

 
Table of Contents:

  1. Example scenarios
    1. Snippet to create test data for DATE_GET_WEEK
  2. Installation steps

(Table of contents generated by https://sandraros.github.io/BuildSAPBlogPostTOC.html)

Example scenarios

The class ZCL_FM_TEST_DATA has very simple methods to be used depending on the scenario you want to implement. Here are a few of them.

If you want to create a new Test Data:

  • Only with input data (see Example code below)
    • Create
    • Set_input_parameters
    • Save
  • With both input and output data to do regression tests (standard SE37 feature)
    • Create
    • Set_input_parameters
    • Execute
    • Save

If you want to execute an existing test data:

  • Load
  • Execute

If you want to backup and restore some Test Data, use the demo programs Z_FM_TEST_DATA_DEMO_EXPORT and Z_FM_TEST_DATA_DEMO_IMPORT:

  • For the export:
    • Load
    • Serialize (to an XML string)
    • Write the XML string to wherever you want
  • For the import:
    • Load the XML string from wherever you want
    • Deserialize
    • Save

Snippet to create test data for DATE_GET_WEEK

REPORT zdemo.

START-OF-SELECTION.
  DATA(test_data) = zcl_fm_test_data=>create( fm_name = 'DATE_GET_WEEK' title = 'demo' ).
  test_data->set_input_parameters( VALUE #( ( name = 'DATE' value = REF #( sy-datum ) ) ) ).
  test_data->save( ).
  COMMIT WORK.
  MESSAGE |Test data { condense( test_data->id ) } created| type 'I'.

NB: the method SET_INPUT_PARAMETERS works the same way as calling a function module with parameters passed in a dynamic way. For more information, see the ABAP documentation: CALL FUNCTION, parameter_tables.

Installation steps

First install abapGit.

Start abapGit and install first these 3 little tools. They are located in 3 of my other projects:

To install each tool with abapGit: click New Online, enter the URL of the tool, enter a name to create a new package, and install.

After that, install the API of FM Test Data:

Now you can run and play with the program Z_FM_TEST_DATA_DEMO, and create your own programs.

 

Assigned tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.