cancel
Showing results for 
Search instead for 
Did you mean: 

function module to uploade excel fiel to crm system

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

hi joot are you shure that this works in crm

Former Member
0 Kudos

Hello,

I copy - pasted this code from a program I wrote myself so yes, it works in CRM.

What is not working?

(Make sure that the file you're trying to open is NOT opened in Excel while executing the function, else you'll get sy-subrc = 13)

Regards,

<u><b>Joost</b></u>

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

would you please explain it clearly for that split of loop

Former Member
0 Kudos

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

Former Member
0 Kudos

from where this 'mystructure' got got into picture and will this work for 1000 fields to upload.

Former Member
0 Kudos

I don't understand what you mean with "from where this 'mystructure' got got into picture".

Yes it will work for 1000 fields, a string has an unrestricted length.

Regards,

Joost