cancel
Showing results for 
Search instead for 
Did you mean: 

Java Mapping

Former Member
0 Kudos

Dear All

I have to implement a scenario using Java Mapping SAX parsing.

The need is such that I have to skip a few records from the incoming file based on the content.

Say if content of a particular field in a record is "PES" I should not map the entire record and should move to process the next record.

When I am trying to skip a record I am getting an error

"XML document structure must start and end within the same entity"

Please let me know how to implement it.

Sourabh

Accepted Solutions (1)

Accepted Solutions (1)

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi ,

I think we can achieve this requirement using Graphical Mapping,you can check the condition at mapping level to check the value of field.

If you want to implement using JAVA Mapping,then you need to familiar with SAP Parcers steps.Pate the code what you have written.

Regards,

Raj

Former Member
0 Kudos

Hi

My source structure is

<root>

<IsValid>Y</IsValid>

<Data><Header>"A000",123,"AR"</Header>

<Body>

"N68",PSE,2102175432

"N68","MAM",2102175431

"N68","MAM",2102175430</Body>

<Footer>sadf,sadf</Footer>

</Data>

</root>

</ns0:FileIn_MT>

Here records are in Body tag. If in any record we find "PSE" then we should skip that record and process the next one to be mapped to the following record structure.

<HeaderName> </HeaderName>

<HeaderField></HeaderField>

<HeaderNumber></HeaderNumber>

<CustomerName></CustomerName>

<CustomerNo></CustomerNo>

<MeterNo></MeterNo>

<FooterName><FooterName>

<FooterNo></FooterNo>

</ns0:FileIn_MT>

I am using following code in Java Mapping

if(!(CustomerNo.equals("PSE")))

{

write("<CustomerName>"CustomerName"</CustomerName>");

write(lineEnd);

write("<CustomerNo>"CustomerNo"</CustomerNo>");

write(lineEnd);

write("<MeterNo>"MeterNo"</MeterNo>");

write(lineEnd);

}

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi,

The code you have written is not correct i gues,you need to write the whole XML document in to Output stream.

Regards,

Raj

Former Member
0 Kudos

Hi

The code that I have pasted here is for Body tag only, the processing of rest of the xml structure is also written and working fine if I remove the "if" condition from the code.

Please let me know if SAX parser allows us to skip records during mapping

Sourabh

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi,

SAP parcer will allow to skip records,but i never tried,try regex.

Regards,

Raj

Former Member
0 Kudos

Hi,

Could you post the whole code, cuz I do not see how you handle SAX events in your mapping ... Btw, if your input doc is not too big, why not going for DOM, it makes things easier when it comes to selections (xpaths) etc

Rgds

Chris

Former Member
0 Kudos

hi

Please verify the content when you get the datastring of the body tag.

If you find the content ignore parsing.

This will allow you to skip the records you want.

Madhav

Answers (0)