[SAP] 查询远程数据库

2023-12-27 13:11:55

查询远程数据库数据至内表

DATA: lo_connection TYPE REF TO cl_sql_connection.
  DATA: lo_statement TYPE REF TO cl_sql_statement.
  DATA: ld_result TYPE REF TO cl_sql_result_set.
  DATA: lv_sql TYPE string.
  DATA: l_ref_cnt           TYPE REF TO data.


  lv_sql = |select * from "/BA1/HKULT"|.

  TRY.
      lo_connection = cl_sql_connection=>get_connection( 'DBCON' ).
      lo_statement = lo_connection->create_statement( ).

      ld_result = lo_statement->execute_query( lv_sql ).
      GET REFERENCE OF lt_data INTO l_ref_cnt.

      CALL METHOD ld_result->set_param_table
        EXPORTING
          itab_ref = l_ref_cnt.

      ld_result->next_package( ).
      ld_result->close( ).
    CATCH cx_root INTO DATA(l_ref_cx).
  ENDTRY.

文章来源:https://blog.csdn.net/Mona_1220/article/details/135241524
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。