07-31-2008 8:44 AM
Hi.
I want to add a textarea on a screen. i think it may be with a container but i couldn't do it.
somebody can help me please.
thanks.
07-31-2008 8:53 AM
Try these programs
SAPTEXTEDIT_DEMO_1
SAPTEXTEDIT_DEMO_2
SAPTEXTEDIT_DEMO_3
SAPTEXTEDIT_DEMO_DRAGDROP
07-31-2008 8:58 AM
hi see this demo,
PROGRAM saptextedit_demo_1.
************************************************************************
This demo program demonstrates how to create and use a TextEdit
control and link it to different containers on different Dynpros.
However currently controls can only be relinked to Dynpros of the
same level and NOT, e.g. from a normal Dynpro to a subscreen!
************************************************************************
START-OF-SELECTION.
CALL SCREEN 100.
CONSTANTS: line_length TYPE i VALUE 256.
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_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.
************************************************************************
P B O
************************************************************************
MODULE pbo OUTPUT.
IF g_editor IS INITIAL.
set status
SET PF-STATUS 'MAIN100'.
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'.
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 = line_length
wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
to handle different containers
g_container_linked = 1.
REFRESH g_mytable. " to initialize table upon OK_CODE 'BACK' at PAI
ENDIF.
IF g_relink NE space.
relink control
when this program was developped, relinking between dynpros
having containers with the same name took place automatically.
This mechanism can lead to strange results if non-unique
names for containers defined in the screen painter are used
(another control bound to a container with the same name on a
previous screnn will popup in your container!).
Additionally your coding is much more easy to read and to
understand if you explicitely link the control to the desired
container whenever you change screens.
Note: using the OO Control Framework as of release 99 relinking
is done on the container!
Thus:
CALL METHOD g_editor_container->link
EXPORTING
repid = g_repid
container = g_mycontainer.
CASE sy-dynnr.
just for better visualization of the different dynpros
WHEN '0100'.
don't show toolbar and statusbar on this screen
CALL METHOD g_editor->set_toolbar_mode
EXPORTING
toolbar_mode = cl_gui_textedit=>false.
CALL METHOD g_editor->set_statusbar_mode
EXPORTING
statusbar_mode = cl_gui_textedit=>false.
WHEN '0200'.
show toolbar and statusbar on this screen
CALL METHOD g_editor->set_toolbar_mode
EXPORTING
toolbar_mode = cl_gui_textedit=>true.
CALL METHOD g_editor->set_statusbar_mode
EXPORTING
statusbar_mode = cl_gui_textedit=>true.
ENDCASE.
reset relinking flag
g_relink = space.
ENDIF.
remember: there is an automatic flush at the end of PBO!
ENDMODULE. " PBO
************************************************************************
P A I
************************************************************************
MODULE pai INPUT.
CASE g_ok_code.
WHEN 'BACK'.
PERFORM back_program.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN 'BREAK'.
PERFORM exit_program.
WHEN 'RELINK'.
relink control to other container on same dynpro
PERFORM relink_control.
WHEN 'SAVE'.
retrieve table from control
CALL METHOD g_editor->get_text_as_r3table
IMPORTING table = g_mytable.
if you would like to work with the table contents
perform a explicit flush here allthough the method
flushes internally (at least up to release 4.6D).
The reason: don't rely on internal flushes of control
wrappers. These might vanish in the future leading to a
malfunction of your transaction. The additional flush here
does no harm. The autmation queue is empty and NO additional
roundtrip to the frontend will be triggered.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
add your handling
ENDIF.
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
WHEN 'OTHER_SCR'.
change dynpro which automatically links control to a container
named in the same way as on original dynpro
PERFORM change_screen.
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.
WHEN '0200'.
SET SCREEN 100.
LEAVE SCREEN.
ENDCASE.
initiate relinking in PBO
g_relink = 'X'.
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
07-31-2008 9:05 AM