cancel
Showing results for 
Search instead for 
Did you mean: 

Handling junk characters in XI

Former Member
0 Kudos

Hello,

I have developed a Inbound File-XI-SAP scenario .Where i have mapping failure in XI .I did my analysis and found that Business is sending us a file alogn with extra empty line as shown below

---> file should be limited to end of this line --> ";,99100;,99100;241;172;41;"9788761920041 ";

-


> this is extra line which i believe is new line character .This is causing my mapping to fail -->

So my question is how do we handle as i tried to write a batch program to handle this but in unix this BOX character as shown above is not there and file when read in unix is perfect.

Other way i tried is to open in different encoding but this is still showing up there .

So can we deal this using within XI ? If yes , plesae let me know .

Thanks for all help .

Accepted Solutions (0)

Answers (2)

Answers (2)

Shabarish_Nair
Active Contributor
0 Kudos

well one suggestion i can give is to write a simple adapter module that will avoid the last line.

the logic can be to substring(0,lastindexOf(";") = this will contain the whole file content from the start to the last delimiter,

Former Member
0 Kudos

Hi,

you can try to handle this inside a CData element within your mapping. Within this XI will not change or try to parse the data. It's handled as "normal" string.

Not quite sure this solves the problem...

Regards,

Kai

Former Member
0 Kudos

You can have java mapping program to get rid of the junk characters:

You can refer the following sample code to achive it:


public class FixEncoding implements StreamTransformation {

public void execute(InputStream in, OutputStream out) 
throws StreamTransformationException {

String instr;
instr = parseIStreamToString(in);

instr = instr.replace( '&', '&' ); 

out.write(instr.getBytes());
}

then in your interface mapping, put the jave mapping in front of normal mapping program.

Regards.

Liang

Edited by: Liang Ji on Mar 12, 2009 4:36 PM

Former Member
0 Kudos

Hi Liang,

I am planning to replace by passing with ASCII codes for the sysmbol i see in my text file .Let me update you with the results i get .

Thankyou all for your replies .

Former Member
0 Kudos

Hi, Forget the function code for you:


public String parseIStreamToString(InputStream is) {
BufferedReader din = new BufferedReader(new InputStreamReader(is));
StringBuffer sb = new StringBuffer();
try {
String line = null;
while ((line = din.readLine()) != null) {
sb.append(line + "\n");
}
} catch (Exception ex) {
ex.getMessage();
} finally {
try {
is.close();
} catch (Exception ex) {
}
}
return sb.toString();
}

Liang

former_member206760
Active Contributor
0 Kudos

dear sitaram,

did using ascii chars help

Former Member
0 Kudos

Hi Liang,

Here is lastest with my interface .Since its an inbound and junk character causing mapping to fail .The required fields on target message type in row where junk character was appering were not being present .This mainly causes our mapping to fail .So i have removed all mandatory fields on target side and let the junk character flow into SAP for my inbound posting.I handled this junk character with ABAP code .All mandatory field validations were done inside SAP .So this proved to be easier as i am comfortable with ABAP rather than Java .So i believe its matter of choice when it comes to Mapping programs .

Thanks Liang ...and all other providing help.

Sitaraman