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

bdc gui_upload

Former Member
0 Likes
1,230

hi all,

i have small issue regarding upload a file..

flat file is in excelsheet i saved it to as tabdelimit....

and trying to upload as follow but it is not not getting upload.......

can any one suggest...

data : begin of itab occurs 999,

data(225),

end of itab.

data :

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'BOOK1.XLS'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

IMPORTING

FILELENGTH = 125

  • HEADER =

tables

data_tab = itab

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17

.

IF sy-subrc <> 0.

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

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

ENDIF.

loop at itab.

write 😕 itab.

endloop.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
977

Hi ranjith,

Give the full path for file name.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'C:/BOOK1.XLS' " If it is in C drive

Regards,

Ravi

11 REPLIES 11
Read only

Former Member
0 Likes
978

Hi ranjith,

Give the full path for file name.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'C:/BOOK1.XLS' " If it is in C drive

Regards,

Ravi

Read only

0 Likes
977

if it is a tab delimitectext file, then wouldn't it be a .txt file?

ie BOOK1.txt

~Suresh

Read only

0 Likes
977

hi ravi,

thanks for responding.........

the file is in desktop....

regards,

ranjith.

Read only

0 Likes
977

hi,

then u need to pass the whole filepath...to the parameter FILENAME.

Regards,

priya.

Read only

0 Likes
977

Right Click on the file , Choose properties to find the path.

C:\Documents and Settings\<your network user name>\Desktop\TEXT.XLS

Regards,

Ravi

Read only

0 Likes
977

Then,,

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

<b>filename = 'C:\Documents and Settings\Desktop\BOOK1.XLS'</b>

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

Read only

Former Member
0 Likes
977

You can also use this FM ALSM_EXCEL_TO_INTERNAL_TABLE

Read only

Former Member
0 Likes
977

hi ranjith,

Give the complete path

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

<b>filename = 'C:/BOOK1.XLS'</b>

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

Read only

ferry_lianto
Active Contributor
0 Likes
977

Hi,

Please try this.


CREATE OBJECT OB_GUI_FRONTEND
  EXCEPTIONS
    NOT_SUPPORTED_BY_GUI = 1
    CNTL_ERROR = 2
    OTHERS = 3.

IF SY-SUBRC <> 0.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
     WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL METHOD OB_GUI_FRONTEND->GUI_UPLOAD
  EXPORTING
    FILENAME = P_FNAME
    FILETYPE = 'ASC'
    HAS_FIELD_SEPARATOR = 'X'
  CHANGING
    DATA_TAB = IT_UPLOAD
  EXCEPTIONS
    FILE_OPEN_ERROR = 1
    FILE_READ_ERROR = 2
    NO_BATCH = 3
    GUI_REFUSE_FILETRANSFER = 4
    INVALID_TYPE = 5
    NO_AUTHORITY = 6
    UNKNOWN_ERROR = 7
    BAD_DATA_FORMAT = 8
    HEADER_NOT_ALLOWED = 9
    SEPARATOR_NOT_ALLOWED = 10
    HEADER_TOO_LONG = 11
    UNKNOWN_DP_ERROR = 12
    ACCESS_DENIED = 13
    DP_OUT_OF_MEMORY = 14
    DISK_FULL = 15
    DP_TIMEOUT = 16
    NOT_SUPPORTED_BY_GUI = 17
    ERROR_NO_GUI = 18
    OTHERS = 19.

Regards,

Ferry Lianto

Read only

0 Likes
977

perhaps make a selection screen for the file upload


SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
    PARAMETERS: P_FILE(255) OBLIGATORY LOWER CASE.
SELECTION-SCREEN END OF BLOCK B1.


INITIALIZATION.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  PERFORM f4_for_file USING p_file space.

START-OF-SELECTION.

FORM f4_for_file USING c_upload i_default_filename.
  DATA:
    t_files TYPE STANDARD TABLE OF file_table,
    wa_files TYPE file_table,
    h_rc TYPE i,
    h_action TYPE i,
  h_filepath TYPE string,
  h_filename TYPE string.


  CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
    EXPORTING
      full_name           = c_upload
    IMPORTING
*     STRIPPED_NAME       =
      file_path           = h_filepath
*   EXCEPTIONS
*     X_ERROR             = 1
*     OTHERS              = 2
            .

  CALL METHOD cl_gui_frontend_services=>file_open_dialog
     EXPORTING
*      WINDOW_TITLE            =
*      DEFAULT_EXTENSION       =
       default_filename        = i_default_filename
*      FILE_FILTER             =
       initial_directory       = h_filepath
*      MULTISELECTION          =
*      WITH_ENCODING           =
    CHANGING
      file_table              = t_files
      rc                      = h_rc
      user_action             = h_action
*      FILE_ENCODING           =
    EXCEPTIONS
      file_open_dialog_failed = 1
      cntl_error              = 2
      error_no_gui            = 3
      not_supported_by_gui    = 4
      OTHERS                  = 5
          .
  READ TABLE t_files INTO wa_files INDEX 1.
  MOVE wa_files-filename TO c_upload.


ENDFORM.                    " f4_for_file

RIU

arthur

Message was edited by:

A. de Smidt

Read only

Former Member
0 Likes
977

Hi ,

I have modified your code check the code below.

Check file path.

data : begin of itab occurs 999,

data(225),

end of itab.

data :

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

<b>*Strat

*filename = 'BOOK1.XLS'

filename = 'C:/BOOK1.XLS'

*End</b>

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

IMPORTING

FILELENGTH = 125

  • HEADER =

tables

data_tab = itab

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17

.

IF sy-subrc <> 0.

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

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

ENDIF.

loop at itab.

write 😕 itab.

endloop.

Thanks

Sunil