Você está na página 1de 10

Ejemplo de cmo crear en un dynpro un campo de Texto

*----------------------------------------------------------------------*
*
DEFINICIN DE TIPOS
*----------------------------------------------------------------------*
type-pools: slis.
type-pools: cxtab.
*----------------------------------------------------------------------*
*
DEFINICIN DE TABLAS
*----------------------------------------------------------------------*
tables: sscrfields.

*----------------------------------------------------------------------*
* CONTENEDORES DE TEXTO
*----------------------------------------------------------------------*
data: editor1
type ref to cl_gui_textedit,
textedit_custom_container1 type ref to cl_gui_custom_container.
" detalles informe financiero
data: begin of e_tabla, "estructura trabajo lineas objetos de texto
linea(256) type c,
end of e_tabla.
data: e_header
like thead. "estructura info para objetos texto
data: i_observaciones like tline occurs 0 with header line.
data: i_tabla(256)
type c occurs 0.
data: v_linea(256)
type c,
"variable para lineas objetos texto
v_contenedor
type c,
"contenedor informe financiero
v_textos_b
type c.
"indicador textos objetos obtenidos

*----------------------------------------------------------------------*
* P. B. O.
*----------------------------------------------------------------------*
process before output.
* Crear los contenedores
module m_crear_contenedores.

* Cambiar el estado de los editores de texto


module m_estado_editores.

*&---------------------------------------------------------------------*
*&
Module m_crear_contenedores OUTPUT
*&---------------------------------------------------------------------*
*
Crear contenedores para escribir texto
*----------------------------------------------------------------------*
module m_crear_contenedores output.
clear: v_ok9000,
sy-ucomm.
if v_contenedor is initial.
v_contenedor = 'X'.
* Crear contenedor detalles informe financiero
perform f_crear_contenedor using 'DETALLES'
textedit_custom_container1
editor1.
endif.
endmodule.

" m_crear_contenedores OUTPUT

*&---------------------------------------------------------------------*
*&
Form f_crear_contenedor
*&---------------------------------------------------------------------*
*
Crear los contenedores de los editores de texto
*----------------------------------------------------------------------*
*
--> PI_CONTENEDOR : Nombre del contenedor
*
--> PI_OBJ_CONT
: Objeto contenedor
*
--> PI_EDITOR
: Nombre del editor que contiene el texto
*----------------------------------------------------------------------*
form f_crear_contenedor using
pi_contenedor
pi_obj_cont type ref to cl_gui_custom_container
pi_editor type ref to cl_gui_textedit.
* Cargar la definicin
class cl_gui_cfw definition load.
* Crear el control
create object pi_obj_cont
exporting
container_name = pi_contenedor
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
if sy-subrc ne 0.
*
add your handling
endif.
* Control de editor de texto
create object pi_editor
exporting
parent = pi_obj_cont
wordwrap_mode =
cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position ='72'
wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
* Mostrarlo
call method cl_gui_cfw=>flush
exceptions
others = 1.
if sy-subrc ne 0.
* add your handling
endif.
endform.

" f_crear_contenedor

*&---------------------------------------------------------------------*
*&
Module m_estado_editores OUTPUT
*&---------------------------------------------------------------------*
*
Cambiar el estado de los editores de texto
*----------------------------------------------------------------------*
module m_estado_editores output.
* Comprobar qeu pasa con los editores de texto
perform f_estado_editores_texto USING X.
perform f_estado_editores_texto USING .
endmodule.

Proteger
Desproteger

" m_estado_editores OUTPUT

*&---------------------------------------------------------------------*
*&
Form f_estado_editores_texto
*&---------------------------------------------------------------------*
*
Cambiar los editores de texto a entrada o slo salida segn
* parametrizaciones
*----------------------------------------------------------------------*
form f_estado_editores_texto USING PI_NOINPUT.
* Datos locales
data: lv_read type i.
* Detalles
if pi_noinput = 'X'.
lv_read = 1.
else.
lv_read = 0.
endif.
call method editor1->set_readonly_mode
exporting
readonly_mode
= lv_read
exceptions
error_cntl_call_method = 1
others
=2
.
endform.

" f_estado_editores_texto

*&---------------------------------------------------------------------*
*&
Module m_obtner_textos OUTPUT
*&---------------------------------------------------------------------*
*
Obtener los textos de observaciones y motivos de rechazo
*----------------------------------------------------------------------*
module m_obtner_textos output.
if v_textos_b is initial.
v_textos_b = 'X'.
* Leer observaciones
perform f_leer_textos tables i_observaciones
using PROP01
'ZFIAPPPOB'.
refresh i_tabla.
loop at i_observaciones.
v_linea = i_observaciones-tdline.
append v_linea to i_tabla.
endloop.
call method editor1->set_text_as_r3table
exporting table = i_tabla.
endmodule.

" m_obtner_textos OUTPUT

*&---------------------------------------------------------------------*

*&
Form f_leer_textos
*&---------------------------------------------------------------------*
*
Leer los textos
*----------------------------------------------------------------------*
*
--> PO_LINEAS : Lneas ledos
*
--> PI_NAME : Nmero de la propuesta de la que se lee
*
--> PI_OBJECT : Objeto del cual se lee
*----------------------------------------------------------------------*
form f_leer_textos tables po_lineas structure tline
using pi_name
pi_object.
data: lv_name like thead-tdname.
lv_name = pi_name.
refresh po_lineas.
clear po_lineas.
* Leer la tabla
call function 'READ_TEXT'
exporting
id
= 'TXT'
language
= sy-langu
name
= lv_name
object
= pi_object
tables
lines
= po_lineas
exceptions
id
=1
language
=2
name
=3
not_found
=4
object
=5
reference_check
=6
wrong_access_to_archive = 7
others
= 8.
endform.

