前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >如何将ABAP透明表的内容导入PostgreSQL数据库

如何将ABAP透明表的内容导入PostgreSQL数据库

作者头像
Jerry Wang
发布2020-08-24 11:41:29
4570
发布2020-08-24 11:41:29
举报

In my previous blog Replicate ABAP database table definition to PostgreSQL the step how to replicate the table definition in ABAP server into PostgreSQL is introduced. As now we already have empty table, the next step is to replicate the transaction data of that table from ABAP server to PostgreSQL.

Now ABAP table COMM_PRODUCT is successfully replicated to PostgreSQL:

In my ABAP server table COMM_PRODUCT has totally 94331 entries:

Execute the report below:

代码语言:javascript
复制
REPORT zexport_data.

DATA: lt_export  TYPE string_table,
      l_filename TYPE string,
      l_path     TYPE string,
      l_fullpath TYPE string,
      lv_from    TYPE string,
      lv_to      TYPE string,
      lt_result  TYPE TABLE OF comm_product.

SELECT * INTO TABLE lt_result FROM comm_product.

LOOP AT lt_result INTO DATA(r).
  PERFORM format_timestamp USING r-valid_from CHANGING lv_from.
  PERFORM format_timestamp USING r-valid_to CHANGING lv_to.
  DATA(lv_line) = |{ r-client };{ r-product_guid };{ r-product_id };{ r-product_type };| &
  |{ r-config };{ r-xnosearch };{ r-object_family };{ r-batch_dedicated };{ r-competitor_prod };| &
  |{ lv_from };{ lv_to };{ r-upname };{ r-histex };{ r-logsys }| .
  APPEND lv_line TO lt_export.
ENDLOOP.

CALL METHOD cl_gui_frontend_services=>file_save_dialog
  EXPORTING
    window_title         = 'Save export data file'
    default_file_name    = 'PostgreSQL.txt'
  CHANGING
    filename             = l_filename
    path                 = l_path
    fullpath             = l_fullpath
  EXCEPTIONS
    cntl_error           = 1
    error_no_gui         = 2
    not_supported_by_gui = 3
    OTHERS               = 4.

IF sy-subrc <> 0.
  WRITE:/ 'file save dialog failed.'.
  RETURN.
ENDIF.

CALL METHOD cl_gui_frontend_services=>gui_download
  EXPORTING
    filename                = l_fullpath
  CHANGING
    data_tab                = lt_export
  EXCEPTIONS
    file_write_error        = 1
    no_batch                = 2
    gui_refuse_filetransfer = 3
    invalid_type            = 4
    no_authority            = 5
    unknown_error           = 6
    header_not_allowed      = 7
    separator_not_allowed   = 8
    filesize_not_allowed    = 9
    header_too_long         = 10
    dp_error_create         = 11
    dp_error_send           = 12
    dp_error_write          = 13
    unknown_dp_error        = 14
    access_denied           = 15
    dp_out_of_memory        = 16
    disk_full               = 17
    dp_timeout              = 18
    file_not_found          = 19
    dataprovider_exception  = 20
    control_flush_error     = 21
    not_supported_by_gui    = 22
    error_no_gui            = 23
    OTHERS                  = 24.

FORM format_timestamp USING iv_timestamp TYPE comt_valid_from CHANGING cv_line.
  CONVERT TIME STAMP iv_timestamp TIME ZONE 'UTC' INTO DATE DATA(date)
     TIME DATA(time).
  CLEAR: cv_line.
  cv_line = |{ date DATE = ISO } { time TIME = ISO }|.
ENDFORM.

Those entries are exported from ABAP server to my local laptop stored in txt format.

Now go back to PostgreSQL console, choose import from context menu:

Load the local text file:

And you can see import successful notification:

Click detail hyperlink, and you see totally 94331 lines are imported from ABAP server.

Just do some double click to confirm whether the data imported are exactly equal to the records in ABAP server.

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-08-22 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档