Skip to Content
Technical Articles
Author's profile photo Praveena N

ABAP code in ECATT scripts

In this blog let’s see how to utilize ABAP/ENDABAP statement in the ECATT script.

We use ABAP/ENDABAP in ECATT scripts when we need to include ABAP code to perform validations like in the case below to check if a given material has valid Production Order.

It can also be used to fetch the data from Database and utilize as a parameter in the ECATT script.

We can either consider existing ECATT script or a new script.

Consider the following steps:

Creation of ECATT script.

  1. Go to SECATT transaction code.

  1. Enter the script name(recommended to use Z as it is identified as user defined script) and click on create icon.

3. Enter the TitlePerson ResponsibleApplication Component.

4. Enter the SDC (System Data Container) and Target System (if available).

5. Click on Save button.

6. When promoted to Create Object Directory Entry dialog box, select Local Object.

7. Click on Pattern.

8. Enter the Group and Command with Target System.

9. When Record SAP GUI Command dialog box appears, enter the transaction to be recorded (for ex: MM01 transaction).

10. Select Start Recording.

11. Select YES in Record SAP GUI Command screen to start recording in new session.

12. Select NO in Generation of RFC destination dialog box (because the RFC destination is                 already mentioned at the time of script creation: Refer step 4).

13. It goes to ‘MM01’ transaction as follows.

14. Record the steps as required.

15. After completing the recording, click on Stop Recording.

16. Click on Save.

17. By double clicking the interface we can observe all the recorded steps.

18. Now the importing and exporting parameters can be defined.

19. Click on ‘Pattern’, Select ‘ALL COMMANDS’ and Command as ABAP…ENDABAP.

By utilizing those importing/exporting parameters we can include the ABAP code.

For instance, let us consider whether the material created has any production order available in AFKO table.

The code is as follows:


DATA : lv_aufnr TYPE aufnr.
INTO lv_aufnr


I_MATERIAL is the importing parameter for the script where the same parameter is utilized in the Select Query.

When ABAP code is included we need to do an Extended Check.

Test script → Check → Extended

After doing an extended check it appears as follows and we can execute the test case.


So through this steps we can add the ABAP code in the ECATT scripts as per the requirements which helps in validations of the parameters which are created through script.

The values which are fetched from the database can also be exported and used as importing parameters to other test automation scripts.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Sandra Rossi
      Sandra Rossi

      Thanks for the post. Could you explain how the given ABAP code will help in “check[ing] if a given material has valid Production Order”? Isn't it incomplete? Moreover, why are you using an intermediate variable LV_MATERIAL?

      Author's profile photo Praveena N
      Praveena N
      Blog Post Author

      Hi Sandra,

      In the ABAP and ENDABAP code the variables declared cannot have the global scope over the ECATT script and cannot be used further. So, a local variable which is created as a parameter in the ECATT script as LV_MATERIAL can be used in ABAP code where PLNBEZ is the material number in the production order and can be viewed in the log after execution.

      I have not added further validation(just a sample for using ABAP/ENDABAP), if needed we can add IF statements.



      Author's profile photo Sandra Rossi
      Sandra Rossi

      Hi Praveena

      In fact I thought you would talk a little bit more about ABAP code because of the post title.

      I guess it’s worth adding the “IF” part so that to answer the “promise” made at the beginning, so that it’s a full step-by-step / end-to-end demo.


      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Agree with Sandra Rossi comments - if something is promised to the readers in the beginning then that what needs to be in the blog.

      It is much more valuable when a blog provides a full solution, including working code that does what is stated. If I needed something like this, after reading this blog I still wouldn't know how exactly to use this code to validate the entries. I'd feel rather bamboozled, to be honest. It's very disappointing to find a blog that leaves the important blanks to fill.

      It's nice of you to share but next time please follow through on the promises to the readers.

      Thank you.