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

background process

Former Member
0 Likes
1,408

Hi Experts,

I have developed report for purchase register . if i execute this report in background process i am not able to get the downloaded file in excel and output is also not coming properly, columns are going to overlap.

i used the functional module SAP_CONVERT_TO_XLS_FORMAT, but it is coming without data i.e excel file is blank.So tell me How to download excel file in background process

directly? If u have reference code send me.

Regards,

Balu.K

11 REPLIES 11
Read only

Former Member
0 Likes
1,330

It is not possible to download the report to XLS directly when the report is run in background..

When the report is run in background.. it actually runs on the application server.. and not on gui frontend...

So the best solution is to .. write the data in a particular file in the application server..

And then once the job is executed successfully ( This can be seen in SM37 )... we can write another logic to fetch that file from application server and put it in XLS format..

Cheer.s....

Read only

Former Member
0 Likes
1,330

Hi,

For this you should check in debugging that if the internal table which you are passing contains the values before the function call.

And for downloading to excle sheet their is OLE method which can easily meet the formatting requiremenst also.

just check with it,

Regards

N.

Read only

Former Member
0 Likes
1,330

Hi Bala,

In background processing the control goes to application server so know of the FM like(GUI_DOWNLOAD/UPLOAD) will work.

You need to write program to transfer the content of internal table to application directory file.

Open dataset

Transfer

Close dataset.

You can create the file separated by commas, so once you save it as .CSV extension using transaction cg3y (Download file from application dir) your problem would be solved.

BR/Manas

Read only

0 Likes
1,330

hi,

can u pls send me the reference code to download file from application server to Presentation server.

i used

open data set

Trasfer

closed data set

but it is not working. do you have any idea to increase no of cloumns in SPAD.

Regards,

balu

Read only

0 Likes
1,330

Hi Bala,

Below is the sample code...

PARAMETERS: p_file TYPE fileextern DEFAULT '/sapout/xyz'.

  • File on Application Server

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE.

  • Transfer the content.

LOOP AT gt_output INTO gs_output.

TRANSFER gs_output TO p_file LENGTH 1000.

ENDLOOP.

CLOSE DATASET p_file.

Hope it will help.

About SPAD, follow the below steps.

Goto SPAD-> Full Administartion-> Device Types-> Format Types->

Check for the format X_65_1024/4.

This is the maximum allowed size format with 65 lines and 1024 charcters.

If its there you can use it.

Or create a new format with 65 lines(20000 lines are allowed without page breaks) and 1024 columns(maximum allowed) Z_65_1024.

Then copy the standard Device type to ZSAPWIN and attach the new format Z_65_1024.

Then copy the Output device LOCL to ZLOCL and assign device type ZSAPWIN.

Then while sheduling jobs in background you can use ZLOCL with the new fromat Z_65_1024.

BR/Manas

Read only

0 Likes
1,330

Hi ,,

You can use it as...

wf_file which contain file name
 OPEN DATASET wf_file FOR INPUT IN TEXT MODE.

*  MSG:Error opening the file
  IF sy-subrc <> 0.
    CLEAR wf_reper.
    MESSAGE e999(/dceur/zais_msg) WITH text-t16.
  ENDIF.

  DO.
*  Reading the data from dataset.
    READ DATASET wf_file INTO wa_file.
    IF sy-subrc = 0.
      APPEND wa_file TO tb_data.
    ELSE.
      EXIT.
    ENDIF.
    CLEAR : wa_file.

  ENDDO.

  CLOSE DATASET wf_file.

Edited by: Nitin Sikka on Apr 8, 2009 8:58 AM

Edited by: Nitin Sikka on Apr 8, 2009 9:00 AM

Read only

0 Likes
1,330

hi,

i wrote the same code with modification, still it is not working, i am sending the below modified code of my programe, pls go through this if any modification reqire inform me.

if you have the code with concatenate statement, pls send to me

data: p_file like rlgrap-filename.

_file = 'c:\temp\data.xls'.

open dataset p_file for input in text mode encoding default.

do.

read dataset p_file into p_file.

if sy-subrc = 0.

append p_file to itab.

else.

exit.

endif.

clear:p_file.

enddo.

close dataset p_file.

Read only

0 Likes
1,330

hi,

And the first thing is that should first write it to the Application server

and should take the same file path in to work field.

I think you are not using the same path.

The place where you are using

read dataset p_file into p_file.

here you should take a work area of type internal table

and then append the work area to internal table

Please check if it works.

Regds

Edited by: Nitin Sikka on Apr 8, 2009 1:34 PM

Read only

Former Member
0 Likes
1,330

hi,

u need to save the data in application server and use tcode CG3Y to save in presentaion server.

~linganna

Read only

Former Member
0 Likes
1,330

Hi Balu,

As mentioned by you earlier you wanted to download the connent of your internal table to excel.

In that case the program would be

if you have the code with concatenate statement, pls send to me

data: p_file like rlgrap-filename.

p_file = '\sapout\test.csv'. " Should be on application directory path not local file

open dataset p_file for input in text mode encoding default.

Loop at itab.

Transfer itab to p_file.

endloop.

close dataset p_file.

Read only

Former Member
0 Likes
1,330

Hi

Use s-batch to confirm whether you are running the program in Background or foreground.

If fore ground then use the function module gui_download to download.

if back ground then use open dataset.

Thanks

Rajesh