既然都用HANA了,为什么还要在SAP端,连接HANA数据库,做数据库处理。。。。。
因为HANA数据库,没个用户在STADIO上建的数据库表。。。只能这个用户使用,而做Universe 设计的时候,最简单的就是直接用表。。。(但是SAPDEV这里表太多了,用起来太麻烦,所以。。。)
1.DBCO连接
DB 连接 HDB
DBMS HDB
用户名 ZYUSER
数据库口令 /
连接信息 192.168.2.106: 连接限制
最佳连接
然后SE38运行ADBC_TEST_CONNECTION,选择HDB测试连接
如果此处不通。。。呵呵哒,自己找原因
2.
*&---------------------------------------------------------------------*
*& Report ZHDB01
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZHDB01. DATA:LC_CONN TYPE REF TO CL_SQL_CONNECTION.
DATA:LC_STATE TYPE REF TO CL_SQL_STATEMENT.
DATA:LC_EXCEP TYPE REF TO CX_SQL_EXCEPTION.
DATA:LC_RESULT TYPE REF TO CL_SQL_RESULT_SET.
DATA:LV_STATE TYPE STRING. "建立连接
TRY.
CALL METHOD CL_SQL_CONNECTION=>GET_CONNECTION
EXPORTING
CON_NAME = 'HDB'
* SHARABLE = SPACE
RECEIVING
CON_REF = LC_CONN.
CATCH CX_SQL_EXCEPTION .
ENDTRY. "Creates a Statement Object for this Database Connection CALL METHOD LC_CONN->CREATE_STATEMENT
* EXPORTING
* TAB_NAME_FOR_TRACE =
RECEIVING
STMT_REF = LC_STATE. "set parameter
*TRY.
* CALL METHOD LC_STATE->SET_PARAM
* EXPORTING
* DATA_REF =
** POS = 0
** IND_REF =
* INOUT = CL_SQL_STATEMENT=>C_PARAM_IN
** IS_LOB = SPACE
* .
* CATCH CX_PARAMETER_INVALID .
*ENDTRY. LV_STATE = 'INSERT INTO ZLYTEST01 VALUES('''','''','''','''',''ZC00'','''',''1000A01'',''13457.89'',''45678.89'')'. TRY.
CALL METHOD LC_STATE->EXECUTE_QUERY
EXPORTING
STATEMENT = LV_STATE
* HOLD_CURSOR = SPACE
RECEIVING
RESULT_SET = LC_RESULT.
CATCH CX_SQL_EXCEPTION .
CATCH CX_PARAMETER_INVALID .
ENDTRY. TRY.
CALL METHOD LC_CONN->COMMIT.
CATCH CX_SQL_EXCEPTION .
ENDTRY.
异常消息没处理。。。自己找类,自己玩。。。