자료실에 처음 올리네요...
여기 저기서 짜집기 해서 되긴했네요...
cbo에 string을 이용해서 저장했습니다.
string 쓰면 좀 이거저거 안되는게 좀 있습니다.
*** CBO TABLE ZSTRING
* MANDT MANDT 3 0 Client
* ZKEY CHAR 3 0 key
* ZSTRING STRING 2000 0
* SCREEN 0100, CUSTOM CONTROL 만드시고 이름 'TEXTEDIT'
REPORT zlong_c.
TYPES : BEGIN OF it_01,
g_text(255) TYPE c ,
END OF it_01.
TYPES : BEGIN OF it_text01,
zkey TYPE zstring-zkey,
zstr1 TYPE zstring-zstring,
END OF it_text01.
DATA : itab TYPE TABLE OF it_01.
DATA : wa LIKE LINE OF itab.
DATA : ok_code LIKE sy-ucomm,
save_ok LIKE sy-ucomm.
DATA : init,
container TYPE REF TO cl_gui_custom_container,
editor TYPE REF TO cl_gui_textedit.
TYPES : g_text_t(72) TYPE c OCCURS 0.
DATA : g_header LIKE thead,
g_lines TYPE tline OCCURS 0 WITH HEADER LINE,
text_table TYPE g_text_t,
modi TYPE i,
g_number(8).
PARAMETERS p_carrid TYPE sflight-carrid OBLIGATORY DEFAULT 'ab'.
*----------------------------------------------------------------------*
* START-OF-SELECTION *
*----------------------------------------------------------------------*
START-OF-SELECTION.
CALL SCREEN 100.
*---------------------------------------------------------------------*
* MODULE status_0100 OUTPUT
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS '1000'.
IF init IS INITIAL.
init = 'X'.
CREATE OBJECT container
EXPORTING
container_name = 'TEXTEDIT'.
CREATE OBJECT editor
EXPORTING
parent = container.
PERFORM read_text.
ENDIF.
ENDMODULE. "status_0100 OUTPUT
*---------------------------------------------------------------------*
* MODULE cancel INPUT
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
MODULE cancel INPUT.
CALL METHOD container->free.
CALL METHOD editor->free.
LEAVE PROGRAM.
ENDMODULE. "cancel INPUT
*---------------------------------------------------------------------*
* MODULE user_command_0100 INPUT
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'SAVE'.
PERFORM save_text.
ENDCASE.
* SET SCREEN 100.
ENDMODULE. "user_command_0100 INPUT
*&---------------------------------------------------------------------*
*& Form READ_TEXT
*&---------------------------------------------------------------------*
FORM read_text .
DATA : l_lines TYPE tline.
DATA : zstr TYPE string.
SELECT SINGLE zstring INTO zstr
FROM zstring
WHERE zkey = p_carrid.
REPLACE ALL OCCURRENCES OF
cl_abap_char_utilities=>cr_lf IN zstr WITH '##'.
SPLIT zstr AT '##' INTO TABLE itab.
CALL METHOD editor->set_selected_text_as_r3table
EXPORTING
table = itab. "text_table.
CALL METHOD editor->set_selection_indexes
EXPORTING
from_index = 1
to_index = 1.
ENDFORM. " READ_TEXT
*&---------------------------------------------------------------------*
*& Form SAVE_TEXT
*&---------------------------------------------------------------------*
FORM save_text .
DATA : zstr TYPE string,
zstr1 TYPE zstring,
zcnt(10) TYPE c.
CHECK editor IS NOT INITIAL.
CLEAR : itab.
CALL METHOD editor->get_text_as_stream
IMPORTING
text = itab
is_modified = modi
EXCEPTIONS
error_dp = 1
error_cntl_call_method = 2
OTHERS = 3.
IF NOT itab[] IS INITIAL.
g_lines[] = itab[].
CALL FUNCTION 'CONVERT_STREAM_TO_ITF_TEXT'
TABLES
text_stream = itab
itf_text = g_lines.
LOOP AT itab INTO wa.
CONCATENATE zstr wa-g_text INTO zstr.
ENDLOOP.
zstr1-zkey = p_carrid.
zstr1-zstring = zstr.
zcnt = STRLEN( zstr ).
CHECK zcnt < 4000.
MODIFY zstring FROM zstr1.
ENDIF.
ENDFORM. " SAVE_TEXT
*&---------------------------------------------------------------------*
*& Module EXIT INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE exit INPUT.
LEAVE TO SCREEN 0.
ENDMODULE. " EXIT INPUT
좋은 자료 감사합니다.