Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Unicode Convertible error - Copying Internal Table into Permanent table

Hi experts!

I'm stuck on a big problem here, which I'm hoping someone can help with. I'm a bit of a newbie at ABAP.

The below ABAP attempts to:

1) Extract data from a .CSV file and place it into an internal table.

2) Then the contents of the internal table are copied into a permanent database table. (Don't worry about advance deletions in the permanent table, I've already got that covered.)

The above ABAP works fine if all the fields in the permanent table have the data type CHAR or LANG. However I run into a major problem if a field in the permanent table is INT4 (Integer). Unfortunately I can't change the data types in the permanent table, so I'm stuck with trying to import into an integer field.

The code I have is below.

"----


REPORT Z_MYTESTPROGRAM.

" Types declarations:

"Columns:

types: begin of ttab,

REC(1000) type c,

end of ttab.

"Rows:

types: begin of tdat,

TEST(20) type c,

LAST_NAME(20) type c,

LANG(1) type c,

INDEXCODE(10) TYPE c,

end of tdat.

" Data declarations:

data: itab type table of ttab with header line.

data: idat type table of tdat with header line.

data: file_str type string.

" FILE PATH:

file_str = 'C:\TempCSVFile.csv'.

" Run code to import from Comma-delim file:

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = file_str

TABLES

data_tab = itab

EXCEPTIONS

others = 17.

" Populate temporary (internal) table idat:

loop at itab.

clear idat.

split itab-REC at ',' into

idat-TEST

idat-LAST_NAME

idat-LANG

idat-INDEXCODE.

append idat.

endloop.

" Now populate permanent table with data from temporary table:

insert ZMM_FIRST_TABLE from table idat. " <- This is the row where the Unicode convertible error get's reported.

"----


The error I get when a field is an integer is:

"The type of the database table and work area (or internal table) "IDAT" are not Unicode convertible."

The field that has the problem is the INDEXCODE field and it only occurs when that field becomes an integer-type field in the permanent table. I have also tried changing the data type in the ABAP of to INDEXCODE TYPE I, but then I get an error message

""INDEXCODE" must be a character-type data object (data type C, N, D, T or STRING)."

Basically SAP's not letting me change the data type to an integer in the Types declaration, yet at the same time it's looking for an Integer data type. - Big clash.

Has anyone else come across this? Can anyone think of how I can resolve this problem?

Cheers!

- Andy

Former Member
Former Member replied

CDAT has to be defined exactly the same as the database table. Use the structure in the definition, not the individual fields.

Rob

1 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question