GET /sap/opu/odata/UI2/PAGE_BUILDER_PERS/Pages?$select=id,title&$filter=catalogId eq '/UI2/FLPD_CATALOG'&sap-client=100&$format=json
GET /sap/opu/odata/UI2/PAGE_BUILDER_PERS/Pages('%2FUI2%2FFiori2LaunchpadHome')/allCatalogs?$expand=Chips/ChipBags/ChipProperties&$select=id,Chips/title,Chips/url,Chips/ChipBags/ChipProperties/chipId,Chips/ChipBags/ChipProperties/value&$filter=type eq 'CATALOG_PAGE' or type eq 'H' or type eq 'SM_CATALOG' or type eq 'REMOTE'&$orderby=title&sap-client=100&$format=json
POST /sap/opu/odata/UI2/PAGE_BUILDER_PERS/PageSets('%2FUI2%2FFiori2LaunchpadHome')/Pages
# Payload (content-type: application/json)
{
"catalogId" : "/UI2/FLPD_CATALOG",
"title" : "My first group"
}
POST /sap/opu/odata/UI2/PAGE_BUILDER_PERS/PageChipInstances
# Payload (content-type: application/json)
{
"pageId" : "006O04N57XIQE1LI39O75AB0X",
"chipId" : "X-SAP-UI2-PAGE:X-SAP-UI2-CATALOGPAGE:SAP_SD_BC_SO_PROC_OP:ET090PW4NWFHY64E22UBU3LBF"
}
# pageID is the ID of the newly created group
# chipId is the ID of the app retrieved from the UI2/PAGE_BUILDER_PERS/Pages query
Manage Sales Orders;Customer Service
Create Billing Documents;Customer Service
Maintain Business Partner;Customer Service
Manage PIRs;Production Planning
Manage Production Orders;Production Planning
Material Documents Overview;Production Planning
Manage Outbound Deliveries;Supply Chain
Freight Orders;Supply Chain
Manage Purchase Requisitions;Procurement
Manage Purchase Orders;Procurement
Manage Customer Line Items;Finance
Post Incoming Payments;Finance
from csv import reader
from getpass import getpass
from requests import session
from requests.auth import HTTPBasicAuth
from sys import argv
from urllib3 import disable_warnings
from urllib3.exceptions import InsecureRequestWarning
apps = {}
groups = {}
try:
appfile = argv[1]
except IndexError:
print('You have to specify semicolon-separated app list!')
exit(1)
user = input('User name: ')
password = getpass('Password: ')
host = input('Hostname and port: ')
client = input('Client: ')
s = session()
# Disable warnings related to insecure certificates, if applicable
disable_warnings(InsecureRequestWarning)
# Get CSRF token
header = {'x-csrf-token': 'Fetch'}
r = s.head('{0}/sap/opu/odata/UI2/PAGE_BUILDER_PERS?sap-client={1}'
.format(host, client), auth=HTTPBasicAuth(user, password),
headers=header, verify=False)
csrf = r.headers['x-csrf-token']
# Get available groups
print('\nGetting available groups, it could take a while...')
r = s.get(('{0}/sap/opu/odata/UI2/PAGE_BUILDER_PERS/Pages?$select=id,title&'
'$filter=catalogId eq \'/UI2/FLPD_CATALOG\''
'&sap-client={1}&$format=json').format(host, client),
auth=HTTPBasicAuth(user, password), verify=False)
for group in r.json()['d']['results']:
groups[group['title'].lower()] = group['id']
# Get available apps
print('Getting available apps, it could take a while...\n')
r = s.get(('{0}/sap/opu/odata/UI2/PAGE_BUILDER_PERS/Pages'
'(\'%2FUI2%2FFiori2LaunchpadHome\')/allCatalogs?'
'$expand=Chips/ChipBags/ChipProperties&'
'$select=id,Chips/title,Chips/url,'
'Chips/ChipBags/ChipProperties/chipId,'
'Chips/ChipBags/ChipProperties/value&'
'$filter=type eq \'CATALOG_PAGE\' or type eq \'H\''
'or type eq \'SM_CATALOG\' or type eq \'REMOTE\'&'
'$orderby=title&sap-client={1}&$format=json'.format(host, client)),
auth=HTTPBasicAuth(user, password), verify=False)
for catalog in r.json()['d']['results']:
for chip in catalog['Chips']['results']:
# Only process applauncher chips
if chip['url'].startswith(
'/sap/bc/ui5_ui5/ui2/ushell/chips/applauncher'):
for chipbag in chip['ChipBags']['results']:
for property in chipbag['ChipProperties']['results']:
apps[property['value'].lower()] = property['chipId']
try:
with open(appfile) as fd:
for app in reader(fd, delimiter=';'):
appname = app[0]
group = app[1]
if group.lower() == 'my home':
group = '/UI2/FLPD_CATALOG'
# Create group if it does not exist yet
if group.lower() not in groups:
header = {'x-csrf-token': csrf, 'accept': 'application/json'}
payload = {'catalogId': '/UI2/FLPD_CATALOG', 'title': group}
r = s.post(('{0}/sap/opu/odata/UI2/PAGE_BUILDER_PERS/PageSets'
'(\'%2FUI2%2FFiori2LaunchpadHome\')/'
'Pages?sap-client={1}').format(host, client),
auth=HTTPBasicAuth(user, password),
headers=header, json=payload, verify=False)
groups[group.lower()] = r.json()['d']['id']
print('Group {} created'.format(group))
# Add app to group
try:
header = {'x-csrf-token': csrf, 'accept': 'application/json'}
payload = {'pageId': groups[group.lower()],
'chipId': apps[appname.lower()]}
r = s.post(('{0}/sap/opu/odata/UI2/PAGE_BUILDER_PERS/'
'PageChipInstances?sap-client={1}')
.format(host, client),
auth=HTTPBasicAuth(user, password),
headers=header, json=payload, verify=False)
print('App {} added to group {}'.format(appname, group))
except KeyError:
print('Could not find app {}'.format(appname))
except FileNotFoundError as e:
print(e)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 | |
4 | |
4 |