본문 바로가기

SAP HANA

HANA STUDIO에서 CREATE TABLE시 ABAP에서 테이블을 읽을수 있을까?

두 가지 대안이 있다.:

1. amdp 클래스에서 HANA 저장 프로시저를 호출.

2. CL_SQL_STATION 및 관련 클래스/methods(ADBC라고도 함)을 참조하십시오. 여기 https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenadbc_query_abexa.htm 를 참조하십시오. AMDP보다 훨씬 유연합니다

 

REPORT demo_adbc_query.

CLASS demo DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS main.
  PRIVATE SECTION.
    CLASS-DATA: BEGIN OF result_line,
                  carrid TYPE sflight-carrid,
                  connid TYPE sflight-connid,
                  fldate TYPE sflight-fldate,
                END OF result_line,
                result_tab LIKE TABLE OF result_line.
ENDCLASS.

CLASS demo IMPLEMENTATION.
  METHOD main.
    DATA carrid TYPE sflight-carrid.
    DATA cols TYPE adbc_column_tab.
    cols = VALUE #( ( CONV adbc_name( 'CARRID' ) )
                    ( CONV adbc_name( 'CONNID' ) )
                    ( CONV adbc_name( 'FLDATE' ) ) ).
    cl_demo_input=>request( CHANGING field = carrid ).
    TRY.
        DATA(result) = NEW cl_sql_statement( )->execute_query(
         `SELECT carrid, connid, fldate ` &&
         `FROM sflight ` &&
         `WHERE mandt  = ` && `'` && sy-mandt && `' AND` &&
         `      carrid = ` &&  cl_abap_dyn_prg=>quote(
                                 to_upper( carrid ) ) ).
        result->set_param_table( itab_ref = REF #( result_tab )
                                 corresponding_fields = cols ).
        IF result->next_package( ) > 0.
          SORT result_tab BY carrid connid fldate.
          cl_demo_output=>display( result_tab ).
        ENDIF.
      CATCH cx_sql_exception INTO DATA(err).
        cl_demo_output=>display(  err->get_text( ) ).
    ENDTRY.
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  demo=>main( ).

'SAP HANA' 카테고리의 다른 글

Fiori Launchad 연결  (1) 2024.04.28
SAP HANA PCE 도입  (0) 2024.04.07