Skip to Content
Author's profile photo Joris Bots

How to get the new ABAP editor in LSMW

Update: I have a second blog about this subject: A second way to get the new ABAP editor in LSMW. This second blog describes a more complex but more flexible solution with even less limitations. The method in the current blog is still valid as it is easier to implement. 

SAP LSM Workbench (LSMW) has for years been a much used tool for data migration into SAP. It is both loved and hated 🙂 While LSMW has had its last update in 2004 it remains a much used tool in this age of more modern toolsets such as SLTSAP DS and the like.

For many frequent and hard core users of LSMW a big nuisance is the old style ABAP editor. This old editor takes up alot of development time, especially in those ABAP-rich LSMW projects.

One night, bored and out of beer, I managed to develop a relatively simple enhancement that enables the new ABAP editor for LSMW.

(Mangled code completion context list is thanks to Windows 10 & a 3K screen)

 Compare that with what you have been working with for the last decades:

Features

  • New ABAP editor for all ABAP coding within LSMW (field mappings, events, user defined routines and form routines)
  • Code completion
  • Use of the Pretty printer
  • Use of the ABAP Syntax checker
  • Use of ABAP patterns
  • No Modification required, just a single implicit enhancement spot
  • Fix of a small LSMW bug where the wrong line is highlighted when doing a syntax check in the __GLOBAL DATA__

Limitations

  • Code completion is not aware of globally defined variables
  • A few, more exotic, editor menu commands are not working and will return ‘Function not implemented’
  • The use of Edit–>Find/Replace issues warning and will eventually cause a short dump (but who needs this function eh?)

The enhancement

The implementation of the new ABAP editor takes just one single Implicit enhancement spot. No modification or any other unwanted hacking! It has been tested on an ECC 606 system with LSMW version 4.0.0 (2004) and SAP Basis 731/02.
Update: Also tested on a brand new ERP 740 SP12 on a 742 kernel with HANA DB underneath.

  1. Create an Implicit enhancement spot (how-to) at the start of Subroutine EDITOR_START of Function group /SAPDMC/LSMW_AUX_080

  2. Paste in the code attached to this post & activate.
  3. 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.
  4. Temporary solution to prevent lines > 72 char getting chopped off (as reported by Cyrus below):
    – Open SE80 and go to Utilities –> settings
    – Check the flag ‘Downwards-Comp. Line Lngth(72)’ and save.

    This will draw a thin red line at position 72 in the editor and will auto-fit lines when they go over 72 chars. This will be a global setting so also your SE38 will now look like this. See my second blog A second way to get the new ABAP editor in LSMW for a permanent solution for this shortcoming.
  5. Start LSMW!


Give it a try and inform me of any bugs. As stated above not all user commands work. All the important ones do and most of the others I have managed to catch and issue a friendly ‘not implemented’ message. Have a look at the second blog A second way to get the new ABAP editor in LSMW if you want to get rid of these limitations.

 

" Joris Bots - Jan. 2016 - info@armadaconsulting.nl
" Posted on http://scn.sap.com
" Enable the new ABAP editor in LSMW
" Using user parameter 'ZLSMW_NEWEDITOR' to enable/disable per user
DATA lv_display_new.
DATA lv_fcode      TYPE sy-ucomm.
DATA lv_linecount  TYPE i.
DATA lv_continue   TYPE c VALUE 'X'.
DATA lv_editorstat TYPE editorstat.
DATA lv_new        TYPE c VALUE 'X'.
DATA lv_offset     TYPE sy-index.
DATA lv_line       TYPE sy-index.
DATA lv_message    TYPE string.
DATA lv_cursor     TYPE char1.
DATA lv_firstline  TYPE num6 VALUE '000001'.
DATA lt_usrpar     TYPE ustyp_t_parameters.
FIELD-SYMBOLS <ls_usrpar> LIKE LINE OF lt_usrpar.

" Check if user parameter 'ZLSMW_NEWEDITOR' = 'X' for this user
" if not, use standard editor
CALL FUNCTION 'SUSR_USER_PARAMETERS_GET'
  EXPORTING
    user_name           = sy-uname
  TABLES
    user_parameters     = lt_usrpar
  EXCEPTIONS
    user_name_not_exist = 1
    OTHERS              = 2.
IF sy-subrc <> 0.
  " Just continue.
ENDIF.

