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: 


Update: Due to the new SCN site all attachments are lost and cannot (at least for now) be attached any more. So, please find the old attachment off-site at http://gofile.me/2GI5l/HtDgFFBI

In my previous blog 'How to get the new ABAP editor in LSMW' I described how a single enhancement enables the new ABAP editor in SAP's LSMW. While that solution only takes one implicit enhancement spot, it has a few (minor) limitations. In this next blog I will describe another approach to enabling the new ABAP editor in LSMW. This new solution is slightly more invasive, but gives us much more flexibility.

The solution


This solution involves an enhancement spot and a new function group with a screen. The big advantage of this solution is that almost all limitations of the first approach are gone. Also you will have full control of the screen and its functions. For this implementation I have added a set of much used LSMW functions directly on the toolbar (as buttons). You are free to add, remove, change those to your liking!



 

Features



  • New ABAP editor for all ABAP coding within LSMW (field mappings, events, user defined routines and form routines)

  • Code completion

  • Pretty printer

  • ABAP Syntax checker

  • Use of LSMW-specific inserts (mapping source fields, global variables, global functions)

  • Use of ABAP statement templates

  • Use of (almost) all new-editor features such as Edit buffers, up- and download of source, etc.

  • Automatic use of 72-character version of the new editor, irrespective of your global setting in SE80
    (Read about the limitation & work around in the previous blog)


 

Limitations



  • Code completion is not aware of globally defined variables.
    (It must be possible to also get rid of this limitation, but that is for the community to pick up. look at CL_ABAP_PARSER for starters.)


Implementation


By far the easiest way to implement is by using SAPlink. This will install the function group, screen and enhancement spot implementation in one go.

The implementation comprises

  • A custom function group ZLSMW_NEW_EDITOR with one function module and one screen

  • An implicit enhancement spot at the start of Subroutine EDITOR_START of Function group /SAPDMC/LSMW_AUX_080

  • (optional) A user parameter to switch the solution on or off per user.


 

I added ample comments in the code, so it is easier to understand what is happening.

 

Implementation using SAPlink


I will assume you have installed- and are familiar with SAPlink.

 

  • Install the .NUGG file attached to this post. It will upload and install the following components

    • Development package ZLSMW

    • Function group ZLSMW_NEW_EDITOR

    • Implicit enhancement spot ZLSMW_NEW_EDITOR @ Subroutine EDITOR_START of Function group /SAPDMC/LSMW_AUX_080



  • Check and activate the new objects. You might need to assign them explicitly to the new package ZLSMW (as they all end up in your $TMP)

  • Manually create User Parameter ZLSMW_NEWEDITOR (how-to, scroll all the way down) and assign the parameter with value 'X' to each user that wants to use the new editor. All other users will not be affected.

  • Done! Start LSMW and check out the new features!


 

 

Manual implementation


Alternatively you can implement it manually;

 

  • Package ZLSMW
    Create a development package ZLSMW. Save and activate.

  • Function group ZLSMW_NEW_EDITOR
    Create function group ZLSMW_NEW_EDITOR and assign it to the newly created package ZLSMW

  • Function module ZCALL_ABAP_EDITORIn the new function group create function module ZCALL_ABAP_EDITOR with the following interface
    IMPORTING
      REFERENCE(IV_EDITMODE) TYPE  CHAR4
    CHANGING
      REFERENCE(CT_SOURCE) TYPE  RSWSOURCET
    For the implementation paste in the FM code from the attached text file code2.txt and save.

     

  • Include LZLSMW_NEW_EDITORTOP
    Create a new include called LZLSMW_NEW_EDITORTOP in the function group and paste in the include code from the attached text file code2.txt. The include holds both the global variables, form routines and PAI/PBO Modules. I know, it is not as it should be done, but it limits the number of includes 😉 If the new PAI and PBO modules etc do not appear in the SE80 tree you need to rebuild the object list. You do this by right clicking on the function group name in the SE80 tree on the left, then go to Other Functions --> Rebuild Object List.

  • Screen 3000
    Create a new screen 3000. Add a custom container called EDITOR over the full size of the canvas and save. In the screens flow logic uncomment the PAI and PBO modules MODULE STATUS_3000 and MODULE USER_COMMAND_3000.

  • Pf-status EDITOR
    Copy pf-status EDITOR from function group /SAPDMC/LSMW_AUX_080 to your new function group. Name it also EDITOR. Next you need to remove a few items from the menu bar. Remove the items in yellow:
    Change the toolbar functions such that it resembles below screenshot.


    Optionally you can change the function keys to your liking.

  • Enhancement spot
    Create an Implicit enhancement spot (how-to) at the start of Subroutine EDITOR_START of Function group /SAPDMC/LSMW_AUX_080. Paste in the enhancement code from file code2.txt attached to this post & activate.

  • User Parameter
    Create a user parameter ZLSMW_NEWEDITOR  in SE80 (how-to scroll all the way down). Assign the parameter with value 'X' to each user that wants to use the new editor. All other users will not be affected. This is optional. If you want all users to use the new editor, omit this step and remove the check in the enhancement spot implementation.

  • Done! Activate all and start LSMW.


 

Enjoy! Please let me know of any bugs or shortcomings.
Feel free to add to or enhance this solution. Particularly the small limitation in the code completion might be a useful addition.

Update: Due to the new SCN site all attachments are lost and cannot (at least for now) be attached any more. So, please find the old attachment off-site at http://gofile.me/2GI5l/HtDgFFBI

6 Comments