We are porting GUICE library (http://code.google.com/p/google-guice/) from Java to ABAP. For full support we need annotations in ABAP (just like they are in Java). We figured out that we can do this pretty easily by using pseudo-comments in ABAP.
Here's an example. We have the following public section for a class (available by Goto->Public Section when editing a class in transaction SE80).
class ZDZ_ACLASS definition public final create public . "#@MyAnnotation *"* public components of class ZDZ_ACLASS *"* do not include other source files here!!! public section. data PUB_ATT1 type INT4 . methods PUB_METHOD1 importing !IA type INT4 . methods PUB_METHOD2 importing !IA type INT4 !IB type INT4 !IC type INT4 !ID type INT4 . class-methods STATIC_PUB_METHOD1 .
You probably noticed the pseudo-comment "#@MyAnnotation added just after class definition. It's added just as ABAP Unit #AU comments. We can process this annotation pretty easy by using the following code.
DATA: compiler TYPE REF TO cl_abap_compiler , p_name TYPE program , p_include TYPE program , p_result TYPE scr_glrefs , result_line TYPE scr_glref , error TYPE c , errors TYPE scr_errors , abort TYPE c , comments TYPE scr_comments , comment TYPE string , p_includes type SCR_PROGRAMS . append 'ZDZ_ACLASS====================CU' to p_includes. append 'ZDZ_ACLASS====================CO' to p_includes. append 'ZDZ_ACLASS====================CI' to p_includes. p_name = 'ZDZ_ACLASS====================CP'. CREATE OBJECT compiler EXPORTING p_name = p_name p_includes = p_includes. CALL METHOD compiler->get_all_refs EXPORTING p_local = ' ' * p_testcode = ' ' * p_types = * p_grades = * p_no_includes = * p_extended = * p_internal = IMPORTING p_result = p_result p_error = error p_errors = errors p_abort = abort . LOOP AT p_result INTO result_line. WRITE: / ' ', result_line-tag, space , result_line-full_name. LOOP AT result_line-symbol->pseudo_comments INTO comment. WRITE: / ' ', comment. ENDLOOP. ENDLOOP.
The problem is with the fact that if we now edit public seciton of a class not by using 'Goto->Public Seciton', but by using the old table-style editor, then our custom pseudo-comments are thrown away.
We tested it on a system where SAP_ABA is Release 701 Level 0005. I've also checked that with the introduction of EHP2 (http://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/1009fbb7-fd08-2d10-0182-852b6fa05f08≺tmode=print [original link is broken]) we will have a new editor that will not be table based (however, I don't have access to a system running EHP2).
My questions are:
- is there anyone running EHP2 that can check for me if any comment added to the public section of a class manually (Goto->Public Seciton) gets overridden, when you modify public section of a class by using the table-style editor
- is there anyone working closely to SAP ABAP development that can tell me why this behavior in editor is occuring - is it a bug, or a feature
- anyone can think of a workaround/fix - the obvious one that I can imagine is say to every programmer: don't use table-based editor - always modify public section by 'Goto->Public Section' - which is of course unreasonable
Edited by: Rob Burbank on Nov 26, 2010 10:05 AM