ALV Grid save layout
Hi all,
in a programm there is a ALV grid of type cl_gui_alv_grid.
When I run the programm, I can change the layout (hide columns etc) but I can't
save the changes I make. What do I have to do to activate the saving of the layout?
Which field do I have to set to activate it or what can already be set which disables the showing of the save possibility?
Greetings Fred.
Hi Fred
U need to transfer the name of the report and the user to the grid class in order to allow to save the layout:
DATA: LT_VARIANT TYPE DISVARIANT.
LT_VARIANT-REPORT = SY-REPID.
LT_VARIANT-USERNAME = SY-UNAME.
CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_VARIANT = LT_VARIANT
I_SAVE = 'A'
IS_LAYOUT = LT_LAYOUT
IT_TOOLBAR_EXCLUDING = GT_NO_CODES
CHANGING
IT_OUTTAB = T_OUTPUT
IT_FIELDCATALOG = GT_FIELDCAT.
The user has to have the authorizations to manage the layout.
Max
Similar Messages
-
IN ALV Report 'SAVE LAYOUT' option missing
Dear All,
I have created one report in ALV GRID using ABAP OBJECTS(Using class CL_GUI_CUSTOM_CONTAINER and
CL_GUI_ALV_GRID).But in output when i click on change layout option i am not getting SAVE layout option.
I have already passed I_SAVE parameter = 'A' while calling metod SET_TABLE_FOR_FIRST_DISPLAY. But i didnt worked.
Please do needful.
Regards,
MayankHi,
You can manage display variants by using parameters, is_variant and i_save of set_table_for_first_display. Here are options for variant handling. <structure_name> is the variant-defining structure of type DISVARIANT. The field report in this structure should contain the value of sy-repid.
Hope this helps. Reward points if helpful.
Thanks,
Balaji -
Disable resizing of columns in ALV grid after layout is fixed
Hello Experts!
I needed to decrease size of some of my columns so I used set_fixed_table_layout( abap_true ).
This worked fine, but when I scroll on the column header , I get a possibility to resize columns by changing the width of culumns at run-time.
Is it possible to disable this functionality?Fixed table layout is a nice way of handling sizing if you wish to eliminate horizontal scrolling. If you want to have specific widths, and disallow re-sizing, why use fixed table layout? Maybe set the columns widths manually in the code.
-
List box in alv grid control through slis and reuse_alv grid_display metho
hello,
i want to display list box in one column of alv by slis method.can u suggest me how to do it?
neonHi,
plz check below code :
TYPE-POOLS : slis.
*data declarations for ALV container,ALV grid, Fieldcatalogues & layout
DATA: g_grid TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container,
gt_fieldcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo.
*INTERNAL TABLE AND WA DECLARATIONS FOR t517 A table
DATA: gt_outtab TYPE STANDARD TABLE OF t517a INITIAL SIZE 0,
wa_outtab TYPE t517a.
*initialisation event
INITIALIZATION.
*Start of selection event
START-OF-SELECTION.
*Call to ALV
CALL SCREEN 600.
*On this statement double click it takes you to the screen painter SE51.
*Create a Custom container and name it CCONT and OK code as OK_CODE.
*Save check and Activate the screen painter.
*Now a normal screen with number 600 is created which holds the ALV grid.
PBO of the actual screen , Here we can give a title and customized menus
Here we also call the subroutine for ALV output.
MODULE PBO OUTPUT *
MODULE pbo OUTPUT.
set pf-status 'xxx'.
set titlebar 'MAIN100'.
Subroutine to display the output in alv
PERFORM alv_output.
ENDMODULE. "pbo OUTPUT
PAI module of the screen created. In case we use an interactive ALV or
*for additional functionalities we can create OK codes and
based on the user command we can do the coding.
MODULE PAI INPUT *
MODULE pai INPUT.
ENDMODULE. "pai INPUT
*& Form BUILD_FIELDCAT
FORM build_fieldcat.
DATA ls_fcat TYPE lvc_s_fcat.
*Build the field catalogue
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'T517A'
CHANGING
ct_fieldcat = gt_fieldcat.
To assign dropdown in the fieldcataogue
LOOP AT gt_fieldcat INTO ls_fcat.
CASE ls_fcat-fieldname.
WHEN 'SLART'.
*drdn-hndl = '1' is the first list box
ls_fcat-drdn_hndl = '1'.
ls_fcat-outputlen = 15.
MODIFY gt_fieldcat FROM ls_fcat.
*drdn-hndl = '2' is the second list box
WHEN 'ABART'.
ls_fcat-drdn_hndl = '2'.
ls_fcat-outputlen = 15.
MODIFY gt_fieldcat FROM ls_fcat.
ENDCASE.
ENDLOOP.
ENDFORM. "build_fieldcat
*& Form ALV_OUTPUT
FORM alv_output .
*Create object for container
CREATE OBJECT g_custom_container
EXPORTING container_name = 'CCONT'.
*create object for grid
CREATE OBJECT g_grid
EXPORTING i_parent = g_custom_container.
Build fieldcat and set column
*Assign a handle for the dropdown listbox.
PERFORM build_fieldcat.
*Build layout
PERFORM build_layout.
Define a drop down table.
PERFORM dropdown_table.
*fetch values from the T517A table
SELECT * FROM t517a INTO TABLE gt_outtab.
*Display ALV output
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_fieldcatalog = gt_fieldcat
it_outtab = gt_outtab.
ENDFORM. "ALV_OUTPUT
*& Form dropdown_table
text
--> p1 text
<-- p2 text
FORM dropdown_table.
*Declarations for drop down lists in ALV.
DATA: lt_dropdown TYPE lvc_t_drop,
ls_dropdown TYPE lvc_s_drop.
First SLART listbox (handle '1').
ls_dropdown-handle = '1'.
ls_dropdown-value = '01 Primary school'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '02 Lower Secondary'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '03 Upper Secondary'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '04 Professional School'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '05 College'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '06 University'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '09 Other Establishment'.
APPEND ls_dropdown TO lt_dropdown.
Second ABART listbox (handle '2').
ls_dropdown-handle = '2'.
ls_dropdown-value = '10 Primary School certificate'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '20 Lower secondary/Junior high'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '30 High school diploma(B-levels)'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '31 Vocational'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '32 Matriculation'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '40 Specialist vocational certificate'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '50 College degree Level1'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '51 College degree Level2'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '52 Masters degree'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '60 Univ Degree level1'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '61 Bachelors degree'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '62 Masters degree'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '63 Licenciate'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '64 Doctors Degree Ph.D'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '89 None'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '90 Unknown'.
APPEND ls_dropdown TO lt_dropdown.
*method to display the dropdown in ALV
CALL METHOD g_grid->set_drop_down_table
EXPORTING
it_drop_down = lt_dropdown.
ENDFORM. " dropdown_table
*& Form build_layout
text
*layout for ALV output
FORM build_layout .
gs_layout-cwidth_opt = 'X'.
gs_layout-grid_title = 'ALV DROPDOWN LISTS'.
gs_layout-no_toolbar = 'X'.
ENDFORM. " build_layout
reference : wiki. -
hi,
Hi,
I am displaying some fields from VBAP in ALV gid and have give drop down check box to storage location making it editable so if the user changes Storage location of
some entries and clicks SAVE button, when we click save button i need to capture all the rows that were been changed and update VA02 using these records through bapi.
but iam not able to capture this SAVE event but iam able to capture Enter and cursor event.
i have written following code for this
LOCAL CLASSES: Definition
class lcl_event_receiver: local class to handle event CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
PRIVATE SECTION.
ENDCLASS. "lcl_event_receiver DEFINITION
LOCAL CLASSES: Implementation
class lcl_event_receiver (Implementation)
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
DATA: l_error_in_data TYPE c.
PERFORM handle_data_changed USING er_data_changed l_error_in_data.
*§7.Display application log if an error has occured.
IF l_error_in_data EQ 'X'.
CALL METHOD er_data_changed->display_protocol.
ENDIF.
ENDMETHOD. "handle_data_changed
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
*& Form handle_data_changed
Identify columns which were changed and check input
-->P_ER_DATA_CHANGED text
FORM handle_data_changed USING p_er_data_changed
TYPE REF TO cl_alv_changed_data_protocol
p_error_in_data TYPE c.
DATA : lw_mod_cell TYPE lvc_s_modi ,
l_value TYPE lvc_value ,
l_lgort TYPE lgort_d.
SORT p_er_data_changed->mt_mod_cells BY row_id .
LOOP AT p_er_data_changed->mt_mod_cells INTO lw_mod_cell
WHERE fieldname = 'LGORT'.
CALL METHOD p_er_data_changed->get_cell_value
EXPORTING
i_row_id = lw_mod_cell-row_id
i_fieldname = 'LGORT'
IMPORTING
e_value = l_value.
SELECT SINGLE lgort FROM t001l INTO l_lgort WHERE werks = p_werks
AND lgort = l_value.
IF sy-subrc NE 0.
In case of error, create a protocol entry in the *application log.
CALL METHOD p_er_data_changed->add_protocol_entry
EXPORTING
i_msgid = '0K'
i_msgno = '000'
i_msgty = 'E'
i_msgv1 = text-003
i_msgv2 = l_value
i_msgv3 = text-004
i_fieldname = lw_mod_cell-fieldname
i_row_id = lw_mod_cell-row_id.
p_error_in_data = 'X'.
EXIT.
ELSE.
*§5b.If the value is valid change values of
cells.
CALL METHOD p_er_data_changed->modify_cell
EXPORTING
i_row_id = lw_mod_cell-row_id
i_fieldname = lw_mod_cell-fieldname
i_value = l_value.
READ TABLE t_list1 INTO w_list1 INDEX lw_mod_cell-row_id.
IF sy-subrc EQ 0.
*comparing old value with the changed value
IF w_list1-lgort <> l_value.
MOVE: w_list1-werks TO w_list3-werks,
w_list1-matnr TO w_list3-matnr,
w_list1-arktx TO w_list3-arktx,
w_list1-vbeln TO w_list3-vbeln,
w_list1-posnr TO w_list3-posnr,
w_list1-pstyv TO w_list3-pstyv,
w_list1-vstel TO w_list3-vstel,
w_list1-auart TO w_list3-auart,
w_list1-kwmeng TO w_list3-kwmeng,
w_list1-vrkme TO w_list3-vrkme,
w_list1-mbdat TO w_list3-mbdat,
l_value TO w_list3-lgort.
APPEND w_list3 TO t_list3.
*t_list3 will contain all the records that are changed
CLEAR w_list3.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
*& Module STATUS_0100 OUTPUT
text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
IF go_custom_container IS INITIAL.
create a custom container control for our ALV Control
CREATE OBJECT go_custom_container
EXPORTING
container_name = g_cont_on_main
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc NE 0.
Display error message.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = sy-repid
txt2 = sy-subrc
txt1 = 'The control could not be created'.
ENDIF.
create an instance of alv control
CREATE OBJECT go_grid
EXPORTING
i_parent = go_custom_container.
*If display or change radio button is cheked
IF ( p_chng = 'X' OR p_disp = 'X' ) .
Set a titlebar for the grid control
g_layout-grid_title = 'Sales Orders'.
g_layout-excp_fname = 'TRAFFIC_LIGHT'.
Define a drop down table.
PERFORM set_drdn_table.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
is_layout = g_layout
CHANGING
it_outtab = t_list1
it_fieldcatalog = t_fieldcat1
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
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.
register ENTER and CURSOR to raise event DATA_CHANGED.
(Per default the user may check data by using the check icon).
CALL METHOD go_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
CALL METHOD go_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
CREATE OBJECT g_event_receiver.
SET HANDLER g_event_receiver->handle_double_click FOR go_grid.
SET HANDLER g_event_receiver->handle_hotspot_click FOR go_grid .
SET HANDLER g_event_receiver->handle_data_changed FOR go_grid .
ENDIF.
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = go_grid.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
MODULE user_command_0100 INPUT.
ok_code = sy-ucomm.
CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN 'SAVE'.
PERFORM update_sales_order using t_list3[].
endcase.
Thanks in Advance,
SiriHi Sirisha,
You can get the event code for Enter because you have regitered in the event reciever .
But for the SAVE you will have to set in the PF-status of the screen and not the ALV-grid save .
Please award if helpful. -
Hi
i'm using ALV-GRID OO and i have problems with
saving my own layout.
In the output-liste i have a button to chage the output, but i'm missig
a button to save the new layout.
CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IT_TOOLBAR_EXCLUDING = GT_EXCLUDE
IS_LAYOUT = GS_LAYOUT
I_SAVE = 'A'
CHANGING
IT_FIELDCATALOG = GT_FIELDCAT
IT_OUTTAB = ITAB.
Any idea?
Regards, DieterMake sure that you pass the variant also.
data: variant type disvariant.
variant-report = sy-repid.
variant-username = sy-uname.
CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IT_TOOLBAR_EXCLUDING = GT_EXCLUDE
IS_LAYOUT = GS_LAYOUT
is_variant = variant
I_SAVE = 'A'
CHANGING
IT_FIELDCATALOG = GT_FIELDCAT
IT_OUTTAB = ITAB.
Regards,
Rich Heilman -
Hi,
I have to save layout in ALV grid which should persist every time when i start the transaction.I am able to get save, change and manage option in the grid and also able to set the default layout but this default layout doesnot work.
please see the code :
l_repvar = sy-repid.
ls_variant = l_repvar.
l_varient = 'A'.
ls_variant-variant = l_varient.
draft_layout-sel_mode = 'D'.
draft_layout-stylefname = 'CELLPROP'.
draft_layout-no_f4 = 'X'.
DISPLAY THE DATA ON THE GRID
CALL METHOD draft_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'PSHLP_DRAFT_ST'
is_layout = draft_layout
it_toolbar_excluding = g_it_exclude
is_variant = ls_variant
i_save = 'A'
i_default = 'X'
CHANGING
it_fieldcatalog = draft_fieldcat
it_outtab = l_draft[].
i have tried by chaging i_save to 'X' and 'U' but no difference.
Useful answers will be rewarded.
Thanks and Regards,
Harshhi,
try with this code,
DATA: wa_disvariant LIKE disvariant.
wa_disvariant-report = g_repid.
wa_disvariant-username = sy-uname.
and pass these values in your function module,
i_save = 'X'
is_variant = wa_disvariant
thanks and regards,
muralidhar. -
How to get the SAVE Layout ICON on ALV Grid display report
Hi,
I am using the standard ALV Layout, and I do not get the SAVE LAYOUT Icon on the Menubar, where I could save the report Layout.I am using the layout routine as,
FORM layout_build USING u_lf_layout TYPE slis_layout_alv.
u_lf_layout-box_fieldname = 'SELK'. " Checkbox
u_lf_layout-zebra = 'X'.
u_lf_layout-colwidth_optimize = 'X'.
u_lf_layout-confirmation_prompt = 'X'.
u_lf_layout-get_selinfos = 'X'.
u_lf_layout-f2code = '&ETA' .
u_lf_layout-detail_titlebar = 'Delivery Due List'.
u_lf_layout-key_hotspot = 'X'.
u_lf_layout-info_fieldname = 'COL'.
ENDFORM. " layout_build
Is there anything that I am missing. Please suggest.Many thanks for your help.
Regards,
MiraHi,
i think you've forgotten param. <b>i_save</b>
x_save = 'X'.
gs_variant-report = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'ZTAB01'
IS_VARIANT = gs_variant
IS_layout = lay
I_SAVE = x_save
TABLES
T_OUTTAB = gridtab
EXCEPTIONS
OTHERS = 1.
regards Andreas -
Save layout option for Block Alv
Hi,
Small Question,
Is there any way to enable Save layout(Ctrl+F10) option for Block ALV?As i cannot see any option to do so with Reuse_*Block like i_save in Grid and For list ALVs...FM.And its by default it is Disable.
Any Hints?
Cheers,
Amit.That's what i already investigated(Small).
wanted Just to confirm.Anyways thanks.
@Gautham:I already found that link([And this also |/message/702997#702997 [original link is broken];) but thought After 2 and
half yrs Vijay found any solution and would land with any solution as always
Anyways Thanks Vijay And Gautham.
Cheers,
Amit. -
'Save layout' button missing in the ALV report layout screen
Hi Friends,
In one of our ALV report the 'save layout' button is missing in the report output screen.i have used the OO concept for creating the ALV output and not the function module.I have attached the code below used for creating the ALV grid.
CREATE OBJECT alv_grid
EXPORTING i_parent = g_container_2.
CALL METHOD alv_grid->set_table_for_first_display
exporting
i_structure_name = 'PA0002'
is_layout =
CHANGING
it_outtab = gt_outtab
it_fieldcatalog = wa_fieldcat.
But i'm not able to trace why the 'save layout' button is missing in the output.Can anyone of you help me in sorting out this problem.
Thanks and Regards,
Vadivel.Pass <u><i><b>A to I_SAVE</b></i></u> parameter. That will give the options to the user to save the layout outs.
I_SAVE = SPACE
Layouts cannot be saved.
I_SAVE = 'U'
Only user-defined layouts can be saved.
I_SAVE = 'X'
Only global layouts can be saved.
I_SAVE = 'A'
Both user-defined and global layouts can be saved.
Regards,
Ravi
Note : Please mark all the helpful answers
Message was edited by: Ravikumar Allampallam -
Change layout button in ALV Grids
Hi Experts,
I have displayed 2 ALV grids in a single screen using OOPS concepts and I have activated the Save Layout option for both the Lists.
Now whenever I will save the layout for the 1st list then automatically it is taken into consideration for the common fields in the second list as well.
Please help me on how I can avoid changing the 2nd list if I will change the 1st list if possible.
Thanks in advance..
Regards,
Srinivas
Edited by: Srinivas Hari on Jun 23, 2009 10:07 AMHello,
I think u can achieve that by populating
HANDLE
LOG_GROUP fields of Disvariant structure in u r program.
Regards -
Alv grid layout as default.
In an alv grid you can personalize the layout (Change layout, save layout). Is it possible to somehow add this saved layout to the report so that it will be shown as the defaylt layout for eveyone that runs the report?
Best Regards ClaesHello Rich Heilman and thank you for your help.
I solved the problem as you suggested in the first example. This has worked great but now i need to set different layouts depending of what the user chooses. This i have not solved yet.
Is there anything else that I need to do except create the layouts with those names <i>/Y23HPAREsum</i> and <i>Y23HPAREind</i> as you se in the code below?
data: variant type disvariant.
variant-report = sy-repid.
if p_sum eq 'X'.
variant-VARIANT = '<i>/Y23HPAREsum</i>'.
else.
variant-VARIANT = '<i>Y23HPAREind</i>'.
endif.
form reuse_alv_list_display.
data : l_repid like sy-repid.
move sy-repid to l_repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = l_repid
i_callback_top_of_page = st_formname_top_of_page
it_fieldcat = st_fieldcat[]
i_save = 'X'
is_variant = variant
tables
t_outtab = lt_rec.
endform. " REUSE_ALV_LIST_DISPLAY
Best Regards Claes -
Manipulate Layout on ALV Grid with dynamic table
Dear all
i'm generating a dynamic table depending of a date selection. That means that I show columns for weeks and the quantity of weeky migh change.
Now the users wants to have a specific layout of the ALV grid with totals. When he saves the layout, only the weeks at this selection will show the next time he runs the programm with a larger selection.
a) Is it possible to modify the layout during runtime by programming?
b) Do you have any other ideas how to solve this problem?
Thank youYou don't know the names of your columns? hmm you do, because before you created dynamic table you had to create field catalog, so the structure and column names of newly (dynamically) created table will be the same like defined in the field catalog.
The last loop also does not look good, in my opinion should be something like:
LOOP AT lt_datatable +(my first table)+ ASSIGNING <ls_data4>.
AT NEW pernr.
APPEND initial line to <fs_1> assigning <fs_2>.
<fs_2>-pernr = <ls_data4>-pernr.
ENDAT.
ASSIGN COMPONENT <ls_data4>-wage_type OF STRUCTURE <fs_2> TO <fs_5>.
<fs_5> = <ls_data4>-amount.
ENDLOOP.
also keep in mind that number of calls of method cl_alv_table_create=>create_dynamic_table is limited to 36 (?) calls within one program session because it uses dynamic subroutine pool behind so you will have short dump if you will execute that 37 times. -
Hello friends,
I want the ALV Grid to be displayed with a default layout. I am able to get the saved layout on the selection screen but when I select that layout still the output layout is not taking it.
Please refer the code which I have written.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_layout.
PERFORM variant_search CHANGING p_layout.
FORM variant_search CHANGING p_layout TYPE slis_vari.
DATA : lv_exit TYPE c,
ls_variant TYPE disvariant.
ls_variant-report = syst-repid.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = ls_variant
i_save = 'A'
IMPORTING
e_exit = lv_exit
es_variant = ls_variant
EXCEPTIONS
not_found = 1
program_error = 2
OTHERS = 3.
IF sy-subrc EQ 0 AND lv_exit IS INITIAL.
p_layout = ls_variant-variant.
ENDIF.
ENDFORM. " variant_search
*-------The above piece of code helps me to save a layout.
Now when I enter the saved layout in my parameter, I want the output to take this layout and display the grid, but I dont know why it is not taking this layout. Please refer the code which I have written.
lr_layout = gr_alv->get_layout( ).
key-report = sy-repid.
lr_layout->set_key( key ).
lr_layout->set_save_restriction( cl_salv_layout=>restrict_none ).
Please let me know how can I achieve this.
Regards,
SalilSalil,
Here is some code that uses a default variant.
*& SELECTION-SCREEN
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_werks FOR marc-werks,
s_matnr FOR mara-matnr,
s_uname FOR sy-uname,
s_datum FOR sy-datum,
s_uzeit FOR sy-uzeit,
s_mtart FOR mara-mtart,
s_matkl FOR mara-matkl.
PARAMETERS: p_toler(3) TYPE n.
SELECTION-SCREEN: END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK v1 WITH FRAME.
PARAMETERS: p_vari LIKE disvariant-variant.
SELECTION-SCREEN END OF BLOCK v1.
*& Event INITIALIZATION
INITIALIZATION.
PERFORM set_defaults.
PERFORM default_variant CHANGING p_vari.
Event AT SELECTION-SCREEN ON VALUE-REQUEST
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
PERFORM f4_for_variant CHANGING p_vari.
*& Form default_variant
text
<--PL_VARI variant
FORM default_variant CHANGING pl_vari.
g_repid = sy-repid.
set options: save variants userspecific or general
g_save = 'A'. " 'A' = standard and user-specific saving
initialize variant
CLEAR gs_variant.
gs_variant-report = g_repid.
get default variant
gs_xvariant = gs_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = g_save
CHANGING
cs_variant = gs_xvariant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
pl_vari = gs_xvariant-variant.
ENDIF.
ENDFORM. " default_variant
*& Form f4_for_variant
text
<--PL_VARI variant
FORM f4_for_variant CHANGING pl_vari.
display variant selection dialog box
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = gs_variant
i_save = g_save
it_default_fieldcat =
IMPORTING
e_exit = g_exit
es_variant = gs_xvariant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 2.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF g_exit = space.
pl_vari = gs_xvariant-variant.
ENDIF.
ENDIF.
ENDFORM. " f4_for_variant
MODULE status_0100 OUTPUT
MODULE status_0100 OUTPUT.
SET PF-STATUS '100'.
SET TITLEBAR '100'.
IF o_container IS INITIAL.
REFRESH: t_fieldcat,
t_sortcat,
t_groupcat,
gt_exclude.
CREATE OBJECT o_container
EXPORTING container_name = 'CONTAINER'.
Create TOP-Document
CREATE OBJECT o_dyndoc_id
EXPORTING style = 'ALV_GRID'.
Create Splitter for custom_container
CREATE OBJECT o_splitter
EXPORTING parent = o_container
rows = 2
columns = 1.
CALL METHOD o_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = o_parent_top.
CALL METHOD o_splitter->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = o_parent_grid.
Set height for g_parent_html
CALL METHOD o_splitter->set_row_height
EXPORTING
id = 1
height = 12.
CREATE OBJECT o_grid
EXPORTING i_parent = o_parent_grid.
gs_layout-smalltitle = 'X'.
gs_layout-no_rowmark = ' '.
gs_layout-cwidth_opt = 'X'.
gs_layout-zebra = 'X'.
gs_layout-sel_mode = 'D'.
gs_variant-report = sy-cprog.
gs_variant-variant = p_vari.
gs_exclude = cl_gui_alv_grid=>mc_fc_info.
APPEND gs_exclude TO gt_exclude.
gs_exclude = cl_gui_alv_grid=>mc_fc_graph.
APPEND gs_exclude TO gt_exclude.
CALL METHOD o_grid->set_3d_border
EXPORTING
border = 1.
SET HANDLER lcl_event_handler=>hotspot_click FOR o_grid.
SET HANDLER lcl_event_handler=>top_of_page FOR o_grid.
SET HANDLER lcl_event_handler=>print_top_of_page FOR o_grid.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'Z1271'
CHANGING
ct_fieldcat = t_fieldcat.
LOOP AT t_fieldcat INTO h_fieldcat.
CASE h_fieldcat-fieldname.
WHEN 'MATNR'.
h_fieldcat-hotspot = 'X'.
WHEN 'VBELN'.
h_fieldcat-hotspot = 'X'.
WHEN 'UNAME'.
h_fieldcat-coltext = 'Maint. By'.
h_fieldcat-tooltip = 'Material maintained by'.
WHEN 'DATUM'.
h_fieldcat-coltext = 'Maint. Date'.
h_fieldcat-tooltip = 'Material maintenance date'.
WHEN 'UZEIT'.
h_fieldcat-coltext = 'Maint. Time'.
h_fieldcat-tooltip = 'Material maintenance time'.
WHEN 'EDAYS'.
h_fieldcat-coltext = 'EDays'.
h_fieldcat-tooltip = 'Elapsed days'.
WHEN 'ETIME'.
h_fieldcat-coltext = 'ETime'.
h_fieldcat-tooltip = 'Elapsed time same day'.
WHEN 'EDATU'.
h_fieldcat-coltext = 'Delivery Date'.
h_fieldcat-tooltip = 'Delivery date'.
ENDCASE.
MODIFY t_fieldcat FROM h_fieldcat.
CLEAR h_fieldcat.
ENDLOOP.
CALL METHOD o_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
i_save = 'A'
is_variant = gs_variant
it_toolbar_excluding = gt_exclude
CHANGING
it_fieldcatalog = t_fieldcat
it_sort = t_sortcat
it_outtab = t_rpt.
CALL METHOD o_grid->list_processing_events
EXPORTING
i_event_name = 'TOP_OF_PAGE'
i_dyndoc_id = o_dyndoc_id.
ENDIF.
ENDMODULE. "status_0100 OUTPUT -
Disabling "Default layout setting" in ALV grid display
Hello,
We have a requirement where we need to disable layout default settings in ALV grid display.
Only certain users should be able to save the report layout as default.
We would be creating an authorization group for this and then based on the Authority check we would need to enable or disable Default layout save option.
I found that using I_SAVE in the FM "REUSE_ALV_GRID_DISPLAY", we can either enable or disable layout save option.
But our requirement is to disable Default layout save option based on the authority check.
We will find this option next to User specific option when we save the report layout.
Can anyone guide me on this?
Thanks,
Regards,
AnidHi Anid,
First of all check if you can do this excluding the buttons from the ALV with the excluding tab. If not, here is the code for the ALV OO to exclude the buttons.
FORM F_DISPLAY_ALV.
* Layout
PERFORM f_layout.
* Exclude Buttons
DATA: gt_excl TYPE ttb_button
REFRESH gt_excl.
* Append those you want to exclude. These are some of them. Check Class in SE24 -> Atributes of class cl_gui_alv_grid.
APPEND: cl_gui_alv_grid=>mc_fc_loc_cut TO gt_excl,
cl_gui_alv_grid=>mc_fc_loc_undo TO gt_excl,
cl_gui_alv_grid=>mc_fc_loc_copy TO gt_excl,
cl_gui_alv_grid=>mc_fc_loc_paste TO gt_excl,
cl_gui_alv_grid=>mc_fc_loc_copy_row TO gt_excl,
cl_gui_alv_grid=>mc_fc_loc_move_row TO gt_excl,
cl_gui_alv_grid=>mc_fc_loc_delete_row TO gt_excl,
cl_gui_alv_grid=>mc_fc_loc_insert_row TO gt_excl,
cl_gui_alv_grid=>mc_fc_loc_append_row TO gt_excl,
cl_gui_alv_grid=>mc_fc_loc_paste_new_row TO gt_excl,
cl_gui_alv_grid=>mc_fc_to_office TO gt_excl,
cl_gui_alv_grid=>mc_fc_expcrdesig TO gt_excl.
CALL METHOD gv_alv_grid->set_table_for_first_display
EXPORTING
it_toolbar_excluding = gt_excl[]
is_layout = wa_layout_main
is_variant = wa_variant
i_save = 'A'
CHANGING
it_outtab = gt_alv[]
it_fieldcatalog = gt_fieldcat[]
it_sort = gt_sort[].
Edited by: Ernesto Caballero on Mar 11, 2010 5:59 PM
Edited by: Ernesto Caballero on Mar 11, 2010 6:03 PM
Maybe you are looking for
-
I have tried many times to restore my new IPod Touch 5G in I Tunes and it will not allow me to do it. My Ipod will not turn on at all even when on a fresh charge. Only displays the arrow leading up to ITunes logo. I have tried the method of holdi
-
How realize a pop-up window?
Hi, I want to create a speech bubble for a little man. This little man and the speech bubble have to appear as a pop up. Does anyone knows how I can realize this? How I can realize when the mouse is moving over a piece of the window, that the little
-
More than one db field displayed in one table field
Hi, I want to create a report in which in the last column there is displayed more than one result, because to each name there is more than one result. The client wants us to display the results in the same line with the name and not one result and on
-
Label x,y coordinate on plot DIAdem
How do I select and label the x,y coordinate for a min/max point in DIAdem (version 11.0) in the VIEW tab? Is it possible to select a point and have the coordinate automatically labele the (x,y) values? (What if it isn't a specific max or min point?)
-
BW Reporting on RPM and C projects
Hi Guys, I have a requirments on BW reporting on RPM and Cprojects.Can any one please suggest how we can do and documents on this would be helpfull Thanks Dp