Export Internal table contents into CSV file in SAP ABAP

 report ztas_test.  
   
 types:  
   begin of ty_mara,  
    matnr type matnr,  
    mtart type mtart,  
    matkl type matkl,  
    bstme type bstme,  
    zeinr type dzeinr,  
    zeiar type dzeiar,  
    brgew type brgew,  
    ntgew type ntgew,  
    volum type volum,  
    spart type spart,  
    breit type breit,  
    hoehe type hoehe,  
   end of ty_mara.  
   
 data: imara type table of ty_mara with header line.  
 data: iout type table of string .  
 data: xout type string.  
 data: temp type string.  
 field-symbols: <fs> type any.  
   
 select matnr mtart matkl bstme zeinr zeiar brgew ntgew volum spart breit hoehe  
                                   into table imara from mara.  
   
 loop at imara.  
   
  clear xout.  
  do.  
   assign component sy-index of structure imara to <fs>.  
   if sy-subrc <> 0.  
    exit.  
   endif.  
   if sy-index = 1.  
    clear temp.  
    temp = <fs>.  
    xout = temp.  
    condense temp.  
   else.  
    clear temp.  
    temp = <fs>.  
    condense temp.  
    concatenate xout temp into xout separated by ';'.  
   endif.  
  enddo.  
   
  append xout to iout.  
   
 endloop.  
   
   
   
 call function 'GUI_DOWNLOAD'  
  exporting  
   filename = 'C:\temp\test.csv'  
  tables  
   data_tab = iout.   "need to declare and populate  
   
   

0 comments: