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

gui_upload problem with splitting

Former Member
0 Likes
1,067

Hi experts,

i have below code which is for uploding the file from local drive, but it is giving error like this "invalid source file/data split selection..." ,

could any one help me in this

form upload_file.

data: w_matnr like mara-matnr,

w_datum like sy-datum.

data:

w_file1 type zppiforecast.

move p_file to w_line.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = W_LINE

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = I_FILE

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.

message w005(z1) with 'File ' p_file ' cannot be opened'.

ENDIF.

loop at i_file into w_file1.

call function 'CONVERSION_EXIT_MATN1_INPUT'

exporting

input = w_file1-matnr

importing

output = w_matnr

exceptions

length_error = 1

others = 2.

i_file-index = sy-index.

*Check that the date is in the correct format.

call function 'CONVERT_DATE_TO_INTERN_FORMAT'

exporting

datum = w_file1-datum

dtype = 'DATS'

importing

error = w_error

idate = w_file1-datum

messg = w_messg

msgln = w_msgln.

*If an error has occurred write entry to error table, otherwise append

*record list

if not w_error is initial.

t_exception = i_file.

t_exception-message = text-006.

append t_exception.

else.

check i_file-datum in so_datum.

modify i_file from w_file1 index sy-tabix.

endif.

endloop.

endform. " upload_file

6 REPLIES 6
Read only

Former Member
0 Likes
871

Hi,

your local file should be tab delimited.

refer following:

  • Input file structure

TYPES: BEGIN OF ty_input,

drcrk, " Debit/Credit Indicator

poper(3), " Posting Perid

kostl(10), " cost centre

rprctr(10), " Profit Center

racct(10), " Account number

hsl(18), " Amount

sgtxt(50), " Text

flag(1), " flag for pc n cc

refdocnr(10), " FI Doc. No.

END OF ty_input.

TYPE-POOLS: pcpp.

PARAMETERS: pr_kokrs TYPE lips-kokrs OBLIGATORY, pr_file TYPE rlgrap-filename OBLIGATORY , " File name

PERFORM f001_f4_filename CHANGING pr_file.

FORM f001_f4_filename CHANGING exp_file TYPE ibipparms-path.

CALL FUNCTION 'F4_FILENAME'

IMPORTING

file_name = exp_file.

ENDFORM.

FORM f002_upload_data .

DATA: l_filenm TYPE string.

l_filenm = pr_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = l_filenm

has_field_separator = 'X'

TABLES

data_tab = it_input

EXCEPTIONS

OTHERS = 1.

IF sy-subrc <> 0.

MESSAGE e208(00) WITH text-e01.

ENDIF.

ENDFORM. " F002_UPLOAD_DATA

Read only

KN-Nampoothiry
Active Participant
0 Likes
871

Hi Venu,

Are you tryin to pick file from Desktop / My Documents. Then an error may occur.

See if the file type 'ASC' is correct for separator 'X'.

Reward if Useful

Read only

0 Likes
871

Hi

i am uploading the file from mydocuments , and giving 'ASC' type and separator 'X' also, still it is giving error

Read only

0 Likes
871

Hi,

Your Internal Table must have all the fields as type C.

If the fields are of any other type in internal table the file will not get uploaded.

check this ....

reward points if helpful....

Regards

Jitendra

Read only

Former Member
0 Likes
871

hi

good

check the flat file position from where you r uploading the data.

thanks

mrutyun^

Read only

Former Member
0 Likes
871

Hi

see this program

you can understand very easyly

REPORT Z11554_DATAU.

types: begin of ty_tab,

matnr type mara-matnr,

matkl type mara-matkl,

end of ty_tab.

data: it_tab type table of ty_tab,

wa_tab type ty_tab.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\data2.txt'

  • FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = it_tab

  • 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 it_tab into wa_tab.

write:/ wa_tab-matnr , wa_tab-matkl.

endloop.

reward if usefull