cancel
Showing results for 
Search instead for 
Did you mean: 

Udf to delete records

silentbull
Participant
0 Kudos

Hi

I have an xml file with 10 records. The structure has Record with header and five elements in that.

The first 4 records are of header information and want to delete or ignore from the mapping.

I can think of doing this in premapping before actual mapping as it is too complicated to do in original mapping.

Any udf or idea please?

Example structure where the first few records always comes with header information.

- <Record>

  <Delivery>LIKP-VBELN</Delivery>

  <Container>Z</Container>

  <ProductNo>LIPS-MATN</ProductNo>

  <HUNumberC>V51VE-EXIDV</HUNumberC>

  <HUNumberV />

  <Batch>LTAP-CHARG</Batch>

  </Record>

Regards

Sam

Accepted Solutions (1)

Accepted Solutions (1)

former_member182412
Active Contributor
0 Kudos

Hi Sam,

You can use below UDF.

Execution Type : All Values Of Context


public void ignoreFirstRows(String[] input, ResultList result, Container container) throws StreamTransformationException {

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

  if (i < 4)

  result.addSuppress();

  else

  result.addValue(input[i]);

  }

  }

Regards,

Praveen.

silentbull
Participant
0 Kudos

Hello Praveen

Do you want me to add this in the premapping connection source Record to Target Record with this udf.

Regards

Sam

AlexanderApel
Participant
0 Kudos

Hi Sam,

you can use funktion substring as well.

Regards,

Alex

former_member182412
Active Contributor
0 Kudos

Hi Sam,

You can do it in the main mapping, map this in the root node level.

Regards,

Praveen.

Answers (1)

Answers (1)

juan_vasquez2
Active Participant
0 Kudos

Hello Sam

You can use If without else

like this

Then only create rows that acomplish the condition

Remember to move the context of condition filed one level up, to avoid context change issue in the mapping.

See the image, and queues.