Difference between revisions of "SAP ABAP TEXT"
From SapWiki
(Created page with "==Cuadro de texto en dynpro ( Clase cl_gui_textedit )== <nowiki>REPORT ytest_texto. *--------------------------------------------------------------------* * Datos para cuadro...") |
|||
Line 177: | Line 177: | ||
dynpro 0100 | dynpro 0100 | ||
<nowiki> PROCESS BEFORE OUTPUT. | <nowiki> PROCESS BEFORE OUTPUT. | ||
− | + | MODULE STATUS_0100. | |
− | + | module texto. | |
* | * | ||
− | PROCESS AFTER INPUT. | + | PROCESS AFTER INPUT. |
− | module exit at EXIT-COMMAND. | + | module exit at EXIT-COMMAND. |
− | MODULE REFRESH_TXT. | + | MODULE REFRESH_TXT. |
− | module exit_0100.</nowiki> | + | module exit_0100.</nowiki> |
Revision as of 18:55, 10 April 2020
Cuadro de texto en dynpro ( Clase cl_gui_textedit )
REPORT ytest_texto. *--------------------------------------------------------------------* * Datos para cuadro de texto *--------------------------------------------------------------------* *Variables extras Control Custom DATA: container TYPE REF TO cl_gui_custom_container, editor TYPE REF TO cl_gui_textedit. DATA: line TYPE tdline, "(256) TYPE c, text_tab type STANDARD TABLE OF TDLINE. ********************************************************************** DATA ok_code TYPE sy-ucomm. START-OF-SELECTION. line = 'Hola Mundo'. append line to text_tab. CALL SCREEN 0100. *&---------------------------------------------------------------------* *& Module STATUS_0100 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE status_0100 OUTPUT. SET PF-STATUS 'STATUS'. "Crear con 'BACK' 'EXIT' 'CANC' de tipo comando exit y 'SAVE' SET TITLEBAR 'T01'. "Editar Texto ENDMODULE. " STATUS_0100 OUTPUT *&---------------------------------------------------------------------* *& Module EXIT INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE exit INPUT. DATA l_ok_code TYPE sy-ucomm. l_ok_code = ok_code. CLEAR ok_code. CASE l_ok_code. WHEN 'BACK' OR 'EXIT' OR 'CANC'. * free editor de texto CLEAR: text_tab[]. IF editor IS BOUND. FREE editor. CALL METHOD container->free EXCEPTIONS cntl_error = 1 cntl_system_error = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. FREE container. ENDIF. SET SCREEN 0. LEAVE SCREEN. ENDCASE. ENDMODULE. " EXIT INPUT *&---------------------------------------------------------------------* *& Module TEXTO OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE texto OUTPUT. IF editor IS NOT BOUND. * create control container CREATE OBJECT: container EXPORTING container_name = 'CC_01', "crear custom container CC_01 en dynpro 0100 editor EXPORTING parent = container. * show toolbar and statusbar on this screen CALL METHOD editor->set_toolbar_mode EXPORTING toolbar_mode = editor->true. "true(saca la barra de herramienta). CALL METHOD editor->set_statusbar_mode EXPORTING statusbar_mode = editor->false. "true(saca la barra de status). * if f_mode = c_display. * call method editor->set_readonly_mode * exporting * readonly_mode = editor->true. * * endif. * CALL METHOD editor->set_visible * EXPORTING * visible = ' '. * CALL METHOD editor->set_enable_editing_protected * EXPORTING * MODE = 0. ENDIF. CALL METHOD editor->set_text_as_stream EXPORTING text = text_tab. ENDMODULE. " TEXTO OUTPUT MODULE refresh_txt INPUT. CALL METHOD editor->get_text_as_stream IMPORTING text = text_tab. ENDMODULE. *&---------------------------------------------------------------------* *& Module EXIT_0100 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE exit_0100 INPUT. l_ok_code = ok_code. CLEAR ok_code. CASE l_ok_code. WHEN 'SAVE'. BREAK-POINT. PERFORM save. ENDCASE. ENDMODULE. " EXIT_0100 INPUT FORM save. *text data DATA: lt_tlinetab type STANDARD TABLE OF tline, lt_text type STANDARD TABLE OF TDLINE, ls_theader type thead, ls_tlinetab type tline, l_key TYPE tdobname. IF editor IS NOT INITIAL. * cuadro texto CALL METHOD editor->get_text_as_r3table IMPORTING table = lt_text[] EXCEPTIONS error_dp = 1 error_cntl_call_method = 2 error_dp_create = 3 potential_data_loss = 4. CLEAR lt_tlinetab[]. LOOP AT lt_text into data(ls_text). MOVE ls_text TO ls_tlinetab-tdline. APPEND ls_tlinetab to lt_tlinetab. ENDLOOP. ENDIF. ls_theader-tdid = 'Z001'. ls_theader-tdspras = sy-langu. ls_theader-tdname = l_key. ls_theader-tdobject = 'ZMYOBJ'. * CALL FUNCTION 'SAVE_TEXT' * EXPORTING * header = ls_theader * insert = 'X' * savemode_direct = 'X' * IMPORTING ** FUNCTION = SD_FUNCTION * newheader = ls_theader * TABLES * lines = lt_tlinetab * EXCEPTIONS * id = 01 * language = 02 * name = 03 * object = 04. * IF sy-subrc <> 0. ** MESSAGE A017. * ENDIF. ENDFORM.
dynpro 0100
PROCESS BEFORE OUTPUT. MODULE STATUS_0100. module texto. * PROCESS AFTER INPUT. module exit at EXIT-COMMAND. MODULE REFRESH_TXT. module exit_0100.