" f_leer_textos

* Grabar los textos


perform f_grabar_textos tables i_tabla
using 'ZFIAPPPOB'.
*&---------------------------------------------------------------------*
*&
Form f_grabar_textos
*&---------------------------------------------------------------------*
*
Grabar los textos de los editores
*----------------------------------------------------------------------*
*
--> PI_TABLA: Tabla con los textos
*
--> PI_OBJECT: Objeto en el qeu se ha de grabar
*----------------------------------------------------------------------*
form f_grabar_textos tables pi_tabla structure e_tabla
using pi_object.
* DAtos locales
data: lv_fname like thead-tdname.
refresh i_observaciones.
loop at pi_tabla into v_linea.
i_observaciones-tdformat = '*'.
i_observaciones-tdline = v_linea.
append i_observaciones.
endloop.
lv_fname = PROP01.
e_header-tdname = lv_fname.
e_header-tdid
= 'TXT'.
e_header-tdspras = sy-langu.
e_header-tdlinesize = 72.
e_header-tdobject = pi_object.
perform f_salvar_texto tables i_observaciones
using e_header.

endform.

" f_grabar_textos

*&---------------------------------------------------------------------*
*&
Form f_salvar_texto
*&---------------------------------------------------------------------*
*
Salvar el texto
*----------------------------------------------------------------------*
*
--> PI_LINEAS : Tabla de lneas a grabar
*
--> PI_HEADER : Objeto en el que se ha de grabar
*----------------------------------------------------------------------*
form f_salvar_texto tables pi_lineas structure tline
using pi_header structure thead.
call function 'SAVE_TEXT'
exporting
header
= pi_header
savemode_direct = 'X'
tables
lines
= pi_lineas
exceptions
id
=1
language
=2
name
=3
object
=4
others
= 5.
commit work and wait.
endform.

" f_salvar_texto

*----------------------------------------------------------------------*
* P. B. O.
*----------------------------------------------------------------------*
process before output.
* MODULE STATUS_0110.

*----------------------------------------------------------------------*
* P. A. I.
*----------------------------------------------------------------------*
process after input.
* Recuperar los textos de los editores de texto
module m_recuperar_textos.
*&---------------------------------------------------------------------*
*&
Module m_recuperar_textos INPUT
*&---------------------------------------------------------------------*
*
Recupera el texto de los editores de texto
*----------------------------------------------------------------------*
module m_recuperar_textos input.
* Pasar los textos de observaciones
refresh i_tabla.
call method editor1->get_text_as_r3table
importing table = i_tabla.
refresh i_observaciones.
loop at i_tabla into v_linea.
i_observaciones-tdformat = '*'.
i_observaciones-tdline = v_linea.
append i_observaciones.
endloop.
endmodule.

" m_recuperar_textos INPUT

Ejemplo de cmo crear en un dynpro dos pestaas

* FUNCTION CODES FOR TABSTRIP 'DATOS'


constants: begin of c_datos,
tab1 like sy-ucomm value 'DATOS_FC1',
tab2 like sy-ucomm value 'DATOS_FC2',
end of c_datos.
* DATA FOR TABSTRIP 'DATOS'
controls: datos type tabstrip.
data:
begin of g_datos,
subscreen like sy-dynnr,
prog
like sy-repid value 'ZFICGD_APPPPROVPROP',
pressed_tab like sy-ucomm value c_datos-tab1,
end of g_datos.
*----------------------------------------------------------------------*
* P. B. O.
*----------------------------------------------------------------------*
process before output.
* PBO FLOW LOGIC FOR TABSTRIP 'DATOS'
module datos_active_tab_set.
call subscreen datos_sca
including g_datos-prog g_datos-subscreen.
*----------------------------------------------------------------------*
* P. A. I.
*----------------------------------------------------------------------*
process after input.
* PAI FLOW LOGIC FOR TABSTRIP 'DATOS'
call subscreen datos_sca.
module datos_active_tab_get.

*---------------------------------------------------------------------*
*
MODULE DATOS_ACTIVE_TAB_SET OUTPUT
*---------------------------------------------------------------------*
*
........
*
*---------------------------------------------------------------------*

module datos_active_tab_set output.


datos-activetab = g_datos-pressed_tab.
case g_datos-pressed_tab.
when c_datos-tab1.
g_datos-subscreen = '9001'.
when c_datos-tab2.
g_datos-subscreen = '9002'.
when others.
DO NOTHING
endcase.
endmodule.
*

*---------------------------------------------------------------------*
*
MODULE DATOS_ACTIVE_TAB_GET INPUT
*---------------------------------------------------------------------*
*
Controlar la pestaa pulsada
*---------------------------------------------------------------------*
module datos_active_tab_get input.
v_ok9000 = sy-ucomm.
case v_ok9000.
when c_datos-tab1.
g_datos-pressed_tab = c_datos-tab1.
when c_datos-tab2.
g_datos-pressed_tab = c_datos-tab2.
when others.
*
DO NOTHING
endcase.
endmodule.

*
*

Você também pode gostar