Advertisement
Guest User

Загрузка и выгрузка данных - по Z-таблицам

a guest
Sep 26th, 2012
1,568
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 2.72 KB | None | 0 0
  1. *&---------------------------------------------------------------------*
  2. *& Report  YECC_BC_TAB_01
  3. *&
  4. *&---------------------------------------------------------------------*
  5. *& Загрузка и выгрузка данных - по Z-таблицам
  6. *&
  7. *&---------------------------------------------------------------------*
  8. *& [TODO] Добавить чёткую обработку ошибок при импорте данных в таблицу
  9. *& [TODO] Добавить возможности неполной очистки при импорте данных в таблицу
  10. *& [TODO] Добавить возможности неполной выгрузки данных в файл
  11.  
  12. report  yecc_bc_tab_01.
  13. type-pools: truxs, abap.
  14.  
  15. parameters: p_tab type tabname16 obligatory memory id dtb.
  16. parameters: p_file type string obligatory default 'c:\TEMP\*.TXT'.
  17.  
  18. parameters: rg_op1 radiobutton group opx default 'X'. "SAP -> File
  19. parameters: rg_op2 radiobutton group opx.             "File -> SAP
  20. parameters: p_del  as checkbox.
  21.  
  22. start-of-selection.
  23.   field-symbols: <f_table>     type standard table.
  24.   field-symbols: <f_structure> type any.
  25.  
  26.   data dref_ type ref to data.
  27.   create data dref_ type standard table of (p_tab).
  28.   assign dref_->* to <f_table>.
  29.  
  30.   data dref__ type ref to data.
  31.   create data dref__ type (p_tab).
  32.   assign dref__->* to <f_structure>.
  33.  
  34.   replace all occurrences of '*' in p_file with p_tab.
  35.  
  36.   data: gd_codepage type abap_encoding.
  37.   gd_codepage = '1504'.
  38.  
  39.   case 'X'.
  40.     when rg_op1. "SAP->FILE
  41. *      check p_tab(4) = 'ZTMP'.
  42. *      check sy-uname(1) = 'I'.
  43.       select * from (p_tab) into table <f_table>.
  44.  
  45.       call function 'GUI_DOWNLOAD'
  46.         exporting
  47.           filename              = p_file
  48.           filetype              = 'ASC'
  49.           write_field_separator = 'X'
  50.           codepage              = gd_codepage
  51.         tables
  52.           data_tab              = <f_table>.
  53.       message 'Данные выгружены в файл'(001) type 'S'.
  54.     when rg_op2. "FILE-SAP
  55.       check p_tab(4) = 'ZTMP'.
  56. *      check sy-uname(1) = 'I'.
  57. *      check sy-mandt = '100' or sy-mandt = '200'.
  58.  
  59.       call function 'GUI_UPLOAD'
  60.         exporting
  61.           filetype            = 'ASC'
  62.           has_field_separator = 'X'
  63.           filename            = p_file
  64.           codepage            = gd_codepage
  65.         tables
  66.           data_tab            = <f_table>.
  67.  
  68.       if p_del = 'X'.
  69.         delete from (p_tab).
  70.       endif.
  71.       loop at <f_table> assigning <f_structure>.
  72.         insert into (p_tab) values <f_structure>.
  73.       endloop.
  74.       message 'Данные загружены в таблицу'(002) type 'S'.
  75.   endcase.
  76.  
  77. end-of-selection.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement