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: 

downaloding a file in the background into excel sheet

Former Member
0 Kudos

hai

how do we downlaod a file in the background into excel file , where when downloaded each internal tables field should be written into different columns. where as my output is writing all the fields in the same column

cheers

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You can write it as a comma delimited file. Then when opening the file in access, you have column separators.

Regards,

Rich Heilman

8 REPLIES 8

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You can write it as a comma delimited file. Then when opening the file in access, you have column separators.

Regards,

Rich Heilman

0 Kudos

hai

thanks for replying.

how to make a file as coma delimited can you give me the syntax pls.

0 Kudos

Sure...



report zrich_0002.


data: begin of itab occurs 0,
      fld1(10) type c,
      fld2(10) type c,
      fld3(10) type c,
      fld4(10) type c,
      end of itab.

data: output(1000) type c.


parameters: d1 type localfile default '/usr/sap/TST/SYS/Data1.txt'.

start-of-selection.


open dataset d1 for output in text mode.

loop at itab.

  concatenate itab-fld1
              itab-fld2
              itab-fld3
              itab-fld4
                   into output
                        separated by ','.

  transfer output to d1.


endloop.

close dataset d1.


Please remember to award points for helpful answers. Thanks.

Regards,

Rich Heilman

0 Kudos

hai rich,

still it is not coming in the seperated coulmn but the output is getting printed along with comma in the same column

thanks

0 Kudos

Change the file extenssion to .CSV...It will work.

Gajendra Bhatt

0 Kudos

Now it is a matter of opening excel, click file-->open, select "all files" for file types, look for your txt file, click it. You should get a dialog where it wants to know how you want to break the columns up. You should check the box for comma delimited.

Or it may work if you change the file extension to .csv

Regards,

Rich Heilman

andreas_mann3
Active Contributor
0 Kudos

Hi Kumar,

try:

open dataset...

  LOOP AT  itab INTO wa.
      CLEAR: str, exp.
      DO.
        ASSIGN COMPONENT sy-index OF STRUCTURE wa TO <f>.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
        MOVE <f> TO str.
        CONCATENATE exp str ';' INTO exp .
      ENDDO.
      TRANSFER exp TO file.
  ENDLOOP.

close dataset...

Andreas

adnanmaqbool
Contributor
0 Kudos

Hi guys every thing is working fine but program is not excuting in background. I m using minisap.

Thnx