Generally MACROs in ABAP can be defined in two different scopes.
Local Scope- If it is defined locally in the program with the keyword DEFINE.......END-OF-DEFINITION.
Global Scope- To make the scope of the MACRO as global so that it can be access in any of the program unlike the local macro, it has to be defined in the DB table. SAP provides a Pooled DB table [ TRMAC ]which consists of all the Global Macros.
------------------------------------------------------------------------------------------------
Step1. Go to Tcode- SE11 and open the global macro table : TRMAC. Let's see the macro defined in this table and how it can be used in our program.
Step2. Go to Tcode- SM30, provide the table name and click on display.
Step3. Here we can see a number of macros. Let's use one of them, BREAKRC- here the code lines are spread among the lines- 0000,0001,0002,0003 & 0004. some lines are commented like 0000 & 0002. So here if the sy-subrc is other than 0 then the system would throw a message.
Step4. Create a program ans make the sy-subrc <> 0 and call the global macro with the name BREALRC and execute the program.
Step5. So here we receive the error message.
Step6. Up to this we just used a global macro. Let's create a our own global macro and call it in our program. Provide the table name and click on Maintain.
Step7. Click on NEW Entries.
Step8. This screen would appear.
Step9. Provide the macro name, line number and the first line code. Save it.
Step10. The first line of the global macro code is saved . Now to add the next line, click on the Right Arrow maintain the line 0001. Save it and click on the right arrow.
Step11. Maintain the new line 0002. Save it and go back .
Step12. So here our macro 'NEW_BREAK' with three lines of code is added. Go Back.
Step13. Go Back and call this macro in the program to test its effect.
Step14. Call the macro. and execute it.
Step15. So here the macro calls the break-point and the debugger has triggered.
Step16. We have the output.
------------------------------------------------------------------------------------------------e
No comments:
Post a Comment