* __ __ ______ _______ __ __ _______ __ _ __ _ _______ ___ _______ * | | | | _ | | | | | | _ | | | | | | | | | | | * | |_| | | || | | |_| | |_| | |_| | |_| | ___| | | _____| * | | |_||_ | | | | | | |___| | | |_____ * | | __ | | _| | | _ | _ | ___| |___|_____ | * | _ | | | | | |_| _ | _ | | | | | | | |___| |_____| | * |__| |__|___| |_| |_______|__| |__|__| |__|_| |__|_| |__|_______|_______|_______| * platform voor Nederlandstalige HR SAP software componenten www.HRchannels.nl * *------------------------------------------------------------------------------------------- * program : ZHRCHANNELS_PERSONAL_F4_LISTS * title : Distributie van persoonlijke waardelijsten * Copy the F4 personal values list on a search help to other users * functional area : Cross modules * environment : 4.7 * program Function : Search helps can work with a personal values list which limits the * number of entries that are shown in the search help results of the * end used. With this report, the settings of a given user (example * user) can be copied into the settings of a list of (up to 20) users. * This can be very usefull if e.g. old values should be suppressed or * if the values-list of a department should be aligned. Can also * be scheduled. * Documentation : Search for "Personal value list" on AbapcadabrA.com * Previous version : This is the initial version * Translation : Translate to English: * L01;Settings from user * L02;Search object (for user) * L03;Clear settings (for target users) * L04;Target user list * M01;No personal preference settings found - create first * M02;Only 50 individual targets supported * M03;Source is also a target (not allowed) * M04;Please confirm * M05;Do you want to remove the preference settings for all target users ? * M06;Personal preference settings removed for target users * M07;No personal preference settings available for target users * M08;Action cancelled * M09;Do you want to replace the preference settings for all target users ? * M10;Personal preference settings were copied * M11;Insert error - Personal preference settings were NOT copied * M12;No target users specified * Developer name : Wim Maasdam * Development date : 29/06/2015 * Version : 0.1 *--------------------------------------------------------------------- * Change list: * Date Description * 29/06/2015 Initial release *--------------------------------------------------------------------- REPORT ZHRCHANNELS_PERSONAL_F4_LISTS. tables: sscrfields, syst. *--------------------------------------------------------------------- * C L A S S D E F I N I T I O N *--------------------------------------------------------------------- CLASS lcl_personal_pref DEFINITION. PUBLIC SECTION. types: begin of ty_target, username type DDSHPVAL50-username, end of ty_target. class-data: gv_source type sy-uname, gv_SHLPNAME type DD30T-SHLPNAME, gr_targets type range of sy-uname, gt_targets type STANDARD TABLE OF ty_target. class-methods: f4_search_help importing uname type sy-uname, select_targets, clear_settings importing direct_call type boolean default abap_true, copy_settings. ENDCLASS. CLASS lcl_personal_pref IMPLEMENTATION. method f4_search_help. data: lt_DDSHPVAL50 type standard table of DDSHPVAL50, lw_DDSHPVAL50 type DDSHPVAL50, lw_DD30T type DD30T, lt_DD30T type STANDARD TABLE OF DD30T. clear: lt_DDSHPVAL50[]. * Compose a list of search helps objects, for which the user * has personal preference settings available select * from DDSHPVAL50 into table lt_DDSHPVAL50 where username = uname. if lt_DDSHPVAL50[] is initial. message 'Geen persoonlijke waarde objecten gevonden - maak ze aan'(M01) type 'S'. exit. endif. sort lt_DDSHPVAL50. DELETE ADJACENT DUPLICATES FROM lt_DDSHPVAL50 COMPARING pvalkey. clear: lt_DD30T[]. loop at lt_DDSHPVAL50 into lw_DDSHPVAL50. select * from DD30T into lw_DD30T up to 1 rows where SHLPNAME = lw_DDSHPVAL50-pvalkey and DDLANGUAGE = sy-langu. endselect. if sy-subrc = 0. append lw_DD30T to lt_DD30T. endif. endloop. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING ddic_structure = 'DD30T' retfield = 'SHLPNAME' dynpprog = SY-REPID dynpnr = '1000' dynprofield = 'X' value_org = 'S' TABLES value_tab = lt_DD30T. endmethod. method select_targets. data: lv_linecount type sy-tabix. clear gt_targets[]. * Compose a list of actual users, from the gr_targets range. select bname from usr01 into table gt_targets where bname in gr_targets. * A maximum number of target users is set to 20, just to ensure * no system-wide updates can de done describe table gt_targets lines lv_linecount. if lv_linecount > 50. message 'Maximaal 50 ontvangers toegestaan'(M02) type 'E'. endif. * Check whether source is also in targets read table gt_targets with key username = gv_source TRANSPORTING NO FIELDS. if sy-subrc = 0. message 'Bron is ook bestemming (niet toegestaan)'(M03) type 'E'. endif. endmethod. method clear_settings. data: lt_DDSHPVAL50 type standard table of DDSHPVAL50, lw_DDSHPVAL50 type DDSHPVAL50, lv_answer type c length 1. lv_answer = '1'. if sy-batch is initial and direct_call = abap_true. * Don't bother with the confirmation when scheduled in background CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING TITLEBAR = 'Graag confirmeren'(M04) TEXT_QUESTION = 'Wilt u de code waardelijsten verwijderen ? (voor doel gebruikers)'(M05) DISPLAY_CANCEL_BUTTON = space IMPORTING ANSWER = lv_answer. endif. if lv_answer = '1'. *--------------------------------------------------- delete from DDSHPVAL50 where username in gr_targets and PVALKEY = gv_SHLPNAME. *--------------------------------------------------- if sy-subrc = 0. message 'Waardelijsten zijn verwijderd'(M06) type 'S'. else. message 'Geen waardelijsten voorhanden (voor de doel gebruikers)'(M07) type 'S'. endif. else. message 'Actie onderbroken'(M08) type 'S'. endif. endmethod. method copy_settings. data: lt_DDSHPVAL50 type standard table of DDSHPVAL50, lw_DDSHPVAL50 type DDSHPVAL50, lt_DDSHPVAL50_new type standard table of DDSHPVAL50, lv_answer type c length 1, lv_target type ty_target. * First select the source settings for the user and search help: select * from DDSHPVAL50 into table lt_DDSHPVAL50 where username = gv_source and PVALKEY = gv_SHLPNAME. if lt_DDSHPVAL50[] is initial. message 'Personal preference settings not found (for this user)' type 'S'. exit. endif. * Now we're in serious business - confirm update step: lv_answer = '1'. if sy-batch is initial. * Don't bother with the confirmation when scheduled in background CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING TITLEBAR = 'Graag confirmeren'(M04) TEXT_QUESTION = 'Wilt u de waardelijsten van alle doel gebruikers vervangen ?'(M09) DISPLAY_CANCEL_BUTTON = space IMPORTING ANSWER = lv_answer. endif. if lv_answer = '1'. * The personal settings for the user are available, now remove existing settings * for the target group clear_settings( exporting direct_call = abap_false ). * Copy new settings for each individual person: clear: lt_DDSHPVAL50_new[]. loop at gt_targets into lv_target. loop at lt_DDSHPVAL50 into lw_DDSHPVAL50. lw_DDSHPVAL50-username = lv_target-username. append lw_DDSHPVAL50 to lt_DDSHPVAL50_new. endloop. endloop. * Insert composed information into the database: *--------------------------------------------------- insert DDSHPVAL50 from table lt_DDSHPVAL50_new. *--------------------------------------------------- if sy-subrc = 0. message 'Instellingen zijn gekopieerd'(M10) type 'S'. else. message 'Fout: instellingen konden niet gekopieerd worden'(M11) type 'S'. endif. endif. endmethod. ENDCLASS. *--------------------------------------------------------------------- * S E L E C T I O N - S C R E E N *--------------------------------------------------------------------- selection-SCREEN BEGIN OF LINE. selection-SCREEN COMMENT 1(28) lbl_01 FOR FIELD pa_uname. PARAMETERS: pa_uname TYPE XUBNAME MATCHCODE OBJECT SX_USER OBLIGATORY DEFAULT sy-uname. selection-SCREEN END OF LINE. selection-SCREEN BEGIN OF LINE. selection-SCREEN COMMENT 1(28) lbl_02 FOR FIELD pa_shlpn. PARAMETERS: pa_shlpn TYPE DD30T-SHLPNAME OBLIGATORY. selection-SCREEN END OF LINE. selection-SCREEN BEGIN OF LINE. PARAMETERS: pa_clear TYPE c AS CHECKBOX DEFAULT space. selection-SCREEN COMMENT 4(40) lbl_03 FOR FIELD pa_clear. selection-SCREEN END OF LINE. selection-SCREEN SKIP. selection-SCREEN BEGIN OF LINE. selection-SCREEN COMMENT 1(25) lbl_04 FOR FIELD so_uname. SELECT-OPTIONS so_uname FOR syst-uname MATCHCODE OBJECT SX_USER NO INTERVALS. selection-SCREEN END OF LINE. selection-SCREEN SKIP. selection-SCREEN BEGIN OF LINE. SELECTION-SCREEN PUSHBUTTON (70) lbl_link USER-COMMAND ABAPCADABRA VISIBLE LENGTH 5. selection-SCREEN END OF LINE. AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_shlpn. * Pick the dynpro value directly from the screen data: lt_DYNPREAD type standard table of DYNPREAD, lw_DYNPREAD type DYNPREAD. lw_DYNPREAD-FIELDNAME = 'PA_UNAME'. clear lt_DYNPREAD[]. append lw_DYNPREAD to lt_DYNPREAD. CALL FUNCTION 'DYNP_VALUES_READ' EXPORTING DYNAME = sy-repid DYNUMB = '1000' TRANSLATE_TO_UPPER = 'X' TABLES DYNPFIELDS = lt_DYNPREAD EXCEPTIONS OTHERS = 0. read table lt_DYNPREAD into lw_DYNPREAD index 1. pa_uname = lw_DYNPREAD-FIELDVALUE. lcl_personal_pref=>f4_search_help( EXPORTING uname = pa_uname ). AT SELECTION-SCREEN ON so_uname. if so_uname[] is initial. message 'Geen doel gebruikers opgegeven'(M12) type 'E'. endif. AT SELECTION-SCREEN. CASE sscrfields-ucomm. WHEN 'HRCHANNELS'. CALL FUNCTION 'CALL_BROWSER' EXPORTING URL = 'http://www.hrchannels.nl/index.php/bibliotheek/18-persoonlijke-waardelijsten' EXCEPTIONS OTHERS = 0. ENDCASE. *--------------------------------------------------------------------- * I N I T I T A L I Z A T I O N *--------------------------------------------------------------------- INITIALIZATION. * All texts for this report have been set up as hard-coded texts (no use * of the report text-pool). Reason: easy copying of report source code. lbl_link = '@N5\QMeer op HRchannels.nl@'. lbl_01 = 'Instellingen van gebruiker'(L01). lbl_02 = 'Object (voor gebruiker)'(L02). lbl_03 = 'Verwijder waardelijsten (voor doel gebruikers)'(L03). lbl_04 = 'Doel gebruikers'(L04). *--------------------------------------------------------------------- * S T A R T - O F - S E L E C T I O N *--------------------------------------------------------------------- START-OF-SELECTION. lcl_personal_pref=>gv_source = pa_uname. lcl_personal_pref=>gv_shlpname = pa_shlpn. lcl_personal_pref=>gr_targets[] = so_uname[]. lcl_personal_pref=>select_targets( ). if lcl_personal_pref=>gt_targets[] is initial. message 'No target users selected' type 'S'. else. if not pa_clear is initial. lcl_personal_pref=>clear_settings( ). else. lcl_personal_pref=>copy_settings( ). endif. endif.