Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
fabianlupa
Contributor
In the ABAP Development Tools for Eclipse one useful feature is code templates. With them you can easily insert boilerplate template code and adjust it as necessary. ADT already comes with many available, but you can also define your own, some of which I want to share as others might find them useful too.


 

Exception class
"! ${descr}
CLASS ${enclosing_object} DEFINITION
PUBLIC
INHERITING FROM ${base}
FINAL
CREATE PUBLIC.

PUBLIC SECTION.
CONSTANTS:
BEGIN OF gc_no_arguments,
msgid TYPE symsgid VALUE '${msgid}',
msgno TYPE symsgno VALUE '${msgno}',
attr1 TYPE scx_attrname VALUE '',
attr2 TYPE scx_attrname VALUE '',
attr3 TYPE scx_attrname VALUE '',
attr4 TYPE scx_attrname VALUE '',
END OF gc_no_arguments.
INTERFACES:
if_t100_message.
METHODS:
"! @parameter is_textid | Textid
"! @parameter ix_previous | Previous exception
constructor IMPORTING is_textid LIKE if_t100_message=>t100key OPTIONAL
ix_previous LIKE previous OPTIONAL.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.



CLASS ${enclosing_object} IMPLEMENTATION.
METHOD constructor.
super->constructor( previous = ix_previous ).

CLEAR me->textid.
IF is_textid IS INITIAL.
if_t100_message~t100key = gc_no_arguments.
ELSE.
if_t100_message~t100key = is_textid.
ENDIF.
ENDMETHOD.
ENDCLASS.

Include file header
*----------------------------------------------------------------------*
***INCLUDE ${enclosing_object}.
*----------------------------------------------------------------------*

Message dummy
MESSAGE ${msgtyno}(${msgid}) WITH ${msgv} INTO DATA(${lv_dummy}) ##NEEDED.

Message to text
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
INTO DATA(${lv_msg_text}).

Initialize object services
cl_os_system=>init_and_set_modes( i_external_commit = ${oscon_false}
i_update_mode = ${oscon_dmode_update_task} ).

Report header
*&--------------------------------------------------------------------*
*& Program ${enclosing_object}
*& Author ${author}
*& Short description ${shortText}
*&--------------------------------------------------------------------*
*& Date ${year}-${month}-${day}
*& Last change ${year}-${month}-${day}
*&--------------------------------------------------------------------*
*& Change protocol
*& Date User Description
*& ____-__-__ ____________ ______________________________________
*&--------------------------------------------------------------------*

Installation


If you want to install all of them you can Right Click -> Save as... on the following link and import the xml file in the code template settings (Preferences -> ABAP Development -> Editors -> Source Code Editors -> ABAP Templates -> Import...).
Download link

Further reading:

https://blogs.sap.com/2013/02/01/insert-code-patterns-and-templates-within-eclipse/
https://blogs.sap.com/2013/05/24/creating-new-code-templates-with-abap-in-eclipse/
7 Comments