Foro de programación ABAP
SAP / ABAP => ALV => Mensaje iniciado por: VitorGarcia en 01 de Abril de 2009, 09:29:06 am
-
Hola a todos, tengo un problemilla con unos checkbox y quería ver si podríais ayudarme...
Tengo un ALV que muestro en una dynpro en el que he añadido unos checkbox, necesito cargar en una tabla interna los registros seleccionados en el ALV.
para mostrar el ALV uso:
CREATE OBJECT go_custom_container
EXPORTING
container_name = u_contenedor.
CREATE OBJECT go_grid
EXPORTING
i_parent = go_custom_container.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
is_layout = u_wa_layout
CHANGING
it_outtab = tit_ofus[]
it_fieldcatalog = tit_catalogo[]
it_sort = lit_sort
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
Una cosa curiosa que veo es que cuando selecciono varios registros y doy al botón que he creado para tratar esos registros seleccionados miro la tabla del alv y no salen marcados los checks pero si selecciono varios registros y luego le doy al boton de "Detalles" al mirar la tabla veo que si que sale la X en el campo CHECK que he creado en la tabla...
A que se debe?? como puedo hacer para que cuando hago click en mi botón y ejecuto mi subrutina la tabla del ALV tenga las X en los registros con los CHECKs marcados??
-
Haber si es esto...
Nos situamos en el data_changed...
method handle_data_changed.
perform data_changed using er_data_changed.
endmethod. "handle_data_changed
Este es el form y donde yo tengo puesto el campo MARCA sería tu campo checkbox.
*&---------------------------------------------------------------------*
*& Form data_changed
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form data_changed using rr_data_changed type ref to
cl_alv_changed_data_protocol.
data: ls_mod_cells type lvc_s_modi.
data: ls_is_stable type lvc_s_stbl.
data: lf_et_index_rows type lvc_t_row,
lf_et_row_no type lvc_t_roid.
data: lf_verid like mkal-verid.
get time.
call method go_grid_listado->get_selected_rows
importing
et_index_rows = lf_et_index_rows
et_row_no = lf_et_row_no.
loop at rr_data_changed->mt_mod_cells into ls_mod_cells.
clear gt_listado.
read table gt_listado index ls_mod_cells-row_id.
if sy-subrc <> 0.
do 100 times.
append gt_listado.
enddo.
read table gt_listado index ls_mod_cells-row_id.
endif.
case ls_mod_cells-fieldname.
when 'MARCA'.
call method rr_data_changed->get_cell_value
exporting
i_row_id = ls_mod_cells-row_id
i_fieldname = ls_mod_cells-fieldname
importing
e_value = gt_listado-marca.
when 'FECHA'.
call method rr_data_changed->get_cell_value
exporting
i_row_id = ls_mod_cells-row_id
i_fieldname = ls_mod_cells-fieldname
importing
e_value = gt_listado-fecha.
when 'HORA'.
call method rr_data_changed->get_cell_value
exporting
i_row_id = ls_mod_cells-row_id
i_fieldname = ls_mod_cells-fieldname
importing
e_value = gt_listado-hora.
when 'MATRICULA'.
call method rr_data_changed->get_cell_value
exporting
i_row_id = ls_mod_cells-row_id
i_fieldname = ls_mod_cells-fieldname
importing
e_value = gt_listado-matricula.
endcase.
modify gt_listado index ls_mod_cells-row_id.
endloop.
call method go_grid_listado->set_selected_rows
exporting
it_index_rows = lf_et_index_rows
it_row_no = lf_et_row_no.
endform. " data_changed
Un saludo.
-
Lo que me fallaba era una chorrada... yo tenía en el PBO, justo a continuación de la llamada al ALV la línea
CALL METHOD go_grid->check_changed_data.
Al moverla al inicio del PAI el problema se solucionó...
Gracias por tu colaboración igualmente.
Un saludo