cancel
Showing results for 
Search instead for 
Did you mean: 

Write file to non sap server

laurent_touillaud
Contributor
0 Kudos

Hi,

I am trying to create a file from sap program and transfer it to other server that has not sap. Does anyone know if this is possible within ABAP programs?

Best regards,

Laurent

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Of course, this is possible and there are several possibilities to accomplish that.

If on windows, SAP from ABAP can directly create a file on a remote shared directory.

You can also create the file on a local file system and use SAPFTP function modules to send the file on an FTP server.

I'm sure there are plenty other possibilies...

Regards,

Olivier

laurent_touillaud
Contributor
0 Kudos

Hi Olivier,

You said :

"If on windows, SAP from ABAP can directly create a file on a remote shared directory."

How can you accomplish that?

Thanks,

Laurent.

For the FTP solution i found this useful blog for readers of this thread :

/people/community.user/blog/2007/01/15/transferring-data-from-sap-to-other-systems

Former Member
0 Kudos

Laurent,

Simply :

f_file= '
myremoteserver\myshareddirectory\myfile'

OPEN DATASET f_file FOR OUTPUT

Olivier

laurent_touillaud
Contributor
0 Kudos

Hi Olivier,

I tried your solution but it doesn't work in my case.

It always writes the file on the application server (dir_home) instead of the remote server.

my code is :

data v_servfile type string value '
myserver.xx.xx.xxxxx.net\mydirectory\mysubdirectory\myfile.csv"

OPEN DATASET v_servfile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

if sy-subrc eq 0.

loop at it_line into ls_line.

transfer ls_line to v_servfile.

endloop.

endif.

CLOSE DATASET v_servfile.

Why is it writing in dir_home?

Best regards,

Laurent.

Former Member
0 Kudos

Hi Laurent,

Is "myserver.xx.xx.xxxxx.net" your remote server and not your application server ?

Is mydirectory a shared directory on the remote server ?

Did you give the permission to write on this shared directory for the sapservice<SID> NT user ?

We have been using this technique in dozens of interface programs over the years.

The file is created in dir_home if only the file name (no path) is given to the open dataset instruction.

Maybe the filename is overwritten in your code : check with the debugger just before the open dataset instruction.

Regards,

Olivier

laurent_touillaud
Contributor
0 Kudos

Hi Olivier,

Thanks for your reply,

I think the problem was that the sap user (SID+adm) who tries to create the file must have authorization of writing files on the target server otherwise the file is created on the application server dir_home.

Actually before getting authorizations i start test of file creation on an ftp server with the ftp solution after writing on the application server.

Best regards,

Laurent.

Former Member
0 Kudos

Hi Laurent,

This seems strange to me : When the authorisations are wrong on the shared directory, we get an error (subrc <> 0) from the "open dataset" instruction and no file is created in the dir_home directory...

Regards,

Olivier

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi

You can also use an external scheduler which takes care of the entire process of initiating a job in sap transferring the file and starting the next job in the non sap system. It takes care of the entire workflow.