04-01-2010 1:38 PM
Hi,
I am using FM 'REUSE_ALV_GRID_DISPLAY' in my report. The heading contains the layout name and description. Once executed the user may decide to change the layout to another saved layout. How can I get the heading to reflect the new layout name and text i.e. what field name will I be using and how will I use it.
Help is much apprecieted,
Thanks,
Leanne
04-01-2010 2:15 PM
Hi Leanne,
Try this.
Try using a variable for giving the layout title and change the value dynamically. Every time after u change the grid title refresh the alv grid.
Hope this may be helpful.
Regards,
Sharin.
04-01-2010 2:15 PM
Hi Leanne,
Try this.
Try using a variable for giving the layout title and change the value dynamically. Every time after u change the grid title refresh the alv grid.
Hope this may be helpful.
Regards,
Sharin.
04-06-2010 7:47 AM
Hi Thanks for the feedback. Do you know where I will be able to get the ALV LAYOUT variable from?
Thanks,
Leanne
04-06-2010 7:58 AM
Hello,
In the FM interface you have the param IT_EVENT_EXIT. Here you can specify for which function codes (in your case "save layout") you need to create an exit routine.
Now you can code for the exit routine mentioned in I_CALLBACK_USER_COMMAND.
Please read the parameter documentation for details.
BR,
Suhas
PS: In the documentation you have an example similar to your requirement
04-06-2010 2:21 PM
Hi, Thanks for the feedback so far. I am still a little lost. It looks like I must use FM 'REUSE_ALV_LIST_LAYOUT_INFO_GET' to get the layout variant information but I am not winning. Can someone supply some sample code or help is any other way?
Thanks,
Leanne
04-06-2010 2:56 PM
Hi,
call function 'REUSE_ALV_LIST_LAYOUT_INFO_GET'
importing
es_layout = layout1
et_fieldcat = fieldcat
exceptions
no_infos = 1
program_error = 2
others = 3.
And in the After return
In the fieldcatalog, look for
- fieldcat-TECH " Field not displayable
- fieldcat-NO_OUT " Field not displayed
- fieldcat-COL_POS " position of field
Regards,
srinivas
04-06-2010 9:16 PM
Hello Leanne,
Seems like the FM cannot retrieve the details of the layout for an ALV Grid. It works fine for an ALV list though
TYPE-POOLS slis.
PARAMETERS p_vari TYPE slis_vari.
DATA:
itab TYPE STANDARD TABLE OF sflight,
v_repid TYPE sy-repid,
it_event TYPE slis_t_event,
wa_event TYPE slis_alv_event,
it_exit TYPE slis_t_event_exit,
wa_exit TYPE slis_event_exit,
st_var TYPE disvariant.
DATA:
g_save(1) TYPE c,
g_default(1) TYPE c,
g_exit(1) TYPE c,
gx_variant TYPE disvariant,
g_variant TYPE disvariant.
INITIALIZATION.
g_save = 'A'.
g_variant-report = sy-repid.
* Get default variant
gx_variant = g_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = g_save
CHANGING
cs_variant = gx_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
p_vari = gx_variant-variant.
ENDIF.
* Process on value request
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
PERFORM f4_for_variant.
START-OF-SELECTION.
SELECT * FROM sflight INTO TABLE itab UP TO 20 ROWS.
IF sy-subrc = 0.
wa_exit-ucomm = '&AVE'.
wa_exit-after = 'X'.
APPEND wa_exit TO it_exit.
CLEAR wa_exit.
v_repid = sy-repid.
wa_event-name = slis_ev_top_of_page.
wa_event-form = 'F_TOP_OF_PAGE'.
APPEND wa_event TO it_event.
st_var-report = sy-repid.
st_var-variant = p_vari.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_callback_user_command = 'F_UCOMM'
i_structure_name = 'SFLIGHT'
i_save = g_save
is_variant = st_var
it_events = it_event
it_event_exit = it_exit
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
04-06-2010 9:18 PM
Contd.:
*&---------------------------------------------------------------------*
*& Form F_TOP_OF_PAGE
*&---------------------------------------------------------------------*
FORM f_top_of_page.
DATA: lt_line TYPE slis_t_listheader,
ls_line TYPE slis_listheader.
IF gx_variant IS INITIAL.
gx_variant-report = sy-repid.
gx_variant-variant = p_vari.
ENDIF.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = g_save
CHANGING
cs_variant = gx_variant
EXCEPTIONS
wrong_input = 1
not_found = 2
program_error = 3
OTHERS = 4.
IF sy-subrc = 0.
ls_line-typ = 'H'.
ls_line-info = 'Variant info'.
APPEND ls_line TO lt_line.
CLEAR ls_line.
ls_line-typ = 'S'.
ls_line-key = `Variant name: `.
ls_line-info = gx_variant-variant.
APPEND ls_line TO lt_line.
CLEAR ls_line.
ls_line-typ = 'S'.
ls_line-key = `Variant desc.: `.
ls_line-info = gx_variant-text.
APPEND ls_line TO lt_line.
CLEAR ls_line.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = lt_line.
ENDIF.
ENDFORM. "F_TOP_OF_PAGE
*&---------------------------------------------------------------------*
*& Form F_UCOMM
*&---------------------------------------------------------------------*
FORM f_ucomm
USING i_ucomm TYPE sy-ucomm
is_selfield TYPE slis_selfield.
DATA: ls_var TYPE disvariant.
IF i_ucomm = '&AVE'.
CALL FUNCTION 'REUSE_ALV_LIST_LAYOUT_INFO_GET'
IMPORTING
es_variant = ls_var
EXCEPTIONS
no_infos = 1
program_error = 2
OTHERS = 3.
IF sy-subrc = 0.
gx_variant = ls_var.
ENDIF.
ENDIF.
ENDFORM. "F_UCOMM
04-07-2010 8:17 AM
Hi,
Thanks once again. I however still get the original layout name. The FM 'REUSE_ALV_LIST_LAYOUT_INFO_GET' returns a code 1 (NO_INFOS). Where is the new layout variant name?
Thanks,
Leanne
04-07-2010 9:33 AM
>
> Thanks once again. I however still get the original layout name. The FM 'REUSE_ALV_LIST_LAYOUT_INFO_GET' returns a code 1 (NO_INFOS). Where is the new layout variant name?
Hello Leanne,
Thats exactly what i am trying to tell. The FM ''REUSE_ALV_LIST_LAYOUT_INFO_GET' ' does not seem to work correctly on ALV grid
Or may be we are doing something wrong when using this FM with ALV grid.
May be other SDNers have something to add here.
BR,
Suhas
06-17-2010 8:56 AM
05-31-2012 11:39 AM
Hi, the answer is simply you need to use
'REUSE_ALV_GRID_LAYOUT_INFO_GET' not ''REUSE_ALV_LIST_LAYOUT_INFO_GET'.
DATA: ls_var TYPE disvariant.
CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_GET'
IMPORTING
es_variant = ls_var
EXCEPTIONS
no_infos = 1
program_error = 2
OTHERS = 3.