on 12-13-2007 12:17 PM
Hi,
can anyone say what is the function module to upload excel file to crm system please make it with screen shot for the values which you give in the
importing parameters
exporting parameters
tables
exception
changing
please i need the screen shot of the above parameters.
the above is the link which gives the function module but i didn't i understand exactly.
Hello,
Use FM GUI_UPLOAD, this is much more easy than the VB calls through OLE.
!! Code below only works for Comma Separated Value (CSV) files!!
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = lv_str
FILETYPE = 'ASC'
TABLES
DATA_TAB = gt_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.
lv_str must contain your file location (E.g. 'C:\test\myexcel.csv')
gt_file declaration:
GT_FILE TYPE TABLE OF ZMYSTRUC.
ZMYSTRUC contains one field; e.g. TEXT TYPE STRING.
gt_file contains an entry for each line in your XL file.
You can save an XL file as CSV. 'File->Save as->File type CSV'
This should do the trick.
Regards,
Joost
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
REPORT ZSAMPL10.
data: begin of itab occurs 0,
lifnr like lfa1-lifnr,
name1 like lfa1-name1,
end of itab.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'c:\poorna\poorna.csv'
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 = 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-lifnr, itab-name1.
endloop.
and when i execuited
i got message saying that acess to file denied.
Hello,
Like mentioned in previous reply, this error is because your file is opened in XL while executing the FM. Close the file in XL (simply close XL) and you won't get this error. (Unless you really don't have access to the file...)
During the loop you must do a
SPLIT ls_itab AT ';' INTO:
lv_field1
lv_field2
....
To split the content of each field into a variable.
Regards,
Joost
Don't forget to reward me points....
Ok... here we go
So you got the table from GUI_UPLOAD, let's say lt_table.
Considering this:
LT_TABLE TYPE TABLE OF ZMYSTRUC,
LS_TABLE TYPE ZMYSTRUC.
And MYSTRUC contains one field, TEXT TYPE STRING.
LOOP AT lt_table INTO ls_table.
SPLIT ls_table-text AT ';' INTO:
lv_field1
lv_field2
.....
ENDLOOP.
lv_field1 will contain the value of COLUMN1 in your XL file
lv_field2 ...
This should make it clear.
<b>Don't forget to reward points!</b>
Regards,
Joost
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.