0% found this document useful (0 votes)
33 views7 pages

HANA CalculationEngine CalculationScenarios

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views7 pages

HANA CalculationEngine CalculationScenarios

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 7

SELECT

/*

[NAME]

- HANA_CalculationEngine_CalculationScenarios

[DESCRIPTION]

- Display calculation scenarios

[SOURCE]

- SAP Note 1969700

[DETAILS AND RESTRICTIONS]

[VALID FOR]

- Revisions: all

[SQL COMMAND VERSION]

- 2014/12/11: 1.0 (initial version)


- 2015/09/15: 1.1 (AGGREGATE_BY
- 2017/10/24: 1.2 (TIMEZONE included)
- 2018/09/28: 1.3 (SCENARIOS output column added)
- 2018/12/04: 1.4 (shortcuts for BEGIN_TIME and END_TIME like 'C', 'E-S900' or
'MAX')

[INVOLVED TABLES]

- M_CE_CALCSCENARIOS_OVERVIEW

[INPUT PARAMETERS]

- BEGIN_TIME

Begin time

'2018/12/05 14:05:00' --> Set begin time to 5th of December 2018, 14:05
'C' --> Set begin time to current time
'C-S900' --> Set begin time to current time minus 900 seconds
'C-M15' --> Set begin time to current time minus 15 minutes
'C-H5' --> Set begin time to current time minus 5 hours
'C-D1' --> Set begin time to current time minus 1 day
'C-W4' --> Set begin time to current time minus 4 weeks
'E-S900' --> Set begin time to end time minus 900 seconds
'E-M15' --> Set begin time to end time minus 15 minutes
'E-H5' --> Set begin time to end time minus 5 hours
'E-D1' --> Set begin time to end time minus 1 day
'E-W4' --> Set begin time to end time minus 4 weeks
'MIN' --> Set begin time to minimum (1000/01/01 00:00:00)

- END_TIME

End time

'2018/12/08 14:05:00' --> Set end time to 8th of December 2018, 14:05
'C' --> Set end time to current time
'C-S900' --> Set end time to current time minus 900 seconds
'C-M15' --> Set end time to current time minus 15 minutes
'C-H5' --> Set end time to current time minus 5 hours
'C-D1' --> Set end time to current time minus 1 day
'C-W4' --> Set end time to current time minus 4 weeks
'B+S900' --> Set end time to begin time plus 900 seconds
'B+M15' --> Set end time to begin time plus 15 minutes
'B+H5' --> Set end time to begin time plus 5 hours
'B+D1' --> Set end time to begin time plus 1 day
'B+W4' --> Set end time to begin time plus 4 weeks
'MAX' --> Set end time to maximum (9999/12/31 23:59:59)

- TIMEZONE

Used timezone (both for input and output parameters)

'SERVER' --> Display times in SAP HANA server time


'UTC' --> Display times in UTC time

- HOST

Host name

'saphana01' --> Specific host saphana01


'saphana%' --> All hosts starting with saphana
'%' --> All hosts

- PORT

Port number

'30007' --> Port 30007


'%03' --> All ports ending with '03'
'%' --> No restriction to ports

- SERVICE_NAME

Service name

'indexserver' --> Specific service indexserver


'%server' --> All services ending with 'server'
'%' --> All services

- COMPONENT

Name of calculation scenario component

'BW' --> Only show calculation scenarios belonging to component BW


'%' --> No restriction related to calculation scenario component

- SCENARIO_NAME

Name of calculation scenario

'SAPSR3:0BW:BIA:Y08NX2004' --> Calculation scenario with name


SAPSR3:0BW:BIA:Y08NX2004
'%cs' --> Calculation scenarios ending with 'cs'
'%' --> No restriction related to calculation scenario
name

- ONLY_PERSISTENT_SCENARIOS

Possibility to restrict result to persistent scenarios

'X' --> Display only persistent scenarios


' ' --> Display all scenarios

- AGGREGATE_BY

Aggregation criteria (possible values can be found in comment)

'COMPONENT' --> Aggregation by component


'HOST, PORT' --> Aggregation by host and port
'NONE' --> No aggregation

- ORDER_BY

Sort criteria (available values are provided in comment)

'SIZE' --> Sorting by size


'TABLE' --> Sorting by table name

[OUTPUT PARAMETERS]

- CREATION_TIME: Creation time of calculation scenario


- HOST: Host name
- PORT: Port
- SERVICE: Service name
- COMPONENT: Component responsible for calculation scenario
- SCENARIO_TIME: Name of calculation scenario
- P: 'X' -> persisted, ' ' -> not persisted
- SCENARIOS: Number of scenarios
- SIZE_MB: Memory size (MB)
- SIZE_PCT: Memory size share (%)

[EXAMPLE OUTPUT]

-----------------------------------------------------------------------------------
---------------------------
|CREATION_TIME |HOST |PORT |COMPONENT|SCENARIO_NAME
|P|SIZE_MB |SIZE_PCT|
-----------------------------------------------------------------------------------
---------------------------
|2015/09/12 15:11:01|saphana1|30003|BW |SAPBWP:0BW:BIA:ZOCNNM14
|X| 16.81| 10.49|
|2015/09/12 15:08:10|saphana1|30003|BW |SAPBWP:0BW:BIA:ZOCNNM55
|X| 9.66| 6.03|
|2015/09/12 15:05:58|saphana1|30003|BW |SAPBWP:0BW:BIA:ZMINNM03
|X| 8.72| 5.44|
|2015/09/12 15:06:14|saphana1|30003|BW |SAPBWP:0BW:BIA:ZSCNNM12
|X| 8.11| 5.06|
|2015/09/12 15:06:30|saphana1|30003|BW |SAPBWP:0BW:BIA:ZAFZZM01
|X| 7.33| 4.57|
|2015/09/12 15:06:02|saphana1|30003|BW |SAPBWP:0BW:BIA:ZSCNNM56
|X| 6.33| 3.95|
|2015/09/12 15:05:59|saphana1|30003|BW |SAPBWP:0BW:BIA:0ASA_MP01
|X| 6.13| 3.82|
|2015/09/12 15:06:09|saphana1|30003|BW |SAPBWP:0BW:BIA:ZRRNNM13
|X| 4.40| 2.74|
|2015/09/12 15:06:59|saphana1|30003|BW |SAPBWP:0BW:BIA:ZOCNNM06
|X| 4.38| 2.73|
|2015/09/12 15:12:13|saphana1|30003|BW |SAPBWP:0BW:BIA:ZSCNNM50
|X| 4.37| 2.73|
|2015/09/12 15:06:05|saphana1|30003|BW |SAPBWP:0BW:BIA:ZSCNNM03
|X| 3.55| 2.21|
-----------------------------------------------------------------------------------
---------------------------

*/

