2005 Sep 15 9:45 AM
Hi all,
I'm trying to write a program which achieves the following:
- Get all single roles a certain composite role contains
- Get the "menu" for each of these single roles
- Delete the current menu for the composite role and rebuild it from the single roles.
This requirement comes from someone who administrates the roles. In the current situation he has to use a button in transaction PFCG for all composite roles to copy the menu if the menu of 1 single role changes.
Finding of which single roles a composite role consists is no problem. However simply copying the entries in AGR_HIER to the composite role doesn't do the trick. The menu items are not unique.
Does anyone have a solution for this?
Hi all,
I'm trying to write a program which achieves the following:
- Get all single roles a certain composite role contains
- Get the "menu" for each of these single roles
- Delete the current menu for the composite role and rebuild it from the single roles.
This requirement comes from someone who administrates the roles. In the current situation he has to use a button in transaction PFCG for all composite roles to copy the menu if the menu of 1 single role changes.
Finding of which single roles a composite role consists is no problem. However simply copying the entries in AGR_HIER to the composite role doesn't do the trick. The menu items are not unique.
Does anyone have a solution for this?
2005 Sep 15 2:29 PM
2007 Mar 14 8:48 AM
Hi Bas,
Have you managed to solve this issue? Actually I'm trying to do the same thing and I achieved it using BDC session but it only works in dialog. Is yours working in background mode?
2007 May 09 1:46 PM
In the end I looked at the BAPI's used by SAP and cooked up my own program (4.6C)
REPORT Z_AGR_REFRESH.
TABLES:
agr_define.
DATA Declaration
TYPES: BEGIN OF result,
agr_define TYPE agr_define.
TYPES: chflag(1) TYPE c,
END OF result.
TYPES: BEGIN OF role,
agr_name TYPE agr_name,
END OF role.
DATA: role TYPE TABLE OF role,
wa_role LIKE LINE OF role,
wa2_role LIKE LINE OF role.
DATA: result TYPE TABLE OF result,
wa_result TYPE result.
DATA: new_menu_node TYPE TABLE OF agr_shier,
new_menu_ref TYPE TABLE OF agr_buffi,
new_menu_text TYPE TABLE OF agr_shiert.
DATA: copy_new_menu_node TYPE TABLE OF agr_hier,
copy_new_menu_ref TYPE TABLE OF agr_buffi,
copy_new_menu_text TYPE TABLE OF agr_hiert.
DATA: old_menu_node TYPE TABLE OF agr_hier,
old_menu_ref TYPE TABLE OF agr_buffi,
old_menu_text TYPE TABLE OF agr_hiert.
DATA: okcode LIKE sy-ucomm.
*----
SELECT-OPTIONS
Select Options
TABLES sscrfields.
*selection-screen begin of screen.
SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME.
*selection-screen start of line.
SELECTION-SCREEN COMMENT 1(70) text-s01.
SELECTION-SCREEN COMMENT /1(70) text-s02.
SELECTION-SCREEN COMMENT /1(70) text-s03.
*selection-screen end of line.
SELECTION-SCREEN END OF BLOCK 1.
SELECT-OPTIONS: s_role FOR agr_define-agr_name OBLIGATORY.
*selection-screen end of screen.
*----
Start of Selection
START-OF-SELECTION.
perform select_roles_to_be_changed.
Now for every composite role find the single roles it consists of,
find their menu info , delete it's original menu info and insert the
new one.
perform find_single_roles.
End-Of-Selection.
perform write_report.
&----
*& Form select_roles_to_be_changed
&----
text
----
--> p1 text
<-- p2 text
----
form select_roles_to_be_changed.
*First select all the roles to be changed
SELECT * FROM agr_define INTO CORRESPONDING FIELDS OF
wa_result-agr_define
WHERE agr_name IN s_role .
APPEND wa_result TO result.
ENDSELECT.
endform. " select_roles_to_be_changed
&----
*& Form find_single_roles
&----
text
----
--> p1 text
<-- p2 text
----
form find_single_roles.
LOOP AT result INTO wa_result.
SELECT child_agr FROM agr_agrs INTO table role
WHERE agr_name = wa_result-agr_define-agr_name.
IF sy-subrc NE 0.
*check if this indeed is a compostie role
wa_result-chflag = 'C'. "for reporting
MODIFY result FROM wa_result.
CONTINUE.
ENDIF.
in case of an existing masterrole add this too.
loop at role into wa_role.
select single parent_agr from agr_define into wa2_role
where agr_name = wa_role-agr_name.
if not wa2_role is initial.
append wa2_role to role.
endif.
endloop.
sort role.
delete adjacent duplicates from role.
REFRESH new_menu_node.
REFRESH new_menu_text.
For each childrole find the menu node entries and put them in
*new_menu together
LOOP AT role INTO wa_role.
perform append_menu_structures.
ENDLOOP.
perform write_new_menu.
ENDLOOP.
endform. " find_single_roles
&----
*& Form append_menu_structures
&----
text
----
--> p1 text
<-- p2 text
----
form append_menu_structures.
REFRESH copy_new_menu_node.
REFRESH copy_new_menu_text.
SELECT * FROM agr_hier INTO TABLE copy_new_menu_node
WHERE agr_name = wa_role-agr_name.
SELECT * FROM agr_hiert INTO TABLE copy_new_menu_text
WHERE agr_name = wa_role-agr_name.
CALL FUNCTION 'PRGN_STRU_ADD_AGR_TO_NODETAB'
EXPORTING
compute_sort_order = 'X'
IMPORTING
NEW_START_ID =
TABLES
selected_nodes = copy_new_menu_node
selected_texts = copy_new_menu_text
SELECTED_URLS =
i_nodes = new_menu_node
i_texts = new_menu_text.
endform. " append_menu_structures
&----
*& Form write_new_menu
&----
text
----
--> p1 text
<-- p2 text
----
form write_new_menu.
*Now first remove all old entries to prevent double entries in the menu.
SELECT * FROM agr_hier INTO TABLE old_menu_node
WHERE agr_name = wa_result-agr_define-agr_name.
CALL FUNCTION 'PRGN_DELETE_FOLDERS_AGR_HIER'
TABLES
i_nodes_to_process = old_menu_node.
*At the end all the added menu's are saved to the Database.
CALL FUNCTION 'PRGN_STRU_SAVE_NODES'
EXPORTING
activity_group = wa_result-agr_define-agr_name
use_global_tables = ' '
ONLY_SY_LANGU = ' '
authority_check = 'X'
enqueue = 'X'
source_agr_time = 'X'
TABLES
menu_hierarchy = new_menu_node
menu_texts = new_menu_text
EXCEPTIONS
not_authorized = 1
activity_group_enqueued = 2
OTHERS = 3
.
IF sy-subrc <> 0.
wa_result-chflag = sy-subrc. "for reporting
MODIFY result FROM wa_result.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform. " write_new_menu
&----
*& Form write_report
&----
text
----
--> p1 text
<-- p2 text
----
form write_report.
SKIP 5.
WRITE: / 'Recreated menu for following roles:'.
WRITE: /40 'Recreated Menu',
60 'Single role',
90 'Errors'.
WRITE: /60 '(no adjustments made)'.
ULINE.
SKIP 1.
LOOP AT result INTO wa_result.
WRITE / wa_result-agr_define-agr_name.
CASE wa_result-chflag.
WHEN '1'.
WRITE 80 'You have no Authorisation'.
WHEN '2'.
WRITE 80 'Role is allready being edited, unable to change'.
WHEN '3'.
WRITE 80 'Unspecified Error'.
WHEN 'C'.
WRITE 60 'X'.
WHEN OTHERS.
WRITE 40 'X'.
ENDCASE.
ENDLOOP.
SKIP 1.
WRITE: 'total number of roles: ', sy-tfill.
endform. " write_report
2007 Aug 09 10:33 PM
Hi all
I have added some lines to the program proposed by Bas and the program condense the menu (collapse). He works in ECC 600
Create a new Include "Z" from copy of LPRGN_STRUCTURETOP.
REPORT Z_AGR_REFRESH.
*New includes
INCLUDE ZLPRGN_STRUCTURETOP.
INCLUDE LPRGN_STRUCTUREF01.
INCLUDE LPRGN_STRUCTUREK02.
INCLUDE LPRGN_STRUCTUREK01.
INCLUDE LPRGN_STRUCTUREO01.
....
Insert this lines in FORM FIND_SINGLE_ROLES
....
LOOP AT ROLE INTO WA_ROLE.
PERFORM APPEND_MENU_STRUCTURES.
ENDLOOP.
*Insert
I_NODES[] = NEW_MENU_NODE[]. "<< New
I_TEXTS[] = NEW_MENU_TEXT[]. "<< New
PERFORM CONTROL_CREATETREECONTROL. "<< New
PERFORM STRUCTURE_COMPRESS_MENU. "<< New
NEW_MENU_NODE[] = I_NODES[]. "<< New
NEW_MENU_TEXT[] = I_TEXTS[]. "<< New
*end insert.
PERFORM WRITE_NEW_MENU.
.....
Jose Mercado
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |