12-14-2006 12:30 AM
Hi ABAP Guru's,
I have a functional requirement to create a dialog program with 2 screens.The first screen would display the material codes and the associated short description via a table control.When you select a line entry from the table control and then click on the a "MAINTAIN" pushbutton,it would take you to the next screen where you can enter the associated long texts(for example when you create a sales order,you can maintain the shipping texts,inspection texts at the header level-Text tabstrip).How can we design the same screen where you maintain the texts?Then once we click the "SAVE" pushbutton,the entered text should be save under a text id...Could you please give me some hints on how to go ahead with the design.I am stuck and would greatly appreciate any help.
Regards,
Rajiv C
12-14-2006 12:35 AM
Hi,
1)
Check this code..To display the text in a text editor control..
First you have to create a custom control in your screen painter and name it as CONTAINER1..
Then apply this code..
TYPES: BEGIN OF type_text,
line(70),
END OF type_text.
DATA: t_texttable1 TYPE STANDARD TABLE OF type_text.
DATA: custom_container TYPE REF TO cl_gui_custom_container,
editor TYPE REF TO cl_gui_textedit,
repid LIKE sy-repid.
repid = sy-repid.
CALL SCREEN '0100'.
*&----
*& Module STATUS_0100 OUTPUT
*&----
text
*----
MODULE status_0100 OUTPUT.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
PERFORM delete_container.
*- Container franchise codes
IF editor IS INITIAL.
repid = sy-repid.
CREATE OBJECT custom_container
EXPORTING
container_name = 'CONTAINER1'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CREATE OBJECT editor
EXPORTING
parent = custom_container
wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_mode = cl_gui_textedit=>wordwrap_at_windowborder
wordwrap_position = '38'
wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
*- Eliminate toolbar
PERFORM toolbar.
ENDIF.
PERFORM load_data.
Load TextEdit control with texts
CALL METHOD editor->set_text_as_r3table
EXPORTING table = t_texttable1.
IF sy-subrc > 0.
Display an error message
EXIT.
ENDIF.
CALL METHOD cl_gui_cfw=>flush.
ENDMODULE. " STATUS_0100 OUTPUT
----
FORM delete_container *
----
........ *
----
FORM delete_container.
IF NOT editor IS INITIAL.
CALL METHOD editor->delete_text.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS
OTHERS = 1.
IF sy-subrc > 0.
Errormessage: Error in flush
ENDIF.
ENDIF.
ENDFORM. " delete_container
----
FORM toolbar *
----
........ *
----
FORM toolbar.
DATA: lv_toolbar_mode TYPE i VALUE 0.
CALL METHOD editor->set_toolbar_mode
EXPORTING
toolbar_mode = lv_toolbar_mode.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc > 0.
Errormessage: Error in flush
ENDIF.
ENDFORM. " toolbar
*&----
*& Form LOAD_DATA
*&----
text
*----
--> p1 text
<-- p2 text
*----
FORM load_data.
DATA: gwa_line TYPE type_text.
gwa_line-line = 'HELLO HOW ARE YOU!!!!!'.
APPEND gwa_line TO t_texttable1.
ENDFORM. " LOAD_DATA
*&----
*& Module USER_COMMAND_0100 INPUT
*&----
text
*----
MODULE user_command_0100 INPUT.
DATA: T_SAVE_TEXT TYPE STANDARD TABLE OF TLINE.
DATA: S_SAVE_tEXT TYPE TLINE.
DATA: S_TEXT TYPE TYPE_TEXT.
Load TextEdit control with texts
CALL METHOD editor->get_text_as_r3table
IMPORTING table = t_texttable1.
ENDMODULE. " USER_COMMAND_0100 INPUT
2) Use the internal table t_texttable1 to move the values to the text id by calling the Function module SAVE_TEXT.
Hope this helps...
Thanks,
Naren
12-14-2006 12:35 AM
Hi,
1)
Check this code..To display the text in a text editor control..
First you have to create a custom control in your screen painter and name it as CONTAINER1..
Then apply this code..
TYPES: BEGIN OF type_text,
line(70),
END OF type_text.
DATA: t_texttable1 TYPE STANDARD TABLE OF type_text.
DATA: custom_container TYPE REF TO cl_gui_custom_container,
editor TYPE REF TO cl_gui_textedit,
repid LIKE sy-repid.
repid = sy-repid.
CALL SCREEN '0100'.
*&----
*& Module STATUS_0100 OUTPUT
*&----
text
*----
MODULE status_0100 OUTPUT.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
PERFORM delete_container.
*- Container franchise codes
IF editor IS INITIAL.
repid = sy-repid.
CREATE OBJECT custom_container
EXPORTING
container_name = 'CONTAINER1'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CREATE OBJECT editor
EXPORTING
parent = custom_container
wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_mode = cl_gui_textedit=>wordwrap_at_windowborder
wordwrap_position = '38'
wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
*- Eliminate toolbar
PERFORM toolbar.
ENDIF.
PERFORM load_data.
Load TextEdit control with texts
CALL METHOD editor->set_text_as_r3table
EXPORTING table = t_texttable1.
IF sy-subrc > 0.
Display an error message
EXIT.
ENDIF.
CALL METHOD cl_gui_cfw=>flush.
ENDMODULE. " STATUS_0100 OUTPUT
----
FORM delete_container *
----
........ *
----
FORM delete_container.
IF NOT editor IS INITIAL.
CALL METHOD editor->delete_text.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS
OTHERS = 1.
IF sy-subrc > 0.
Errormessage: Error in flush
ENDIF.
ENDIF.
ENDFORM. " delete_container
----
FORM toolbar *
----
........ *
----
FORM toolbar.
DATA: lv_toolbar_mode TYPE i VALUE 0.
CALL METHOD editor->set_toolbar_mode
EXPORTING
toolbar_mode = lv_toolbar_mode.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc > 0.
Errormessage: Error in flush
ENDIF.
ENDFORM. " toolbar
*&----
*& Form LOAD_DATA
*&----
text
*----
--> p1 text
<-- p2 text
*----
FORM load_data.
DATA: gwa_line TYPE type_text.
gwa_line-line = 'HELLO HOW ARE YOU!!!!!'.
APPEND gwa_line TO t_texttable1.
ENDFORM. " LOAD_DATA
*&----
*& Module USER_COMMAND_0100 INPUT
*&----
text
*----
MODULE user_command_0100 INPUT.
DATA: T_SAVE_TEXT TYPE STANDARD TABLE OF TLINE.
DATA: S_SAVE_tEXT TYPE TLINE.
DATA: S_TEXT TYPE TYPE_TEXT.
Load TextEdit control with texts
CALL METHOD editor->get_text_as_r3table
IMPORTING table = t_texttable1.
ENDMODULE. " USER_COMMAND_0100 INPUT
2) Use the internal table t_texttable1 to move the values to the text id by calling the Function module SAVE_TEXT.
Hope this helps...
Thanks,
Naren
12-17-2006 1:46 AM
Hi Narendran,
Thanks a lot for the sample code.I am able to get the text controls as i had desired.
Thanks,
Rajiv C