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: 

Problem in "execute in background"

Former Member
0 Kudos
142

Hi all experts,

I have a program which is doing housekeeping to delete outdated data in a customized table.

Before the data is deleted, the program will save all the data into a internal table.

After all, it will call a function GUI_DOWNLOAD to move the internal table data to a shared drive,

let's say G:\backup data\

The program runs perfectly if I executed it manually by clicking the button "execute".

But it is not running if I run it in "execute in background".

How should I solve this problem?

Please advice and thanks in advance.

10 REPLIES 10

Former Member
0 Kudos
110

Helllo,

You cannot use GUI_DOWNLOAD in background. You can use application server "OPEN DATASET" in place of GUI_DOWNLOAD while running the program in background. (Check sy-batch = 'X' --> background).

Thanks,

Jayant Sahu

0 Kudos
110

Hello Jayant Sahu,

Thanks for your prompt reply. Could you please tell me more how should I do it? If possible, example of code is much appreciated.

Looking forward to you.

0 Kudos
110

Hi,

use application server indeed ..

read dataset <datasetname> output in text mode encoding default..

then transfer data and then close data set..

It will work..

Regards,

Nagaraj

0 Kudos
110

Hello,

Please find the code below.

Open Dataset for Storing the file in Application Server.

OPEN DATASET w_filepath WITH WINDOWS LINEFEED FOR OUTPUT IN TEXT

MODE ENCODING DEFAULT.

IF sy-subrc EQ 0.

LOOP AT p_t_output INTO w_output.

TRANSFER w_output TO w_filepath LENGTH 133.

CLEAR w_output.

ENDLOOP.

CLOSE DATASET w_output.

ENDIF.

w_filepath - -> This should be the physical file path of the application server. You can just choose the path you want to store file/path that is given to you. Please go to AL11 which is directory for application server.

Please let me know if you need to know more. (Much Information is available on Application server in SDN and on other SAP related sites).

Thanks,

Jayant Sahu.

0 Kudos
110

Hi Jayant Sahu,

I think I am not allowed to store the "backup data" into the application server. Will it affects the SAP application?

What is the alternative ways? Please help.

Hi all,

Thanks for the the replies.

Former Member
0 Kudos
110

Hi

This FM can work only in foreground, because it uses presentation server API functions.

In background your program runs at application server.so downloading it to presentation server in background is somewhat odd...isn't it?

i do not know the alternative..

Regards

Deepak

Former Member
0 Kudos
110

Hello,

I believe you can store every kind of data in Application server. Please check whether you are passing the right physical path of the application server for storing the data. Try to use a TEMP directory for storing the data.

Hope it helps!

Thanks,

Jayant.

0 Kudos
110

Thanks again.

Could you please let me know what should I declare the type for "w_output".

I am trying to write a simple program for my testing purpose.

Thanks.

0 Kudos
110

In the code which I have specified earlier the internal table if of character 133 length. Take the type of it same as the structure of your internal table.

Thanks,

Jayant.

0 Kudos
110

Hi Jayant Sahu,

Not sure whether you still around.

I have eventually come back to this abap program and try the suggestion you gave me last time.

How should I program it in abap in the way, it will automatically copy all the files that are generated in the application server and save it in local PC directory?

I have tried to use function call "C13Z_FILE_DOWNLOAD_ASCII". It is running successfully, the files generated in the program are all shown in the application server .

However if it is "Execute in background", it is not working.

Any ideas?

Thanks in advance.