cancel
Showing results for 
Search instead for 
Did you mean: 

clean hidden characters

Former Member
0 Kudos

Hello,

I have scenario from IDOC to XML file.

The XML file use by VAN company that transfer it to EDI format.

My problem is in TELX1 field.

This field look normal in IDOC, Look normal in XML.

But when the VAN company open the XML file with text editor in ANSI format they found more characters like in the example below:

<TELX1>גu20ACŽ310גu20AC</TELX1>

Have a way to clean this hidden characters?

Elad

Accepted Solutions (0)

Answers (4)

Answers (4)

stefan_grube
Active Contributor
0 Kudos

>

> But when the VAN company open the XML file with text editor in ANSI format they found more characters like in the example below:

> <TELX1>גu20ACŽ310גu20AC</TELX1>

> Have a way to clean this hidden characters?

> Elad

You should not clean any characters. The question ist: What is in the field and what do you expect? Maybe you open the file with Word or Internet Explorer and set the encoding to UTF-8.

If the customer needs different encoding as UTF-8, ask first, what encoding he wants.

Regards

Stefan

Former Member
0 Kudos

Hi,

<TELX1>u05D2u20ACŽ310u05D2u20AC</TELX1>

i think this is because of new line characters are coming in the TELX1 field. so you have to ckean these characters during your mapping.

i am suggesting you to use this udf:

create a udf named cleanHidden with the value cache type.

public String cleanHidden(String a,Container container){
     return a.replaceAll("
", "");
}

now use this udf in your mapping like this:

Source-->cleanHidden-->TELX1

*Reward points if helpful.

--Sankar Choudhury

Former Member
0 Kudos

Hello Sankar,

I try to use with this UDF and i received this error message:

08:20:32 Start of test

Source code has syntax error: L:/usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map48a91ac2383f11dd82ad001635c5b25f/source/com/sap/xi/tf/_Invoice_MM_.java:488: illegal start of expression public String cleanHidden(String a){ ^ L:/usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map48a91ac2383f11dd82ad001635c5b25f/source/com/sap/xi/tf/_Invoice_MM_.java:491: ';' expected ^ 2 errors Source code has syntax error: L:/usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map48a91ac2383f11dd82ad001635c5b25f/source/com/sap/xi/tf/_Invoice_MM_.java:488: illegal start of expression public String cleanHidden(String a){ ^ L:/usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map48a91ac2383f11dd82ad001635c5b25f/source/com/sap/xi/tf/_Invoice_MM_.java:491: ';' expected ^ 2 errors

08:20:34 End of test

Any idea?

Elad

Former Member
0 Kudos

Hi,

i think you have copied the whole code in your udf. its not like that.

first create a udf named "cleanHidden" with a string argument "a".

then in the udf editor just write this line:

return a.replaceAll("\n", "");

tell me if any issues

--Sankar Choudhury

Former Member
0 Kudos

Hello Sankar,

Now the I succeed to compile this UDF but is not solved the problem.

The file is the same like before

Elad

Former Member
0 Kudos

Hi,

In your example given

<TELX1>u05D2u20ACŽ310u05D2u20AC</TELX1>

which characters you want to remove??

do you want to remove all characters here except 310??????

Former Member
0 Kudos

yes

Former Member
0 Kudos

Hi,

Make the Text Encoding Format as Text in Communication channel and use UTF-16 in Text Encoding.

This will allwo you to convert these chars. instead of just supressing with the use of UDF

Thanks

Swarup

Former Member
0 Kudos

Hello Swarup,

I tried to change encoting format without any result

Any new idea?

Elad

Former Member
0 Kudos

Hi,

try this code in your udf "cleanHidden".

StringBuffer str=new StringBuffer();
    for(int i=0;i<a.length();i++) 
        if((a.charAt(i)>=48&&a.charAt(i)<=57)||(a.charAt(i)>=65&&a.charAt(i)<=90)||(a.charAt(i)>=97&&a.charAt(i)<=122))
                str.append(a.charAt(i));
String result=new String(str);
return result;

--Sankar Choudhury

Former Member
0 Kudos

Hello,

Thank you for your answers.

The UDF and processing parameters not solved the problem.

We take decision to change data in our R/3 system (the source)

Elad

former_member190389
Active Contributor
0 Kudos

in the xml declaration i.e

instead of :

<?xml version="1.0" encoding="utf-8" ?>

use

<?xml version="1.0" encoding="utf-16" ?>

former_member190389
Active Contributor
0 Kudos

try using UTF-16 as encoding instead of UTF-8..

Former Member
0 Kudos

Where I change encoding settings?

Former Member
0 Kudos

Hi,

Try chaning encoding settings in

File communication channel in Processing Parameters-> File Encoding

Regards,

Shabari

Former Member
0 Kudos

hi,

All SAP XML is encoded in Unicode (UTF16)

regards

chandra

Former Member
0 Kudos

Change in the file communication channel and check.

Regards

Sunita

Former Member
0 Kudos

Hello,

in Processing Parameters i'm not found File Encoding.

Elad