Ayuda de Búsqueda, tipo parameters en Dynpro
Lo primero es insertan en la Dynpro los elementos, en este
caso
V_TRFAR [Campo], P_TRFAR [Botón con Icono] .
V_TRFGB [Campo], P_TRFGB [Botón con Icono] .
Visualmente quedará así.
La Función que utilizare es la siguiente: 'COMPLEX_SELECTIONS_DIALOG'
Ahora la Lógica:
Para no generar confusión, solo les mostrare para un caso.
*&---------------------------------------------------------------------*
*& Include DY0000
*&---------------------------------------------------------------------*
data : begin of it_dynpfields occurs 3.
include structure dynpread.
data : end of it_dynpfields.
tables: p0008.
ranges: r_trfar for p0008-trfar. “Range uso interno
data: v_trfar like p0008-trfar. “Campo de la Dynpro
data: p_trfar(30) type c. “Boton de la Dynpro
*----------------------------------------------------------------------
module get_cursor_v_trfar input. “Para el Campo, HELP
refresh it_dynpfields.
clear it_dynpfields.
move 'V_TRFAR' to it_dynpfields-fieldname.
append it_dynpfields.
clear it_dynpfields.
call function 'DYNP_VALUES_READ'
exporting
dyname = sy-cprog
dynumb = sy-dynnr
translate_to_upper = 'X'
tables
dynpfields = it_dynpfields
exceptions
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
invalid_parameter = 7
undefind_error = 8
double_conversion = 9
stepl_not_found = 10
others = 11.
if sy-subrc = 0.
read table it_dynpfields with key fieldname = 'V_TFAR'.
if sy-subrc = 0.
v_trfar = it_dynpfields-fieldvalue.
endif.
endif.
perform get_multiple_trfar.
endmodule.
*----------------------------------------------------------------------
form get_multiple_trfar . “Para el Campo, HELP con Range
* Dynamically holding Field name
field-symbols: <fst> type standard table.
if r_trfar[] is initial.
if not v_trfar is initial.
r_trfar-sign = 'I'.
r_trfar-option = 'EQ'.
r_trfar-low = v_trfar.
append r_trfar.
clear r_trfar.
endif.
endif.
*
assign r_trfar[] to <fst>.
*
call function 'COMPLEX_SELECTIONS_DIALOG'
exporting
title = 'Select Multiple Value'(059)
text = 'Finish Group'(058)
signed = 'X'
lower_case = ' '
no_interval_check = ' ' "'X'
just_display = ' '
just_incl = ' ' "'X'
EXCLUDED_OPTIONS = ' '
DESCRIPTION = ' '
HELP_FIELD = ' '
search_help = 'ZH_T510G'
"Ayuda descrita en se11 (F4)
* TAB_AND_FIELD = tab_and_field "Ref.ocupa help de tabla-campo
tables
range = <fst>
exceptions
no_range_tab = 1
cancelled = 2
internal_error = 3
invalid_fieldname = 4
others = 5.
*
if sy-subrc = 0.
read table r_trfar index 1.
if sy-subrc = 0.
v_trfar = r_trfar-low.
else.
refresh it_dynpfields.
clear it_dynpfields.
move 'V_TRFAR' to it_dynpfields-fieldname.
append it_dynpfields.
clear it_dynpfields.
call function 'DYNP_VALUES_UPDATE' “Act. Directa a la Dynpro
exporting
dyname = sy-cprog
dynumb = sy-dynnr
tables
dynpfields = it_dynpfields
exceptions
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
undefind_error = 7
others = 8.
endif.
endif.
perform set_icons. “Ajuste del icono
endform.
*----------------------------------------------------------------------
form set_icons. “Ajuste del icono
refresh it_dynpfields.
clear it_dynpfields.
* defino el icono
* Esto funciona si el botón está definido solo como salida
* '@1F@' "ICON_ENTER_MORE
* '@1E@' "ICON_DISPLAY_MORE
describe table r_trfar lines sy-tfill.
if ( sy-tfill > 1 ).
p_trfar = '@1E@'. "ICON_DISPLAY_MORE
else.
p_trfar = '@1F@'. "ICON_ENTER_MORE
endif.
move 'P_TRFAR' to it_dynpfields-fieldname.
move p_trfar to it_dynpfields-fieldvalue.
append it_dynpfields.
clear it_dynpfields.
*
call function 'DYNP_VALUES_UPDATE' “Act. Directa a la Dynpro
exporting
dyname = sy-cprog
dynumb = sy-dynnr
tables
dynpfields = it_dynpfields
exceptions
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
undefind_error = 7
others = 8.
endform. "set_icons
*&---------------------------------------------------------------------*
*& Module STATUS_0000 OUTPUT
*&---------------------------------------------------------------------*
module convert_trfar output.
* Se procede a componer los ranges r_trfar
* ya que están guardados como string
* mido el largo del texto para setear el do().
data: l_leng type i, l_regi type i, l_seg type i.
data: l_trfar type string.
*
clear: r_trfar. refresh: r_trfar.
clear: l_trfar.
l_leng = l_regi = l_seg = 0.
* TRFAR
l_trfar = [Tabla]-d_trfar.
“donde se guarda el
range como texto
l_leng = strlen( l_trfar ).
l_regi = l_leng / 7. " ABBCCDD,...
do l_regi times.
r_trfar-sign = l_trfar+l_seg(1). add 1 to l_seg.
r_trfar-option = l_trfar+l_seg(2). add 2 to l_seg.
r_trfar-low = l_trfar+l_seg(2). add 2 to l_seg.
if ( l_leng > l_seg ).
r_trfar-high = l_trfar+l_seg(2). add 2 to l_seg.
endif.
append r_trfar. “restauro el range
enddo.
* defino el icono
perform set_icons.
endmodule.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0000 INPUT
*&---------------------------------------------------------------------*
module uc_trfar_trfgb input. “convierto el Range en texto
data: t_dynpfields type table of dynpread,
r_dynpfields type dynpread.
data: l_str01 type string .
clear: l_str01.
* if ( ok_code eq 'SAVE' ).
* Se procede a descomponer el range r_trfar.
* ya que deberan ser guardados como string
if not ( r_trfar is initial ).
loop at r_trfar.
concatenate l_str01
r_trfar-sign "# 1 X
r_trfar-option "# 2 XX
r_trfar-low "# 2 XX
r_trfar-high "# 2 XX
into l_str01 respecting blanks.
endloop.
[Tabla]-d_trfar = l_str01.
else.
[Tabla]-d_trfar = ''.
v_trfar = ''.
endif.
*
case ok_code. “ Para el Push
del botón
when 'P_TRFAR'.
perform get_multiple_trfar .
endcase.
endmodule.
*&---------------------------------------------------------------------*
Dympro 0000
*&---------------------------------------------------------------------*
process before output.
…
module convert_trfar_trfgb.
…
process after input.
…
module uc_trfar_trfgb.
…
process on value-request .
field v_trfar module get_cursor_v_trfar.
field v_trfgb module get_cursor_v_trfgb.
…
*&---------------------------------------------------------------------*
Estoy consciente de que no se ve muy fácil, pero les
recomiendo que intenten implementarlo, es de mucha utilidad.
No hay comentarios:
Publicar un comentario