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

Create CSV file through a program in background

luizfelipe_martin
Product and Topic Expert
Product and Topic Expert
0 Likes
5,698

Hello everyone!

I'm facing a problem using class CL_GUI_FRONTEND_SERVICES to generate a csv file.

I have a report in SCM that will export data from APO to some csv files.

At this moment I'm using GUI_DOWNLOAD method, it works perfectly! The problem is that this program is supposed to run in a background job, and as far as I read and searched for it.. GUI_DOWNLOAD and GUI_UPLOAD are not supposed to run in bakcground because of a "client-server" problem... well.. ok...

So... I tried with the "OPEN DATASET" and it worked fine also, but now comes another issue: the "open dataset" method only writes/reads files located in the system server(is that right?)... and my file will be located on another location in the intranet.

What should I use to generate this csv files in a background job!?

Thanks,

Martin

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,322

there isn't a "client-server" problem...background jobs have no connectivity to a gui/presentation server and therefore no ability to upload/download to a desktop target....

You can save, as noted, to any server visible to the SAP instance you're executing on. I would recommend that you look at a multi-step process....

create your internal table

store that internal table in a file on your apps server (comma-delimited is okay, but tab-delimited would be much better choice)

if you need to place the file where another system can access,

utilize FTP capability in SAP to "copy" or "send" that file to an FTP target, after you have successfully written the file to the APPS server.

If the file can be retrieved by a SAP user,

write or utilize an existing piece of code to grab the file, upload into SAP and then utilize GUI_DOWNLOAD to transfer to the user's desktop target.

This allows you to have both a background process, but have the file accessible to an SAP user after the file has been created. I have several processes that do this and retrieval by the user is both easy and convenient, since the user is notified by my background job that the file has been created, etc.

7 REPLIES 7
Read only

Former Member
0 Likes
2,322

Hi

You wrote:

the "open dataset" method only writes/reads files located in the system server(is that right?

No it's wrong: OPEN DATASET manage files of APPLICATION SERVER, that doesn't mean SAP SERVER only, but the whole network whom server sap belongs

So if the path where you need to place the files can be reached by SAP, you can use OPEN DATASET, but you need to ask your basis for that

Max

Read only

0 Likes
2,322

Thank you, Max!

But I need a little more help:

I tried again with OPEN DATASET but I'm not sure how to input the file path.

OPEN DATASET '\\10.10.0.8\FILES\file.csv' FOR OUTPUT IN TEXT MODE
                            ENCODING DEFAULT
                            MESSAGE str_message.

my SCM server is '10.182.10.69'

The file was created on the root directory of scm server... on directory "./" with the filename being "
10.10.0.8\FILES\file.csv".

How should I build the path of the directory for sap to understand "
10.10.0.8" is another local, not the name of the file?

Read only

Former Member
0 Likes
2,322

Hi

Are you using FTP server.

Regards,

Raghu

Read only

Former Member
0 Likes
2,323

there isn't a "client-server" problem...background jobs have no connectivity to a gui/presentation server and therefore no ability to upload/download to a desktop target....

You can save, as noted, to any server visible to the SAP instance you're executing on. I would recommend that you look at a multi-step process....

create your internal table

store that internal table in a file on your apps server (comma-delimited is okay, but tab-delimited would be much better choice)

if you need to place the file where another system can access,

utilize FTP capability in SAP to "copy" or "send" that file to an FTP target, after you have successfully written the file to the APPS server.

If the file can be retrieved by a SAP user,

write or utilize an existing piece of code to grab the file, upload into SAP and then utilize GUI_DOWNLOAD to transfer to the user's desktop target.

This allows you to have both a background process, but have the file accessible to an SAP user after the file has been created. I have several processes that do this and retrieval by the user is both easy and convenient, since the user is notified by my background job that the file has been created, etc.

Read only

Clemenss
Active Contributor
0 Likes
2,322

Hi Martin,

our basis people created scripts to transfer files from sap server to network drive. In the script, I found something like

smbclient \\\\nnn.nnn.nnn.nnn\\<path> 5humpel4 -U saptransfer -W DE -c "put $file_and_path $<subpath>\\\\$file_no_path"

I do not understand fully, but smbclient seems to be a solution.

Regards

Clemens

Read only

luizfelipe_martin
Product and Topic Expert
Product and Topic Expert
0 Likes
2,322

Hi everyone!

Thanks for the answers!

I'm not using a FTP server.

It´s just a directory on the same server SCM is, but in an "upper" directory.. a root one.

I asked the Basis guy to create a directory on the same server as SCM. I thought it would appear on AL11 but it didn't.

The problem, right now is that I can't reach that folder through "open dataset" method.

Tried to to create a directory on AL11 that points to this folder but I couldn't, I'll ask the Basis guy to do that.. (if that's possible)..

smbclient doesn't seem to be what I'm looking for, but thanks anyway, I'll take a look at it.

Edited by: lfpmartin on Sep 5, 2011 1:02 PM

Read only

0 Likes
2,322

Hi Luiz,

I am having the same problem of exporting CSV file from a report to a network path,

So that another application can read it for further processing.

Please post your code if you were able to do the exporting correctly.

Thanks,

Vishal