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: 

Regarding downloading file on application server ?

Former Member
0 Kudos

i am using open data set and close data set to create file on application server.

the program is compiling fine, but when i execute it, it throws a dump saying

DATASET_NOT_OPEN , it says that the file is not open.

when i check value of sy-sub-rc it is 8. no file on server.

i want to create a dynamic file name, like i want to append the sy-cdate to the file name, so that when i schedule my program every day, i will create a new file.

what is the t-code to look at directories on app server. i tried al11, but couldnt find mine..but the basis said they had already created a folder for me there.

- Points will be awarded for inputs.

Message was edited by:

ravi a

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

The function module 'RZL_READ_DIR_LOCAL' can be used to retrieve the files in the application server directory. See the sample code below.

<b>Code</b>

REPORT  ZTEST.

PARAMETER: p_fdir type pfeflnamel DEFAULT 'usrsapYRDSYSprofile'.

data:
  t_files like salfldir occurs 0 with header line.

*START-OF-SELECTION
START-OF-SELECTION.

* Retrieving the list of files in the given directory
  call function 'RZL_READ_DIR_LOCAL'
       exporting
            name     = p_fdir
       tables
            file_tbl = t_files.

* List of files are contained within table it_filedir
  loop at t_files.
    write: / t_files-NAME.
  endloop.

Regards

Sudheer

4 REPLIES 4

Former Member
0 Kudos

Hi Ravi,

You should verify that the adress that you are pointing with yor filename is created in the same server in with SAP is instalated, otherwise, this adress must be mapped in that server. The other thing you should check is the autorizations for that directory, if the user that is going to execute that process doesn´t have the correct autorizations the file isn't going to be created.

Try giving all the autorizations to that user and executed again, after that begin to restrict the user autorizations until you give the ones that you need.

Regards,

Eric

Former Member
0 Kudos

Hi,

The function module 'RZL_READ_DIR_LOCAL' can be used to retrieve the files in the application server directory. See the sample code below.

<b>Code</b>

REPORT  ZTEST.

PARAMETER: p_fdir type pfeflnamel DEFAULT 'usrsapYRDSYSprofile'.

data:
  t_files like salfldir occurs 0 with header line.

*START-OF-SELECTION
START-OF-SELECTION.

* Retrieving the list of files in the given directory
  call function 'RZL_READ_DIR_LOCAL'
       exporting
            name     = p_fdir
       tables
            file_tbl = t_files.

* List of files are contained within table it_filedir
  loop at t_files.
    write: / t_files-NAME.
  endloop.

Regards

Sudheer

Former Member
0 Kudos

Hi,

You can use the FM RZL_WRITE_FILE_LOCAL to write the contents to the application server path..

Thanks,

Naren

Former Member
0 Kudos

Hi,

May be you don't have write permission for the corresponding folder on the application server. thats why you could not create file on that folder.so ask you basis people for read/write permission on the that destination folder..

For creating dynamic file , you can use logical file and physical file concept..

for each interface maintain a logical file name in a ztable and ask your basis people to maintain a physical file path on application server for each logical file name.(using FILE Txn).

first get the logical file name from ztable then get corresponding physical path onapplication server using FM 'FILE_GET_NAME' and finally concatenate the sydatun to physical file name...

DATA: l_file_folder TYPE string,

l_logical_file TYPE fileintern,

CLEAR: file1.

*<b> First get the logical file name from table zabc021</b>

SELECT SINGLE log_file " Actual file location

INTO l_logical_file

FROM zabc021

WHERE interface = p_interface

AND inorout = 'O'. "outbound interface

<b>* Get the physical file name from the logical file name</b>

CALL FUNCTION 'FILE_GET_NAME'

EXPORTING

  • CLIENT = SY-MANDT

logical_filename = l_logical_file

IMPORTING

file_name = l_file_folder

EXCEPTIONS

file_not_found = 1

OTHERS = 2

.

IF sy-subrc = 0.

<b>* In actual situation the file name should come from FILE txn</b>

CONCATENATE l_file_folder

p_interface '_' sydatum4(2) sydatum6(2) '.DAT' INTO file1.

ELSE.

CLEAR file1.

MESSAGE s999 WITH 'No logical file maintained with name ' l_logical_file.

EXIT.

ENDIF.

now file1 is the file name.

I hope this info is useful to you...

Reward if needful