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: 

Create and send the file to the destination directory

Former Member
0 Kudos

Hi All,

I need to create a file and send this file to the required directory (network device like
10.000.00\).

My SAP system has Windows NT OS and we dont have any middlie ware for the file transfer.

if i create the file using OPEN DATASET statement then how will i send it to the required destination folder.

Please tell me the detail process to achieve the solution for the above requirements.

Regards,

Sheelesh

9 REPLIES 9

Former Member
0 Kudos

For the creation of the directory you can use

CALL METHOD cl_gui_frontend_services=>directory_create
      EXPORTING
        directory = p_file1
      CHANGING
        rc        = rc.

and for cpying the file and delete you can use :

CALL METHOD cl_gui_frontend_services=>file_copy
    EXPORTING
      SOURCE      = src_file
      DESTINATION = dest_file.

  CALL METHOD cl_gui_frontend_services=>file_delete
    EXPORTING
      filename = src_file
    CHANGING
      rc       = rc.

Former Member
0 Kudos

hi Sheelesh,

If you want to place the file in application server then

1) First Generate a file with filename and logical path using 'FILE_GET_NAME_USING_PATH'

2)Open the file created and write the data.

here is the sample code

PERFORM get_filepath USING c_opath c_ofile.( This is output file to write on appln server)

w_outputfname = w_filename.

FORM read_file .

CALL FUNCTION 'FILE_GET_NAME_USING_PATH'

EXPORTING

client = sy-mandt

logical_path = po_logp

operating_system = sy-opsys

  • PARAMETER_1 = ' '

  • PARAMETER_2 = ' '

  • PARAMETER_3 = ' '

  • USE_BUFFER = ' '

file_name = po_file

  • USE_PRESENTATION_SERVER = ' '

eleminate_blanks = 'X'

IMPORTING

file_name_with_path = w_filename

EXCEPTIONS

path_not_found = 1

missing_parameter = 2

operating_system_not_found = 3

file_system_not_found = 4

OTHERS = 5.

  • Display message 'Unable to Get file path'.

IF sy-subrc <> 0.

MESSAGE e999(zfi_ap_gl) WITH text-t05 .

ENDIF.

ENDFORM.

*Open file to write

PERFORM openfile_towrite.

FORM openfile_towrite .

*open file in the application server for writing

OPEN DATASET w_outputfname FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

if sy-subrc = 0.

                  • here write the data to outputfile*******

else

MESSAGE e999(zfi_ap_gl) WITH text-t05 w_outputfname.

STOP.

ENDIF.

ENDFORM. " OPENFILE_TOWRITE

0 Kudos

Hi Arvind,

Thanks for the response.

I have already used the processs suggested by you but am getting the message 'Invalid Argument'.

i have used the following code.

Call the function module to get the complete file name

Open dataset statement with addition message msg and i am getting the message 'Invalid Argument'.

Regards,

Sheelesh

0 Kudos

Is this process done in foreground mode ???

Does the destination path exists in the same domain or different one .

0 Kudos

U can just for GUI_DOWNLOAD i guess

0 Kudos

I can not use GUI_DOWNLOAD and i need to use OPEN DATASET statement and the drive on which i want to save the file is network drive.

Edited by: Sheelesh on Apr 21, 2009 4:00 PM

0 Kudos

Ex:

create a shared folder in the destination PC names share.

Give write authorization to that folder.

then in GUI_DOWNLOAD.

pass the path Ex: '
10.121.65.76\share\abc.txt.

also pass the itab with data.

is this possible for ur scenario ????

0 Kudos

Hi

If you need to use the statament OPEN DATASET u make sure the target path is mapped in your application server, that means Server SAP can see the path:

so your path'll belong to Application Server.

The main path are mapped in trx AL11, so u check it there, but if you can't find your path there, it doesn't mean Server SAP can't see it, but only the path isn't mapped in AL11.

So u should ask help to your basis in order your path is available for SAP Server.

Max

kesavadas_thekkillath
Active Contributor
0 Kudos

check it here link:[Communication to Presentation

Server in Background Mode|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/9831750a-0801-0010-1d9e-f8c64efb2bd2]