04-05-2018 4:30 PM
All,
I have a requirement wherein, there is a need to create custom long text fields in screen exits. I was able to get the pointers from few SDN posts in that regards and was able to successfully create that field. Another challenge is that the users are now asking for the Text Editor button which will take them to SAP Script kind of editor. I am not sure how to code for that or what steps to be taken. Appreciate if someone can help me. I am putting the current code which works for a regular long text field and also the screen shot for what exactly i am looking to get.
DATA:gv_line_length TYPE i VALUE 132,
gv_editor_container TYPE REF TO cl_gui_custom_container,
gv_text_editor TYPE REF TO cl_gui_textedit.
CONSTANTS ytrue TYPE i VALUE 1.
IF gv_text_editor IS INITIAL.
CREATE OBJECT gv_editor_container
EXPORTING
container_name = 'TEXTEDITOR' "Editor name
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
CREATE OBJECT gv_text_editor
EXPORTING
parent = gv_editor_container
wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position = gv_line_length
wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
CALL METHOD gv_text_editor->set_toolbar_mode
EXPORTING
toolbar_mode = cl_gui_textedit=>false.
CALL METHOD gv_text_editor->set_statusbar_mode
EXPORTING
statusbar_mode = cl_gui_textedit=>false.
ENDIF.
IF gv_text_editor IS NOT INITIAL.
IF sy-tcode = 'QM03'.
CALL METHOD gv_text_editor->set_readonly_mode
EXPORTING
readonly_mode = ytrue.
ENDIF.
ENDIF.
04-12-2018 1:43 PM
04-12-2018 10:18 PM
04-12-2018 10:25 PM
Hi,
SAPscript: Edit text in the text editor
This function module is used to call the fullscreen editor. The lines of text can be edited with the functions available there. The editor interface is set according to the interface assigned to the text object.
When you exit the editor, the function module SAVE_TEXT is generally called implicitly with the function 'Save' or 'Flag', as long as the text is saved in the text file according to the text object set. This call can be deactivated via the parameter SAVE.
and there is one more FM TERM_CONTROL_EDIT
thanks!!
04-13-2018 8:46 AM
No, there will be a solution for sure!
But this word editor is not a must one! so if you can, convince them.
As if you google this requirement you can find only enabling it for the Smartforms and the SAP script only.
Else wait for the experts solution.
04-13-2018 9:56 AM
Create a custom Screen and use an ALV-Container.
Using CL_GUI_TEXTEDITOR and its Methods you can prepare for the Visualization of the Screen ...
Then, just call the screen ...
Below is a sample that should work more or less :
"LongText Data in TextEditor ...
CREATE OBJECT txteditor "CL_GUI_TEXTEDITOR
EXPORTING
wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position = 132
wordwrap_to_linebreak_mode = cl_gui_textedit=>false
parent = lr_container_txt "CL_GUI_CONTAINER
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
gui_type_not_supported = 5
OTHERS = 6.
IF sy-subrc <> 0.
"Do Excp.Handling
ENDIF.
txteditor->set_text_as_stream(
EXPORTING
text = longtexttab "TDLINE-TABLE
EXCEPTIONS
error_dp = 1
error_dp_create = 2
OTHERS = 3 ).
IF sy-subrc <> 0.
"Do Excp.Handling
ENDIF.
txteditor->set_toolbar_mode(
EXPORTING
toolbar_mode = 0 "No Toolbar
EXCEPTIONS
error_cntl_call_method = 1
invalid_parameter = 2
OTHERS = 3 ).
IF sy-subrc <> 0.
"Do Excp.Handling
ENDIF.
"Possibly Update StatusBar Text ...
txteditor->set_status_text(
EXPORTING
status_text = lv_status_txt
EXCEPTIONS
error_cntl_call_method = 1
OTHERS = 2 ).
IF sy-subrc <> 0.
"Do Excp.Handling
ENDIF.
"Call your Custom Screen
CALL SCREEN 1001.
PROCESS BEFORE OUTPUT.
MODULE status_1001.
MODULE status_1001 OUTPUT.
SET PF-STATUS 'ZSTATUS'.
SET TITLEBAR 'ZTITLE' WITH text-t01.
txteditor->set_readonly_mode(
EXPORTING
readonly_mode = cl_gui_textedit=>true "ReadOnly
EXCEPTIONS
error_cntl_call_method = 1
invalid_parameter = 2
OTHERS = 3 ).
IF sy-subrc <> 0.
"Do Excp.Handling
RETURN.
ENDIF.
ENDMODULE.
Hope this helps
Nic T.
04-19-2018 9:46 PM
Thanks Nic for your response.
I actually forgot to mention that, this change is required in QM01/02/03 transaction.
We need to create a new custom tab, add a custom subscreen and within this subscreen create text editor. Now the issue is, user enters text into this editor and may go to another tab or hit Save. At that point of time, the reference of the user exit is gone and i dont see the text inserted any where.
I am trying to SAVE the text in SAVE user exit but the table is empty.