Crear custom control en dynpro
TYPES: BEGIN OF tp_text,
line TYPE c LENGTH 120,
END OF tp_text.
data:
v_container_104_1 TYPE REF TO cl_gui_custom_container,
v_ccontrol_104_1 TYPE scrfname VALUE 'CCCOMENTARIOS',
v_texto TYPE REF TO cl_gui_textedit,
t_text TYPE tp_ttext,
tp_ttext TYPE STANDARD TABLE OF tp_text.
EN PAI:
FORM f_crea_contenedor_texto .
DATA lw_line_length TYPE i VALUE 120.
* Crea contenedor y lo asocia con la DYNPRO
CREATE OBJECT v_container_104_1
EXPORTING
container_name = v_ccontrol_104_1
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF NOT sy-subrc IS INITIAL.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*$ Crea el Objeto EDITOR
CREATE OBJECT v_texto
EXPORTING
wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position = lw_line_length
parent = v_container_104_1
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
gui_type_not_supported = 5
OTHERS = 6.
IF NOT sy-subrc IS INITIAL.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF v_actvt = '03' AND v_edit IS INITIAL.
CALL METHOD v_texto->set_readonly_mode
EXPORTING
readonly_mode = '1'
EXCEPTIONS
error_cntl_call_method = 1
invalid_parameter = 2.
ELSE.
CALL METHOD v_texto->set_readonly_mode
EXPORTING
readonly_mode = '0'
EXCEPTIONS
error_cntl_call_method = 1
invalid_parameter = 2.
ENDIF.
CALL METHOD v_texto->set_toolbar_mode
EXPORTING
toolbar_mode = cl_gui_textedit=>false
EXCEPTIONS
error_cntl_call_method = 1
invalid_parameter = 2
OTHERS = 3.
CALL METHOD v_texto->set_statusbar_mode
EXPORTING
statusbar_mode = cl_gui_textedit=>false
EXCEPTIONS
error_cntl_call_method = 1
invalid_parameter = 2
OTHERS = 3.
ENDFORM. " f_crea_contenedor_texto
EN PBO: fuera de todo
MODULE rescata_comentarios INPUT.
CHECK sy-ucomm NE 'YPR9_NO'.
IF NOT v_texto IS INITIAL.
PERFORM f_rescata_dd_dynpro.
ENDIF.
ENDMODULE. " rescata_comentarios
FORM f_rescata_dd_dynpro .
DATA: u_text TYPE tp_ttext,
w_true TYPE i.
CLEAR u_text[].
w_true = 1.
CALL METHOD v_texto->get_text_as_r3table
IMPORTING
table = u_text
EXCEPTIONS
error_dp = 1
error_cntl_call_method = 2
error_dp_create = 3
potential_data_loss = 4
OTHERS = 5.
.
IF NOT sy-subrc IS INITIAL.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
t_text[] = u_text[].
ENDFORM. " f_rescata_dd_dynpro
-----
FORM f_recupera_comentarios .
TYPES: tp_lines TYPE STANDARD TABLE OF tline.
DATA: w_name TYPE tdobname,
u_line TYPE tp_lines,
x_line TYPE tline,
x_line_txt TYPE tp_text.
w_name = v_vbeln.
* Rescata comentarios
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = c_0002
language = c_s
name = w_name
object = c_vbbk
TABLES
lines = u_line
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc IS INITIAL.
LOOP AT u_line INTO x_line.
x_line_txt-line = x_line-tdline.
APPEND x_line_txt TO t_text.
CLEAR x_line_txt.
ENDLOOP.
ENDIF.
* Mueve el texto al Objeto Editor
IF NOT t_text[] IS INITIAL.
IF v_vehiculo_rasa = abap_true.
CALL METHOD v_texto->set_enable
EXPORTING
enable = abap_false
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF NOT sy-subrc IS INITIAL.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
CALL METHOD v_texto->set_text_as_stream
EXPORTING
text = t_text
EXCEPTIONS
error_dp = 1
error_dp_create = 2
OTHERS = 3.
IF NOT sy-subrc IS INITIAL.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1
sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDFORM. " f_recupera_comentarios