‎2007 Jun 06 12:06 PM
Hi,
got a question regarding the selection of layout formats.
Is it possible to modify the alv grid layout, that no other users than the one, who created the layout can change the format?
Currently it is possible to define a layout and provide it to all users, but all the other user are able to change the columns. Is there a way to make this impossible?
Regards
Florian
‎2007 Jun 06 12:16 PM
hi,
chk the standard program BCALV_EDIT_05 with the same functionality
u have to use OO ALV .
regards,
sudheer.
‎2007 Jun 06 12:42 PM
Does anybody know the auhtorization object for this alv grid?
I heard that it is possible to check if somebody has the authorization to save the layout.
Now i am looking for the auth. and how we can implement it in the transaction.
Any hint is welcome...
Regards
Florian
‎2007 Jun 06 2:38 PM
Hello Florian
The important parameter is I_SAVE of method SET_TABLE_FOR_FIRST_DISPLAY. This parameter allows the following values:
I_SAVE
Determines the options available to the user for saving a layout:
'X': global saving only
'U': user-specific saving only
'A': corresponds to 'X' and 'U'
SPACE: no savingIf you set I_SAVE = 'A' any user can maintain all global and his or her user-specific layouts.
If you set I_SAVE = 'U' any user can maintain only his or her user-specific layouts.
If you have not got a copy of <a href="http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907">An Easy Reference For ALV Grid Control</a> I highly recommend to read this document.
Regards
Uwe
‎2007 Jun 06 2:42 PM
Hello Florian
Have forgotten to add my sample report. Run this report with UserA and save several global and user-specific layouts. Next run the same report with UserB and check which layouts this user can manage.
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_ALVGRID_EVENTS_6
*&
*&---------------------------------------------------------------------*
*&
*&
* Flow logic of screen '100' (no elements, ok-code => gd_okcode ):
**PROCESS BEFORE OUTPUT.
** MODULE STATUS_0100.
***
**PROCESS AFTER INPUT.
** MODULE USER_COMMAND_0100.
*&---------------------------------------------------------------------*
REPORT zus_sdn_alvgrid_events_6.
TYPE-POOLS: abap.
DATA:
gd_okcode TYPE ui_func,
*
gt_fcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo,
gs_variant TYPE disvariant,
go_docking TYPE REF TO cl_gui_docking_container,
go_grid1 TYPE REF TO cl_gui_alv_grid.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1.
PARAMETERS:
p_bukrs TYPE bukrs DEFAULT '2000' OBLIGATORY.
*---------------------------------------------------------------------*
* CLASS lcl_eventhandler DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING
e_ucomm
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_eventhandler IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_user_command.
BREAK-POINT.
CHECK ( e_ucomm = cl_gui_alv_grid=>mc_fc_save_variant OR
e_ucomm = cl_gui_alv_grid=>mc_fc_maintain_variant ).
ENDMETHOD. "handle_user_command
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = p_bukrs.
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create ALV grid
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_docking
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Set event handler
SET HANDLER:
lcl_eventhandler=>handle_user_command FOR go_grid1.
* Build fieldcatalog and set hotspot for field KUNNR
PERFORM build_fieldcatalog_knb1.
PERFORM set_layout_and_variant.
* Display data
CALL METHOD go_grid1->set_table_for_first_display
EXPORTING
is_layout = gs_layout
is_variant = gs_variant
i_save = 'A'
CHANGING
it_outtab = gt_knb1
it_fieldcatalog = gt_fcat
EXCEPTIONS
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.
* NOTE:
* Documenation of I_SAVE ("An Easy Reference for ALV Grid Control")
*I_SAVE
*Determines the options available to the user for saving a layout:
* 'X': global saving only
* 'U': user-specific saving only
* 'A': corresponds to 'X' and 'U'
* SPACE: no saving
* Link the docking container to the target dynpro
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
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.
* ok-code field = GD_OKCODE
CALL SCREEN '0100'.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATALOG_KNB1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM build_fieldcatalog_knb1 .
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'KNB1'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT gt_fcat INTO ls_fcat
WHERE ( fieldname = 'KUNNR' OR
fieldname = 'ERNAM' ).
ls_fcat-hotspot = abap_true.
MODIFY gt_fcat FROM ls_fcat.
ENDLOOP.
ENDFORM. " BUILD_FIELDCATALOG_KNB1
*&---------------------------------------------------------------------*
*& Form SET_LAYOUT_AND_VARIANT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_layout_and_variant .
CLEAR: gs_layout,
gs_variant.
gs_layout-cwidth_opt = abap_true.
gs_layout-zebra = abap_true.
gs_variant-report = syst-repid.
gs_variant-handle = 'GRID'.
ENDFORM. " SET_LAYOUT_AND_VARIANTRegards
Uwe