REPORT z20_002 .
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).
TABLES: stxh.
PARAMETERS p_carrid TYPE sflight-carrid OBLIGATORY.
START-OF-SELECTION.
CALL SCREEN 100.
*---------------------------------------------------------------------*
* MODULE status_0100 OUTPUT
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN_100'.
IF init IS INITIAL.
init = 'X'.
CREATE OBJECT container
EXPORTING container_name = 'TEXTEDIT'.
create object editor
EXPORTING parent = container
* wordwrap_mode = cl_gui_textedit=>wordwrap_OFF
* wordwrap_to_linebreak_mode = 0
* wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
* WORDWRAP_POSITION = 10.
.
*
* CALL METHOD editor->set_toolbar_mode
* EXPORTING
* toolbar_mode = cl_gui_textedit=>false.
*
* CALL METHOD editor->set_statusbar_mode
* EXPORTING
* statusbar_mode = cl_gui_textedit=>false.
g_header-tdobject = 'ZSFLIGHT'.
g_header-tdid = 'Z01'.
g_header-tdspras = sy-langu.
SELECT SINGLE tdname INTO g_header-tdname
FROM zcarrlt
WHERE carrid = p_carrid.
IF sy-subrc EQ 0.
PERFORM read_text.
ELSE.
PERFORM text_init.
ENDIF.
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.
PERFORM save_table.
WHEN OTHERS.
MESSAGE i888(sabapdocu) WITH text-002.
CALL METHOD cl_gui_cfw=>dispatch. "for application events
MESSAGE i888(sabapdocu) WITH text-003.
ENDCASE.
SET SCREEN 100.
ENDMODULE. "user_command_0100 INPUT
*&---------------------------------------------------------------------*
*& Form READ_TEXT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM read_text .
DATA : l_lines TYPE tline.
SELECT SINGLE * FROM stxh INTO stxh
WHERE tdobject = g_header-tdobject
AND tdname = g_header-tdname
AND tdid = g_header-tdid
AND tdspras = sy-langu.
IF sy-subrc NE 0.
EXIT.
ENDIF.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = g_header-tdid
language = sy-langu
name = g_header-tdname
object = g_header-tdobject
IMPORTING
header = g_header
TABLES
lines = g_lines.
*
LOOP AT g_lines INTO l_lines.
l_lines-tdformat = '*'.
REPLACE '*' WITH '' INTO l_lines-tdline.
MODIFY g_lines FROM l_lines.
ENDLOOP.
IF NOT g_lines[] IS INITIAL.
CALL FUNCTION 'CONVERT_ITF_TO_STREAM_TEXT'
TABLES
itf_text = g_lines
text_stream = text_table.
*
CALL METHOD editor->set_selected_text_as_R3TABLE
EXPORTING
TABLE = text_table.
* CALL METHOD editor->set_selected_text_as_stream
* EXPORTING
* selected_text = text_table.
CALL METHOD editor->set_selection_indexes
EXPORTING
from_index = 1
to_index = 1.
ENDIF.
ENDFORM. " READ_TEXT
*&---------------------------------------------------------------------*
*& Form TEXT_INIT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM text_init .
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = '01'
object = 'ZABAP'
subobject = p_carrid "'AA'
quantity = '1'
IMPORTING
number = g_number
EXCEPTIONS
interval_not_found = 1
number_range_not_intern = 2
object_not_found = 3
quantity_is_0 = 4
quantity_is_not_1 = 5
interval_overflow = 6
buffer_overflow = 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.
EXIT.
ENDIF.
CONCATENATE g_header-tdobject g_header-tdid g_number
INTO g_header-tdname.
CALL FUNCTION 'INIT_TEXT'
EXPORTING
id = g_header-tdid
language = sy-langu
name = g_header-tdname
object = g_header-tdobject
IMPORTING
header = g_header
TABLES
lines = g_lines.
IF sy-subrc <> 0.
RAISE no_text_init.
ENDIF.
ENDFORM. " TEXT_INIT
*&---------------------------------------------------------------------*
*& Form SAVE_TEXT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM save_text .
CHECK editor IS NOT INITIAL.
data g_table(256) TYPE c OCCURS 0.
CALL METHOD editor->get_text_as_stream
IMPORTING
text = text_table
is_modified = modi
EXCEPTIONS
error_dp = 1
error_cntl_call_method = 2
OTHERS = 3.
* CALL METHOD editor->get_selected_text_as_r3table
* IMPORTING
* table = g_table.
* CALL METHOD editor->get_selected_text_as_stream
* IMPORTING
* selected_text = text_table.
IF NOT text_table[] IS INITIAL.
g_lines[] = text_table[].
CALL FUNCTION 'CONVERT_STREAM_TO_ITF_TEXT'
TABLES
text_stream = text_table
itf_text = g_lines.
*
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
header = g_header
* INSERT = 'X'
IMPORTING
newheader = g_header
TABLES
lines = g_lines
EXCEPTIONS
id = 1
language = 2
name = 3
object = 4
OTHERS = 5.
ENDIF.
IF sy-subrc NE 0.
*MESSAGE e001 WITH 'Error occurred when saving'.
EXIT.
ENDIF.
ENDFORM. " SAVE_TEXT
*&---------------------------------------------------------------------*
*& Form SAVE_TABLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM save_table .
DATA : ls_tab LIKE zcarrlt.
ls_tab-carrid = p_carrid.
ls_tab-tdname = g_header-tdname.
MODIFY zcarrlt FROM ls_tab.
IF sy-subrc EQ 0.
COMMIT WORK.
ENDIF.
ENDFORM. " SAVE_TABLE
댓글 2
-
이종원
2007.04.17 23:28
zcarrit CBO 디비 구조 좀 알려주세요...이걸 어떻게 해야 하나? -
e-abap
2007.04.18 21:04
3개 필드 입니다.
MANDT MANDT CLNT 3 0 Client
CARRID S_CARR_ID CHAR 3 0 Airline Code
TDNAME TDOBNAME CHAR 70 0 Name
________________ ______________________________ __________ ______ ______ ____________________________________________________________
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
111 | REPORT Z05_022 | sapjoy | 2007.05.28 | 2136 |
110 | REPORT Z05_021 | sapjoy | 2007.05.28 | 2087 |
109 | REPORT Z05_011 | sapjoy | 2007.05.28 | 2066 |
108 | REPORT Z05_011 | sapjoy | 2007.05.28 | 2159 |
107 | REPORT Z05_002 | sapjoy | 2007.05.22 | 2172 |
106 | REPORT z03_026 | sapjoy | 2007.05.16 | 2313 |
105 | REPORT Z03_020 | sapjoy | 2007.05.15 | 2170 |
104 | TYPE-POOL ztgrp [1] | sapjoy | 2007.05.15 | 2700 |
103 | REPORT Z03_010 [2] | sapjoy | 2007.05.15 | 2664 |
102 | REPORT Z03_002 [4] | sapjoy | 2007.05.11 | 2581 |
101 | REPORT Z03_004 | sapjoy | 2007.05.11 | 2433 |
100 | REPORT Z03_003 [7] | sapjoy | 2007.05.11 | 2879 |
99 | INCLUDE Z16_001I01 | sapjoy | 2007.04.27 | 2892 |
98 | Include Z16_001TOP | sapjoy | 2007.04.27 | 2601 |
97 | PROGRAM z16_001 | sapjoy | 2007.04.27 | 2952 |
» | REPORT z20_002 [2] | sapjoy | 2007.04.16 | 3096 |
95 | REPORT z20_001 | sapjoy | 2007.04.13 | 2499 |
94 | REPORT z18_027 | sapjoy | 2007.04.10 | 2315 |
93 | REPORT z19_010 [2] | sapjoy | 2007.04.07 | 2843 |
92 | REPORT z19_004 | sapjoy | 2007.03.28 | 3238 |