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: 

downloading a file using CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD - how to add linefeed

Former Member
0 Kudos
11,151

Hi all,

   We are using the standard  method,  CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD to download data from an internal table to .txt file.  We use the ECC 6 version.  The downloaded file should not have a carriage return, but it should have line feed.  Here are the parameters that we are passing to call the method.  When it downloads the file, it does not have a carriage return which is want we want, but it does not have a line feed either.  How can I put line feeds to separate the lines?  The last field in the internal table is all blanks.

    VL_FILENAME = S_L-FILENM.               

    VL_FILETYPE = 'ASC'.
    VL_CODEPAGE = '1160'.                         

    VL_TRUNC    = ' '.                            

    VL_LF       = ' '.

   DATA: BEGIN OF TEMPTEST2 OCCURS 0,
    fld001(001)      type c,
    fld002(003)      type n,
    fld003(002)      type n,
    fld004(014)      type n,
    fld005(001)      type c,
    fld006(001)      type c,
    fld007(001)      type c,
    fld008(001)      type c,
    fld009(011)      type n,
    fld010(010)      type n,
    fld011(006)      type n,
    FLD012(035)      TYPE C,
    fld013(021)      type c,
    fld014(035)      type c,
    fld015(158)      type c,
  END OF TEMPTEST2.


    CALL METHOD                                   
      CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD      
         EXPORTING
              FILENAME                          = VL_FILENAME   
              FILETYPE                           = VL_FILETYPE
              TRUNC_TRAILING_BLANKS = VL_TRUNC       
              CODEPAGE                        = VL_CODEPAGE    

              WRITE_LF                           = VL_LF
         CHANGING                                 

              DATA_TAB            =       TEMPTEST2[]               
         EXCEPTIONS
              FILE_NOT_FOUND        = 1              
              FILE_WRITE_ERROR    = 2
              FILESIZE_NOT_ALLOWED    = 3         
              INVALID_TYPE        = 5
              NO_BATCH            = 6
              UNKNOWN_ERROR       = 7
              OTHERS              = 8.

Thanks!

7 REPLIES 7

former_member491621
Contributor
0 Kudos
2,105

Hi Anjana,

For putting line feeds using the method, try the below code

VL_LF       = ' X'.

CALL METHOD                                   

      CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD      

         EXPORTING

              FILENAME                          = VL_FILENAME   

              FILETYPE                           = VL_FILETYPE

              TRUNC_TRAILING_BLANKS = VL_TRUNC       

              CODEPAGE                        = VL_CODEPAGE    

              WRITE_LF                           = VL_LF

         CHANGING                                 

              DATA_TAB            =       TEMPTEST2[]               
         EXCEPTIONS
              FILE_NOT_FOUND        = 1              
              FILE_WRITE_ERROR    = 2
              FILESIZE_NOT_ALLOWED    = 3         
              INVALID_TYPE        = 5
              NO_BATCH            = 6
              UNKNOWN_ERROR       = 7
              OTHERS              = 8.

Hope this helps

0 Kudos
2,105

Thanks Aniket...but putting the value for WRITE_LF as 'X'  puts the carriage return in the file.  I do not want carriage return, but want the line feed. 

0 Kudos
2,105

Hi Anjana,

You can also set VL_TRUNC    = ' X'

Please see the below link


http://sap.ittoolbox.com/groups/technical-functional/sap-dev/prevent-carriage-return-at-eof-for-gui_...

By setting both the variables, you can fulfill your requirement

Hope this helps...

former_member195270
Active Participant
0 Kudos
2,105

    Use code as below.

    VL_FILENAME = S_L-FILENM.               

    VL_FILETYPE = 'ASC'.
    VL_CODEPAGE = '1160'.                         

    VL_TRUNC    = ' '.                            

    VL_LF       = ABAP_TRUE.

   DATA: BEGIN OF TEMPTEST2 OCCURS 0,
    fld001(001)      type c,
    fld002(003)      type n,
    fld003(002)      type n,
    fld004(014)      type n,
    fld005(001)      type c,
    fld006(001)      type c,
    fld007(001)      type c,
    fld008(001)      type c,
    fld009(011)      type n,
    fld010(010)      type n,
    fld011(006)      type n,
    FLD012(035)      TYPE C,
    fld013(021)      type c,
    fld014(035)      type c,
    fld015(158)      type c,
  END OF TEMPTEST2.


    CALL METHOD                                   
      CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD      
         EXPORTING
              FILENAME                          = VL_FILENAME   
              FILETYPE                           = VL_FILETYPE
              TRUNC_TRAILING_BLANKS = VL_TRUNC       
              CODEPAGE                        = VL_CODEPAGE    

              WRITE_LF                           = VL_LF
         CHANGING                                 

              DATA_TAB            =       TEMPTEST2[]               
         EXCEPTIONS
              FILE_NOT_FOUND        = 1              
              FILE_WRITE_ERROR    = 2
              FILESIZE_NOT_ALLOWED    = 3         
              INVALID_TYPE        = 5
              NO_BATCH            = 6
              UNKNOWN_ERROR       = 7
              OTHERS              = 8.

Former Member
0 Kudos
2,105

hello,

please read the below blog to understand line feed and carriage return.

http://blog.sqlauthority.com/2009/07/01/sql-server-difference-between-line-feed-n-and-carriage-retur...

Once you identify your issue you could use the solutions others have provided already to resolve your issue.

best regards,

swanand

0 Kudos
2,105

Thanks...but so far none of the above suggestions did work.  It is always "either..or" situation with carriage return and line feed.

Former Member
0 Kudos
2,105

Just for the record, I am answering my own question...

I was able to achieve the requirement of no carriage return but with a linefeed by adding a hexadecimal character field to the end of the internal table, TEMPTEST2 as,

  CARRIAGE_RETURN(1) TYPE X,

Gave the value '0D' to the field as,

  MOVE '0D' TO TEMPTEST2-CARRIAGE_RETURN.

All the values for exporting parameters were kept the same as before.

Thanks for all the input.