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: 

Download to Loca(Excel)

Former Member
0 Kudos

Hello All,

Would like to have ur view/coreections on this point -

For downloading the data to the Local drive :

Loop at ITAB. (i have the fields retrieved ITAB)

Write:/000 ITAB-name1,

010 itab-nmae2.

endloop.

In here i use an another loop to write it to the excel:

Concatenate itab-name1 itab-name2 into STR seperated by ','.

append str.

clear str.

Is this an Idean way, as i am looping the iTAB for writing on the list screen as well as for downloading to Excel.

would be glad to have ur feedback.

Regards,

- Sravan

7 REPLIES 7

ssimsekler
Active Contributor
0 Kudos

Hi Sravan

If I have understood right, you can do it like:

LOOP AT itab .
  WRITE:/000 itab-name1,
         010 itab-name2.

  CLEAR str .
  CONCATENATE itab-name1 itab-name2 INTO str
              SEPARATED BY ',' .
  APPEND str .

ENDLOOP .

And after this piece you can call the function to download itab to a local file using the internal table "str" you've filled.

However, a better way (if OK for your scenario) may be to link download operation to a button which will be executed by user command.

*--Serdar

0 Kudos

Hi Serdar,

Thanks for the posting. Yes, i cuurently have a check box for the user to select on the selection screen for download to the local. So in this case will this be good and this is an extension to the code that u have provided:

LOOP at itab.

Write :/000 itab-name1,

010 itab-name2,

if p_download = 'X'.

clear STR.

Concatenate itab-name1 itab-name2 INTO STR seperated by

','.

Append STR.

endif.

endloop.

Correct me if i am wrong.

Thank you,

- Sravan

Former Member
0 Kudos

Hi Sravan,

There is also a FM which could be used to conver the internal table to be comma separated for CSV download. Call the FM and pass the internal table. The FM will add comma field between the itab fields.

Hope this helps.

Regards,

VJ

0 Kudos

Hello Vijayendra,

can you provide me the FM name.

Regs,

- Sravan

0 Kudos

Hi Sravan,

Try this "SAP_CONVERT_TO_CSV_FORMAT " I am not sure check for CSV on se37 u will get few more.

I have used this one's and it works.

Cheers

VJ

Former Member
0 Kudos

Hi Sravan,

Another function module I like to use is RH_START_EXCEL_WITH_DATA. When calling this FM you pass the internal table, then Excel starts automatically and opens up with the data from your internal table.

Regards,

Graham

0 Kudos

Hi Sravan

Your code is OK for populating data, however it lacks the downloading FM at the end.

Since you have already populated your data in coma-separated format, you can directly download it to a file at the presentation layer by using the function module <b>"GUI_DOWNLOAD"</b>.

<b>Or</b> you may populate your data into a structured internal table, then convert it into CSV format by the FM mentioned in one of previous posts and then download it again by <b>"GUI_DOWNLOAD"</b>.

<b>Or</b> you may use the FM "RH_START_EXCEL_WITH_DATA" to open MS Excel directly with the data and leave to the user the decision of saving.

*--Serdar