25.10.2016 Views

SAP HANA Predictive Analysis Library (PAL)

sap_hana_predictive_analysis_library_pal_en

sap_hana_predictive_analysis_library_pal_en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

INSERT INTO PDATA VALUES (2, 'DM_<strong>PAL</strong>','<strong>PAL</strong>_CONTROL_T', 'IN');<br />

INSERT INTO PDATA VALUES (3, 'DM_<strong>PAL</strong>','<strong>PAL</strong>_DISTRRANDOM_RESULT_T', 'OUT');<br />

call SYS.AFLLANG_WRAPPER_PROCEDURE_DROP('DM_<strong>PAL</strong>','<strong>PAL</strong>_DISTRRANDOM');<br />

call SYS.AFLLANG_WRAPPER_PROCEDURE_CREATE('AFL<strong>PAL</strong>', 'DISTRRANDOM',<br />

'DM_<strong>PAL</strong>','<strong>PAL</strong>_DISTRRANDOM', PDATA);<br />

---------------------------<br />

----------YEAR 1 -----------<br />

-----Product revenue------<br />

DROP TABLE <strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB;<br />

CREATE COLUMN TABLE <strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB LIKE<br />

<strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_T;<br />

INSERT INTO <strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB VALUES ('DISTRIBUTIONNAME', 'NORMAL');<br />

INSERT INTO <strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB VALUES ('MEAN', '0');<br />

INSERT INTO <strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB VALUES ('VARIANCE', '0.0001');<br />

DROP TABLE <strong>PAL</strong>_CONTROL_TAB;<br />

CREATE COLUMN TABLE <strong>PAL</strong>_CONTROL_TAB LIKE <strong>PAL</strong>_CONTROL_T;<br />

INSERT INTO <strong>PAL</strong>_CONTROL_TAB VALUES ('NUM_RANDOM',5000,null,null);<br />

INSERT INTO <strong>PAL</strong>_CONTROL_TAB VALUES ('SEED', 0, null, null);<br />

INSERT INTO <strong>PAL</strong>_CONTROL_TAB VALUES ('THREAD_NUMBER', 8, null, null);<br />

DROP TABLE <strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_REVENUE;<br />

CREATE COLUMN TABLE <strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_REVENUE LIKE<br />

<strong>PAL</strong>_DISTRRANDOM_RESULT_T;<br />

CALL DM_<strong>PAL</strong>.<strong>PAL</strong>_DISTRRANDOM(<strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB, <strong>PAL</strong>_CONTROL_TAB,<br />

<strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_REVENUE) with overview;<br />

--SELECT * FROM <strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_REVENUE;<br />

---------Product Costs---------<br />

DELETE FROM <strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB;<br />

INSERT INTO <strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB VALUES ('DISTRIBUTIONNAME', 'NORMAL');<br />

INSERT INTO <strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB VALUES ('MEAN', '1000');<br />

INSERT INTO <strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB VALUES ('VARIANCE', '5625');<br />

DROP TABLE <strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_COSTS;<br />

CREATE COLUMN TABLE <strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_COSTS LIKE<br />

<strong>PAL</strong>_DISTRRANDOM_RESULT_T;<br />

CALL DM_<strong>PAL</strong>.<strong>PAL</strong>_DISTRRANDOM(<strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB, <strong>PAL</strong>_CONTROL_TAB,<br />

<strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_COSTS) with overview;<br />

--SELECT * FROM <strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_COSTS;<br />

--------OVERHEADS---------<br />

DELETE FROM <strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB;<br />

INSERT INTO <strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB VALUES ('DISTRIBUTIONNAME',<br />

'UNIFORM');<br />

INSERT INTO <strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB VALUES ('MIN', '1400');<br />

INSERT INTO <strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB VALUES ('MAX', '1500');<br />

DROP TABLE <strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_OVERHEADS;<br />

CREATE COLUMN TABLE <strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_OVERHEADS LIKE<br />

<strong>PAL</strong>_DISTRRANDOM_RESULT_T;<br />

CALL DM_<strong>PAL</strong>.<strong>PAL</strong>_DISTRRANDOM(<strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB, <strong>PAL</strong>_CONTROL_TAB,<br />

<strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_OVERHEADS) with overview;<br />

-- SELECT * FROM <strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_OVERHEADS;<br />

-------INVESTMENT---------<br />

DELETE FROM <strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB;<br />

INSERT INTO <strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB VALUES ('DISTRIBUTIONNAME', 'NORMAL');<br />

INSERT INTO <strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB VALUES ('MEAN', '10000');<br />

INSERT INTO <strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB VALUES ('VARIANCE', '250000');<br />

DROP TABLE <strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_INVESTMENT;<br />

CREATE COLUMN TABLE <strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_INVESTMENT LIKE<br />

<strong>PAL</strong>_DISTRRANDOM_RESULT_T;<br />

CALL DM_<strong>PAL</strong>.<strong>PAL</strong>_DISTRRANDOM(<strong>PAL</strong>_DISTRRANDOM_DISTRPARAM_TAB, <strong>PAL</strong>_CONTROL_TAB,<br />

<strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_INVESTMENT) with overview;<br />

--SELECT * FROM <strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_INVESTMENT;<br />

--------calculate cash flow -------<br />

DROP TABLE <strong>PAL</strong>_CASHFLOW_YEAR1;<br />

CREATE COLUMN TABLE <strong>PAL</strong>_CASHFLOW_YEAR1(ID INTEGER,CASH DOUBLE);<br />

INSERT INTO <strong>PAL</strong>_CASHFLOW_YEAR1 SELECT <strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_REVENUE.ID,<br />

<strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_REVENUE.RANDOM<br />

- <strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_COSTS.RANDOM -<br />

<strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_OVERHEADS.RANDOM -<br />

<strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_INVESTMENT.RANDOM<br />

FROM <strong>PAL</strong>_DISTRRANDOM_RESULT_TAB_REVENUE left<br />

<strong>SAP</strong> <strong>HANA</strong> <strong>Predictive</strong> <strong>Analysis</strong> <strong>Library</strong> (<strong>PAL</strong>)<br />

End-to-End Scenarios P U B L I C 559

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!