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: 

exceptions in cl_gui_frontend_services=>file_open_dialog

Former Member
0 Kudos

hi when upgrading from 4.5 to 6.o Im getting the following exception

When the pop up box is cancelled during the download option, a success message is displayed in 6.0 whereas an error message is displayed in 4.5.

here is the code

CALL METHOD cl_gui_frontend_services=>file_open_dialog

EXPORTING

DEFAULT_EXTENSION = '*.xls,'

DEFAULT_FILENAME = '*.xls,'

FILE_FILTER = '.'

CHANGING

file_table = W_FILENAME

rc = w_rc

EXCEPTIONS

FILE_OPEN_DIALOG_FAILED = 1

CNTL_ERROR = 2

ERROR_NO_GUI = 3

NOT_SUPPORTED_BY_GUI = 4

others = 5.

IF W_RC IS NOT INITIAL.

READ TABLE W_FILENAME INTO W_AREA INDEX 1.

IF SY-SUBRC = 0.

L_FILE = W_AREA-FILENAME.

ENDIF.

ENDIF.

IF SY-SUBRC EQ 3.

MESSAGE I999 WITH 'Action Cancelled by user'(044).

EXIT.

ENDIF.

plz tell me where is the eror

2 REPLIES 2

Former Member
0 Kudos

chk the data declearsation data type.

CALL METHOD cl_gui_frontend_services=>file_open_dialog

EXPORTING

window_title = 'Import from a local file'

default_extension = 'DAT'

  • DEFAULT_FILENAME =

file_filter = l_file_filter

initial_directory = 'C:\'

  • MULTISELECTION =

  • WITH_ENCODING =

CHANGING

file_table = l_file_table

rc = l_rc

  • USER_ACTION =

  • FILE_ENCODING =

EXCEPTIONS

file_open_dialog_failed = 1

cntl_error = 2

error_no_gui = 3

not_supported_by_gui = 4

OTHERS = 5

CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD

EXPORTING

FILENAME = V_FILE

FILETYPE = 'ASC'

WRITE_FIELD_SEPARATOR = 'X'

CHANGING

DATA_TAB = IT_MAIN[]

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

NO_AUTHORITY = 5

UNKNOWN_ERROR = 6

HEADER_NOT_ALLOWED = 7

SEPARATOR_NOT_ALLOWED = 8

FILESIZE_NOT_ALLOWED = 9

HEADER_TOO_LONG = 10

DP_ERROR_CREATE = 11

DP_ERROR_SEND = 12

DP_ERROR_WRITE = 13

UNKNOWN_DP_ERROR = 14

ACCESS_DENIED = 15

DP_OUT_OF_MEMORY = 16

DISK_FULL = 17

DP_TIMEOUT = 18

FILE_NOT_FOUND = 19

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

NOT_SUPPORTED_BY_GUI = 22

OTHERS = 23.

IF SY-SUBRC <> 0.

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

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

ENDIF.

Pawan_Kesari
Active Contributor
0 Kudos

try this code


PARAMETERS : p_path TYPE char100 .

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path .

  DATA : w_filename TYPE filetable  ,
         w_area     TYPE file_table ,
         w_rc       TYPE i          ,
         w_ret      TYPE i          .

  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      default_extension       = '*.xls'
      default_filename        = '*.xls'
      file_filter             = '*.*'
    CHANGING
      file_table              = w_filename
      rc                      = w_rc
      user_action             = w_ret
    EXCEPTIONS
      file_open_dialog_failed = 1
      cntl_error              = 2
      error_no_gui            = 3
      not_supported_by_gui    = 4
      OTHERS                  = 5.

  IF w_ret =  cl_gui_frontend_services=>action_ok .
    IF w_rc > 0 .
      READ TABLE w_filename INTO w_area INDEX 1.
      IF sy-subrc = 0.
        p_path = w_area-filename.
      ENDIF.
    ENDIF.
  ENDIF.

  IF w_ret =  cl_gui_frontend_services=>action_cancel .
    MESSAGE i001(00) WITH 'Action Cancelled by user'.
    EXIT.
  ENDIF.