Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

‘GUI_DOWNLOAD ‘doesn’t create comma delimited file.

former_member295881
Contributor
0 Kudos

Hello Experts,

I’m working with ‘GUI_DOWNLOAD ‘and according to my requirement I have to create file on local ‘COMMA DELIMITED’. I’ve tried everything but it’s not working for. Can somebody please take a look at my following code suggests how to make it working?

CONCATENATE 'SAP_ECLIPSE_EMP' sy-datum '.csv' into lv_file_emp.
     CLEAR lv_empfile.
     CONCATENATE p_file
                 lv_file_emp
                 INTO lv_empfile.


       LOOP AT pgt_emp INTO lwa_emp.
         CONCATENATE   lwa_emp-pernr
                       lwa_emp-vorna
                       lwa_emp-nachn
                       lwa_emp-sprsl
                       lwa_emp-telty
                       lwa_emp-telnr
                       lwa_emp-com01
                       lwa_emp-num01
                       lwa_emp-dat01
                       lwa_emp-zzrank
                       lwa_emp-stat2
                       lwa_emp-mgtxt
                       lwa_emp-vehop
                       lwa_emp-vehca
                       lwa_emp-group
                       lwa_emp-hpten
                       lwa_emp-hptfr
                       INTO wa_emp-l_record
                       separated by ','.
             APPEND wa_emp to gt_emp.
       ENDLOOP.

     CALL FUNCTION 'GUI_DOWNLOAD'
       EXPORTING
         FILENAME                     = lv_empfile
         filetype                    = 'ASC'
         "APPEND                       = 'X'
         WRITE_FIELD_SEPARATOR         = ','
*       HEADER                        = '00'
*       TRUNC_TRAILING_BLANKS         = 'X'
*       WRITE_LF                      = 'X'
*       COL_SELECT                    = ' '
*       COL_SELECT_MASK               = ' '
*       DAT_MODE                      = ' '
*       CONFIRM_OVERWRITE             = ' '
*       NO_AUTH_CHECK                 = ' '
*       CODEPAGE                      = ' '
*       IGNORE_CERR                   = ABAP_TRUE
*       REPLACEMENT                   = '#'
*       WRITE_BOM                     = ' '
*     IMPORTING
*       FILELENGTH                    =
       TABLES
         DATA_TAB                      = GT_EMP
     EXCEPTIONS
       file_write_error        = 1
       no_batch                = 2
       gui_refuse_filetransfer = 3
       invalid_type            = 4
       no_authority            = 5
       unknown_error           = 6
       header_not_allowed      = 7
       separator_not_allowed   = 8
       filesize_not_allowed    = 9
       header_too_long         = 10
       dp_error_create         = 11
       dp_error_send           = 12
       dp_error_write          = 13
       unknown_dp_error        = 14
       access_denied           = 15
       dp_out_of_memory        = 16
       disk_full               = 17
       dp_timeout              = 18
       file_not_found          = 19
       dataprovider_exception  = 20
       control_flush_error     = 21
       OTHERS                  = 22.
     IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
     ELSEIF sy-subrc = 0.
       WRITE: / 'File downloaded at: ', lv_empfile.
     ENDIF.

Many thanks in advance.

7 REPLIES 7

arindam_m
Active Contributor
0 Kudos

Hi,

Try to make the GT_EMP as internal table with fields not like comma separated single field l_record .

Please clarify on the following points. What is the structure of GT_EMP. I do not understand why are you taking all the values in l_record of wa_emp and then appending to GT_EMP.

Cheers,

Arindam

Former Member
0 Kudos

Change the below field information ...

  FILETYPE                                          'DBF' .

WRITE_FIELD_SEPARATOR         =   '    ' .              "space



Regard's

Smruti

0 Kudos

Many thanks everybody for your valuable input. The issue is almost resolved with Smruti suggestion. However, now GUI_DOWNLOAD add an additional row with F1 value in it, which I don't need. How I can get ride of it? Please suggest.

0 Kudos

Hi Zero Cool,

Check http://scn.sap.com/thread/1525206 . you should use FM SAP_CONVERT_TO_TEX_FORMAT for converting itab to CSV.

Hope this helps.

Regards,

Karthik Dharmarajan

0 Kudos

Hi Cool ,

If you use File Type = 'DBF'  then you must be pass Field name Structure into GUI_DOWNLOAD FM otherwise System automatically Assign Header Field as "F1" , F2 etc... as per Number of Column in your Internal table (i.e. GT_EMP ) which you pass into GUI_DOWNLOAD .  if you debug your GUI_DOWNLOAD FM with your all values and Look in to this Include program "LSFESF09  " (i.e. Subroutine GUI_DBF_DOWNLOAD) you can easily find Why "F1, F2 ...etc Header Field name automatically download without passing Field name Structure into GUI_DOWNLOAD .

Regard's

Smruti

former_member189059
Active Contributor
0 Kudos

Hi,

Try opening the file in Notepad and see if the commas show.

The default program for .csv files is Excel which will automatically show the values in different columns.

Regards,

Kris

Former Member
0 Kudos

Hi zero cool

Sure,  just declare a flat structure in your program.

data: itab type table of string. data: xtab type string.

Then fill this internal table with data from another internal concatenating the fields .

loop at ianother.       
concatenate ianother-fld1   ianother-fld2       ianother-fld3           ianother-fld4          into xtab separated by ','   
append xtab to itab.  
endloop.

Now just pass ITAB to the GUI_DOWNLOAD function module.

Regards

Suganya