Hola,
te dejo un ejemplo de un ALV con objetos bastante resumido.
Recuerda que tienes que crearte el CONTAINER en el MODULE POOL.
Este sería el código del programa.
*&---------------------------------------------------------------------*
*& Report ZALV_OO_SENCILLO
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZALV_OO_SENCILLO.
************************************************************************
* INCLUDE
************************************************************************
INCLUDE: zalv.
************************************************************************
* TABLES
************************************************************************
TABLES: mara, " Datos generales material
marc, " Datos centro p.material
mard, " Datos de almacén para el material
makt. " Textos breves de material
************************************************************************
*DATA
************************************************************************
DATA: BEGIN OF gt_listado OCCURS 0,
matnr LIKE mara-matnr, " Material
werks LIKE mard-werks, " Centro
lgort LIKE mard-lgort, " Almacen
mtart LIKE mara-mtart, " Tipo Material
eisbe_uv LIKE marc-eisbe, " Stock seguridad
eisbe_umb LIKE marc-eisbe, " Stock seguridad
mabst_uv LIKE marc-mabst, " Stock máximo
mabst_umb LIKE marc-mabst, " Stock máximo
maktx LIKE makt-maktx, " Descrip. material
color_celdas TYPE lvc_t_scol,
END OF gt_listado.
DATA: g_container_listado TYPE scrfname VALUE 'CONTAINER_LISTADO',
go_grid_listado TYPE REF TO cl_gui_alv_grid,
go_custom_container TYPE REF TO cl_gui_custom_container.
DATA: gt_f4 TYPE lvc_t_f4.
DATA: gs_f4 TYPE lvc_s_f4.
DATA: gs_layout TYPE lvc_s_layo.
DATA: gs_variant TYPE disvariant.
DATA: gs_fieldcat TYPE lvc_s_fcat.
DATA: gt_fieldcat TYPE lvc_t_fcat.
DATA: gs_fieldtab TYPE slis_fieldcat_alv.
DATA: gt_sort TYPE lvc_t_sort.
DATA: gf_okcode TYPE ok.
FIELD-SYMBOLS: <fieldcat> TYPE lvc_s_fcat.
*---------------------------------------------------------------------*
* CLASS LCL_EVENT_RECEIVER DEFINITION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
METHODS handle_data_changed_finished
FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING e_modified
et_good_cells.
METHODS handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive.
METHODS handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS. "lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
PERFORM data_changed USING er_data_changed.
ENDMETHOD. "handle_data_changed
METHOD handle_data_changed_finished.
PERFORM data_changed_finished USING e_modified
et_good_cells.
ENDMETHOD. "handle_data_changed_finished
METHOD handle_toolbar.
PERFORM barra_herramientas USING e_object
e_interactive.
ENDMETHOD. "handle_toolbar
METHOD handle_user_command.
PERFORM user_command USING e_ucomm.
ENDMETHOD. "handle_user_command
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
************************************************************************
*SELECTION-SCREEN
************************************************************************
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME.
SELECT-OPTIONS: s_werks FOR mard-werks. " Centro
SELECT-OPTIONS: s_lgort FOR mard-lgort. " Almacen
SELECT-OPTIONS: s_mtart FOR mara-mtart. " Tipo Material
SELECT-OPTIONS: s_matnr FOR mara-matnr. " Material
SELECTION-SCREEN END OF BLOCK b01.
************************************************************************
*START-OF-SELECTION
************************************************************************
START-OF-SELECTION.
PERFORM recuperar_datos.
PERFORM datos_listado.
************************************************************************
*END-OF-SELECTION
************************************************************************
END-OF-SELECTION.
PERFORM mostrar_listado.
*&---------------------------------------------------------------------*
*& Form recuperar_datos
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM recuperar_datos .
SELECT mara~matnr
marc~werks
* mard~lgort
mara~mtart
marc~eisbe
marc~mabst
makt~maktx
INTO (gt_listado-matnr,
gt_listado-werks,
* gt_listado-lgort,
gt_listado-mtart,
gt_listado-eisbe_uv,
gt_listado-mabst_uv,
gt_listado-maktx)
FROM marc AS marc
INNER JOIN mara AS mara
ON mara~matnr EQ marc~matnr
INNER JOIN makt AS makt
ON makt~matnr EQ mara~matnr
* INNER JOIN mard AS mard
* ON mard~matnr EQ makt~matnr
* AND mard~werks EQ marc~werks
WHERE mara~matnr IN s_matnr
AND marc~werks IN s_werks
* AND mard~lgort IN s_lgort
AND mara~mtart IN s_mtart
AND makt~spras EQ sy-langu.
APPEND gt_listado.
CLEAR gt_listado.
ENDSELECT.
ENDFORM. " recuperar_datos
*&---------------------------------------------------------------------*
*& Form datos_listado
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM datos_listado .
LOOP AT gt_listado.
PERFORM md_convert_material_unit USING gt_listado-matnr
gt_listado-eisbe_uv
gt_listado-eisbe_umb.
PERFORM md_convert_material_unit USING gt_listado-matnr
gt_listado-mabst_uv
gt_listado-mabst_umb.
MODIFY gt_listado.
CLEAR gt_listado.
ENDLOOP.
ENDFORM. " datos_listado
*&---------------------------------------------------------------------*
*& Form mostrar_listado
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM mostrar_listado .
repname = sy-repid.
* Descripción estándar de campos
PERFORM obt_descrip_campos_tabla USING repname 'GT_LISTADO'.
CLEAR gt_fieldcat[].
LOOP AT fieldtab INTO gs_fieldtab.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = gs_fieldtab-fieldname.
gs_fieldcat-ref_field = gs_fieldtab-ref_fieldname.
gs_fieldcat-ref_table = gs_fieldtab-ref_tabname.
gs_fieldcat-outputlen = gs_fieldtab-outputlen.
gs_fieldcat-key = gs_fieldtab-key.
gs_fieldcat-tabname = 'GT_LISTADO'.
gs_fieldcat-scrtext_l = gs_fieldtab-seltext_l.
gs_fieldcat-scrtext_m = gs_fieldtab-seltext_m.
gs_fieldcat-scrtext_s = gs_fieldtab-seltext_s.
gs_fieldcat-coltext = gs_fieldtab-seltext_m.
gs_fieldcat-selddictxt = 'L'.
IF gs_fieldtab-fieldname = 'EISBE_UV'
OR gs_fieldtab-fieldname = 'MABST_UV'.
gs_fieldcat-edit = 'X'.
ENDIF.
APPEND gs_fieldcat TO gt_fieldcat.
ENDLOOP.
* Cambio de descripciones
PERFORM cambio_descripcion USING:
'EISBE_UV' text-l01 text-l01 text-l01 text-l01,
'EISBE_UMB' text-l02 text-l02 text-l02 text-l02,
'MABST_UV' text-l03 text-l03 text-l03 text-l03,
'MABST_UMB' text-l04 text-l04 text-l04 text-l04.
* Se fijan los campos claves
PERFORM eliminar_o_fijar_campo_clave USING: 'MATNR' 'X',
'WERKS' ' ',
'LGORT' ' ',
'MTART' ' '.
CALL SCREEN 9001.
ENDFORM. " mostrar_listado
*&---------------------------------------------------------------------*
*& Form barra_herramientas
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM barra_herramientas USING rr_object TYPE REF TO
cl_alv_event_toolbar_set
pf_e_interactive.
DATA: ls_toolbar TYPE stb_button.
* Se añade un separador
CLEAR ls_toolbar.
MOVE 3 TO ls_toolbar-butn_type.
APPEND ls_toolbar TO rr_object->mt_toolbar.
* Añadimos icono Grabar
CLEAR ls_toolbar.
MOVE 'OK_SAVE' TO ls_toolbar-function.
MOVE icon_system_save TO ls_toolbar-icon.
MOVE 'Grabar'(ic2) TO ls_toolbar-quickinfo.
* MOVE 'Grabar'(ic2) TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO rr_object->mt_toolbar.
ENDFORM. " barra_herramientas
*&---------------------------------------------------------------------*
*& 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: lf_busab TYPE t001s-busab.
DATA: ls_t001s LIKE t001s.
DATA: lf_vendedor LIKE zvbrk_mex-vendedor.
DATA: ls_lfa1 LIKE lfa1.
DATA: lf_fecha LIKE sy-datum.
DATA: lf_folio_acuse LIKE zvbrk_mex-folio_acuse.
DATA: lf_observaciones LIKE zvbrk_mex-observaciones.
DATA: ls_zvbrk_mex LIKE gt_listado.
DATA: ls_cellcolor TYPE lvc_s_scol .
DATA: ls_is_stable TYPE lvc_s_stbl.
DATA: lf_eisbe_uv LIKE marc-eisbe.
DATA: lf_mabst_uv LIKE marc-mabst.
DATA: lf_et_index_rows TYPE lvc_t_row,
lf_et_row_no TYPE lvc_t_roid.
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.
READ TABLE gt_listado INDEX ls_mod_cells-row_id.
CASE ls_mod_cells-fieldname.
WHEN 'EISBE_UV'.
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 = lf_eisbe_uv.
gt_listado-eisbe_uv = lf_eisbe_uv.
DELETE gt_listado-color_celdas
WHERE fname = ls_mod_cells-fieldname.
IF ls_zvbrk_mex-eisbe_uv <> gt_listado-eisbe_uv.
CLEAR ls_cellcolor.
ls_cellcolor-fname = ls_mod_cells-fieldname.
ls_cellcolor-color-col = '7' .
ls_cellcolor-color-int = '1'.
APPEND ls_cellcolor TO gt_listado-color_celdas.
ENDIF.
PERFORM md_convert_material_unit USING gt_listado-matnr
gt_listado-eisbe_uv
gt_listado-eisbe_umb.
MODIFY gt_listado INDEX ls_mod_cells-row_id.
WHEN 'MABST_UV'.
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 = lf_mabst_uv.
gt_listado-mabst_uv = lf_mabst_uv.
DELETE gt_listado-color_celdas
WHERE fname = ls_mod_cells-fieldname.
IF ls_zvbrk_mex-mabst_uv <> gt_listado-mabst_uv.
CLEAR ls_cellcolor.
ls_cellcolor-fname = ls_mod_cells-fieldname.
ls_cellcolor-color-col = '7' .
ls_cellcolor-color-int = '1'.
APPEND ls_cellcolor TO gt_listado-color_celdas.
ENDIF.
PERFORM md_convert_material_unit USING gt_listado-matnr
gt_listado-mabst_uv
gt_listado-mabst_umb.
MODIFY gt_listado INDEX ls_mod_cells-row_id.
ENDCASE.
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
*---------------------------------------------------------------------*
* MODULE PBO OUTPUT *
*---------------------------------------------------------------------*
MODULE pbo OUTPUT.
PERFORM pbo_output.
ENDMODULE. "pbo OUTPUT
*---------------------------------------------------------------------*
* MODULE PAI INPUT *
*---------------------------------------------------------------------*
MODULE pai INPUT.
PERFORM pai_input.
ENDMODULE. "pai INPUT
*&---------------------------------------------------------------------*
*& Form pbo_output
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM pbo_output.
DATA: lo_event_receiver TYPE REF TO lcl_event_receiver.
DATA: lt_it_toolbar_excluding
TYPE ui_functions.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'T9001_1'.
IF go_custom_container IS INITIAL.
CREATE OBJECT go_custom_container
EXPORTING
container_name = g_container_listado.
CREATE OBJECT go_grid_listado
EXPORTING
i_parent = go_custom_container.
CREATE OBJECT lo_event_receiver.
SET HANDLER lo_event_receiver->handle_data_changed
FOR go_grid_listado.
SET HANDLER lo_event_receiver->handle_data_changed_finished
FOR go_grid_listado.
SET HANDLER lo_event_receiver->handle_user_command
FOR go_grid_listado.
SET HANDLER lo_event_receiver->handle_toolbar FOR go_grid_listado.
CALL METHOD go_grid_listado->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
gs_layout-zebra = 'X'.
gs_layout-cwidth_opt = 'X'.
* gs_layout-grid_title
gs_layout-ctab_fname = 'COLOR_CELDAS'.
gs_layout-no_rowmark = 'X'.
gs_variant-report = 'ZALV_OO_SENCILLO'.
PERFORM excluir_ok_codigos TABLES lt_it_toolbar_excluding.
CALL METHOD go_grid_listado->set_table_for_first_display
EXPORTING " i_buffer_active = 'X'
i_save = 'A'
is_variant = gs_variant
is_layout = gs_layout
it_toolbar_excluding = lt_it_toolbar_excluding
CHANGING
it_fieldcatalog = gt_fieldcat
it_sort = gt_sort
it_outtab = gt_listado[].
ENDIF.
ENDFORM. " pbo_output
*&---------------------------------------------------------------------*
*& Form pai_input
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM pai_input.
CASE gf_okcode.
WHEN 'EXIT'.
SET SCREEN 0.
LEAVE SCREEN.
ENDCASE.
CLEAR gf_okcode.
ENDFORM. " pai_input
*&---------------------------------------------------------------------*
*& Form excluir_ok_codigos
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM excluir_ok_codigos TABLES pt_it_toolbar_excluding.
DATA: lf_ui_func TYPE ui_func.
lf_ui_func = go_grid_listado->mc_fc_loc_append_row.
APPEND lf_ui_func TO pt_it_toolbar_excluding.
lf_ui_func = go_grid_listado->mc_fc_loc_copy.
APPEND lf_ui_func TO pt_it_toolbar_excluding.
lf_ui_func = go_grid_listado->mc_fc_loc_copy_row.
APPEND lf_ui_func TO pt_it_toolbar_excluding.
lf_ui_func = go_grid_listado->mc_fc_loc_cut.
APPEND lf_ui_func TO pt_it_toolbar_excluding.
lf_ui_func = go_grid_listado->mc_fc_loc_delete_row.
APPEND lf_ui_func TO pt_it_toolbar_excluding.
lf_ui_func = go_grid_listado->mc_fc_loc_insert_row.
APPEND lf_ui_func TO pt_it_toolbar_excluding.
lf_ui_func = go_grid_listado->mc_fc_loc_move_row.
APPEND lf_ui_func TO pt_it_toolbar_excluding.
lf_ui_func = go_grid_listado->mc_fc_loc_paste.
APPEND lf_ui_func TO pt_it_toolbar_excluding.
lf_ui_func = go_grid_listado->mc_fc_loc_paste_new_row.
APPEND lf_ui_func TO pt_it_toolbar_excluding.
lf_ui_func = go_grid_listado->mc_fc_loc_undo.
APPEND lf_ui_func TO pt_it_toolbar_excluding.
ENDFORM. " excluir_ok_codigos
*&---------------------------------------------------------------------*
*& Form user_command
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM user_command USING pf_e_ucomm TYPE syucomm.
DATA: ls_is_stable TYPE lvc_s_stbl.
CASE pf_e_ucomm.
WHEN 'OK_SAVE'.
LOOP AT gt_listado. " WHERE marca = 'X'.
CLEAR marc.
SELECT SINGLE * FROM marc
WHERE matnr = gt_listado-matnr
AND werks = gt_listado-werks.
IF gt_listado-eisbe_uv <> marc-eisbe.
MOVE gt_listado-eisbe_uv TO marc-eisbe.
MODIFY marc.
ENDIF.
IF gt_listado-mabst_uv <> marc-mabst.
MOVE gt_listado-mabst_uv TO marc-mabst.
MODIFY marc.
ENDIF.
ENDLOOP.
IF sy-subrc <> 0.
*------ No se han seleccionado registros
MESSAGE s324(zy).
ELSE.
*------ Se han actualizado los datos
MESSAGE s411(zy).
ls_is_stable-row = 'X'.
ls_is_stable-col = 'X'.
CALL METHOD go_grid_listado->refresh_table_display
EXPORTING
is_stable = ls_is_stable.
ENDIF.
ENDCASE.
ENDFORM. " user_command
*&---------------------------------------------------------------------*
*& Form eliminar_o_fijar_campo_clave
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM eliminar_o_fijar_campo_clave USING pf_fieldname
pf_valor.
READ TABLE gt_fieldcat WITH KEY fieldname = pf_fieldname
ASSIGNING <fieldcat>.
IF sy-subrc EQ 0.
<fieldcat>-key = pf_valor.
ENDIF.
ENDFORM. " eliminar_o_fijar_campo_clave
*&---------------------------------------------------------------------*
*& Form data_changed_finished
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM data_changed_finished USING e_modified
et_good_cells TYPE lvc_t_modi.
DATA: ls_is_stable TYPE lvc_s_stbl.
IF NOT e_modified IS INITIAL.
ls_is_stable-row = 'X'.
ls_is_stable-col = 'X'.
CALL METHOD go_grid_listado->refresh_table_display
EXPORTING
is_stable = ls_is_stable.
ENDIF.
ENDFORM. " data_changed_finished
*&---------------------------------------------------------------------*
*& Form cambio_descripcion
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM cambio_descripcion USING pf_fieldname
pf_scrtext_l
pf_scrtext_m
pf_scrtext_s
pf_coltext.
READ TABLE gt_fieldcat WITH KEY fieldname = pf_fieldname
ASSIGNING <fieldcat>.
IF sy-subrc EQ 0.
<fieldcat>-scrtext_l = pf_scrtext_l.
<fieldcat>-scrtext_m = pf_scrtext_m.
<fieldcat>-scrtext_s = pf_scrtext_s.
<fieldcat>-coltext = pf_coltext.
ENDIF.
ENDFORM. " cambio_descripcion
*&---------------------------------------------------------------------*
*& Form md_convert_material_unit
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_LISTADO_MATNR text
* -->P_GT_LISTADO_EISBE_UV text
* -->P_GT_LISTADO_EISBE_UMB text
*----------------------------------------------------------------------*
FORM md_convert_material_unit USING p_matnr
p_in_uv
p_out_umb.
DATA: aux_unit_in LIKE ekpo-menge,
aux_unit_out LIKE ekpo-menge,
lf_meins LIKE mara-meins.
SELECT SINGLE meins INTO lf_meins FROM mara
WHERE matnr = p_matnr.
aux_unit_in = p_in_uv.
CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
EXPORTING
i_matnr = p_matnr
i_in_me = 'UV'
i_out_me = lf_meins
i_menge = aux_unit_in
IMPORTING
e_menge = aux_unit_out
EXCEPTIONS
error_in_application = 1
error = 2
OTHERS = 3.
p_out_umb = aux_unit_out.
ENDFORM. " md_convert_material_unit
En el MODULE.
PROCESS BEFORE OUTPUT.
MODULE pbo.
PROCESS AFTER INPUT.
MODULE pai.
Espero que te sirva de algo.
Un Saludo.