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

Problem with validation of selection screen

Former Member
0 Likes
620

I am creating session process for BDC

For that i am taking the flat file at runtime.i want check whether the entered file is valid or not..that means it exists are not?

how to do that..

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
594

Hi,

If you are uploading file from Presentation server, you will be using GUI_UPLOAD function module. If file does not exist it will return error. (sy-subrc <> 0).

If you are fetching from Application server ,

OPEN DATASET ...

will return sy-subrc as 4.

I am creating session process for BDC

For that i am taking the flat file at runtime.i want check whether the entered file is valid or not..that means it exists are not?

how to do that..

4 REPLIES 4
Read only

Former Member
0 Likes
594

Hi Ravee

If you are reading the file from the presentation server then use this class method, CL_GUI_FRONTEND_SERVICES->FILE_EXIST to check if the file exists.

If you are reading the file from the application server then use the FM SUBST_GET_FILE_LIST, by passing the file name and path. If it returns an entry then that file is valid.

Cheers

~ Ranganath

Read only

Former Member
0 Likes
595

Hi,

If you are uploading file from Presentation server, you will be using GUI_UPLOAD function module. If file does not exist it will return error. (sy-subrc <> 0).

If you are fetching from Application server ,

OPEN DATASET ...

will return sy-subrc as 4.

Read only

former_member404244
Active Contributor
0 Likes
594

Hi,

DATA: W_FILENAME TYPE STRING,

W_RESULT TYPE C.

W_FILENAME = WK_DIRECTRY.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST

EXPORTING

FILE = W_FILENAME

RECEIVING

RESULT = W_RESULT

EXCEPTIONS

CNTL_ERROR = 1

ERROR_NO_GUI = 2

WRONG_PARAMETER = 3

NOT_SUPPORTED_BY_GUI = 4

others = 5.

IF SY-SUBRC 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-* MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

IF W_RESULT IS INITIAL.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_EXIST

EXPORTING

DIRECTORY = W_FILENAME

RECEIVING

RESULT = W_RESULT

EXCEPTIONS

CNTL_ERROR = 1

ERROR_NO_GUI = 2

WRONG_PARAMETER = 3

NOT_SUPPORTED_BY_GUI = 4

OTHERS = 5.

IF SY-SUBRC 0.

ENDIF.

ENDIF.

IF W_RESULT = 'X'.

RC = '1'.

ELSE.

RC = '0'.

ENDIF.

Regards,

nagaraj

Read only

Former Member
0 Likes
594

Hi Ravindra,

After uploading the data using GUI_UPLOAD check the sy-subrc value .

If it is ZERO : successful (FILE IS UPLOADED)

If it is NON-ZER0 : unsuccessful

Reward points if helpful.

Kiran Kumar.G.A

Have a Nice Day..