cancel
Showing results for 
Search instead for 
Did you mean: 

Getting error in mapping execution Invalid CHAR

Former Member
0 Kudos

hi

i am having file to RFC scenario, and the input file is an xml file and i am getting erron in mapping as below but when i download the payload and load it in the integration repository mapping tool ,i am able to execute it succesfully. i think the problem is with the encoding , i tried with processing it in utf-8 and ansi. both the format it is giving the sam error.

<SAP:Stack>Runtime exception occurred during application mapping com/sap/xi/tf/_MMMMMMMMM_; com.sap.aii.utilxi.misc.api.BaseRuntimeException:Fatal Error: com.sap.engine.lib.xml.parser.ParserException: Invalid char #0xb (:main:, row:1, col:4~</SAP:Stack>

regards

sandeep

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

0b is a vertical tab.

Is it a tab delimited file and your content conversion is not correct?

Former Member
0 Kudos

hi,

there is no content conversion used the source is an xml file.

regards

sandeep

Former Member
0 Kudos

Hi Sandeep,

You can remove the invalid characters using java mapping.

Regards,

Aravind

Former Member
0 Kudos

Hi

Can you please tell me how can i remove it using java mapping.

regards

sandeep

Former Member
0 Kudos

Hi,

Considering the following invalid characters. You can use the below code to filter these characters:

#x9 , #xA , #xD , [#x20-#xD7FF] , [#xE000-#xFFFD] , [#x10000-#x10FFFF]

public String stripNonValidXMLCharacters(String in) {

StringBuffer out = new StringBuffer(); // Used to hold the output.

char current; // Used to reference the current character.

if (in == null || ("".equals(in))) return ""; // vacancy test.

for (int i = 0; i < in.length(); i++) {

current = in.charAt(i); // NOTE: No IndexOutOfBoundsException caught here; it should not happen.

if ((current == 0x9) ||

(current == 0xA) ||

(current == 0xD) ||

((current >= 0x20) && (current <= 0xD7FF)) ||

((current >= 0xE000) && (current <= 0xFFFD)) ||

((current >= 0x10000) && (current <= 0x10FFFF)))

out.append(current);

}

return out.toString();

}

Thanks,

Aravind

Former Member
0 Kudos

hi ,

But my character is not given in the list that u mentioned my character is 0xb

regards

sandeep

stefan_grube
Active Contributor
0 Kudos

> But my character is not given in the list that u mentioned my character is 0xb

The Java code checks any entry to be valid, so the list are the allowed characters.

Where does the XML come from? Maybe there is a chance to fix the issue at sender application.

Former Member
0 Kudos

Hi Stefen /ajnayak ,

