
" 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
3 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |