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: 

how to check there input file path is correct or not

Former Member
0 Kudos

hi all,

my requirement is to check given file path while downloading a report into flat file is correct or not. i.e if file path is wrong then an error message should be given otherwise the report should be downloaded.how to do this.

with regards,

suresh babu aluri.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
Instead of validating path , u can give F4 help for that
 
PARAMETERS:p_file LIKE rlgrap-filename.
data : v_file type string.
 
 
*Input Help for the Download Directory
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
 
  CALL FUNCTION 'F4_FILENAME'
       EXPORTING
            program_name  = v_repid
            dynpro_number = syst-dynnr
            field_name    = 'P_FILE'
       IMPORTING
            file_name     = p_file.
 
v_filename = p_file.
5 REPLIES 5

Former Member
0 Kudos

Hi

is there a pre-defined folder or location where you have to download the report to,

then you can compare using the string.

regards,

Raghavendra

Former Member
0 Kudos
Instead of validating path , u can give F4 help for that
 
PARAMETERS:p_file LIKE rlgrap-filename.
data : v_file type string.
 
 
*Input Help for the Download Directory
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
 
  CALL FUNCTION 'F4_FILENAME'
       EXPORTING
            program_name  = v_repid
            dynpro_number = syst-dynnr
            field_name    = 'P_FILE'
       IMPORTING
            file_name     = p_file.
 
v_filename = p_file.

Former Member
0 Kudos

<b>To download in desktop</b>

DATA: l_ofile1 TYPE string.
    CLEAR: l_ofile1.
    l_ofile1 = p_ofile_file.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename                = l_ofile1
        filetype                = 'ASC'
      TABLES
        data_tab                = p_local_table
      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
        OTHERS                  = 22.
    IF sy-subrc EQ  19.
      MESSAGE e000 WITH 'File Not Found'.
    ENDIF.
  ENDIF.

0 Kudos

<b>For application server</b>* Audit file download in application server

OPEN DATASET p_ofile_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

    IF sy-subrc = 0.
      CLEAR: wa_local.

      LOOP AT p_local_table INTO wa_local.
        TRANSFER wa_local TO p_ofile_file.
        CLEAR: wa_local.
      ENDLOOP.

      CLOSE DATASET p_ofile_file.
    ELSE.

      MESSAGE e000 WITH 'File Not Found'.
    ENDIF.

Former Member
0 Kudos

Hi Sureshbabu,

<b> FM 'gui_download' is having exception regarding this .

FILE NOT FOUND.</b> check exception 19 in FM

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

filename = v_file

filetype = 'ASC'

  • APPEND = ' '

write_field_separator = 'X'

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • CONFIRM_OVERWRITE = ' '

  • NO_AUTH_CHECK = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • TRUNC_TRAILING_BLANKS_EOL = 'X'

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

wk1_t_size = '30'

  • IMPORTING

  • FILELENGTH =

TABLES

data_tab = i_tab

  • FIELDNAMES =

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

<b> FILE_NOT_FOUND = 19</b>

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

OTHERS = 22

.

IF sy-subrc <> 0.

message e001 " e001 - file not found.

ENDIF.

Reward points if helpful.

Regards,

Hemant