Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Sandra_Rossi
Active Contributor
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.


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. There are all the instructions to install abapGit there.

For installing the API of FM Test Data, you must repeat the following steps for each one of the 4 required Git repositories:

  • Start ZABAPGIT

  • Click the button "New Online"

  • Enter the URL of the Git repository, for instance https://github.com/sandraros/S-RTTI for the first repository

  • Enter any package name, one dedicated to each Git repository, for instance $SRTTI for the first repository

  • Keep the default values of all the other fields

  • Click the button "Create Online Repo"

  • Click the button "Pull" (that will create and activate the packages, classes and programs)


Repeat the steps above for the 4 repositories:

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

 
13 Comments
Labels in this area