CREATION_TIME,
HOST,
PORT,
SERVICE_NAME SERVICE,
COMPONENT,
SCENARIO_NAME,
MAP(PERSISTENT, 'TRUE', 'X', '') P,
LPAD(SCENARIOS, 9) SCENARIOS,
LPAD(TO_DECIMAL(SIZE_MB, 10, 2), 8) SIZE_MB,
LPAD(TO_DECIMAL(MAP(SIZE_MB, 0, 0, SIZE_MB / SUM(SIZE_MB) OVER () * 100), 10, 2),
8) SIZE_PCT
FROM
( SELECT
CASE WHEN BI.AGGREGATE_BY = 'NONE'
THEN TO_VARCHAR(CASE BI.TIMEZONE WHEN 'UTC' THEN ADD_SECONDS(CS.CREATE_TIME,
SECONDS_BETWEEN(CURRENT_TIMESTAMP, CURRENT_UTCTIMESTAMP)) ELSE CS.CREATE_TIME
END, 'YYYY/MM/DD HH24:MI:SS') ELSE 'any'
END CREATION_TIME,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'HOST') != 0
THEN CS.HOST ELSE MAP(BI.HOST, '%', 'any', BI.HOST)
END HOST,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'PORT') != 0
THEN TO_VARCHAR(CS.PORT) ELSE MAP(BI.PORT, '%', 'any', BI.PORT)
END PORT,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'SERVICE') != 0
THEN S.SERVICE_NAME ELSE MAP(BI.SERVICE_NAME, '%', 'any',
BI.SERVICE_NAME) END SERVICE_NAME,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'COMPONENT') != 0
THEN CS.COMPONENT ELSE MAP(BI.COMPONENT, '%', 'any', BI.COMPONENT)
END COMPONENT,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'SCENARIO') != 0
THEN CS.SCENARIO_NAME ELSE MAP(BI.SCENARIO_NAME, '%', 'any',
BI.SCENARIO_NAME) END SCENARIO_NAME,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'PERSISTENT') != 0
THEN CS.IS_PERSISTENT ELSE MAP(BI.ONLY_PERSISTENT_SCENARIOS, 'X', 'TRUE',
'any') END PERSISTENT,
COUNT(*) SCENARIOS,
SUM(CS.MEMORY_SIZE / 1024 / 1024) SIZE_MB,
BI.ORDER_BY
FROM
( SELECT
CASE
WHEN BEGIN_TIME = 'C' THEN CURRENT_TIMESTAMP
WHEN BEGIN_TIME LIKE 'C-S%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(BEGIN_TIME, 'C-S'))
WHEN BEGIN_TIME LIKE 'C-M%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(BEGIN_TIME, 'C-M') * 60)
WHEN BEGIN_TIME LIKE 'C-H%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(BEGIN_TIME, 'C-H') * 3600)
WHEN BEGIN_TIME LIKE 'C-D%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(BEGIN_TIME, 'C-D') * 86400)
WHEN BEGIN_TIME LIKE 'C-W%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(BEGIN_TIME, 'C-W') * 86400 * 7)
WHEN BEGIN_TIME LIKE 'E-S%' THEN
ADD_SECONDS(TO_TIMESTAMP(END_TIME, 'YYYY/MM/DD HH24:MI:SS'), -
SUBSTR_AFTER(BEGIN_TIME, 'E-S'))
WHEN BEGIN_TIME LIKE 'E-M%' THEN
ADD_SECONDS(TO_TIMESTAMP(END_TIME, 'YYYY/MM/DD HH24:MI:SS'), -
SUBSTR_AFTER(BEGIN_TIME, 'E-M') * 60)
WHEN BEGIN_TIME LIKE 'E-H%' THEN
ADD_SECONDS(TO_TIMESTAMP(END_TIME, 'YYYY/MM/DD HH24:MI:SS'), -
SUBSTR_AFTER(BEGIN_TIME, 'E-H') * 3600)
WHEN BEGIN_TIME LIKE 'E-D%' THEN
ADD_SECONDS(TO_TIMESTAMP(END_TIME, 'YYYY/MM/DD HH24:MI:SS'), -
SUBSTR_AFTER(BEGIN_TIME, 'E-D') * 86400)
WHEN BEGIN_TIME LIKE 'E-W%' THEN
ADD_SECONDS(TO_TIMESTAMP(END_TIME, 'YYYY/MM/DD HH24:MI:SS'), -
SUBSTR_AFTER(BEGIN_TIME, 'E-W') * 86400 * 7)
WHEN BEGIN_TIME = 'MIN' THEN
TO_TIMESTAMP('1000/01/01 00:00:00', 'YYYY/MM/DD HH24:MI:SS')
WHEN SUBSTR(BEGIN_TIME, 1, 1) NOT IN ('C', 'E', 'M') THEN
TO_TIMESTAMP(BEGIN_TIME, 'YYYY/MM/DD HH24:MI:SS')
END BEGIN_TIME,
CASE
WHEN END_TIME = 'C' THEN CURRENT_TIMESTAMP
WHEN END_TIME LIKE 'C-S%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(END_TIME, 'C-S'))
WHEN END_TIME LIKE 'C-M%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(END_TIME, 'C-M') * 60)
WHEN END_TIME LIKE 'C-H%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(END_TIME, 'C-H') * 3600)
WHEN END_TIME LIKE 'C-D%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(END_TIME, 'C-D') * 86400)
WHEN END_TIME LIKE 'C-W%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(END_TIME, 'C-W') * 86400 * 7)
WHEN END_TIME LIKE 'B+S%' THEN
ADD_SECONDS(TO_TIMESTAMP(BEGIN_TIME, 'YYYY/MM/DD HH24:MI:SS'),
SUBSTR_AFTER(END_TIME, 'B+S'))
WHEN END_TIME LIKE 'B+M%' THEN
ADD_SECONDS(TO_TIMESTAMP(BEGIN_TIME, 'YYYY/MM/DD HH24:MI:SS'),
SUBSTR_AFTER(END_TIME, 'B+M') * 60)
WHEN END_TIME LIKE 'B+H%' THEN
ADD_SECONDS(TO_TIMESTAMP(BEGIN_TIME, 'YYYY/MM/DD HH24:MI:SS'),
SUBSTR_AFTER(END_TIME, 'B+H') * 3600)
WHEN END_TIME LIKE 'B+D%' THEN
ADD_SECONDS(TO_TIMESTAMP(BEGIN_TIME, 'YYYY/MM/DD HH24:MI:SS'),
SUBSTR_AFTER(END_TIME, 'B+D') * 86400)
WHEN END_TIME LIKE 'B+W%' THEN
ADD_SECONDS(TO_TIMESTAMP(BEGIN_TIME, 'YYYY/MM/DD HH24:MI:SS'),
SUBSTR_AFTER(END_TIME, 'B+W') * 86400 * 7)
WHEN END_TIME = 'MAX' THEN
TO_TIMESTAMP('9999/12/31 00:00:00', 'YYYY/MM/DD HH24:MI:SS')
WHEN SUBSTR(END_TIME, 1, 1) NOT IN ('C', 'B', 'M') THEN
TO_TIMESTAMP(END_TIME, 'YYYY/MM/DD HH24:MI:SS')
END END_TIME,
TIMEZONE,
HOST,
PORT,
SERVICE_NAME,
COMPONENT,
SCENARIO_NAME,
ONLY_PERSISTENT_SCENARIOS,
AGGREGATE_BY,
ORDER_BY
FROM
( SELECT /* Modification section */
'1000/10/18 07:58:00' BEGIN_TIME, /* YYYY/MM/DD HH24:MI:SS
timestamp, C, C-S<seconds>, C-M<minutes>, C-H<hours>, C-D<days>, C-W<weeks>, E-
S<seconds>, E-M<minutes>, E-H<hours>, E-D<days>, E-W<weeks>, MIN */
'9999/10/18 08:05:00' END_TIME, /* YYYY/MM/DD HH24:MI:SS
timestamp, C, C-S<seconds>, C-M<minutes>, C-H<hours>, C-D<days>, C-W<weeks>,
B+S<seconds>, B+M<minutes>, B+H<hours>, B+D<days>, B+W<weeks>, MAX */
'SERVER' TIMEZONE, /* SERVER, UTC */
'%' HOST,
'%' PORT,
'%' SERVICE_NAME,
'%' COMPONENT,
'%' SCENARIO_NAME,
'X' ONLY_PERSISTENT_SCENARIOS,
'HOST, PORT' AGGREGATE_BY, /* HOST, PORT, SERVICE, COMPONENT, SCENARIO,
PERSISTENT or comma separated combinations, NONE for no aggregation */
'SIZE' ORDER_BY /* TIME, NAME, SIZE */
FROM
DUMMY
)
) BI,
M_SERVICES S,
M_CE_CALCSCENARIOS_OVERVIEW CS
WHERE
S.HOST LIKE BI.HOST AND
TO_VARCHAR(S.PORT) LIKE BI.PORT AND
S.SERVICE_NAME LIKE BI.SERVICE_NAME AND
CS.HOST = S.HOST AND
CS.PORT = S.PORT AND
CS.COMPONENT LIKE BI.COMPONENT AND
CS.SCENARIO_NAME LIKE BI.SCENARIO_NAME AND
CASE BI.TIMEZONE WHEN 'UTC' THEN ADD_SECONDS(CS.CREATE_TIME,
SECONDS_BETWEEN(CURRENT_TIMESTAMP, CURRENT_UTCTIMESTAMP)) ELSE CS.CREATE_TIME END
BETWEEN BI.BEGIN_TIME AND BI.END_TIME AND
( BI.ONLY_PERSISTENT_SCENARIOS = ' ' OR CS.IS_PERSISTENT = 'TRUE' )
GROUP BY
CASE WHEN BI.AGGREGATE_BY = 'NONE'
THEN TO_VARCHAR(CASE BI.TIMEZONE WHEN 'UTC' THEN ADD_SECONDS(CS.CREATE_TIME,
SECONDS_BETWEEN(CURRENT_TIMESTAMP, CURRENT_UTCTIMESTAMP)) ELSE CS.CREATE_TIME
END, 'YYYY/MM/DD HH24:MI:SS') ELSE 'any'
END,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'HOST') != 0
THEN CS.HOST ELSE MAP(BI.HOST, '%', 'any', BI.HOST)
END,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'PORT') != 0
THEN TO_VARCHAR(CS.PORT) ELSE MAP(BI.PORT, '%', 'any', BI.PORT)
END,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'SERVICE') != 0
THEN S.SERVICE_NAME ELSE MAP(BI.SERVICE_NAME, '%', 'any',
BI.SERVICE_NAME) END,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'COMPONENT') != 0
THEN CS.COMPONENT ELSE MAP(BI.COMPONENT, '%', 'any', BI.COMPONENT)
END,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'SCENARIO') != 0
THEN CS.SCENARIO_NAME ELSE MAP(BI.SCENARIO_NAME, '%', 'any',
BI.SCENARIO_NAME) END,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'PERSISTENT') != 0
THEN CS.IS_PERSISTENT ELSE MAP(BI.ONLY_PERSISTENT_SCENARIOS, 'X', 'TRUE',
'any') END,
BI.ORDER_BY
)
ORDER BY
MAP(ORDER_BY, 'TIME', CREATION_TIME) DESC,
MAP(ORDER_BY, 'SIZE', SIZE_MB) DESC,
MAP(ORDER_BY, 'NAME', SCENARIO_NAME)

You might also like