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

Five 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 

Community Manager

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)
Five 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 ? 

Community Manager

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)
Five 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. 

 

Community Manager

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.

Five Stars

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

The solution was not to attempt to read RAW but to use the RFC_READ_TEXT object which would then return the text in an XML DOC structure. Screen Shot 2019-02-12 at 14.21.50.png

With thanks to Chetan! 

Cloud Free Trial

Try Talend Cloud free for 30 days.

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.