Application Development and Automation 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: 
Read only

Excel Download-Background

kiran_k8
Active Contributor
0 Likes
1,597

Hi,

Is it possible to download the data in the internal table into an excel sheet when the report is executed in the background.

Thanks,

K.Kiran.

Hi,

Is it possible to download the data in the internal table into an excel sheet when the report is executed in the background.

Thanks,

K.Kiran.

14 REPLIES 14
Read only

daixiong_jiang3
Active Participant
0 Likes
1,484

yes,you can.

and you should pay attention to the file directory and file name,it should be different everytime.

otherwise the former file will be overwrittened.

Read only

0 Likes
1,484

Jiang,

Can you please let me know how.

Thanks,

K.Kiran.

Read only

0 Likes
1,484

However,i can give you another way to download data in background,at last the file will be sent as an email

attachment.

Step1: get the data into an internal table

Step2: If running in batch, get from spool

data: l_requestid like tsp01-rqident,

t_attachment like solisti1 occurs 0 with header line.

if sy-batch eq 'X'.

new-page.

commit work.

move sy-spono to l_requestid.

call function 'RSPO_RETURN_SPOOLJOB'

exporting

rqident = l_requestid

tables

buffer = t_attachment

exceptions

no_such_job = 1

job_contains_no_data = 2

selection_empty = 3

no_permission = 4

can_not_access = 5

read_error = 6

type_no_match = 7

others = 8.

if sy-subrc ne 0.

message 'Spool request not found' type 'E'.

endif.

Step3: * Set up email message content

  • Set up packing list

  • Set up mail document attributes

data: t_packlist like sopcklsti1 occurs 2 with header line,

t_attachment like solisti1 occurs 0 with header line,

t_textmsg like solisti1 occurs 0 with header line,

t_receivers like somlreci1 occurs 8 with header line,

g_docdata like sodocchgi1.

Step4: * Send data to a Mail Inbox

call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'

exporting

document_data = g_docdata

commit_work = 'X'

tables

packing_list = t_packlist

contents_bin = t_attachment

contents_txt = t_textmsg

receivers = t_receivers

exceptions

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

others = 8.

if sy-subrc eq 0.

else.

endif.

Read only

Former Member
0 Likes
1,484

Hi Kiran,

No you can not download when the program runs in background.

Regards,

Atish

Read only

0 Likes
1,484

Atish,

Can it be done if we move the data as CSV and then using open dataset.....

Thanks,

K.Kiran.

Read only

0 Likes
1,484

Hi Kiran,

What is your requirement? If you want to download the file on application server then better use comma separated or tab separated and then you can anytime open this file in excel.

Regards,

Atish

Read only

0 Likes
1,484

Atish,

I am trying to do as mentioned by you.But it is returning an error saying file is not opened

DATA : v_filepath(80) VALUE 'E:\USERDATA\BARCODE_FILES',

c_coma VALUE ',',

v_string type string.

OPEN DATASET V_FILEPATH FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc EQ 0.(here it is returning sy-subrc = 😎

LOOP AT itab_grId.

CONCATENATE itab_grid-gdc_matkl c_coma

itab_grid-gdc_wgbez c_coma

itab_grid-gdc_mblnr c_coma

itab_grid-gdc_budat c_coma

itab_grid-gdc_name1 c_coma

itab_grid-gdc_ebeln c_coma

itab_grid-gdc_ebelp c_coma

itab_grid-gdc_matnr c_coma

itab_grid-gdc_sobsl c_coma

itab_grid-gdc_maktx c_coma

itab_grid-gdc_bwtar c_coma

INTO v_string.

TRANSFER v_string TO V_FILEPATH.

ENDLOOP.

CLOSE DATASET V_FILEPATH.

endif.

K.Kiran.

Read only

0 Likes
1,484

Hi Kiran,

This may be because there is no file on the application server. The path you are providing is it application server path or your local machine path?

Regards,

Atish

Read only

0 Likes
1,484

Atish,

It is the path of the file on the application server.

Thanks,

K.Kiran.

Read only

0 Likes
1,484

Hi Kiran,

Instead of hard coding path in the code use the selection screen parameter. you can find lots of sample code for the F4 help from the application server file. You can use FM F4_DXFILENAME_4_DYNP

Regards,

Atish

Read only

0 Likes
1,484

Jiang,

My report's output is having around 30 fields and when run in the background it is getting me only 19 fields in the ALV list.Hence I am trying to download the output into an excel sheet so that I can get all the 30 fields even when the report is executed in the background.

Your code will work only when a file gets created in the spool,here in this case even though a spool request gets created it will not have all the 30 fields.

Thanks,

K.Kiran.

Read only

0 Likes
1,484

Hi,

I am using the below given Fn Mod to convert the internal table data into CSV format

CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'.

1.Will this function module work even when a report is executed in background?

2. I_FIELD_SEPERATOR = ';'

Even after the giving the field sepearator as , or ; it is getting the records in a single column.

Please let me know how to avoid this.

Thanks,

K.Kiran.

Read only

Former Member
0 Likes
1,484

Hi,

Yes U can download the data from internal table to excel file.

1. Execute ur program

2. on the menu bar ot the out put list u find Local file item

3. Select ur required file formate and store location

Then u can view the data in that file.

Regards,

kavitha.

Read only

Former Member
0 Likes
1,484