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

Application Server file Validity

Former Member
0 Likes
768

Hi Experts,

I have one query. I wanted to check the validity of file in application server. The scenerio is like in my selection screen I will provide application server file name.

I wanted to validate whether that file is existing or not. If file is not existing then I need to display an error message.

Can anybody will suggest me how I can achieve this requirement?

Thanks,

Neha

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
726

Hi,

Simply use the statement: OPEN DATASET. If the sy-subrc after the statement is NE 0 , then the file is not existing.

You need to pass the filename and filepath for the above.

For eg: FNAME = '/tmp/myfile'.

OPEN DATASET FNAME.

For more information on OPEN DATASET, check sap help.

To open a file in binary mode, use the IN BINARY MODE addition to the OPEN DATASET statement

To open a file for reading, use the FOR INPUT addition to the OPEN DATASET statement.

Regards

Shiva

Edited by: Shiva Kumar Tirumalasetty on Aug 19, 2009 7:57 PM

3 REPLIES 3
Read only

Former Member
0 Likes
726

Hi,

Check these FMs

CONV_UTIL_CHECK_FILE_EXISTENCE

CV120_DOC_FILE_EXISTENCE_CHECK

CV122_DOC_FILE_EXISTENCE_CHECK

DX_FILE_EXISTENCE_CHECK

PFL_CHECK_OS_FILE_EXISTENCE

Regards,

Vik

Edited by: vikred on Aug 19, 2009 6:21 PM

Read only

Former Member
0 Likes
727

Hi,

Simply use the statement: OPEN DATASET. If the sy-subrc after the statement is NE 0 , then the file is not existing.

You need to pass the filename and filepath for the above.

For eg: FNAME = '/tmp/myfile'.

OPEN DATASET FNAME.

For more information on OPEN DATASET, check sap help.

To open a file in binary mode, use the IN BINARY MODE addition to the OPEN DATASET statement

To open a file for reading, use the FOR INPUT addition to the OPEN DATASET statement.

Regards

Shiva

Edited by: Shiva Kumar Tirumalasetty on Aug 19, 2009 7:57 PM

Read only

Former Member
0 Likes
726

Hi Neha,

To access the files on Application server we use DATASET operationsd like open, read, close etc.

Now in your case use opendataset as:

open dataset ds_name for output in text mode encoding default.

IF sy-subrc NE 0.

//write your message here.

ENDIF.

CLOSE DATASET ds_name.

Where ds_name = logical path name of your file, or if you want to check for just one file, hard code the path.

Better practice is to use logical path name.

Also declare ds_name as

DATA: ds_name LIKE rfpdo-rfbifile.

Close dataset is used in case file exists you need to close it.

Revert back if you wantto know abt logical file name.

Regards,

Sana.