Like ABAP code patterns, there is another handy tool tucked away in the corner of the ABAP editor that can speed up some aspects of your development. It’s called the ABAP Code Templates. Whenever you get code suggestions while typing keywords like ‘If’, or ‘Loop’ or ‘Case’, this is where it is coming from. When the suggestions appear, on press of the ‘TAB’ button, that template will be applied to your code.
But these templates can be dynamic too, although only to a certain extent. I will demonstrate that by using a very common scenario: tagging of modified code with a modification log or comment. Normally such a tag is to let other developers know when, why and by who has the code been last changed.
So, let’s say, we would want to surround any newer piece of code inside of an older code module with the following information:
- User Name of the person responsible
- Date and time of the change made
- Some change tracking number or some description of the change.
- A ‘BEGIN’ and an ‘END’ label.
We would also want to position the cursor in such a way that right after the template is applied you can start writing your code.
STEPS:
- Create a new report in SE38. Mine is called ZSS_DEMO_CODE_COMPLETION.
- In the right and bottom corner of the screen there is a small yellow button. Click on that.
|