cancel
Showing results for 
Search instead for 
Did you mean: 

Validating a sender file using a JAVA UDF in PI message mapping

Former Member
0 Kudos

Hi,

I have a sender file with one header and multiple detail lines. I have been asked to read a tag on the header which contains the total number of detail lines.

I then loop round the detail lines counting the total number. If the total number of detail lines matches the total value in the header tag then XI can process the files otherwise the mapping should raise an exception.

Has anyone encountered this before and if so do you have an example of the Java code you used ?

Many thanks

Mark

Accepted Solutions (1)

Accepted Solutions (1)

aashish_sinha
Active Contributor
0 Kudos

Hi,

You can refer to this link for a similar kind of requirement but it is of inserting newline at the end of each line.

But you can customize the code for ur use.

Please refer https://www.sdn.sap.com/irj/sdn/wiki?path=/display/xi/howtoappendCarriageReturnintheendofeachtagofxml+file.

Now in this code you can use the logic something like this.

1. You must be knowing the header tag where your actual Total Count number resides. Put it in some variable, while looping over xmlString. Don't put anything in resultset until u come to actual line items.

2. Now start adding your counter. At the end of this loop you will have 2 variable. 1 contains the actual given total counts from header and other will contain calculated count.

3. Match it in if condition , if not matched do nothing no resultset append or may b you can send some exception or if matched send the actual XML.

Hope this will help you a bit.

Regards

Aashish Sinha

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Mark

You can use Count in message mapping as well for counting the tags. If you have hierarchical structure.

You can use count and compare.

Thanks

Gaurav

Former Member
0 Kudos

Thanks Aashish,

That was a useful reply. In the end I used and ABAP mapping for validation.

Regards,

Mark