Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
arnabdatta3
Participant
Hi folks,

I know SM30 is very old and not relevant anymore. But from SAP functional person perspective, it is very useful and important tool. Sometime scenario comes that we need to store more than 255-characters text in table and want to maintain it from SM30 as it is very easy and quick to develop. But SAP only allows 255 characters to save and display in table maintenance.

While solving this I thought that I will add a button to SM30 and clicking on that button will display a text edit box in which user can enter the text up to 1000 characters or more.

****** GitHub repo: https://github.com/arnabdatta/abap-sm30-text-input/ **********

Lets create a table SM30_DEMO


Once you generate the table maintenance, you will get a warning message like this.


Now let's begin the solution.

Double click on the screen number to open the screen painter. Then click on "Layout" button on the toolbar.

In screen painter take the button and draw it at the end of the table.me it "Edit Text"

Save and activate it, go back to flow logic and go to "Element List" tab.

Click on attributes icon at the top to open and give the icon and function code as shown.


 

In the flow logic add one module in the end and double click to create it.
PROCESS BEFORE OUTPUT.
MODULE LISTE_INITIALISIEREN.
LOOP AT EXTRACT WITH CONTROL
TCTRL_ZSM30_DEMO CURSOR NEXTLINE.
MODULE LISTE_SHOW_LISTE.
ENDLOOP.
*
PROCESS AFTER INPUT.
MODULE LISTE_EXIT_COMMAND AT EXIT-COMMAND.
MODULE LISTE_BEFORE_LOOP.
LOOP AT EXTRACT.
MODULE LISTE_INIT_WORKAREA.
CHAIN.
FIELD ZSM30_DEMO-VALUE .
FIELD ZSM30_DEMO-TEXT .
MODULE SET_UPDATE_FLAG ON CHAIN-REQUEST.
ENDCHAIN.
FIELD VIM_MARKED MODULE LISTE_MARK_CHECKBOX.
CHAIN.
FIELD ZSM30_DEMO-VALUE .
MODULE LISTE_UPDATE_LISTE.
ENDCHAIN.
ENDLOOP.
MODULE LISTE_AFTER_LOOP.
MODULE BTN_EDIT_TEXT. " <====== Add here

Write the below code in the module.
*&---------------------------------------------------------------------*
*& Module BTN_EDIT_TEXT INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE btn_edit_text INPUT.
TYPES BEGIN OF lty_tab.
INCLUDE STRUCTURE zsm30_demo. " Incident Sub types
INCLUDE STRUCTURE vimtbflags. " Flag structure for view maint. tool: Flags for tables
TYPES END OF lty_tab.

DATA: lt_tab TYPE STANDARD TABLE OF lty_tab,
ls_tab TYPE lty_tab.

DATA: lv_line TYPE i, " Line of type Integers
lt_text TYPE catsxt_longtext_itab, " Text editor text line
ls_line_struc TYPE lty_tab,
lv_old_text TYPE text1000, " Explanation
lv_changed_text TYPE text1000. " Explanation

FIELD-SYMBOLS: <fs_line_struc> TYPE lty_tab, " Incident Sub types
<fs_explaination> TYPE any.

CASE function.
WHEN 'EDIT_TXT'.

GET CURSOR LINE lv_line.

LOOP AT extract .
IF sy-tabix EQ lv_line.
ASSIGN extract TO <fs_line_struc> CASTING.
EXIT.
ENDIF. " IF sy-tabix EQ lv_line
ENDLOOP. " LOOP AT extract

ls_line_struc = <fs_line_struc>.

lv_old_text = <fs_line_struc>-text.

CLEAR lt_text.
CALL FUNCTION 'RKD_WORD_WRAP'
EXPORTING
textline = <fs_line_struc>-text
outputlen = 72
TABLES
out_lines = lt_text
EXCEPTIONS
outputlen_too_large = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF. " IF sy-subrc <> 0


CALL FUNCTION 'CATSXT_SIMPLE_TEXT_EDITOR'
EXPORTING
im_title = 'Explanation Text'
CHANGING
ch_text = lt_text.

CLEAR lv_changed_text.
LOOP AT lt_text INTO DATA(ls_text).
CONCATENATE lv_changed_text ls_text INTO lv_changed_text SEPARATED BY space.
ENDLOOP. " LOOP AT lt_text INTO DATA(ls_text)

CONDENSE lv_changed_text.

IF lv_old_text NE lv_changed_text.
<fs_line_struc>-text = lv_changed_text.
<fs_line_struc>-vim_action = aendern.

MODIFY extract INDEX lv_line.
<status>-upd_flag = 'X'.
total[] = extract[].
ENDIF. " IF lv_old_text NE lv_changed_text

ENDCASE.
ENDMODULE.

 

Now you have fully functional Sm30 with a popup taking more than 255 characters. The last touch , you can also make the text field read only so that user will only use the popup to enter the long text.

Demo:


 

Hope this helps! Let me know in your comments any improvement I can do to this.

 

To know more about SM30 events and variables please check the SAP Help site.

Extended Table Maintenance Events | SAP Help Portal

Happy coding!! 🙂
17 Comments
Labels in this area