Skip to Content

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.

!https://weblogs.sdn.sap.com/weblogs/images/1918/EditorObject_In_VS.jpg|height=325|alt=image|width=593|src=https://weblogs.sdn.sap.com/weblogs/images/1918/EditorObject_In_VS.jpg|border=0!

image

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.

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.

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.

!https://weblogs.sdn.sap.com/weblogs/images/1918/NewEditorOutput.jpg|height=395|alt=image|width=406|src=https://weblogs.sdn.sap.com/weblogs/images/1918/NewEditorOutput.jpg|border=0

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.

!https://weblogs.sdn.sap.com/weblogs/images/1918/NewEditorInsertMethod.jpg|height=159|alt=image|width=392|src=https://weblogs.sdn.sap.com/weblogs/images/1918/NewEditorInsertMethod.jpg|border=0!

image

       

I even edited the template definition to create my own custom report header.

!https://weblogs.sdn.sap.com/weblogs/images/1918/NewEditorOptions.jpg|height=345|alt=image|width=534|src=https://weblogs.sdn.sap.com/weblogs/images/1918/NewEditorOptions.jpg|border=0!

!https://weblogs.sdn.sap.com/weblogs/images/1918/NewEditorOptionsInAction.jpg|height=188|alt=image|width=372|src=https://weblogs.sdn.sap.com/weblogs/images/1918/NewEditorOptionsInAction.jpg|border=0!

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.

Code Download

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.

!https://weblogs.sdn.sap.com/weblogs/images/1918/QuickInfo.jpg|height=207|alt=image|width=509|src=https://weblogs.sdn.sap.com/weblogs/images/1918/QuickInfo.jpg|border=0!

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.

To report this post you need to login first.

67 Comments

You must be Logged on to comment or reply to a post.

  1. Thomas Jung
    I should have mentioned it in WebLog, put you probably actually want patch 11, not 10. This has nothing to do with the ABAP editor itself.  According to some threads on the SAPGui forum, patch 10 had some nasty bugs, so SAP moved up the release date of 11 (See OSS note 855320).  I am actually running Patch 11 on my system.  

    (0) 
  2. Thomas Jung
    Hit enter a few times to create some blank lines.  It is probably something we are initializing correctly, but this seems to take care of the problem.
    (0) 
  3. Anonymous
    Hi,

    How did you manage to save (export) your code to an external file? Everything else I could do, on a 4.6C.

    Thank you

    (0) 
    1. Thomas Jung
      I went into the customizing options menu under KEYBOARD. I then assigned a new keyboard short cut to that command.  You should see the commands for exporting to PDF, HTML, etc in the list.  By default they don’t have short cuts.
      (0) 
  4. Ajay Das
    Even though I may not try it, cannot help but highly appreciate your approach. Can imagine you smiling ear-to-ear when you first figured this out!

    Very interesting, indeed!

    (0) 
  5. Lars Wilhelmsen
    Having a problem with this code:

           CREATE OBJECT custom_container
        EXPORTING
          container_name              = ‘CUSTOM_CONTAINER’.

    Where/how should I define the custom_container?

    regards,

    Lars Wilhelmsen

    (0) 
    1. Thomas Jung
      I didn’t share the code for most of the dialog program, because there really isn’t anything out of the ordinary there.

      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.

      (0) 
  6. Stefan Wagner
    still waiting for the abap-editor to give code hints regarding object methods and attributes. Do you think those might come some day ?

    Regards,
    Stefan

    (0) 
  7. Satyabrata Basu
    Hi Thomas,

    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.

    (0) 
    1. Thomas Jung
      I have a downloadable code sample that includes all the data declarations that is still pending approval in SDN.  Just as soon as it is approved I will add it here.  It should have everything you need.

      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.

      (0) 
      1. Satyabrata Basu
        Thomas,
        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 !!

        (0) 
        1. Thomas Jung

          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:

          (0) 
          1. Satyabrata Basu

            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/>

            (0) 
            1. Thomas Jung
              That seems a little strange that you had to split the CR_LF.  You might try CL_ABAP_CHAR_UTILITIES=>NEWLINE instead.

              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.

              (0) 
  8. Anonymous
    Great work Thomas !
    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
    (0) 
    1. Thomas Jung
      It sounds like you are looking in the area where you can order the SAPGui on CD/DVD.

      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

      (0) 
      1. Sanjay Badhai
        Hi Thomas,

        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

        (0) 
  9. Alexander Häußler
    Hello,

    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

    (0) 
    1. Thomas Jung
      I find that such a process usually involves cut-and-paste 🙂

      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.

      (0) 
        1. Satyabrata Basu
          indeed…I also could not edit the “public section” of my class in WAS 620.
          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 !!
          (0) 
          1. Thomas Jung
            I’m afraid that I don’t have a 620 system to try it out on, but I do remember having more flexibility for direct defintion and input of classes once we upgraded to 640 (I just couldn’t remember exactly what).  Unfortuntely that probably means typing in the definitions manually.

            The other route is that you could create the whole class as a local class in an include.  I really prefer global classes however.

            (0) 
            1. Radim Stefek
              Can you please tell me, how can I make this public definitions for ‘TYPES’ through CLASS BUILDER?

              Or how can I use the way with local classes in module?

              THX

              (0) 
              1. Thomas Jung
                > how can I make this public definitions for ‘TYPES’ through CLASS BUILDER

                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.

                (0) 
                1. Radim Stefek
                  Oh, sorry for my bad meaning question.

                  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.

                  (0) 
                  1. Thomas Jung
                    If you are on 640 this is quite simple.  You have a TYPES tab in the Global Class Builder.  That is where you can degifine these public types.  Of course you could always define them as table types and data elements in the data dictionary as well.
                    (0) 
  10. flavio ciotola
    Hi Thomas,

    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

    (0) 
    1. Thomas Jung
      The main problem with the example program working with 46C is that the editor control in the SAPGui expects the program coding to be in Unicode (UTF-16le) format.  You can still try out the example program, you just won’t be able to load existing source code into the editor. 

      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.

      (0) 
  11. jiang cj
    Hi Thomas,
    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.
    (0) 
    1. Thomas Jung
      I saw that early on as I was first programming the wrapper class.  I had the name of the program ID wrong in the constructor.  Make sure it is:
          prog_id = ‘SAPGUI.AbapEditor.1’.

      The program ID for the old old editor is similar and I had grabbed the wrong one.

      (0) 
    1. Thomas Jung
      That type definition should be coming from the type group SEOO.  This type group along with CNDP, CNTL, SEOS, and SWBSE should all be listed as forward declarations in on the Properties tab of your class. 

      The Type definition itself is
      types:
      * attribute
        seoo_attribute_r like vseoattrib,

      (0) 
      1. Stephan Marx
        Thanks,

        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

        (0) 
  12. Anonymous
    Hi Thomas,
    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
    (0) 
    1. Thomas Jung
      To export the class I used the program BSP_EXPORT_CLASSES.  Although it has BSP in the name, it can export any class to file.

      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. 

      (0) 
      1. Anonymous
        Hi Thomas,
        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
        (0) 
        1. Thomas Jung
          >Since the Public Section is not directly editable

          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). 

          (0) 
    1. Peter Inotai
      Hi 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

      (0) 
  13. Peter Inotai
    Does anyone checked the AB4 editor with patch 14?

    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

    (0) 
  14. Matthew Billingham
    I’ve got most of the stuff loaded from the zipped file.  Syntax checking I get a mesage saying that the statement “get_value_descr” is not defined.  Simlarly with “replace_all_occurrences”.

    Have I missed something?

    Regards

    matt

    (0) 
  15. Noah SILVA
    This is very nice, but somewhat of a pain to actually install ont he system, due to the manual entry needed in class builder and data dictionary.  (Especially when you have multiple systems).

    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.

    (0) 
    1. Thomas Jung Post author
      I guess why install this test version of the editor on 4.7 now that you can have the real thing.  The Editor has been backported and is avaiable via Support Packages.
      (0) 
  16. Virendra Pathak
    Ihave implemeted the new code editor to extended with node tree, and drag n drop functionality.
    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

    (0) 
    1. Thomas Jung Post author
      The original purpose of this example application was so that people could try out the new editor.  It was never intended to be a full ABAP development environment. 

      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. 

      (0) 
  17. Vipul Agrawal
    This is in reference to the blog
    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

    (0) 
    1. Thomas Jung Post author
      I’m a little confused.  Are you working with Virendra Pathak on the same development?  You seem to both be trying to do the same thing.  My answer is the same you can’t just mix control proxy methods from different controls. They wouldn’t have the same implementation on the frontend libraries – which is why you are getting a control framework error.  You are calling a method on the frontend control that doesn’t exist.

      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.

      (0) 
  18. Thorsten Wolf

    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

    (0) 
    1. Thomas Jung Post author

      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.

      (1) 

Leave a Reply