‎2008 Dec 15 4:45 AM
hi all ,
i doin one task in that i need to display text editor in module pool and using push-button i need to enter some values into text editor and i need to change the text editor only for read only . pls let me how to display text editor and how to enter some values in text editor and make it read only . thanks
‎2008 Dec 15 4:51 AM
‎2008 Dec 15 4:59 AM
hi
have a look at this document
it would definitely help you out
regards
Aakash Banga
‎2008 Dec 15 5:06 AM
Hi
u have to create first text object like:
DATA textobj LIKE thead-tdobject.
DATA textid LIKE thead-tdid.
DATA: BEGIN OF i_header OCCURS 0.
INCLUDE STRUCTURE thead.
DATA: END OF i_header.
DATA : BEGIN OF i_lines OCCURS 0.
INCLUDE STRUCTURE thead.
DATA : END OF i_lines.
DATA: BEGIN OF nheader OCCURS 0.
INCLUDE STRUCTURE thead.
DATA: END OF nheader.
DATA : li_lines TYPE STANDARD TABLE OF tline WITH HEADER LINE.
TYPES: BEGIN OF x_texttable,
line_length(132) TYPE c,
END OF x_texttable.
DATA : it_remark TYPE TABLE OF x_texttable,
wa_remark TYPE x_texttable.
textobj = 'BUT000'.
textid = '0001'.
PERFORM read_text USING textobj textid .
*********************Call this perform for reading text
FORM read_text USING p_textobj
p_textid.
DATA etrdm type c.
DATA erlins TYPE i.
DATA : li_lines TYPE STANDARD TABLE OF tline WITH HEADER LINE.
data : wa_lines type tline.
DATA ltdname type thead-tdname.
REFRESH : i_header, i_lines, nheader.
CLEAR: i_header, i_lines, nheader.
ltdname = zlcr-lc_req_num.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = p_textid
language = 'E'
name = ltdname
object = p_textobj
ARCHIVE_HANDLE = 0
IMPORTING
header = i_header
TABLES
lines = li_lines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
CLEAR : it_remark,
wa_remark,
li_lines.
LOOP AT li_lines ."into wa_lines.
wa_remark-line_length = li_lines-tdline.
*wa_remark-line_length = wa_lines-tdline.
APPEND wa_remark TO it_remark.
CLEAR : wa_remark,
li_lines.
ENDLOOP.
ENDFORM. " read_text
/**********Then u have to create screen. In which u have to add custom control.
CALL SCREEN 201 STARTING AT 15 5 ENDING AT 100 40.
ROCESS BEFORE OUTPUT.
MODULE status_0201.
*
PROCESS AFTER INPUT.
MODULE user_command_0201.
MODULE status_0201 OUTPUT.
DATA : l_var TYPE i.
In PBO for 201 u have to create container
SET TITLEBAR 'xxx'.
PERFORM create_container.
IF NOT it_remark IS INITIAL.
PERFORM get_text_to_container.
ENDIF.
IF NOT v_flag IS INITIAL.
l_var = 1.
SET PF-STATUS '201' EXCLUDING 'SAVE'.
ELSE.
l_var = 0.
SET PF-STATUS '201'.
ENDIF.
CALL METHOD editor1->set_readonly_mode
EXPORTING
readonly_mode = l_var
EXCEPTIONS
error_cntl_call_method = 1
invalid_parameter = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDMODULE. " STATUS_0201 OUTPUT
MODULE user_command_0201 INPUT.
CASE ok_201.
WHEN 'SAVE'.
PERFORM cntrl_text_into_it_tab.
LEAVE SCREEN.
WHEN 'EXIT' OR 'BACK' OR 'CANCEL'.
LEAVE SCREEN.
ENDCASE.
ENDMODULE. " user_command_0201 INPU
to set that editor in read only mode. assign 1 to l_var.
‎2008 Dec 15 5:18 AM
I guess this will resolve your problem
IF g_splitter IS INITIAL.
CREATE OBJECT g_text_cont
EXPORTING
container_name = 'TEXT_CONTAINER'.
CREATE OBJECT g_splitter
EXPORTING
parent = g_text_cont
orientation = 1
sash_position = 30.
ENDIF.
IF g_text_editor IS INITIAL.
create text_edit control
take control container from splitter_control
CREATE OBJECT g_text_editor
EXPORTING
parent = g_splitter->bottom_right_container
wordwrap_mode = cl_gui_textedit=>wordwrap_at_windowborder
wordwrap_to_linebreak_mode = cl_gui_textedit=>false
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
gui_type_not_supported = 5.
CALL METHOD g_text_editor->set_readonly_mode
EXPORTING
readonly_mode = c_readonly.
ENDIF.
IF g_tree IS INITIAL.
wa_tree_header-heading = 'Header Texts'(t13).
wa_tree_header-width = 30.
CREATE OBJECT g_tree
EXPORTING
parent = g_splitter->top_left_container
node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
item_selection = c_x
hierarchy_column_name = 'Column1'(t14)
hierarchy_header = wa_tree_header
EXCEPTIONS
cntl_system_error = 1
create_error = 2
failed = 3
illegal_node_selection_mode = 4
illegal_column_name = 5
lifetime_error = 6.
wa_events-eventid = cl_gui_column_tree=>eventid_node_double_click.
wa_events-appl_event = c_x.
APPEND wa_events TO i_events.
wa_events-eventid = cl_gui_column_tree=>eventid_item_double_click.
wa_events-appl_event = c_x.
APPEND wa_events TO i_events.
CALL METHOD g_tree->set_registered_events
EXPORTING
events = i_events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3
OTHERS = 4.
CLEAR wa_node.
CLEAR wa_item.
wa_node-node_key = 'Z001'.
CLEAR wa_node-relatkey.
CLEAR wa_node-relatship.
wa_node-hidden = ' '.
wa_node-disabled = ' '.
CLEAR wa_node-expander.
wa_node-isfolder = ' '.
wa_node-n_image = '@0O@'.
wa_node-exp_image = '@0O@'.
APPEND wa_node TO i_node_table.
wa_item-node_key = 'Z001'.
wa_item-item_name = 'Column1'(t14).
wa_item-class = cl_gui_column_tree=>item_class_text.
wa_item-text = 'Count Comments'(t15).
APPEND wa_item TO i_item_table.
CALL METHOD g_tree->add_nodes_and_items
EXPORTING
node_table = i_node_table
item_table = i_item_table
item_table_structure_name = c_tree_structure
EXCEPTIONS
failed = 1
cntl_system_error = 2
error_in_tables = 3
dp_error = 4
table_structure_name_not_found = 5
OTHERS = 6.
CALL METHOD g_tree->expand_root_nodes
EXPORTING
level_count = 0
expand_subtree = c_x
EXCEPTIONS
failed = 1
illegal_level_count = 2
cntl_system_error = 3
OTHERS = 4.
ENDIF.
IF NOT i_tlines IS INITIAL.
CALL METHOD g_tree->node_set_n_image
EXPORTING
node_key = 'Z001'
n_image = '@0Q@'
EXCEPTIONS
failed = 1
node_not_found = 2
cntl_system_error = 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.
ELSE.
CALL METHOD g_tree->node_set_n_image
EXPORTING
node_key = 'Z001'
n_image = '@0O@'
EXCEPTIONS
failed = 1
node_not_found = 2
cntl_system_error = 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.
ENDIF.
CALL FUNCTION 'CONVERT_ITF_TO_STREAM_TEXT'
TABLES
itf_text = i_tlines
text_stream = i_editor_text.
CALL METHOD g_text_editor->set_text_as_stream
EXPORTING
text = i_editor_text
EXCEPTIONS
error_dp = 1
error_dp_create = 2
OTHERS = 3.
MOVE i_tlines TO i_tlines_temp.
**************
CALL METHOD g_text_editor->get_text_as_stream
IMPORTING
text = i_editor_text
is_modified = g_xthead_update
EXCEPTIONS
error_dp = 1
error_cntl_call_method = 2
OTHERS = 3.
IF NOT i_editor_text IS INITIAL.
CALL FUNCTION 'CONVERT_STREAM_TO_ITF_TEXT'
TABLES
text_stream = i_editor_text
itf_text = i_tlines.
ENDIF. " IF NOT i_editor_text
I guess this will resolve your problem
‎2008 Dec 15 5:54 AM
Hi,
Hope this code helps you out....
In Top Include:
Data declarations for custom controls.
DATA : ob_editor TYPE REF TO cl_gui_textedit, " Text editor
ob_container_comments TYPE REF TO cl_gui_custom_container. " Custom Container
DATA: it_text TYPE STANDARD TABLE OF line.
On the layout of the screen:
Create custom control (Container) with name CC_TEXTEDITOR on your screen
In PBO Module:
Create a text editor for description
IF ob_container_comments IS INITIAL.
CREATE OBJECT ob_container_comments
EXPORTING
container_name = c_editor. " 'CC_TEXTEDITOR'
IF sy-subrc EQ 0.
CREATE OBJECT ob_editor
EXPORTING
parent = ob_container_comments.
ENDIF.
ENDIF.
CALL METHOD ob_editor->set_enable
EXPORTING
enable = '1'.
IF v_activity = c_dis_03 " Display
METHOD to make the text editor Readonly
CALL METHOD ob_editor->set_readonly_mode
EXPORTING
readonly_mode = 1
EXCEPTIONS
error_cntl_call_method = 1
invalid_parameter = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ELSEIF v_activity = c_create_01 " Create
OR v_activity = c_change_02. " Change
CALL METHOD ob_editor->set_readonly_mode
EXPORTING
readonly_mode = 0
EXCEPTIONS
error_cntl_call_method = 1
invalid_parameter = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
Fill the data to be displayed in the atble IT_TEXT and then display the same in PBO
Display the text into the text editor created on the screen
CHECK NOT it_text IS INITIAL.
CALL METHOD ob_editor->set_text_as_stream
EXPORTING
text = it_text.
IN PAI Module:
Declaration of local variables
DATA: v_cur_strlen TYPE i, " Current string length
v_line TYPE string, " Line of Legal Description
wa_text TYPE line. " Work area for Line text
REFRESH it_text.
CLEAR: wa_ci_data-zz_legal,
v_line,
v_strlen,
v_cur_strlen.
Check for the activity type as L2PL
IF ( v_activity = c_create_01 " Create
OR v_activity = c_change_02 ). " Change
Call method to get the data into the internal table.
CALL METHOD ob_editor->get_text_as_stream
IMPORTING
text = it_text.
Check the length of the legal description entered
and display ane error message
LOOP AT it_text INTO wa_text.
MOVE wa_text-line TO v_line.
v_strlen = STRLEN( v_line ).
v_cur_strlen = v_strlen + v_cur_strlen.
ENDLOOP.
IF v_cur_strlen GT 255.
MESSAGE text-005 TYPE 'E'.
" Legal description is greater than 255 characters
ENDIF.
Loop at internal table and concatenate the data
LOOP AT it_text INTO wa_text.
CONCATENATE wa_ci_data-zz_legal wa_text INTO wa_ci_data-zz_legal (Screen fields)
SEPARATED BY space.
ENDLOOP.
Condense to remove spaces.
CONDENSE wa_ci_data-zz_legal.
ENDIF.
Regards,
Lavanya.
‎2008 Dec 15 11:00 AM
hi lavanya ..
thanks for sending the code ..
one more doudt
what is c_disp_o3 , c_create_02 and c_change_02 . please let me know .thanks
‎2008 Dec 22 11:08 AM
Hi,
Sorry for the delay, please find the info on the constants I have used:
c_dis_03 = '03'. " Display
c_create_01 = '01'. " Create
c_change_02 = '02'. " Change
Let me know if anything else is required and hope the solution I have provided helped you.
Regards,
Lavanya.
‎2008 Dec 15 6:19 AM
Hi,
Just use:
DATA:objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
EDITOR-CALL FOR objtxt.
In case you want in 'protect mode' or 'display mode' then use
EDITOR-CALL FOR objtxt DISPLAY-MODE.
I hope this helps,
Regards
Raju Chitale