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: 

file path error in same screen.

Former Member
0 Kudos

hey guys,

I want to check my file path validation and display error in same screen itself.

I used my GUI_UPLOAD method in START OF SELECTION. to read the file.

If error it displays error in some other plain screen.

I know AT selection screen will allow me to display in same screen.

But is the way of using GUI_UPLOAD method in AT selection screen is advisable?

or else please give me alternate way.

ambichan

9 REPLIES 9

Former Member
0 Kudos

Hi Ambhi,

If you want to validate for existance of file

use

DATA : l_f_exist(1).

CALL FUNCTION 'TMP_GUI_GET_FILE_EXIST'

EXPORTING

fname = p_inp

IMPORTING

exist = l_f_exist

EXCEPTIONS

fileinfo_error = 1

OTHERS = 2.

IN AT SELECTION SCREEN.

<i>I assume you are not validating data in the file at selection screen.</i>

Rgds,

Mano Sri

Message was edited by: Mano Sri

0 Kudos

hai mano,

thanks for your reply.

Does P_inp parameter allows only file name or

FILE PATH.

could you pls confirm.

ambichan

0 Kudos

up to 128 char i guess , so you can try with file path

Rgds,

M

Former Member
0 Kudos

Hi

You can use in AT Selection screen

data result.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST

EXPORTING

FILE = 'C:\test.txt'

RECEIVING

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.

the return parameter will be "X" if file exists else it will be blank.

Cheers

Former Member
0 Kudos

Hi Ambi,

You can do the GUI_UPLOAD in the AT SELECTION-SCREEN event, provided you do that only when the user presses the 'Execute' or 'F8' button. That way you will avoid doing it all the time. AT SELECTION-SCREEN will be executed before the START-OF-SELECTION and any error you give there, the processing stops there and you remain in the selection screen.


AT SELECTION-SCREEN.

  CASE sscrfields-ucomm.
    WHEN 'ONLI'.
      CALL FUNCTION 'GUI_UPLOAD'
         ........
         .....
    WHEN OTHERS.
  ENDCASE.

0 Kudos

To valid the existance of file in presentation or application server u can use SXDA_FILE_EXISTENCE_CHECK

CALL FUNCTION 'SXDA_FILE_EXISTENCE_CHECK'

EXPORTING

DS_NAME = P_FPATH "file path

DATA_APP = 'X'

DATA_REM = SPACE

SERVER = SPACE

DATA_FRN = SPACE

PC_FILE = SPACE

IMPORTING

FILE_EXISTS = W_XFLAG

EXCEPTIONS

RFC_FAILURE = 1

FRONTEND_ERROR = 2

DB_ERROR = 3

OTHERS = 4.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

STOP.

ENDIF.

IF W_XFLAG EQ 'X'.

WRITE:/001 'File exists'.

ELSE.

WRITE:/001 'File does not exists'.

ENDIF.

regards

venkat

Former Member
0 Kudos

Give an Information message and do a leave to transaction <same program>

Rajiv

Former Member
0 Kudos

Hello Mr. Chan,

I guess you forgot to close the thread , hope problem is not persisting.

-M

0 Kudos

Did the answers help you? Can you please close the post if resolved?

Thanks,

Srinivas