10-17-2006 3:37 PM
Hi all!
Today i have to do a dynpro with a text field, but i need that the field looks like an editor like notepad, i need a lot of characters in.
How can i declarate this field??
10-17-2006 3:44 PM
Hi,
Try to use STRING. It may resolve u r prob.
If helpful pl reward.
Cheers
10-17-2006 3:39 PM
Hi,
You can declare as type string.
DATA: WA_TEXT TYPE STRING.
Hope this will help.
Regards,
Ferry Lianto
10-17-2006 3:44 PM
Hi,
Try to use STRING. It may resolve u r prob.
If helpful pl reward.
Cheers
10-17-2006 3:45 PM
Hi
You can define it as type tdline which is the standard used for the 'SAVE_TEXT' function modules .
Please check the following link for the same
10-17-2006 3:48 PM
HI Julio,
Check the code below:
&----
<b>*& Include YSW_CIC_CacctL_TOP </b> *
&----
CONSTANTS: line_length TYPE i VALUE 256.
CONSTANTS : c_object LIKE thead-tdobject VALUE 'ZSW_NOTES',
c_objectid LIKE thead-tdid VALUE 'ZCO'.
DATA:
reference to wrapper class of control
g_editor TYPE REF TO cl_gui_textedit,
reference to custom container: necessary to bind TextEdit Control
g_editor_container TYPE REF TO cl_gui_custom_container,
g_repid LIKE sy-repid,
g_ok_code LIKE sy-ucomm, " return code from screen
g_relink TYPE c, " to manage relinking
g_mytable(line_length) TYPE c OCCURS 0,
g_mytable1(line_length) TYPE c OCCURS 0,
wa_table(line_length),
wa_table1(line_length),
g_mycontainer(30) TYPE c, " string for the containers
g_container_linked TYPE i. "#EC NEEDED
" container to which control is linked
necessary to flush the automation queue
CLASS cl_gui_cfw DEFINITION LOAD.
DATA : ws_cacct LIKE thead-tdname.
DATA : ws_cont_acct LIKE thead-tdname.
DATA : ws_thead LIKE thead.
DATA : it_line TYPE STANDARD TABLE OF tline WITH HEADER LINE.
DATA : it_final_line TYPE STANDARD TABLE OF tline WITH HEADER LINE.
DATA : lwa_line TYPE tline .
DATA : ws_lines TYPE i.
DATA : ws_lines1 TYPE i.
DATA : ws_lines2 TYPE i.
DATA : ws_history_line TYPE tline-tdline.
DATA : flg_history_line.
<b>INCLUDE zsw_cic_contract_acct_top.</b>
PARAMETERS : p_cacct LIKE fkkvkp-vkont.
START-OF-SELECTION.
CALL SCREEN 100.
************************************************************************
P B O
************************************************************************
MODULE pbo OUTPUT.
DATA : ws_flg.
IF g_editor IS INITIAL.
set status
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'TITLE-100'.
create control container
CREATE OBJECT g_editor_container
EXPORTING
container_name = 'TEXTEDITOR1'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc NE 0.
add your handling
ENDIF.
g_mycontainer = 'TEXTEDITOR1'.
*Read the Previous Text :
ws_cacct = p_cacct.
ws_cont_acct = p_cacct.
SHIFT ws_cacct LEFT DELETING LEADING '0'.
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = c_objectid
language = sy-langu
name = ws_cont_acct
object = c_object
TABLES
lines = it_line
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
SHIFT ws_Cacct LEFT DELETING LEADING '0'.
LOOP AT it_line INTO lwa_line.
APPEND lwa_line-tdline TO g_mytable.
CLEAR : lwa_line.
ENDLOOP.
IF NOT g_mytable[] IS INITIAL.
DESCRIBE TABLE g_mytable LINES ws_lines.
ELSE.
ws_flg = 'X'.
ENDIF.
APPEND space TO g_mytable.
DESCRIBE TABLE g_mytable LINES ws_lines2.
create calls constructor, which initializes, creats and links
TextEdit Control
CREATE OBJECT g_editor
EXPORTING
parent = g_editor_container
wordwrap_mode =
cl_gui_textedit=>wordwrap_off
cl_gui_textedit=>wordwrap_at_fixed_position
cl_gui_textedit=>WORDWRAP_AT_WINDOWBORDER
wordwrap_position = 75
wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
to handle different containers
g_container_linked = 1.
ENDIF.
CALL METHOD g_editor->set_text_as_r3table
EXPORTING
table = g_mytable.
IF ws_flg NE 'X'.
CLEAR ws_flg.
CALL METHOD g_editor->select_lines
EXPORTING
from_line = 1
to_line = ws_lines.
CALL METHOD g_editor->protect_selection
EXPORTING
protect_mode = 1.
ws_lines1 = ws_lines + 1.
DESCRIBE TABLE g_mytable LINES ws_lines.
CALL METHOD g_editor->select_lines
EXPORTING
from_line = ws_lines1
to_line = ws_lines2.
CALL METHOD g_editor->protect_selection
EXPORTING
protect_mode = 0.
ENDIF.
CALL METHOD g_editor->set_selection_pos_in_line
EXPORTING
line = '1'
pos = '1'
EXCEPTIONS
error_cntl_call_method = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
CALL METHOD g_editor->set_wordwrap_behavior
EXPORTING
wordwrap_mode = 1
wordwrap_position = 50
wordwrap_to_linebreak_mode = bool_initial
EXCEPTIONS
error_cntl_call_method = 1
OTHERS = 2.
IF sy-subrc <> 0.
*
ENDIF.
ENDMODULE. " PBO
************************************************************************
P A I
************************************************************************
MODULE pai INPUT.
DATA : ws_lines4 TYPE i.
CASE g_ok_code.
WHEN 'BACK'.
PERFORM back_program.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN 'BREAK'.
PERFORM exit_program.
WHEN 'SAVE'.
g_mytable1[] = g_mytable[].
retrieve data from control
CALL METHOD g_editor->get_text_as_r3table
IMPORTING
table = g_mytable.
LOOP AT g_mytable INTO wa_table.
READ TABLE it_line WITH KEY tdline = wa_table.
IF sy-subrc <> 0.
*This creates a new history line (TimedateUser Stamp):
IF flg_history_line <> 'X'.
CALL FUNCTION 'ZTEXT_CREATE_HISTORY_LINE'
IMPORTING
history_line = ws_history_line.
MOVE ws_history_line TO it_final_line-tdline.
APPEND it_final_line.
ENDIF.
flg_history_line = 'X'.
ENDIF.
MOVE wa_table TO it_final_line-tdline.
APPEND it_final_line.
ENDLOOP.
ws_thead-tdname = ws_cont_acct .
ws_thead-tdid = 'ZCO'.
ws_thead-tdspras = sy-langu.
ws_thead-tdobject = 'ZSW_NOTES'.
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
client = sy-mandt
header = ws_thead
savemode_direct = 'X'
TABLES
lines = it_final_line
EXCEPTIONS
id = 1
language = 2
name = 3
object = 4
OTHERS = 5.
IF sy-subrc EQ 0.
ENDIF.
REFRESH it_line.
CLEAR it_line.
PERFORM exit_program.
WHEN 'LOAD'.
send table to control
CALL METHOD g_editor->set_text_as_r3table
EXPORTING
table = g_mytable.
no flush here:
the automatic flush at the end of PBO does the job
ENDCASE.
CLEAR g_ok_code.
ENDMODULE. " PAI
************************************************************************
F O R M S
************************************************************************
&----
*& Form EXIT_PROGRAM
&----
FORM exit_program.
Destroy Control.
IF NOT g_editor IS INITIAL.
CALL METHOD g_editor->free
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
add your handling
ENDIF.
free ABAP object also
FREE g_editor.
ENDIF.
destroy container
IF NOT g_editor_container IS INITIAL.
CALL METHOD g_editor_container->free
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
add your handling
ENDIF.
free ABAP object also
FREE g_editor_container.
ENDIF.
finally flush
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
add your handling
ENDIF.
LEAVE PROGRAM.
ENDFORM. " EXIT_PROGRAM
&----
*& Form BACK_PROGRAM
&----
FORM back_program.
CASE sy-dynnr.
WHEN '0100'.
Destroy Control.
IF NOT g_editor IS INITIAL.
CALL METHOD g_editor->free
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
add your handling
ENDIF.
free ABAP object also
FREE g_editor.
ENDIF.
destroy container
IF NOT g_editor_container IS INITIAL.
CALL METHOD g_editor_container->free
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
add your handling
ENDIF.
free ABAP object also
FREE g_editor_container.
ENDIF.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
add your handling
ENDIF.
LEAVE PROGRAM.
ENDCASE.
ENDFORM. " BACK_PROGRAM
&----
*& Form RELINK_CONTROL
&----
FORM relink_control.
toggle container which displays control
IF g_mycontainer EQ 'TEXTEDITOR1'.
g_mycontainer = 'TEXTEDITOR2'.
ELSE.
g_mycontainer = 'TEXTEDITOR1'.
ENDIF.
initiate relinking in PBO
g_relink = 'X'.
ENDFORM. " RELINK_CONTROL
&----
*& Form CHANGE_SCREEN
&----
FORM change_screen.
CASE sy-dynnr.
WHEN '0100'.
set screen
SET SCREEN 200.
LEAVE SCREEN.
WHEN '0200'.
set screen
SET SCREEN 100.
LEAVE SCREEN.
ENDCASE.
initiate relinking in PBO
g_relink = 'X'.
CLEAR g_ok_code.
ENDFORM. " CHANGE_SCREEN
Hope this helps.
Manish