This tutorial is the second part of How to create first ABAP global class (simple calculator) in transaction SE24 (part I)?
Step 12. Click on ADD method:
Step 13. Click on Parameters button:
Step 14. Add parameters as on the following screen:
Step 15. Click on Sourcecode button:
Step 16. The system will ask you if you want to save changes. Click on Yes button:
Step 17. On this screen you can put code fo method ADD. Just like on the screen:
[cc lang=”abap”]
r_result = i_a + i_b.
[/cc]
Step 18. Click on Back button:
Step 19. Click on Methods button:
Step 20. Follow steps 12-19 for the SUBSTRACT method. Put following ABAP in method body:
[cc lang=”abap”]
r_result = i_a – i_b.
[/cc]
Step 21. Follow steps 12-19 for the MULTIPLY method. Put following ABAP in method body:
[cc lang=”abap”]
r_result = i_a – i_b.
[/cc]
Step 22. Follow steps 12-19 for the DIVIDE method. Put following ABAP in method body:
[cc lang=”abap”]
r_result = i_a – i_b.
[/cc]
Step 23. Click on Activate button to activate your class.
Step 24. Now you can use this global class in your ABAP report:
[cc lang=”abap”]
DATA: lv_result type int4.
result = zcl_calculator=>add( i_a = 5 i_b = 12).
WRITE: result.
[/cc]