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

FILE EXISTING VALIDATION

Former Member
0 Likes
577

HI,

I am uploading the data for open AR line items through a file in the applicaiton server.

can any one give me some idea how to validate whether that file is existing or not...?

please its bit urgent

If anyone can give me some code, that would be really helpful for me

SRI

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
550

All you need to do is evaluate SY-SUBRC after the OPEN statement, if it is not 0, then it either does not exist or you don't have permission to open it, I think 4 is that it does not exist, and 8, means that you don't have permission. Anyway, simply check the value of SY-SUBRC after the OPEN DATASET statement.

Regards,

Rich Heilman

Read only

0 Likes
550

Rich ,

Just i want to do the validation in at selection screen output even so that the mentioned file is existing or not

does it make any sense... then how to do that

Read only

Former Member
0 Likes
550

Hi,

Open the file using the OPEN DATASET syntax..If the return code is not successful..then the file does not exits.



OPEN DATASET '/tmp/test.txt' FOR INPUT.

IF SY-SUBRC <> 0.
  MESSAGE 'Error in opening file or file does not exists'.
ENDIF.

Thanks

Naren

Read only

Former Member
0 Likes
550

Hi,

Please try something like this.


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_apath.
 
* Open the Browse Dialog Box on the Application Server
CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
  IMPORTING
    serverfile = p_apath
  EXCEPTIONS
    canceled_by_user = 1
    others = 2.
 
IF sy-subrc <> 0.
  ...                                   " Error Message
ENDIF.

Regards,

Ferry Lianto