Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

refresh table-control

Former Member
0 Likes
562

i made an alv,when i choose line i made a bapi update and get another alv-LOG (the number of update).

when i come back to fisrt alv and made another update i get in the alv-log the number of the first update.

i use refresh_table and clear control but not work

ant idea PLSSSS

3 REPLIES 3
Read only

Former Member
0 Likes
524

Hi,

The best thing you can do is debug through yuor code and try and spot when yuo think the data should be cleared and add code at that point to clear it.

Gareth.

Read only

0 Likes
524

that's exactly my problem i get to debug , isee in the table the new data but in alv i see the old data.

Read only

Former Member
0 Likes
524

Hi ,

Please check this link

http://www.geocities.com/mpioud/Z_ALV_GRID_CTRL_REFRESH.html

TYPES:
  BEGIN OF ty_mara,
    ernam TYPE mara-ernam,
    matnr TYPE mara-matnr,
    ersda TYPE mara-ersda,
    brgew TYPE mara-brgew,
  END OF ty_mara.

DATA:
  gt_mara TYPE STANDARD TABLE OF ty_mara.

DATA :
  go_container TYPE REF TO cl_gui_docking_container,
  go_alv_grid  TYPE REF TO cl_gui_alv_grid,

  okcode    TYPE syucomm,
  gv_okcode TYPE syucomm.

*---------------------------------------------------------------------*
START-OF-SELECTION.

  PERFORM f_read_data.

  CALL SCREEN 100.

*---------------------------------------------------------------------*
*       Module  status_0100  OUTPUT
*---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.

  SET PF-STATUS 'MAIN'.

  IF go_container IS INITIAL.
    PERFORM create_and_init_alv.
  ENDIF.

ENDMODULE.                             " STATUS_0100  OUTPUT
*---------------------------------------------------------------------*
*       Module  user_command_0100  INPUT
*---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  gv_okcode = okcode.
  CLEAR okcode.

  CASE gv_okcode.
    WHEN 'BACK'.
      SET SCREEN 0.
    WHEN 'REFRESH'.
      PERFORM f_refresh_table.
    WHEN 'EXIT'.
      LEAVE PROGRAM.
  ENDCASE.

ENDMODULE.                             " USER_COMMAND_0100  INPUT
*---------------------------------------------------------------------*
*      Form  f_read_data
*---------------------------------------------------------------------*
FORM f_read_data.

  STATICS :
    l_rows TYPE i.

  ADD 1 TO l_rows.
  SELECT ernam matnr ersda brgew INTO TABLE gt_mara FROM mara
                                   UP TO l_rows ROWS.

  MESSAGE s208(00) WITH 'Reading data ...'.

ENDFORM.                               " F_READ_DATA
*---------------------------------------------------------------------*
*       Form  create_and_init_alv
*---------------------------------------------------------------------*
FORM create_and_init_alv.

* Macro definition
  DEFINE m_fieldcat.
    add 1 to ls_alv_cat-col_pos.
    ls_alv_cat-fieldname = &1.
    ls_alv_cat-ref_table = 'MARA'.
    append ls_alv_cat to lt_alv_cat.
  END-OF-DEFINITION.

  DATA:
    ls_variant TYPE disvariant,
    lt_alv_cat TYPE lvc_t_fcat,
    ls_alv_cat TYPE lvc_s_fcat,
    ls_alv_lay TYPE lvc_s_layo,
    l_offline  TYPE char1.

  CALL METHOD cl_gui_alv_grid=>offline
    RECEIVING
      e_offline = l_offline.

  IF l_offline EQ 0.
    CREATE OBJECT go_container
        EXPORTING
            extension = 2000
        EXCEPTIONS
            cntl_error = 1
            cntl_system_error = 2
            create_error = 3
            lifetime_error = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
    IF sy-subrc NE 0.
      MESSAGE e208(00) WITH 'The control could not be created'.
    ENDIF.
  ENDIF.

* Create an instance of alv control
  CREATE OBJECT go_alv_grid
      EXPORTING i_parent = go_container.

* Build field catalog
  m_fieldcat 'ERNAM'.
  m_fieldcat 'MATNR'.
  m_fieldcat 'ERSDA'.
  m_fieldcat 'BRGEW'.

* Layout
  CLEAR ls_alv_lay.
  ls_alv_lay-zebra      = 'X'.
  ls_alv_lay-cwidth_opt = 'X'.

  ls_variant-report = sy-cprog.

* Display
  CALL METHOD go_alv_grid->set_table_for_first_display
    EXPORTING
      is_variant      = ls_variant
      is_layout       = ls_alv_lay
      i_save          = 'A'
    CHANGING
      it_outtab       = gt_mara[]
      it_fieldcatalog = lt_alv_cat.

ENDFORM.                               " CREATE_AND_INIT_ALV
*---------------------------------------------------------------------*
*      Form  F_REFRESH_TABLE
*---------------------------------------------------------------------*
FORM f_refresh_table.

  DATA: ls_layout TYPE lvc_s_layo.

  PERFORM f_read_data.

  CALL METHOD go_alv_grid->get_frontend_layout
    IMPORTING
      es_layout = ls_layout.

  ls_layout-cwidth_opt = 'X'.

  CALL METHOD go_alv_grid->set_frontend_layout
    EXPORTING
      is_layout = ls_layout.

  CALL METHOD go_alv_grid->refresh_table_display.

ENDFORM.                               " F_REFRESH_TABLE

Best regards,

raam