Skip to Content
avatar image
Former Member

cl_gui_alv_grid refresh

I create a module pool to management information about timetables.

In the module pool we have several options like create ,modify and delete records from several tables.We have 3 dynpros than contain ALVS based in OO .In the general screen we can select these alvs ,but when i try to use the alvs again with other parameters ,it show the same data (when i close the alv the first time and reach the general screen i delete the reference to the objects).

¿Somebody knows the way to refresh the ALV OO? . I try to use the method refresh table display ,but the header don't change and the data are the same again.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Jul 26, 2006 at 03:13 PM

    Hi,

    call method grid (name of grid )->refresh_table_display .

    Best regards,

    Prashant

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 26, 2006 at 03:26 PM

    Can I see your code?

    Regards,

    Rich heilman

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      I try to use the posts but i don't get some positive result

      My code :

      *&----


      *

      *& Module STATUS_7000 OUTPUT

      *&----


      *

      • text

      *----


      *

      MODULE status_7000 OUTPUT.

      SET PF-STATUS '7000'.

      SET TITLEBAR '700'.

      IF g_custom_container IS INITIAL.

      *Creamos la instancia del contenedor

      CREATE OBJECT g_custom_container

      EXPORTING

      container_name = g_container1

      EXCEPTIONS

      cntl_error = 1

      cntl_system_error = 2

      create_error = 3

      lifetime_error = 4

      lifetime_dynpro_dynpro_link = 5

      OTHERS = 6 .

      IF sy-subrc <> 0.

      *Manejo de excepciones

      ENDIF.

      • Createmos el objeto Documento de cabecera

      CREATE OBJECT g_documento

      EXPORTING style = 'ALV_GRID'.

      • Creamos el separador del contenedor

      CREATE OBJECT g_separador

      EXPORTING parent = g_custom_container

      rows = 2

      columns = 1.

      *Dividimos el contenedor global en 2 : una referencia para el

      *documento de cabecera y otra para el contenedor del alv

      CALL METHOD g_separador->get_container

      EXPORTING

      row = 1

      column = 1

      RECEIVING

      container = g_padre_html.

      CALL METHOD g_separador->get_container

      EXPORTING

      row = 2

      column = 1

      RECEIVING

      container = g_padre_grid.

      *Ajustamos la altura del separador

      CALL METHOD g_separador->set_row_height

      EXPORTING

      id = 1

      height = 20.

      *Creamos la instancia del ALV

      CREATE OBJECT g_grid

      EXPORTING

      i_parent = g_padre_grid

      EXCEPTIONS

      error_cntl_create = 1

      error_cntl_init = 2

      error_cntl_link = 3

      error_dp_create = 4

      OTHERS = 5 .

      IF sy-subrc <> 0.

      *Manejo de excepciones

      ENDIF.

      *Registramos el event de edicion

      CALL METHOD g_grid->register_edit_event

      EXPORTING

      i_event_id = cl_gui_alv_grid=>mc_evt_enter.

      *Creamos el manejador de eventos

      CREATE OBJECT g_manejador.

      *Activamos el manejador del evento de cabecera

      SET HANDLER g_manejador->top_of_page FOR g_grid.

      *Obtenemos los datos

      IF zcochecuadro IS INITIAL.

      SELECT * FROM ztm29aumcocua INTO TABLE gt_tablacc

      WHERE zsociedad = g_p_tabla30-zsociedad AND

      zdivision = g_p_tabla30-zdivision AND

      zcuadro = g_p_tabla30-zcuadro AND

      ztipdiacua = g_p_tabla30-ztipdiacua AND

      zlinea = g_p_tabla30-zlinea AND

      • zcochecuadrovar = g_p_tabla29-zcochecuadrovar AND

      zfechainivig LE zfecini AND

      zfechafinvig GE zfecini.

      ELSE.

      SELECT * FROM ztm29aumcocua INTO TABLE gt_tablacc

      WHERE zsociedad = g_p_tabla30-zsociedad AND

      zdivision = g_p_tabla30-zdivision AND

      zcuadro = g_p_tabla30-zcuadro AND

      ztipdiacua = g_p_tabla30-ztipdiacua AND

      zlinea = g_p_tabla30-zlinea AND

      zcochecuadrovar = g_p_tabla29-zcochecuadrovar AND

      zfechainivig LE zfecini AND

      zfechafinvig GE zfecini.

      ENDIF.

      *Seleccionamos como foco el control ALV

      CALL METHOD cl_gui_control=>set_focus

      EXPORTING

      control = g_grid.

      *Creacion del catalogo de campos

      PERFORM prepare_field_catalog USING 'GT_TABLACC'

      CHANGING gt_fieldcat .

      *Preparando el formato del ALV

      PERFORM prepare_layout CHANGING gs_layout .

      *Preparamos la ordenación de campos

      PERFORM prepare_sort_table USING 'GT_TABLACC'

      CHANGING gt_sort.

      *Mostramos la tabla

      CALL METHOD g_grid->set_table_for_first_display

      EXPORTING

      • I_BUFFER_ACTIVE =

      • I_CONSISTENCY_CHECK =

      • i_structure_name =

      • IS_VARIANT =

      • I_SAVE =

      • I_DEFAULT = 'X'

      is_layout = gs_layout

      • IS_PRINT =

      • IT_SPECIAL_GROUPS =

      • IT_TOOLBAR_EXCLUDING =

      • IT_HYPERLINK =

      CHANGING

      it_outtab = gt_tablacc[]

      it_fieldcatalog = gt_fieldcat

      it_sort = gt_sort

      • IT_FILTER =

      EXCEPTIONS

      invalid_parameter_combination = 1

      program_error = 2

      too_many_lines = 3

      OTHERS = 4 .

      IF sy-subrc <> 0.

      *--Exception handling

      ENDIF.

      • Inicializamos el documento

      CALL METHOD g_documento->initialize_document.

      • Procesamos los eventos

      CALL METHOD g_grid->list_processing_events

      EXPORTING

      i_event_name = 'TOP_OF_PAGE'

      i_dyndoc_id = g_documento.

      ELSE .

      *Refrescamos la tabla

      CALL METHOD g_grid->refresh_table_display

      • EXPORTING

      • IS_STABLE =

      • I_SOFT_REFRESH =

      EXCEPTIONS

      finished = 1

      OTHERS = 2 .

      IF sy-subrc <> 0.

      *--Exception handling

      ENDIF.

      ENDIF .

      ENDMODULE. " STATUS_7000 OUTPUT

      *&----


      *

      *& Form prepare_field_catalog

      *&----


      *

      FORM prepare_field_catalog USING p_tabla

      CHANGING pt_fieldcat TYPE lvc_t_fcat .

      *Crea el catalogo de campos asociado al listado ALV

      DATA ls_fcat TYPE lvc_s_fcat .

      *Rellenamos el catalogo de campos del listado

      DEFINE catalogo_campos.

      clear ls_fcat.

      ls_fcat-fieldname = &1.

      ls_fcat-tabname = p_tabla.

      ls_fcat-ref_table = &2.

      append ls_fcat to gt_fieldcat.

      END-OF-DEFINITION.

      IF p_tabla EQ 'GT_TABLACC'.

      • catalogo_campos 'ZSOCIEDAD' 'ZTM29AUMCOCUA'.

      • catalogo_campos 'ZDIVISION' 'ZTM29AUMCOCUA'.

      *

      • catalogo_campos 'ZTIPDIACUA' 'ZTM29AUMCOCUA'.

      • catalogo_campos 'ZLINEA' 'ZTM29AUMCOCUA'.

      catalogo_campos 'ZFECHAINIVIG' 'ZTM29AUMCOCUA'.

      catalogo_campos 'ZFECHAFINVIG' 'ZTM29AUMCOCUA'.

      catalogo_campos 'ZCOCHECUADROVAR' 'ZTM29AUMCOCUA'.

      catalogo_campos 'ZMOTIVOVAR' 'ZTM29AUMCOCUA'.

      catalogo_campos 'ZNATUVARIACION' 'ZTM29AUMCOCUA'.

      catalogo_campos 'ZCUADRO' 'ZTM29AUMCOCUA'.

      *catalogo_campos 'ZHORAINIVAR' 'ZTM29AUMCOCUA'.

      *catalogo_campos 'ZHORAFINVAR' 'ZTM29AUMCOCUA'.

      ELSEIF p_tabla EQ 'GT_TABLANP'.

      catalogo_campos 'ZFECHAINIVIG' 'ZTM30TURVAR'.

      catalogo_campos 'ZFECHAFINVIG' 'ZTM30TURVAR'.

      catalogo_campos 'ZTURNOVAR' 'ZTM30TURVAR'.

      catalogo_campos 'ZCLATURNOVAR' 'ZTM30TURVAR'.

      catalogo_campos 'ZMOTIVOVAR' 'ZTM30TURVAR'.

      catalogo_campos 'ZNATUVARIACION' 'ZTM30TURVAR'.

      catalogo_campos 'ZCUADRO' 'ZTM30TURVAR'.

      ENDIF.

      ENDFORM . "prepare_field_catalog

      *&----


      *

      *& Form prepare_layout

      *&----


      *

      FORM prepare_layout CHANGING ps_layout TYPE lvc_s_layo.

      *Establece el formato de disposicion del ALV

      ps_layout-zebra = 'X' .

      ps_layout-cwidth_opt = 'X' .

      ps_layout-keyhot = 'X' .

      ENDFORM. " prepare_layout

      *&----


      *

      *& Form prepare_sort_table

      *&----


      *

      FORM prepare_sort_table USING p_tabla

      CHANGING pt_sort TYPE lvc_t_sort .

      DATA ls_sort TYPE lvc_s_sort .

      *Ordenacion de las columnas del catalogo de campos

      IF p_tabla EQ 'GT_TABLACC'.

      ls_sort-spos = '1' .

      ls_sort-fieldname = 'ZFECHAINIVIG' .

      ls_sort-up = 'X' . "A to Z

      ls_sort-down = space .

      APPEND ls_sort TO pt_sort .

      ls_sort-spos = '2' .

      ls_sort-fieldname = 'ZFECHAFINVIG' .

      ls_sort-up = 'X'.

      ls_sort-down = space .

      APPEND ls_sort TO pt_sort .

      ELSEIF p_tabla EQ 'GT_TABLANP'.

      ls_sort-spos = '1' .

      ls_sort-fieldname = 'ZFECHAINIVIG' .

      ls_sort-up = 'X' . "A to Z

      ls_sort-down = space .

      APPEND ls_sort TO pt_sort .

      ls_sort-spos = '2' .

      ls_sort-fieldname = 'ZFECHAFINVIG' .

      ls_sort-up = 'X'.

      ls_sort-down = space .

      APPEND ls_sort TO pt_sort .

      ls_sort-spos = '3' .

      ls_sort-fieldname = 'ZTURNOVAR' .

      ls_sort-up = 'X'.

      ls_sort-down = space .

      APPEND ls_sort TO pt_sort .

      ENDIF.

      ENDFORM. " prepare_sort_table

      *&----


      *

      *& Form EVENT_TOP_OF_PAGE

      *&----


      *

      FORM event_top_of_page USING dg_dyndoc_id TYPE REF TO cl_dd_document.

      *Aqui se crean los textos de la cabecera luego habra que incluirlos

      *con el modulo de funcion para los comentarios

      DATA : dl_text(255) TYPE c. "Texto

      *Lineas de registros seleccionados

      DATA l_lineas(10) TYPE c.

      *Variables para calcular el texto del tipo de dia

      DATA l_texto(30) TYPE c.

      *Variable de dia

      DATA l_dia(50) TYPE c.

      • Creando cabecera del ALV

      *CREAMOS UNA SEPARACION VERTICAL PARA EL LOGOTIPO

      CALL METHOD g_documento->vertical_split

      EXPORTING

      split_area = g_documento

      split_width = '85%'

      IMPORTING

      right_area = g_logo.

      CALL METHOD g_logo->add_picture

      EXPORTING

      picture_id = 'LOGOEMT'.

      *TEXTOS DE CABECERA

      IF ztipoau = '1'.

      CALL METHOD g_documento->add_text

      EXPORTING

      text = 'COCHES CUADRO'

      sap_style = cl_dd_area=>heading.

      *Calculamos los registros de la tabla cargada

      DESCRIBE TABLE gt_tablacc LINES g_registros.

      l_lineas = g_registros.

      ELSEIF ztipoau = '2'.

      • CALL METHOD g_documento->add_text

      • EXPORTING

      • text = 'AUMENTOS COCHE CUADRO'

      • sap_style = cl_dd_area=>heading.

      **Calculamos los registros de la tabla cargada

      • DESCRIBE TABLE gt_tablanp LINES g_registros.

      • l_lineas = g_registros.

      ELSEIF ztipoau = '3'.

      CALL METHOD g_documento->add_text

      EXPORTING

      text = 'AUMENTOS NO PROGRAMADOS'

      sap_style = cl_dd_area=>heading.

      *Calculamos los registros de la tabla cargada

      DESCRIBE TABLE gt_tablanp LINES g_registros.

      l_lineas = g_registros.

      ELSEIF ztipoau = '4'.

      CALL METHOD g_documento->add_text

      EXPORTING

      text = 'SUPRESIONES NO PROGRAMADAS'

      sap_style = cl_dd_area=>heading.

      *Calculamos los registros de la tabla cargada

      DESCRIBE TABLE gt_tablanp LINES g_registros.

      l_lineas = g_registros.

      ENDIF.

      *****************************************

      *Añadimos una linea

      CALL METHOD g_documento->new_line.

      *Añadimos una linea

      CALL METHOD g_documento->new_line.

      CLEAR : dl_text.

      *Fecha de seleccion

      CONCATENATE zfecini6(2) '.' zfecini4(2) '.' zfecini+0(4) INTO dl_text.

      CONCATENATE 'Fecha de seleccion: ' dl_text INTO dl_text SEPARATED BY space.

      • Añadimos texto

      PERFORM add_text USING dl_text.

      *****************************************

      *Añadimos una linea

      CALL METHOD g_documento->new_line.

      CLEAR : dl_text.

      *Resto de parametros

      *Leemos el texto del dominio

      l_dia = g_p_tabla30-ztipdiacua.

      CALL FUNCTION 'RM_TEXT_READ_FROM_DOMAIN'

      EXPORTING

      i_domname = 'ZTIPDIACUA'

      • I_LANGU = SY-LANGU

      i_domvalue = l_dia

      IMPORTING

      e_text = l_texto.

      *Visualizamos la informacion de cabecera restante

      IF ztipoau = '1'.

      CONCATENATE 'Cuadro : ' g_p_tabla30-zcuadro 'Linea : ' g_p_tabla30-zlinea

      'Día : ' l_texto INTO dl_text SEPARATED BY space.

      ELSEIF ztipoau = '2'.

      • CONCATENATE 'Cuadro : ' g_p_tabla30-zcuadro 'Linea : ' g_p_tabla30-zlinea

      • 'Día : ' l_texto INTO dl_text SEPARATED BY space.

      ELSEIF ztipoau = '3'.

      CONCATENATE 'Cuadro : ' g_p_tabla30-zcuadro 'Linea : ' g_p_tabla30-zlinea

      'Día : ' l_texto INTO dl_text SEPARATED BY space.

      ELSEIF ztipoau = '4'.

      CONCATENATE 'Cuadro : ' g_p_tabla30-zcuadro 'Linea : ' g_p_tabla30-zlinea

      'Día : ' l_texto INTO dl_text SEPARATED BY space.

      ENDIF.

      • Añadimos texto

      PERFORM add_text USING dl_text.

      *****************************************

      *Añadimos una linea

      CALL METHOD g_documento->new_line.

      CLEAR : dl_text.

      • Registros seleccionados

      CONCATENATE 'Registros seleccionados: ' l_lineas

      INTO dl_text.

      • Añadimos texto

      PERFORM add_text USING dl_text.

      *****************************************

      *Añadimos una linea

      CALL METHOD g_documento->new_line.

      CLEAR : dl_text.

      *Fecha de ejecucion

      CONCATENATE sy-datum6(2) '.' sy-datum4(2) '.' sy-datum+0(4) INTO dl_text.

      CONCATENATE 'Fecha de ejecución : ' dl_text INTO dl_text SEPARATED BY space.

      • Añadimos texto

      PERFORM add_text USING dl_text.

      • Pasamos los datos al control html

      PERFORM html.

      ENDFORM. " EVENT_TOP_OF_PAGE

      *&----


      *

      *& Form ADD_TEXT

      *&----


      *

      FORM add_text USING p_text TYPE sdydo_text_element.

      • Añadimos textos a la cabecera

      CALL METHOD g_documento->add_text

      EXPORTING

      text = p_text

      sap_emphasis = cl_dd_area=>heading.

      ENDFORM. " ADD_TEXT

      *&----


      *

      *& Form HTML

      *&----


      *

      FORM html.

      DATA : dl_length TYPE i, " Longitud

      dl_background_id TYPE sdydo_key VALUE space. " Fondo

      • Creamos html control

      IF g_html_cntrl IS INITIAL.

      CREATE OBJECT g_html_cntrl

      EXPORTING

      parent = g_padre_html.

      ENDIF.

      *Creamos la cabecera

      CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET'

      EXPORTING

      document = g_documento

      bottom = space

      IMPORTING

      length = dl_length.

      • Fusionamos documento

      CALL METHOD g_documento->merge_document.

      • Introducimos fondo

      CALL METHOD g_documento->set_document_background

      EXPORTING

      • picture_id = 'LOGO_EMT'.

      picture_id = dl_background_id.

      • Conectamos el control con el documento de cabecera

      g_documento->html_control = g_html_cntrl.

      • Mostramos el documento de cabecera

      CALL METHOD g_documento->display_document

      EXPORTING

      reuse_control = 'X'

      parent = g_padre_html

      EXCEPTIONS

      html_display_error = 1.

      IF sy-subrc NE 0.

      MESSAGE e016(rp) WITH text-013.

      ENDIF.

      ENDFORM. " HTML

      Leave to initial screen

      *&----


      *

      *& Form clear_pantalla_inicial

      *&----


      *

      FORM clear_pantalla_inicial .

      *Limpiamos la pantalla de seleccion.

      *Areas de trabajo de la pantalla de seleccion

      CLEAR: g_p_tabla30,

      g_p_tabla29.

      CLEAR: ztipoau,

      zfecini,

      ztxtipoau,

      zturno,

      zpo,

      zcochecuadro,

      principio,

      zcrear,

      zmodificar,

      zmostrar.

      zcrear = 'X'.

      CLEAR: gt_tablacc,

      gt_tablanp,

      gt_sort,

      gt_fieldcat.

      *Borro las tablas

      REFRESH: gt_tablacc,

      gt_tablanp,

      gt_sort,

      gt_fieldcat.

      *Libero los objetos

      FREE: g_manejador,

      • g_grid,

      • g_custom_container,

      g_documento,

      g_separador,

      g_padre_grid,

      g_html_cntrl,

      g_padre_html,

      g_logo.

      *Destruimos el objeto

      • CALL METHOD g_manejador->finalize.

      CALL METHOD g_grid->finalize.

      CALL METHOD g_custom_container->finalize.

      CALL METHOD cl_gui_cfw=>flush.

      ENDFORM. " clear_pantalla_inicial

  • avatar image
    Former Member
    Jul 26, 2006 at 03:37 PM

    Hi Jorge,

    try using CL_GUI_CFW=>flush.

    Regards,

    vidya.

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 26, 2006 at 04:06 PM

    I don't see where you are getting the new data again before "Refreshing the grid".

    else .
    
    
    * I think you need to get the new data into your 
    * internal table here,  then the following method will 
    * refresh the grid with new data.
    
    *Refrescamos la tabla
      call method g_grid->refresh_table_display
    * EXPORTING
    * IS_STABLE =
    * I_SOFT_REFRESH =
      exceptions
      finished = 1
      others = 2 .
    
    endif .

    This is how I have used this method in the past, but

    also, never in the PBO, always in the PAI.

    Regards,

    Rich Heilman

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      When i use alv again and go to the dynpro with the alv. I change the data and i try to create the grid,but i show the old data .If i sort the table by a field the data change