How can I convert a RAW ( Or LRAW) into sting ?

Highlighted
Four Stars

How can I convert a RAW ( Or LRAW) into sting ?

I want to read a SAP Table STXL which contains a RAW field and insert into a SQL Server table with type nvarchar. 

 

The Schema suggested converting the RAW into byte[] but how can I convert this to nvarchar ? 

 

Thank you in advance. 


Andrew 

Sixteen Stars

Re: How can I convert a RAW ( Or LRAW) into sting ?

Have you tried this in your tMap? Create your String output column and use the code below (or similar) to convert the byte[] ....

new String(row1.yourRawByteArray, StandardCharsets.UTF_8)
Four Stars

Re: How can I convert a RAW ( Or LRAW) into sting ?

Hi Rhall_2_0 , 


Thanks for your input. When I tried adding what you've suggested , I get the error message "StandardCharSets cannot be resolved to a variable". 

I enclose a picture of what I've attempted - is that what you meant ? 

Sixteen Stars

Re: How can I convert a RAW ( Or LRAW) into sting ?

My mistake. You need to give it's full path unless you have previously imported it. To make it easy, just replace with this...

 

new String(row1.yourRawByteArray, java.nio.charset.StandardCharsets.UTF_8)
Four Stars

Re: How can I convert a RAW ( Or LRAW) into sting ?

One Step further.... thank you.... but I still appears to me to be just raw data rather than the character text. 

 

Sixteen Stars

Re: How can I convert a RAW ( Or LRAW) into sting ?

I can't help you without knowing more about the Raw data. It could just be the wrong character set that is being used in the conversion. I guessed UTF-8. Do you know the original character set? Do you know what the data should look like? Do you know if maybe it has been converted or encrypted? The first thing I would do is look for the correct character set or just try others out if you cannot get the character set.