READ TABLE lt_usrpar WITH KEY parid = 'ZLSMW_NEWEDITOR' ASSIGNING <ls_usrpar>.
IF <ls_usrpar> IS ASSIGNED.
  IF <ls_usrpar>-parva = 'X'.

    CASE p_mode.
      WHEN con_mode_change OR con_mode_administrate.
        lv_display_new = no.
      WHEN OTHERS.
        lv_display_new = yes.
    ENDCASE.

	"Inserting ABAP coding with S_DEVELOP authority only
    IF lv_display_new = no.
      AUTHORITY-CHECK OBJECT 'S_DEVELOP'
        ID 'DEVCLASS' DUMMY
        ID 'OBJTYPE'  DUMMY
        ID 'OBJNAME'  DUMMY
        ID 'P_GROUP'  DUMMY
        ID 'ACTVT'    FIELD '02'.
      IF sy-subrc NE 0.
        MESSAGE s003.
        lv_display_new = yes.   " toggle mode
      ENDIF.
    ENDIF.

    WHILE lv_continue = abap_true.
      CALL FUNCTION 'EDITOR_APPLICATION'
        EXPORTING
          anfangszeile       = lv_firstline
          application        = 'OB'         "This triggers new ABAP editor
*         CALLED_BY_SCRP     = ' '
          cursor             = lv_cursor
          display            = lv_display_new
*         DYNPRO_MODIFIED    = ' '
*         FBNAME             = ' '
          line               = lv_line
          message            = lv_message
*         NAME               = ' '
          new                = lv_new
          offset             = lv_offset
          varied             = lv_editorstat-changed  "Send back changed flag after code check
*         TRDIR_INF          = ' '
          title_text         = p_title
*         EXTEND_MOD         = ' '
*         EDITOR_MODE        = ' '
          callback_program   = '/SAPDMC/SAPLLSMW_AUX_080'
          callback_usercom   = 'EDITOR_CALLBACK_USER_COMMAND'
*         callback_set_pfkey = 'EDITOR_CALLBACK_SET_STATUS'
        IMPORTING
          changed            = p_flg_changed
*         DISPLAY            =
          fcode              = lv_fcode
*         PARAMETER          =
*         ANFANGSZEILE_O     =
*         LINE_O             =
*         OFFSET_O           =
        TABLES
          content            = pt_coding
        EXCEPTIONS
          line               = 1
          linenumbers        = 2
          offset             = 3
          OTHERS             = 4.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.

      "Keep changed flag once p_flg_changed is X at one point
      IF p_flg_changed = abap_true.
        lv_editorstat-changed = abap_true.
      ENDIF.

      "Map Editor's user commands to commands LSMW framework understands
      "And prevent editor to show again when we do not want that (when pressing Back)
      CASE lv_fcode.
        WHEN 'OBCH'.
          lv_editorstat-fcode = 'CHCK'.
          lv_cursor = abap_true.
        WHEN 'SBCK'.
          lv_editorstat-fcode = 'BACK'.
          lv_continue = abap_false.
        WHEN 'OBUP'.
          lv_editorstat-fcode = 'OOSV'.
*        lv_continue = abap_false.
        WHEN OTHERS.
          MESSAGE 'Function not implemented' TYPE 'S'.
      ENDCASE.

      "Let LSMW framework handle user commands
      PERFORM editor_callback_user_command
                  TABLES
                     pt_coding
                  USING
                     lv_editorstat.

      "After a check, set the line/offset values and recall the editor
      IF lv_editorstat-fcode = 'CHCK'.
        lv_linecount   = lines( pt_coding ).
        lv_message     = lv_editorstat-message.
        lv_offset      = lv_editorstat-coffset.
        lv_line        = lv_editorstat-cline.
        IF lv_line > lv_linecount.
          "Don't overshoot the actual number of lines of the code (LSMW bug)
          lv_line = 1.
        ENDIF.
        lv_firstline = lv_line - 5. "First visible line number, triggers scroll down
        IF lv_firstline < 1.
          lv_firstline = 1.
        ENDIF.
      ELSE.
        CLEAR: lv_message, lv_line, lv_offset, lv_firstline.
      ENDIF.

      lv_new = abap_false.
    ENDWHILE.
    RETURN. "Do not process the rest of this Form
  ENDIF.
ENDIF.

 

 

Assigned Tags

      5 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Rob Smeets
      Rob Smeets

      That's an amazing idea. Will try this out! It's true, the LSMW editor is it's true achilles heel (love LSMW though 😉 )

      Author's profile photo Former Member
      Former Member

      But be careful, when using Pretty Printer, it will chop off from character position 73 !!!

      (and it already does that in the old editor as well).

      Author's profile photo Joris Bots
      Joris Bots
      Blog Post Author

      Thanks Cyrus, I will look into it.

      Joris

      Author's profile photo Joris Bots
      Joris Bots
      Blog Post Author

      Cyrus,

      I described a temporary work around in the blog until I find time to work out a final solution.
      Thanks.

      Joris

      Author's profile photo Joris Bots
      Joris Bots
      Blog Post Author

      All,

      I have a second blog about the same subject. Among other things, it will solve the 72-char issue Cyrus reported earlier.

      A second way to get the new ABAP editor in LSMW

      Thanks,

      Joris