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: 

CSV upload using GUI_UPLOAD

Former Member
0 Kudos

Hi,

i have a requirement to upload a CSV file. I used the fm GUI_UPLOAD for this. the internal table will be one with a single field and all the field values seperated by ',' right? is there any way to get this fields populated into the corresponding fields while uploading using the FM itself and how?

i tried to use split at ',' to achieve this after uploading. but since some fields are with data type quantity its not working. how i can proceed to achieve my requirement?

Regards,

Anoop R.S

2 REPLIES 2

Former Member
0 Kudos

Hi anoop,

1. simple

2. just copy paste.

3. the file name is d:\myfile.txt

the contents are - 2 records:

amit;mittal

mr;xyz

4.

report abc.

type-pools : TRUXS.

*----


data : rawdata type TRUXS_T_TEXT_DATA.

data : begin of itab occurs 0,

f1(10) type c,

f2(10) type c,

end of itab.

*----


CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'd:\myfile.txt'

TABLES

DATA_TAB = rawdata

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

.

*----


CALL FUNCTION 'TEXT_CONVERT_CSV_TO_SAP'

EXPORTING

I_FIELD_SEPERATOR = ';'

  • I_LINE_HEADER =

I_TAB_RAW_DATA = rawdata

  • I_FILENAME = 'd:\myfile1.txt'

TABLES

I_TAB_CONVERTED_DATA = itab

EXCEPTIONS

CONVERSION_FAILED = 1

OTHERS = 2

.

break-point.

regards,

amit m.

Former Member
0 Kudos

define your internal table with the fields you have in the text file.

then call GUI_UPLOAD function module,

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\ABC.CSV'

FILETYPE = 'ASC'

<b> HAS_FIELD_SEPERATOR = 'X'

TABLES

DATATAB = ITAB.</b>

here ITAB is your Internal table with all the Fields.

if you place <b> HAS_FIELD_SEPERATOR = 'X' field ,then SAP will automatically populate values to those fields of ITAB accordingly.

but if you have any quantity/currency fields with decimals or thousand seperator as comma(,)then it would be a problem. check it once.

regards,

Srikanth