Updated!
If you really can’t wait for the new Editor, read Speak Your Voice; New ABAP Editor for Older Releases. Add your opinion to the list and see if there is enough interest for SAP to back-port the new editor to older releases.
Introduction
I have never been accused of being a patient person. As a child, I just couldn’t wait to open the presents on Christmas morning. I would poke and prod everything under the tree. I have even been know to peel back the wrapping ever so slightly to get a peek at what is inside.
If you are like me and just can’t wait for the new ABAP editor, then this weblog might help you get through the ordeal. I decided that I didn’t want to wait until I had access to a WebAS 7.0 system. I set out to create a small ABAP dialog program that could be run even in older releases that would allow me to try out some of the features in the new editor. The trick to this whole thing is that you must have SAPGui 640 Patch 10 or higher loaded on your system (Technially the ABAP editor is delivered in Patch 10. However due to some bugs in patch 10 unrelated to the ABAP editor, you probably want to skip 10 and go directly for patch 11 just to be safe). This is the patch level and release where the front end components of the new ABAP editor are delivered. Remember that the SAPGui is backwards compatible, so you can run the SAPGui 640 on your PC and still connect just fine even to older 46X releases.
The ABAP Editor Control
The new ABAP editor is implemented as an ActiveX control running on your windows client machine. It is integrated with ABAP using the Control Framework. That means that if you have the control running on your PC, all you need to do is create an ABAP Proxy class for it to be able to access its most basic features. If you want more details on this general technology see: Using Classic ActiveX Controls in the ABAP Control Framework. The first thing we need to do is determine some information about the control; like what are its methods and attributes. To do this I included the OCX into a project in Microsoft Visual Studio .Net 2003. I then used the Object browser to lookup the details.
The ABAP Proxy Class
Armed with the information about the control, we are ready to create our ABAP proxy class. I created a class called ZCL_ES_GUI_ABAP_EDITOR that inherits from CL_GUI_CONTROL and has a forward declaration for CNTL. To get started, we will have to implement just two methods in this class.
The first method is the CONSTRUCTOR. This method will instantiate the control on the front-end and register it with the control framework. The parameters of the method are shown as comments at the beginning of the method.
METHOD CONSTRUCTOR .
*@78QImporting@ VALUE( STYLE ) TYPE I DEFAULT 0 control style, if initial a defined value is choosen
*@78QImporting@ VALUE( PARENT ) TYPE REF TO CL_GUI_CONTAINER Parent Container
*@78QImporting@ VALUE( LIFETIME ) TYPE I OPTIONAL for life time management
*@78QImporting@ VALUE( NAME ) TYPE STRING OPTIONAL name for the control
*@03QException@ ERROR_CNTL_CREATE Error Creating Control
*@03QException@ ERROR_CNTL_INIT Error Initializing Control
*@03QException@ ERROR_CNTL_LINK Error Linking Control
*@03QException@ ERROR_DP_CREATE DataProvider Error
*@03QException@ GUI_TYPE_NOT_SUPPORTED This type of GUI is not supported!
DATA prog_id(80).
IF parent IS INITIAL.
RAISE error_cntl_create.
ENDIF.
CLASS cl_gui_cfw DEFINITION LOAD.
-
assign prog_id to get the frontend specific control
IF NOT activex IS INITIAL.
prog_id = ‘SAPGUI.AbapEditor.1’.
ELSEIF NOT javabean IS INITIAL.
RAISE gui_type_not_supported.
ENDIF.
IF prog_id IS INITIAL.
RAISE gui_type_not_supported.
ENDIF.
-
Set the window styles of the control when style parameter was not
-
set with constructor call.
-
For more information on the styles see WIN32 SDK
IF style IS INITIAL.
-
otherwise the control would be invisible and the mistake would be
-
hard to find
style = cl_gui_control=>ws_visible
+ cl_gui_control=>ws_child
+ cl_gui_control=>ws_clipsiblings.
ENDIF.
-
Create the control
CALL METHOD super->constructor
EXPORTING
clsid = prog_id
shellstyle = style
parent = parent
lifetime = lifetime
name = name
EXCEPTIONS
OTHERS = 1.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS
cntl_system_error = 1
cntl_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
RAISE error_cntl_create.
ENDIF.
-
register instance at framework
CALL METHOD cl_gui_cfw=>subscribe
EXPORTING
shellid = h_control-shellid
ref = me
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
RAISE error_cntl_create.
ENDIF.
ENDMETHOD.
The second method, called ADD_EMPTY_DOC, will initialize an empty document into the editor. It has parameter to set the language type (ABAP, BSP, etc) and Read Only mode.
method ADD_EMPTY_DOC .*@78QImporting@ STR_NAME TYPE STRING *@78QImporting@ B_READONLY TYPE I DEFAULT CFALSE Boolean Variable (X=True, -=False, Space=Unknown)*@78QImporting@ STR_EXTENSION TYPE STRING DEFAULT ‘ABAP’ *@78QImporting@ STR_TOOLTIP TYPE STRING DEFAULT ‘Test’ *@03QException@ UNABLE_TO_SET_DOC Font Set Error call method call_method exporting method = ‘AddEmptyDoc’ p_count = 4 p1 = str_name p2 = b_readonly p3 = str_extension p4 = str_tooltip exceptions cntl_system_error = 1 cntl_error = 2 others = 3. if sy-subrc <> 0. raise UNABLE_TO_SET_DOC. endif.endmethod.
Test Program
We now need a relatively simple test program. I create a dialog program with a single screen. On the screen, in the screen painter, I inserted a custom control. The only special coding we really need is in the PBO. This is where we will create the instances of the custom container and the ABAP editor.
MODULE status_0100 OUTPUT. SET PF-STATUS ‘MAIN’. SET TITLEBAR ‘100’. IF custom_container IS INITIAL. PERFORM create_controls. ENDIF.ENDMODULE. ” STATUS_0100 OUTPUT
CREATE OBJECT custom_container EXPORTING container_name = ‘CUSTOM_CONTAINER’. CREATE OBJECT abap_editor EXPORTING parent = custom_container. IF sy-subrc <> 0. ENDIF. CALL METHOD abap_editor->add_empty_doc EXPORTING str_name = ‘Test Program’ b_readonly = ‘0’ “Edit Mode str_extension = ‘ABAP’ str_tooltip = ‘Tooltip1’. IF sy-subrc <> 0. ENDIF. cl_gui_cfw=>flush( ).
Lacking
documentation on the actual values for the parameters, I had to play with a little to get it working. But in the end I have a sample program with the empty editor.
This gives me enough functionality to try out the auto complete, code collapse, key word coloring, and several other features.
The next two screen shots show how you can use templates to insert a new method.
I even edited the template definition to create my own custom report header.
The new editor’s front end export (Text, PDF, and HTML) all appear to be working fine as well. I exported my test document and added here to the weblog (that’s inline HTML generated by the ABAP Editor – not an Image). It turned out looking quite nice.
SPAN {
font-family: “Courier New”;
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S31 {
font-style: italic;
color: #808080;
}
.L0S32
.L0S51
.L0S52
.L0S54
.L0S55
>
class=”L0S31″>—-
class=”L0S31″>* Report : Test Program
class=”L0S31″>* Author : Thomas Jung – Alpha Nerd
class=”L0S31″>—-
class=”L0S51″>REPORT Test class=”L0S51″>Program
class=”L0S55″>no class=”L0S55″>standard class=”L0S55″>page heading
class=”L0S55″>line- class=”L0S55″>size class=”L0S32″>80
class=”L0S55″>line- class=”L0S55″>count class=”L0S32″>65( class=”L0S32″>0)
class=”L0S55″>message- class=”L0S55″>id
defining class=”L0S55″>database .
start- class=”L0S54″>of-selection.
class=”L0S54″>perform test1.
class=”L0S31″>**********************************************************************
class=”L0S31″>* FORM : test1
class=”L0S31″>* Created : 03.08.2005 13:05:38
class=”L0S31″>**********************************************************************
class=”L0S54″>FORM test1 class=”L0S55″>USING
class=”L0S55″>CHANGING .
class=”L0S54″>IF sy-subrc = class=”L0S32″>0.
class=”L0S54″>ENDIF.
class=”L0S54″>ENDFORM. class=”L0S31″>”test1
class=”L0S52″>class class=”L0S52″>implementation lcl_test.
class=”L0S31″>**********************************************************************
class=”L0S31″>* METHOD : test1
class=”L0S31″>* Created : 03.08.2005 13:09:43
class=”L0S31″>**********************************************************************
class=”L0S54″>METHOD test1 .
class=”L0S54″>ENDMETHOD. class=”L0S31″>”test1
Updated on August 9th 2005
For those of you who may have thought that the original version of this example wrapper didn’t go far enough, I now have a new version.
Thanks to help from Alexey Arseniev (the author of the new ABAP editor), I have a newer enhanced version of the demo of the new ABAP editor. This new demo includes MUCH more coding in the control proxy class.
UPDATED August 11th
I now have the link where you can download the code.
Let me know if you have any problems. There should be screen shots of any table types or structures that you need to declare. Many of the other other type definitions are declared in-line in the class. This sample was written on 640 SP12.
The new version also only works in WebAS 610 and higher. It turns out that the new ABAP editor expects to receive its source code in Unicode (UTF-16LE to be exact). Therefore you need certain functions to perform the conversion.
I will list a few of the updated methods here that allow you to load any program into the editor, in case anyone just can’t wait until they get file download.
METHOD constructor .
*@78QImporting@ VALUE( STYLE ) TYPE I DEFAULT 0 control style, if initial a defined value is choosen
*@78QImporting@ VALUE( PARENT ) TYPE REF TO CL_GUI_CONTAINER Parent Container
*@78QImporting@ VALUE( LIFETIME ) TYPE I OPTIONAL for life time management
*@78QImporting@ VALUE( NAME ) TYPE STRING OPTIONAL name for the control
*@78QImporting@ REPORT_NAME TYPE SYREPID OPTIONAL ABAP Program: Current Main Program
*@03QException@ ERROR_CNTL_CREATE Error Creating Control
*@03QException@ ERROR_CNTL_INIT Error Initializing Control
*@03QException@ ERROR_CNTL_LINK Error Linking Control
*@03QException@ ERROR_DP_CREATE DataProvider Error
*@03QException@ GUI_TYPE_NOT_SUPPORTED This type of GUI is not supported!
DATA prog_id(80).
IF parent IS INITIAL.
RAISE error_cntl_create.
ENDIF.
CLASS cl_gui_cfw DEFINITION LOAD.
-
assign prog_id to get the frontend specific control
IF NOT activex IS INITIAL.
prog_id = ‘SAPGUI.AbapEditor.1’.
ELSEIF NOT javabean IS INITIAL.
RAISE gui_type_not_supported.
ENDIF.
IF prog_id IS INITIAL.
RAISE gui_type_not_supported.
ENDIF.
-
Set the window styles of the control when style parameter was not
-
set with constructor call.
-
For more information on the styles see WIN32 SDK
IF style IS INITIAL.
-
otherwise the control would be invisible and the mistake would be
-
hard to find
style = cl_gui_control=>ws_visible
+ cl_gui_control=>ws_child
+ cl_gui_control=>ws_clipsiblings.
ENDIF.
-
Create the control
CALL METHOD super->constructor
EXPORTING
clsid = prog_id
shellstyle = style
parent = parent
lifetime = lifetime
name = name
EXCEPTIONS
OTHERS = 1.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS
cntl_system_error = 1
cntl_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
RAISE error_cntl_create.
ENDIF.
-
register instance at framework
CALL METHOD cl_gui_cfw=>subscribe
EXPORTING
shellid = h_control-shellid
ref = me
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
RAISE error_cntl_create.
ENDIF.
-
create and initialize dataprovider => m_dp_handle
CALL FUNCTION ‘DP_CREATE’
CHANGING
h_dp = m_dp_handle
EXCEPTIONS
dp_create_error = 1
dp_install_error = 2
dp_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
RAISE error_dp_create.
ENDIF.
-
Register control events
CALL METHOD register_events.
-
Enable control events
CALL METHOD call_method
EXPORTING
method = ‘SubscribeOnCommand’
p1 = 37311
p2 = cfalse
p_count = 2
EXCEPTIONS
OTHERS = 1.
-
CALL METHOD set_property
-
EXPORTING
-
property = ‘bNavigateOnDblClick’
-
value = ctrue.
*
-
Set default language to ABAP
-
CALL METHOD set_property
-
EXPORTING
-
property = ‘sProgLanguage’
-
value = ‘ABAP4’.
-
If report name provided – load it
CHECK NOT report_name IS INITIAL.
CALL METHOD load
EXPORTING
report_name = report_name.
ENDMETHOD. “constructor
LIKE LINE OF lt_report.
CHECK NOT report_name IS INITIAL.
-
Check existense and attributes
CALL FUNCTION ‘RPY_EXISTENCE_CHECK_PROG’
EXPORTING
name = report_name
TABLES
progdir_tab = lt_progdir
EXCEPTIONS
not_exist = 1
OTHERS = 2.
CHECK sy-subrc EQ 0.
gt_progdir = lt_progdir.
gv_report_name = report_name.
-
Get main program
CALL FUNCTION ‘RS_GET_MAINPROGRAMS’
EXPORTING
name = gv_report_name
dialog_required = gc_true
TABLES
mainprograms = lt_mainprog
EXCEPTIONS
OTHERS = 1.
IF sy-subrc EQ 0.
READ TABLE lt_mainprog INDEX 1 INTO gv_main_prog.
ENDIF.
-
Load report
READ REPORT gv_report_name INTO lt_report.
-
send table to control
CALL METHOD set_text_as_r3table
EXPORTING
table = lt_report.
CALL METHOD call_method
EXPORTING
method = ‘LoadDocFromDP’
p1 = report_name
p2 = m_dp_handle
p_count = 2
EXCEPTIONS
OTHERS = 1.
ENDMETHOD. “LOAD
METHOD set_text_as_r3table.
*@78QImporting@ TABLE TYPE STANDARD TABLE
*@03QException@ ERROR_DP
-
set_table_property table. “‘YES_ABAP_EDITOR’.
TYPES: x256(120) TYPE x.
DATA: l_table TYPE TABLE OF x256.
DATA: x_test TYPE xstring.
DATA: s_test TYPE string.
FIELD-SYMBOLS: 0.
ENDIF.
CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’
EXPORTING
buffer = x_test
TABLES
binary_tab = l_table.
-
create dataprovider object and send data to frontend
call function ‘DP_CREATE_FROM_STREAM’
exporting
type = cndp_sap_tab_mimetype
subtype = ‘ABAP_SOURCE’ ” cndp_sap_subtype_unknown
-
size = len
tables
data = l_table
changing
h_dp = m_dp_handle
exceptions
DP_ERROR_GENERAL = 1
DP_ERROR_CREATE = 2
DP_ERROR_SEND = 3
others = 4.
ENDMETHOD.
Closing
The new ABAP editor has tons of methods, many of which would be necessary for unlocking all the features it has. I have only scratched the surface here. There is just enough to wet your appetite for more. I really wanted to implement enough methods to be able to load an existing program from the back end into the editor. However the contents of the program are loaded as DP Objects to the front end control and therefore I don’t have good documentation on the format of the internal table to pass in.
Thank you.
Thank you.
How did you manage to save (export) your code to an external file? Everything else I could do, on a 4.6C.
Thank you
Very interesting, indeed!
Thanks a lot for this weblog!
I already know with what I gonna playing around during this weekend.:-)
Cheers,
Peter
CREATE OBJECT custom_container
EXPORTING
container_name = 'CUSTOM_CONTAINER'.
Where/how should I define the custom_container?
regards,
Lars Wilhelmsen
custom_container should be declared in your data area like:
data: custom_container type ref to cl_gui_custom_container.
Don't forget to also go into your screen (in the screen painter) and draw an area for the custom control. Name it the same thing you name the container_name inporting parameter.
It would be nice to have the new editor on 4.6C.
Regards,
Stefan
In Method load it gives error with TYPE report_tbl, gt_progdir and so on.
Is there any data declaration missing...
Also in CONSTRUCTOR method it could not find REGISTER_EVENT.
Cheers !!
Sat.
I really put the limited code sample that I did out there just for people to look over and try if they are brave. You can just comment out the call to REGISTER_EVENT.
Here are the missing types:
types:
report_tbl type standard table of char255 .
data:
gt_progdir type table of progdir .
data: gt_sources tyep SOURCE_TBL.
Thanks a lot. I could now make it work and it can load an old abap program in new editor.
One problem I notice that at the beginning of each line of old code it puts a 'new line characted' (rectangle).
I now wait for your downloadable code 🙂
It is really brilliant. Thx a lot again. I sincerely hope SAP backports it to 620.
Cheers !!
I don't have the problem with the new line character. I suspect that has something to do with the code that turns the source code internal table into a string. You might check the following section in the debugger:
Thanks. indeed that was the problem. CR_LF is of two character and was leaving linefeed character as whitespace. So, I altered the code: and it works fine now 🙂 <br/>BTW: my system is 620 SP53.<br/><br/>Cheers !!<br/>
I will check today and see if any of our sister companies have a 620 system (I only have access to 640 and 46C systems) where I could try this out.
But I have a little problem: in the software distribution center you can only download the compilation 3 with patchlevel 8.
Any hint where I can find the PL 11 ?
Thx a lot, Uwe
Please try:
https://smpdl.sap-ag.de/~swdc/002007974700000211032005D/gui640_11-10001615.exe?_ACTION=DL_DIRECT
Cheers !!
To download the latest patch - goto the Service Marketplace:
http://service.sap.com/patches
Then choose Entry by Application Group
Then SAP Frontend Components
Then SAPGui For Windows
Then SAPGui for Windows 640
Then Win32
Successfully I have downloaded the 'SAP GUI for Windows 6.40 Patch 12' from the Service Market Place but while executing it is asking for Application with which it should be opened. Any idea how it should be installed.
thanks in advance.
sanjay
thanks
I downloaded the code provided by Thomas. Now I want to use this to fill my class with the code necessary, so I don't have to type it all by myself. Unfortunatelly I don't know how to do this. I am using WebAS6.20 and GUI6.40 SP11.
Any help appreciated.
Regards,
ALEX
On 640 (I can't remember if you can do this in 620 or not) you can goto the definition selection in code (GOTO->Public Section, Private Section, Protect Section). You can then cut and paste in all the method/attribute/type defintions. This saves a ton of time. You can then go one-by-one and cut and paste in each method's code.
You might be able to find a completely automated upload process, but I tend to like to pick through the coding as I put in the system and learn from it. However importing all the attributes and method parameters is a real time saver.
Any suggestions?
ALEX
Also, there is no possibilities to define 'TYPES' in "public section" either.
So, Public section I needed to create from Class builder. However, in Private and Protected section Cut&paste worked like charm 🙂 Cheers !!
The other route is that you could create the whole class as a local class in an include. I really prefer global classes however.
Or how can I use the way with local classes in module?
THX
I'm not sure that I understand you question. There are some limitations in releases older than 640 on the ability to define new type statements within the class definition. On these older releases you can always just go ahead and create these in the data dictionary.
Second part of my previous question was oriented on you.
"Or how can I use the way with local classes in module?"
The first part with question how to make this
TYPES bookmark_tbl TYPE zes_bookmark_tbl.
TYPES breakpoint_tbl TYPE zes_breakpoint_tbl.
TYPES point TYPE zes_point.
TYPES protected_lines_tbl TYPE zes_protected_lines_tbl.
through class builder when I can't create it in making the whole class? Cause the PUBLIC section is locked? (answer by Satyabrata Basu)
And it's for release 6.40 indeed
BIG THX for gimmi some reason .... 🙂 i want to try this new ABAP editor.
In the update Aug 11th I have read 'The new version also only works in WebAS 610 and higher.'
Is there any chance to make this working with 4.6C?
Thanks a lot.
Flavio
The routines I used in 610 and higher to convert the ABAP program code to Unicode just don't exist in 46C. If anyone knows of some routines that do exist on 46C then this could be acomplished. I thought about using the translate codepage command, but I just have not had a chance to try it out yet. My company is in the process of upgrading to ERP2004, so my access to a 46C is limited (no new development in that system is allowed) and will soon be gone all together.
Thanks for your share.
I downloaded your code and made it work,but in the new editor,it only showed the line number and the source code,nothing especial than the old editor.Maybe I did not implement the code correctly,Would you please give some advices?thanks!
I am in GUI 640 Patch level 12,windowsxp.
prog_id = 'SAPGUI.AbapEditor.1'.
The program ID for the old old editor is similar and I had grabbed the wrong one.
I got the problem, that type "seoo_attributes_r" is not found.
Any ideas?
Thanks a lot.
Walter
The Type definition itself is
types:
* attribute
seoo_attribute_r like vseoattrib,
I solved the problem by including the type-pools:
TYPE-POOLS seoo.
TYPE-POOLS cndp.
TYPE-POOLS seos.
TYPE-POOLS swbse.
The program works, but there is no functionality. in the editor ( prog_id = 'SAPGUI.AbapEditor.1' ).
I found the same problem on this blog a little bit earlier. Is there already a solution known ?
Greetings,
Walter
Firstly, what did you use to create the single CLAS.ZCL_ES_GUI_ABAP_EDITOR.abap file?
Secondly, there are 4 type definitions in your Public section:-
TYPES bookmark_tbl TYPE zes_bookmark_tbl.
TYPES breakpoint_tbl TYPE zes_breakpoint_tbl.
TYPES point TYPE zes_point.
TYPES protected_lines_tbl TYPE zes_protected_lines_tbl.
But in 640, it is not possible to edit the public section, so how do you define these four - do you use a type-pool??
Many thanks
Jack
The types you mention are all declared as table types in the data dictionary. The screen shots of their definition are included in the downloadable package.
I declareded the zes_bookmark_tbl as a table type in the data dictionary, as per the screen-shots. But in the Public Section of the class there are also 4 type definitions using these table types. Since the Public Section is not directly editable, how did you add those four type definitions? - TYPES bookmark_tbl TYPE zes_bookmark_tbl.
Many Thanks
Jack
I guess that is where I have some confusion. My public Types Section is Editable. I just went to the TYPES tab in the class editor and defined BOOKMARK_TBL Public Type ZES_BOOKMARK_TBL.
For that matter in 640 you can just choose GOTO->Public Section and you have the code editor where you can directly input the definitions as well (or cut and paste from the text file).
This program is very interesting. Is there also a counter-part to import classes from the *.abap files..?
Thanks in advance, Markus
Thanks.
Gustav
You first have to run a program with method "ADD_EMPTY_DOC", it will give you a popup if you want to read the quick introduction.
It will also create ab4_data dir in your SapWorkDir.
Until it's not yet done, it will run in TEXT mode.
We had the same problem with one of my collegue, even we patched the SAPGUI to level 13 it was still in TEXT. After we run the first demo program with "ADD_EMPTY_DOC" it was fine.
Hope helps,
Peter
Peter
I've installed it in order to check the WebDynpro client. Now the syntax highlighting doesn't work anymore, everything is grey although the editor language is ABAP. I checked on basis 46C and 6.20.
Thanks,
Peter
Have I missed something?
Regards
matt
thanks!
matt
Any chance of a SAPLink version? This would be probably easier to create and update, and certainly easier to install. SAPLink doesn't work on 4.6C if I remember correctly, but it does work on 4.7.
I Went throught the entire blog and implemented the code provided in the blog. Its good to have so much functionalities with editor.
For that i ahev crearted a zclaa with CL_GUI_TEXTEDIT as its super class whcih provided me all the methods n properties of CL_GUI_TEXTEDIT & CL_GUI_CONTROl. I added the two methods of CONTAINER & ADD_EMPTY_DOC to the zclass.
When iam executing my program iam getting this dump.
Short text
The current application triggered a termination with a short dump.
What happened?
The current application program detected a situation which really
should not occur. Therefore, a termination with a short dump was
triggered on purpose by the key word MESSAGE (type X).
Error analysis
Short text of error message:
Control Framework : Error processing control
Long text of error message:
Diagnosis
An error occurred when the system tried to process the commands
from the Automation Queue on the presentation server.
There are several possible reasons for this:
- The installation of the SAP GUI on the presentation server is
faulty or obsolete.
- There is an error in the application program
- There is an error in the SAPGUI or an integrated control
Could you please assist what would be the problem area.
Thanks in advance
To that end, the new editor has been backported and is available for WebAS 6.20 and NetWeaver04. Therefore I don't see any reason to continue to add functionality to a demo program when you can just use the real thing in the ABAP workbench.
You are getting a dump in the control framework. That is probably because you are mixing calls to more than one frontend control since you inherited from CL_GUI_TEXTEDIT. The control proxy classes are just wrappers for different controls (libraries) on the frontend. You can just just copy proxy methods (or inherit them) and expect them to work against a different frontend control. If you really wanted to implement these additional methods you would want to study how them are done with CL_GUI_ABAPEDIT.
New ABAP Editor; too good to wait for.
If we are extending the class cl_gui_control to make our own custom class then we are able to see the new editor. To implement the functionalities of the existing text editor (class cl_gui_textedit), like transferring data from the application program to the front-end (method set_text_as_r3table) I tried to extend the class cl_gui_textedit instead of cl_gui_control. The editor is visible and is working fine but I am not able to make use of the methods like set_text_as_r3table. Whenever I try to run the program I get a runtime error. I tried to analyse the error and came to the conclusion that there is some error while calling the method cl_gui_cfw=>flush.
The sample code of the program is given here. This program uses the class ZCL_ES_GUI_ABAP_EDITOR. The creation of the class is described in the link above. The only change is in the class to be extended i.e. cl_gui_textedit instead of cl_gui_control.
code :
REPORT ZVIP_CONTROL.
CONSTANTS: line_length TYPE i VALUE 256.
TYPES: BEGIN OF mytable_line,
line(line_length) TYPE c,
END OF mytable_line.
DATA: mytable TYPE TABLE OF mytable_line,
textstruct TYPE mytable_line,
g_loaded TYPE c.
DATA: custom_container TYPE REF TO cl_gui_custom_container,
editor TYPE REF TO ZCL_ES_GUI_ABAP_EDITOR,
repid LIKE sy-repid.
START-OF-SELECTION.
SET SCREEN '100'.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
IF editor IS INITIAL.
repid = sy-repid.
CREATE OBJECT custom_container
EXPORTING
container_name = 'MYCONTAINER1'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
CREATE OBJECT editor
EXPORTING
parent = custom_container
wordwrap_mode = ZCL_ES_GUI_ABAP_EDITOR=>wordwrap_at_fixed_position
wordwrap_position = line_length
wordwrap_to_linebreak_mode = ZCL_ES_GUI_ABAP_EDITOR=>true.
ENDIF. "editor is initial
DO 20 TIMES.
WRITE text-001 TO textstruct-line.
APPEND textstruct TO mytable.
ENDDO.
perform load_tab.
endmodule.
FORM load_tab .
CALL METHOD editor->set_text_as_r3table
EXPORTING
table = mytable
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = repid
txt2 = ' '
txt1 = 'Error in set_text_as_r3table'(600).
ELSE.
g_loaded = 'X'.
ENDIF.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = repid
txt2 = sy-subrc
txt1 = 'Form LOAD_TAB: Error in FLUSH'(601).
ENDIF.
ENDFORM.
Creation of screen:
create the screen with the following attributes:
Screen type: Normal
Next screen: 100
2. Edit the layout of your screen in the Screen Painter and mark an area for your custom
control.
If you use the alphanumeric mode of the Screen Painter, follow these steps:
a. Place your cursor on a line of the screen and choose Edit Create element Custom
control.
b. To select the bottom right corner of the area, you can either double-click the
corresponding line and column, or choose the Mark end of ctrl pushbutton. The system
displays a dialog box for the element attributes.
c. Enter the name MYCONTAINER1 and copy your settings.
If you use the graphical mode of the Screen Painter, follow these steps:
a. Choose the custom control icon (which you can recognize by the letter 'C') and mark an
area on the screen.
b. Enter the name MYCONTAINER1 in the Name field. You can also define the name on the attributes dialog box that is displayed when you double-click the element you have created.
This gives a runtime error. Please help achieve the desired functionality
I guess I am also not sure why at this point you would want to continue to add functionality to this demo application. The editor shipped last summer for 6.20 and 6.40. If your systems support package level is fairly up to date then you already have the new editor. From SE80 check the menu Utilities->Settings, then the ABAP Editor Tab. If you have the Front-End Editor (New) option in the Editor tab then you are good to go.
Dear Thomas,
thanks for this great post. First of all I would like to tell you that I am a big fan of you and your big big technical knowledge of so many different areas of SAP.
I am currently working on a project which makes intensive use of the SAP Formula Builder (Package: S_FORMULA_BUILDER and Programs SFBE_EXAMPLE1 - 8 if you don't know it) . We already used the great enhancement possibilities there and got it to work for our application perfectly.
Since the project has grown a lot and many many custom functions have been implemented by us the users would like to have a better an faster user experience when using the formula editor.
So we came across the Idea of using the New ABAP Editor with its auto completion capabilities which would be absolutely awesome: Building Formulas with context sensitive auto completion (STRG+Space) with only matching parameters!
We already built a prototype which "kind of works" but we soon came across some problems:
What works currently:
We subclassed CL_GUI_SOURCEEDIT and created event handlers for the events COMPLETION INSERT_PATTERN QUICK_INFO of class CL_GUI_SOURCEEDIT.
If we use Source Type ABAP (Method SET_SOURCE_TYPE) we are able to establish connection between the control and the STRG+space command --> the dispatching of the event_completion is called by the control and we can handle the code completion.
Awesome!
The problem is:
Syntax of ABAP and the formula builder is completely different. For example:
If we use a formula function which has more then 1 parameter they are separated by comma. Code completion should be invokable for each parameter. but this does not work.
For example:
CONCATENETE( <Strg+space:works>, <Strg+space:does not work> )
we figured out that there is a lexer working on the frontend which controls whether current cursor position should make a call to backend on strg+space or not. The frontend already understands the ABAP syntax with its lexer. The lexer itself ist defined within ABAP Editor file: abap_spec.xml
<LexerDll>sapab4lex.dll</LexerDll>
So if we create our own code specification file for the formula builder form_spec.xml and remove the lexer and we set the source type to 'FORM' we are able to influence the syntax highlighting, the code language statements and so on but unfortunately the backend communication for code completion does not work anymore 🙁
Maybe you can help us with this problem.
Do you know if it is possible to establish somehow the backend communication without a lecture working on the frontend control?
Or is it even possible to define a custom lexer which could understand formula syntax (which of course is a lot simpler than ABAP language)?
If you or any other SAP Tech guru could help us with this problem we would like to implement a new UI Add-on for the SAP Formula Builder with an intelligent code completion editor. We would provide the development objects to SAP that you and all SAP customers could benefit from this addon.
Of course we would build it so flexible and generic that it works for SAPs standard Formula builder out of the box with all builtins functions but having enhancement capabilities in mind with BADIs that we can extend it for our project.
Would be really nice to enhance the formula builder with this great feature 😉
Regards
Thorsten
Of course this blog is more than 11 years old. A lot has changed in that time. For ABAP developers both SAPGUI and SE80 have been replaced by ABAP Development Tools in Eclipse. So I wouldn't really recommend building anything based upon the ABAP Editor control in the SAPGUI. You would be building upon something that now is essentially obsolete and that even when new and being development wasn't intended for anyone to extend for other means.