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.
- Go to SECATT transaction code.
- Enter the script name(recommended to use Z as it is identified as user defined script) and click on create icon.
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.
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.
SELECT SINGLE aufnr
WHERE PLNBEZ = LV_MATERIAL.
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.