Chinaunix首页 | 论坛 | 博客
  • 博客访问: 176956
  • 博文数量: 31
  • 博客积分: 3000
  • 博客等级: 中校
  • 技术积分: 585
  • 用 户 组: 普通用户
  • 注册时间: 2007-11-17 23:11
文章分类

全部博文(31)

文章存档

2011年(1)

2009年(18)

2008年(12)

我的朋友

分类:

2009-08-04 12:31:12

We just want to transfer some tables until runtime from other system.but the system doesn't support common types, such as 'DATA','ANY' .
how shall we do that ?
we can't consider it in another way. we know that the key words "export to database" can store any type data. so we use this kind of structure to transfer the data which type is known at runtime.therefore,
  1. create a system index table
  2. create a RFC-function 'ZTRANSFER_ANY_TABLE' , the code like bellow
        FUNCTION ZTRANSFER_ANY_TABLE.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(TABLE_NAME) TYPE  CHAR30
*"  EXPORTING
*"     VALUE(DATA) TYPE  ZDATATRANSFER
*"----------------------------------------------------------------------
  DATA: O_DATA TYPE REF TO DATA.
  CREATE DATA O_DATA TYPE TABLE OF (TABLE_NAME).
  FIELD-SYMBOLS: TYPE ANY TABLE.
  ASSIGN O_DATA->* TO
.
  SELECT * FROM (TABLE_NAME) INTO TABLE
..
  DELETE FROM ZDATATRANSFER.
  COMMIT WORK.
  EXPORT p1 =
TO DATABASE ZDATATRANSFER(XY) ID 'DATA'.
  SELECT SINGLE * FROM ZDATATRANSFER INTO DATA.
ENDFUNCTION.

3. create normal function 'ZTRANSFER_TABLE'
FUNCTION ZTRANSFER_TABLE.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(TABLE_NAME) TYPE  CHAR30
*"     REFERENCE(DEST) TYPE  CHAR30
*"  EXPORTING
*"     REFERENCE(DATA) TYPE  DATA
*"----------------------------------------------------------------------
  DELETE FROM ZDATATRANSFER.
  COMMIT WORK.

  DATA: TAB TYPE ZDATATRANSFER.
  CALL FUNCTION 'ZTRANSFER_ANY_TABLE' DESTINATION DEST
    EXPORTING
      TABLE_NAME = TABLE_NAME
    IMPORTING
      DATA       = TAB.
  MODIFY ZDATATRANSFER FROM TAB.
  COMMIT WORK.
  DATA: O_DATA TYPE REF TO DATA.
  CREATE DATA O_DATA TYPE TABLE OF (TABLE_NAME).
  FIELD-SYMBOLS:
TYPE ANY TABLE.
  ASSIGN O_DATA->* TO
.
  IMPORT p1 to
FROM DATABASE ZDATATRANSFER(XY) ID 'DATA'.
  DATA = O_DATA.

ENDFUNCTION.
 
ok . the test example bellow
REPORT  z_victor_test_transferdata               .

DATA: DATA TYPE REF TO DATA.
CALL FUNCTION 'ZTRANSFER_TABLE'
  EXPORTING
    TABLE_NAME       = 'ZADVICE_DAILY'
    DEST             = '223'
 IMPORTING
   DATA             = DATA
          .

阅读(883) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~