Posted By

qrist0ph on 03/29/10


Tagged

abap


Versions (?)

Export SAP Table to CSV


 / Published in: C#
 

  1. *&---------------------------------------------------------------------*
  2. *& Report ZCA_TEST1
  3. *&
  4. *&---------------------------------------------------------------------*
  5. *&
  6. *&
  7. *&---------------------------------------------------------------------*
  8.  
  9. REPORT ZCA_TEST1.
  10.  
  11.  
  12. TYPE-POOLS: truxs.
  13. TYPES:
  14. BEGIN OF ty_Line,
  15. vbeln LIKE plogi-MANDT,
  16. posnr LIKE plogi-PLVAR,
  17. END OF ty_Line.
  18.  
  19. DATA: itab TYPE STANDARD TABLE of ty_Line WITH DEFAULT KEY.
  20. DATA: itab1 TYPE truxs_t_text_data.
  21.  
  22. SELECT
  23. MANDT
  24. PLVAR
  25. UP TO 10 ROWS
  26. FROM PLOGI
  27. INTO TABLE itab.
  28.  
  29. CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
  30. EXPORTING
  31. i_field_seperator = ';'
  32. TABLES
  33. i_tab_sap_data = itab
  34. CHANGING
  35. i_tab_converted_data = itab1
  36. EXCEPTIONS
  37. conversion_failed = 1
  38. OTHERS = 2.
  39. IF sy-subrc <> 0.
  40. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
  41. WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  42. ENDIF.
  43.  
  44. CALL FUNCTION 'GUI_DOWNLOAD'
  45. EXPORTING
  46. filename = 'C:\TEMP\test.txt'
  47. TABLES
  48. data_tab = itab1
  49. EXCEPTIONS
  50. OTHERS = 1.

Report this snippet  

You need to login to post a comment.