Created
May 23, 2015 09:16
-
-
Save JouryJonkergouw/41fd0e5c185878f9b445 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REPORT ZBW_SET_BEX_USER_TEMPLATE. | |
* Author: Joury Jonkergouw | |
* Date: August 2014 | |
* | |
* This program allows you to set the default template of a specific user | |
* to a template defined in the parameter "workbook ID". | |
* If parameter "All users" is set to a X, the template will be set for all users. | |
PARAMETER lv_wbid LIKE rsrwbindex-workbookid. | |
PARAMETER lv_user LIKE rsrwbtemplate-templateuser. | |
PARAMETER lv_all TYPE c. | |
DATA : lv_message TYPE c LENGTH 250. | |
CLEAR: lv_message. | |
* Check if there is a workbook ID filled | |
IF lv_wbid IS NOT INITIAL AND ( lv_user IS NOT INITIAL OR lv_all eq 'X' ). | |
* Check if there is an user ID has been set. If not template should be enabled for all users | |
IF lv_user IS NOT INITIAL. | |
SELECT COUNT( * ) FROM rsrwbtemplate UP TO 1 ROWS WHERE templateuser = lv_user. | |
IF sy-subrc EQ 0. | |
UPDATE rsrwbtemplate SET workbookid = lv_wbid WHERE templateuser = lv_user. | |
WRITE: 'Template of user', lv_user, 'changed to workbook ID', lv_wbid. | |
ELSE. | |
* Check if user exists in SAP | |
SELECT COUNT( * ) FROM usr02 UP TO 1 ROWS WHERE bname = lv_user. | |
IF sy-subrc NE 0. | |
WRITE: 'User', lv_user, 'does not exist in SAP'. | |
ELSE. | |
* Insert specific user in template table | |
TABLES rsrwbtemplate. | |
DATA wa_rsrwbtemplate TYPE rsrwbtemplate. | |
wa_rsrwbtemplate-templateuser = lv_user. | |
wa_rsrwbtemplate-workbookid = lv_wbid. | |
INSERT INTO rsrwbtemplate VALUES wa_rsrwbtemplate. | |
IF sy-subrc EQ 0. | |
WRITE: 'Template of user', lv_user, 'changed to workbook ID', lv_wbid. | |
ELSE. | |
WRITE: 'Could not add', lv_user, 'to table rsrwbtemplate'. | |
ENDIF. | |
ENDIF. | |
ENDIF. | |
* Enable template for all users | |
ELSE. | |
IF lv_all eq 'X'. | |
UPDATE rsrwbtemplate SET workbookid = lv_wbid. | |
IF sy-subrc EQ 0. | |
WRITE: 'Template of all users changed to workbook ID', lv_wbid. | |
ELSE. | |
WRITE: 'Not able to change the template for all users to workbood ID', lv_wbid. | |
ENDIF. | |
ENDIF. | |
ENDIF. | |
ELSE. | |
WRITE: 'No valid option defined'. | |
ENDIF. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment