Interne Tabell: Export in Excel

BusinessServerPages; Erstellung von Webapplikationen.

Interne Tabell: Export in Excel

Postby Tomas1433 » Thu Sep 18, 2003 12:06 pm

Hallo,

ich bin auf der Suche nach einer Möglichkeit über eine BSP eine
Tabelle in MS-Excel zu exportieren. Ich habe schon einiges dazu
gelesen, wie man das mit der SAP GUI macht!!

Leider fehlt mir eine Idee so etwas über eine BSP zu lösen.
Habt Ihr Erfahrung damit bzw. eine Ahnung, ob soetwas
überhaupt möglich ist :?:

Würde mich freuen von euch zu hören!
Tomas1433
.
.
 
Posts: 1
Joined: Thu Sep 18, 2003 12:06 pm

Postby Philippa2744 » Thu Sep 18, 2003 12:29 pm

Philippa2744
...
...
 
Posts: 303
Joined: Fri Mar 07, 2003 5:17 pm

Postby Alva1590 » Thu Sep 18, 2003 6:53 pm

Hallo,

ich habe mal ein wenig getüftelt und das Problem im Folgenden gelöst:
Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
  1. * event handler for data retrieval
  2. DATA: wa_OrderList LIKE LINE OF ts_OrderList,
  3.  
  4.       file TYPE XString,
  5.       content_length TYPE String,
  6.       numC1 TYPE STRING,
  7.       numC2 TYPE STRING,
  8.  
  9.       tempStr TYPE STRING,
  10.  
  11.       TAB(1) type c,
  12.       CRLF(1) type c.
  13.  
  14. * define special chars
  15. TAB = CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
  16. CRLF = CL_ABAP_CHAR_UTILITIES=>NEWLINE.
  17.  
  18. * call function RFC: get orderlist
  19. CALL FUNCTION 'ZORDERLIST_GETDATA'
  20.     ITVALUES       = ts_OrderList.
  21.  
  22. * concatenate table into tempStr: Format for MS-Excel
  23. LOOP AT ts_OrderList INTO wa_OrderList.
  24.     tempStr
  25.     wa_OrderList-SD_DOC
  26.     TAB
  27.     wa_OrderList-CREATION_DATE
  28.     TAB
  29.     wa_OrderList-Plant
  30.     TAB
  31.     wa_OrderList-Short_Text
  32.     TAB
  33.     wa_OrderList-Currency
  34.     CRLF
  35.     INTO tempStr.
  36.  
  37. * convert tempString to binary
  38. DATA: conv   TYPE REF TO CL_ABAP_CONV_OUT_CE.
  39.  
  40. * convert tempString to binary
  41. conv = CL_ABAP_CONV_OUT_CE=>CREATE( ).
  42. CALL METHOD conv->write( data = tempStr ).
  43.  
  44. * get binary file from buffer
  45. file = conv->get_buffer( ).
  46.  
  47. content_length = xstrlen( file ).
  48.  
  49. *  set response data to be the file content
  50. runtime->server->response->set_data( file ).
  51.  
  52. * set the mime-type and file size in the response
  53. runtime->server->response->set_header_field(
  54.  
  55.             name  = 'Content-Type'
  56.  
  57.             value = 'application/vnd.ms-excel' ).
  58.  
  59. runtime->server->response->set_header_field(
  60.  
  61.             name  = 'Content-Length'
  62.  
  63.             value = content_length ).
  64.  
  65. runtime->server->response->delete_header_field(
  66.             name = 'Cache-Control' ).
  67.  
  68. runtime->server->response->delete_header_field(
  69.             name = 'Expires' ).
  70.  
  71. *  response data is complete don't call onLayout method
  72. navigation->response_complete( ).
  73.  
GeSHi ©


Es wird keine Datei erstellt. Die Daten liegen lediglich im Buffer
und werden erst in Dateiform 'gebrannt', wenn sich der User im
Browser zum Speichern entscheidet!

Am Mittelteil "Concatenate" arbeite ich noch!!
Ist noch nicht wirklich schön!

Über Verbesserungsvorschläge würde ich mich freuen :)

Beste Grüße!
Alva1590
.....
.....
 
Posts: 4387
Joined: Mon Dec 02, 2002 3:01 pm


Return to BSP + BHTML

Who is online

Users browsing this forum: No registered users and 11 guests