Friday 22 February 2019

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.

SAP ABAP Study Material, SAP  ABAP Guides, SAP ABAP Tutorial and Material, SAP ABAP Certifications

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

SAP ABAP Study Material, SAP  ABAP Guides, SAP ABAP Tutorial and Material, SAP ABAP Certifications

3. Enter the Title, Person Responsible, Application Component.

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

5. Click on Save button.

SAP ABAP Study Material, SAP  ABAP Guides, SAP ABAP Tutorial and Material, SAP ABAP Certifications

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

SAP ABAP Study Material, SAP  ABAP Guides, SAP ABAP Tutorial and Material, SAP ABAP Certifications

7. Click on Pattern.

SAP ABAP Study Material, SAP  ABAP Guides, SAP ABAP Tutorial and Material, SAP ABAP Certifications

8. Enter the Group and Command with Target System.

SAP ABAP Study Material, SAP  ABAP Guides, SAP ABAP Tutorial and Material, SAP ABAP Certifications

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

10. Select Start Recording.

SAP ABAP Study Material, SAP  ABAP Guides, SAP ABAP Tutorial and Material, SAP ABAP Certifications

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

SAP ABAP Study Material, SAP  ABAP Guides, SAP ABAP Tutorial and Material, SAP ABAP Certifications

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).

SAP ABAP Study Material, SAP  ABAP Guides, SAP ABAP Tutorial and Material, SAP ABAP Certifications

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

SAP ABAP Study Material, SAP  ABAP Guides, SAP ABAP Tutorial and Material, SAP ABAP Certifications

14. Record the steps as required.

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

SAP ABAP Study Material, SAP  ABAP Guides, SAP ABAP Tutorial and Material, SAP ABAP Certifications

16. Click on Save.

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

SAP ABAP Study Material, SAP  ABAP Guides, SAP ABAP Tutorial and Material, SAP ABAP Certifications

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

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

SAP ABAP Study Material, SAP  ABAP Guides, SAP ABAP Tutorial and Material, SAP ABAP Certifications

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:

ABAP.

DATA : lv_aufnr TYPE aufnr.
SELECT SINGLE aufnr
INTO lv_aufnr
FROM AFKO
WHERE PLNBEZ = LV_MATERIAL.

ENDABAP.

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.

SAP ABAP Study Material, SAP  ABAP Guides, SAP ABAP Tutorial and Material, SAP ABAP Certifications

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.

No comments:

Post a Comment