So java mapping only supports thes (#x9 , #xA , #xD , x20-#xD7FF , xE000-#xFFFD , x10000-#x10FFFF) and dont support 0xb(vertical tab), So i cant do any thing in PI, and i should ask the sender application to Avoid it right

public String stripNonValidXMLCharacters(String in) {

StringBuffer out = new StringBuffer(); // Used to hold the output.

char current; // Used to reference the current character.

if (in == null || ("".equals(in))) return ""; // vacancy test.

for (int i = 0; i < in.length(); i++) {

current = in.charAt(i); // NOTE: No IndexOutOfBoundsException caught here; it should not happen.

if ((current == 0x9) ||

(current == 0xA) ||

(current == 0xD) ||

((current >= 0x20) && (current <= 0xD7FF)) ||

((current >= 0xE000) && (current <= 0xFFFD)) ||

((current >= 0x10000) && (current <= 0x10FFFF)))

out.append(current);

}

return out.toString();

}

Thanks,

sandeep

Edited by: pendyalas on Feb 2, 2011 11:09 AM

baskar_gopalakrishnan2
Active Contributor
0 Kudos

I think you dont understand Stefan's reply. This code will fix the issue.

The java code checks for only valid characters in this logic. If your vertical tab char appears , the code will ignore that character and take care your issue. Sure , you could try to fix the problem at the sender application too.

Former Member
0 Kudos

hi,

we are allready using graphical mapping and xslt together in this interface, so i can now include a java mapping with the code mentioned above before to these, to remove the invalid characters .

We can also do the correction in sender application i.e sap R3, but that even has to be done by me . as it is and idoc which is generated as xml. and xi file adapter is picking it . instead of generating the xml file can we try to post directly to PI as idoc and then will it resolve the issue.as the note 1004368 will help if it is an idoc

regards

sandeep

Edited by: pendyalas on Feb 2, 2011 8:48 PM

Edited by: pendyalas on Feb 2, 2011 8:54 PM

Edited by: pendyalas on Feb 2, 2011 8:55 PM

stefan_grube
Active Contributor
0 Kudos

> as it is and idoc which is generated as xml. and xi file adapter is picking it .

what nonsense!

> instead of generating the xml file can we try to post directly to PI as idoc and then will it resolve the issue.as the note 1004368 will help if it is an idoc

Yes, please!

Former Member
0 Kudos

hi Stephen ,

The problem is all the idoc that were generated in the day will be packed into single xml file and generated. and then PI picks this file to process. So can this be done using PI by directly posting as the idocs.instead of generating xml file at the end of the day

regards

sandeep

Edited by: pendyalas on Feb 3, 2011 4:57 PM

stefan_grube
Active Contributor
0 Kudos

This is possible only with PI 7.1 ehp1.

Anyway: report to SAP that there is an error in IDoc -> file download. An XML must be valid according to XML specification, a vertical tab is not allowed.. So this is a bug and needs to be fixed.

Former Member
0 Kudos

>> This is possible only with PI 7.1 ehp1.

Yes !Our verstion is SAP EHP 1 for SAP NetWeaver 7.1 so how can i do this.

__instead for fixing in PI i can use the belwo java mapping__

import java.io.InputStream;

import java.io.OutputStream;

import java.util.HashMap;

import java.util.Map;

import com.sap.aii.mapping.api.StreamTransformation;

import com.sap.aii.mapping.api.StreamTransformationConstants;

import com.sap.aii.mapping.api.StreamTransformationException;

public final class MyMapping implements StreamTransformation {

public void execute(InputStream in, OutputStream out)

throws StreamTransformationException {

// removing non valid characters

BufferedReader br = new BufferedReader(in);

out = stripNonValidXMLCharacters(br.readLine());

// implement mapping ...

}

public String stripNonValidXMLCharacters(String in) {

StringBuffer out = new StringBuffer(); // Used to hold the output.

char current; // Used to reference the current character.

if (in == null || ("".equals(in))) return ""; // vacancy test.

for (int i = 0; i < in.length(); i++) {

current = in.charAt(i); // NOTE: No IndexOutOfBoundsException caught here; it should not happen.

if ((current == 0x9) ||

(current == 0xA) ||

(current == 0xD) ||

((current >= 0x20) && (current <= 0xD7FF)) ||

((current >= 0xE000) && (current <= 0xFFFD)) ||

((current >= 0x10000) && (current <= 0x10FFFF)))

out.append(current);

}

return out.toString();

}

}

regards

sandeep

Edited by: pendyalas on Feb 4, 2011 2:07 PM

stefan_grube
Active Contributor
0 Kudos

> Yes !Our verstion is SAP EHP 1 for SAP NetWeaver 7.1 so how can i do this.

/people/shabarish.vijayakumar/blog/2010/01/22/idoc-packaging--sap-pi-71-ehp1-and-above

0 Kudos

Hi stephen ,

Thankyou for your support , i implemented java mappign to remove the invalide characters , and the issue is resolved , as implenting the note 1004368 /1420744 may lead to performance issues .

regards

sandeep

Edited by: Vipin Singh on Feb 8, 2011 2:31 PM

Answers (4)

Answers (4)

RaghuVamseedhar
Active Contributor
0 Kudos

Hi Sandeep,

Can you paste here the the payload which is going to graphical mapping, make sure that it selected as "code <>".

Regards,

Raghu_Vamsee

former_member463616
Contributor
0 Kudos

Hi Sandeep,

Hopefully, the below link might be useful to you.

http://en.wikipedia.org/wiki/Byte-order_mark#UTF-8

Regards,

Rajesh

Former Member
0 Kudos

Hi Sandeep,

Ref:

Thanks,

baskar_gopalakrishnan2
Active Contributor
0 Kudos

What PI version do you use?

Check this link

Former Member
0 Kudos

hi baskar,

PI7.1

regards

sandeep