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 ALV fieldcat without OO

Former Member
0 Likes
437

Hi,

Im using 'alv_grid_display' and after a button is clicked on the output(and backend record created) i 'CALL METHOD ref1->refresh_table_display' to update the IT_REPORT table and make the processed field = 'X' for example.

This works fine, but unfortunatly i also need to change the fieldcat. I changed it and appened but this isnt picked up when 'CALL METHOD ref1->refresh_table_display' is executed. Only the ITab refreshes. Then i found the code below;

  • CALL METHOD grid_9002->set_frontend_fieldcatalog

  • EXPORTING

  • it_fieldcatalog = gt_fieldcat[].

but since im not using OO, my gt_fieldcat is not of the same TYPE as it_fieldcatalog so that cant work either.

Any ideas?

Hi,

Im using 'alv_grid_display' and after a button is clicked on the output(and backend record created) i 'CALL METHOD ref1->refresh_table_display' to update the IT_REPORT table and make the processed field = 'X' for example.

This works fine, but unfortunatly i also need to change the fieldcat. I changed it and appened but this isnt picked up when 'CALL METHOD ref1->refresh_table_display' is executed. Only the ITab refreshes. Then i found the code below;

  • CALL METHOD grid_9002->set_frontend_fieldcatalog

  • EXPORTING

  • it_fieldcatalog = gt_fieldcat[].

but since im not using OO, my gt_fieldcat is not of the same TYPE as it_fieldcatalog so that cant work either.

Any ideas?

1 REPLY 1
Read only

Former Member
0 Likes
362

Yes it is possible....

Please use the sample code.

Just observe the user_command form.

Here i am using the FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR' to update the internal table with the latest data. and also

WHEN '&DATA_SAVE'.

i am adding new column here , and then i am exiting from the alv using selfield-exit and displaying latest one.(here you can see three columns.)

wa_fcat-fieldname = 'FLDATE'.

wa_fcat-tabname = 'IT_DATA'.

wa_fcat-outputlen = 10.

wa_fcat-seltext_l = 'Fldate'.

APPEND wa_fcat TO it_fcat.

selfield-refresh = 'X'.

selfield-exit = 'X'.

PERFORM display_data.

REPORT  ztest_alv1.
TYPE-POOLS: slis.

DATA: it_fcat TYPE slis_t_fieldcat_alv,
      wa_fcat LIKE LINE OF it_fcat.

DATA: it_data TYPE sflight_tab1.


SELECT *
  FROM sflight
  INTO TABLE it_data
  UP TO 20 ROWS.

wa_fcat-fieldname = 'CARRID'.
wa_fcat-tabname  = 'IT_DATA'.
wa_fcat-outputlen = 5.
wa_fcat-edit = 'X'.
wa_fcat-input = 'X'.
wa_fcat-seltext_l = 'Carrid'.
APPEND wa_fcat TO it_fcat.

wa_fcat-fieldname = 'CONNID'.
wa_fcat-tabname  = 'IT_DATA'.
wa_fcat-outputlen = 5.
wa_fcat-seltext_l = 'COnnid'.
APPEND wa_fcat TO it_fcat.

PERFORM display_data.

*&---------------------------------------------------------------------*
*&      Form  display_data
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM display_data.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program      = sy-repid
      it_fieldcat             = it_fcat
      i_callback_user_command = 'USER_COMMAND'
    TABLES
      t_outtab                = it_data
    EXCEPTIONS
      program_error           = 1.
ENDFORM.                    "display_data

*&---------------------------------------------------------------------*
*&      Form  user_command
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM user_command USING ucomm TYPE sy-ucomm
            selfield TYPE slis_selfield.

  DATA: gd_repid LIKE sy-repid, "Exists
  ref_grid TYPE REF TO cl_gui_alv_grid.
  IF ref_grid IS INITIAL.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
      IMPORTING
        e_grid = ref_grid.
  ENDIF.
  IF NOT ref_grid IS INITIAL.
    CALL METHOD ref_grid->check_changed_data .
  ENDIF.

  CASE ucomm.
    WHEN '&DATA_SAVE'.

      wa_fcat-fieldname = 'FLDATE'.
      wa_fcat-tabname  = 'IT_DATA'.
      wa_fcat-outputlen = 10.
      wa_fcat-seltext_l = 'Fldate'.
      APPEND wa_fcat TO it_fcat.
      selfield-refresh = 'X'.
      selfield-exit = 'X'.
      PERFORM display_data.

  ENDCASE.

ENDFORM.                    "user_command

Regards

Vijay Babu Dudla