cancel
Showing results for 
Search instead for 
Did you mean: 

Xpath-String Function for Interface determination

Former Member
0 Kudos

Hi All,

My requirement is to find the number of records in the field CSVData and compare it with value in the field 'RecordCount'.We want to use xpath functions in Interface determination to do the same.

The source structure is as follows:

MT_Segment           
-Records	  	
--Record	  	
---AddressDetails  
----HouseAddressDetails
-------CSVData
-------RecordCount

The entire data is coming in the field 'CSVData' which will contain multiple records separated by new line.

eg:CSVData contains:

abc,1,2,3

xyz,11,22,33

Tried with:

(/p1:MT_Segment/[count(tokenize(Records/Record/AddressDetails/HouseAddressDetails/CSVData,"\n"))=

(Records/Record/AddressDetails/HouseAddressDetails/RecordCount)]EX)

This is not working.

It is confirmed that string functions work as I've tried string-length.

Problems could be either:

1.The syntax is incorrect

2.Combination of string functions cannot be used

3.tokenize and count connot be used in PI.We tried some other combinations like count(Index-of(CSVData)).It didn't work.

4.Any other ?

Already referred the below blog and few other threads on sdn

/people/shabarish.vijayakumar/blog/2006/06/07/customise-your-xpath-expressions-in-receiver-determination

Can this requirement be achieved with Xpath functions?If yes, please help with the syntax for it.

That will be real help!

Thanks,

Manjusha.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Couple of thoughts...

AFAIK, tokenize() function is an XPATH extension available in XSLT..

1. Check which version of XML toolkit PI is using.. SAP XML toolkit/JDK 5 XML toolkit? also check XSLT 2.0 version is supported?

See the links given below for more info..

[SAP Help - Replacement of SAP XML Toolkit by JDK 5|http://help.sap.com/saphelp_nwpi71/helpdata/EN/73/f61eea1741453eb8f794e150067930/frameset.htm]

[SAP Help - Enhancement mechanism of the XSL transformation|http://help.sap.com/saphelp_nwpi71/helpdata/EN/55/7ef3003fc411d6b1f700508b5d5211/frameset.htm]

2. You can try a workaround: Check the counts in mapping and based on the outcome either generate target XML or raise an User defined exception to stop the message flow.

Thanks & Regards,

Ananth

Former Member
0 Kudos

Hi,

One solution could be using the BPM as a service.

You need to create 2 Receiver Determinations. The first RD will be between Source System & BPM as target System.

The design will require additional message interface & interface mapping for BPM.

Basically there will be 2 inteface mappings & 2 Receiver Determination and rest of the objects accordingly.

So in BPM just use receive & send step and send the same data with CSVData count after mapping to XI.... and then do your second Receiver Determination by using BPM as source service and use your X-path conditions here..

If you need further info or steps just let me know.

Regards,

Sarvesh

stefan_grube
Active Contributor
0 Kudos

Have you tested the XPATH with an external program?

http://www.w3schools.com/xpath/xpath_functions.asp#string

> fn:tokenize(string,pattern)

> Example: tokenize("XPath is fun", "\s+")

> Result: ("XPath", "is", "fun")

maybe "\n" does not work as desired?

Shabarish_Nair
Active Contributor
0 Kudos

I suggest avoiding xpath determination in this case.

its better to design your scenario using other alternatives.

former_member187339
Active Contributor
0 Kudos

Hi Manjusha,

You are reading a csv file and converting it to this structure?

MT_Segment

-Records

--Record

---AddressDetails

-


HouseAddressDetails

-


CSVData

-


RecordCount

Can you check the payload of the inbound message and see whether you received the required structure . If possible paste teh same here for a better understanding

Regards

Suraj

Former Member
0 Kudos

Thanks for the response.

@Suraj

Not reading a CSV File.It is a HTTP sender.

Sample Payload:

<?xml version="1.0"?>

<MT_Segment xmlns:ns1="http://abc.com">

<Records>

<Record>

<AddressDetails>

<HouseAddressDetails>

<RecordCount>1</RecordCount>

<CSVData>1,2,3

11,22,33

</CSVData>

</HouseAddressDetails>

</HouseAddressDetails>

</Record>

</Records>

</MT_Segment>

@Shabarish

Why do you think we should avoid Xpath functions here?

santhosh_kumarv
Active Contributor
0 Kudos

Hi Manjusha,

Count function should be passed with nodename as input, how ever in your case the single string is been split @ newline and passed as an input, thus it will not help you...

To my understanding Count returns no. of time a node occurs accepting a nodename or a path and not how may string are there in a array of string.

if you can repeat node <CSVData> for every new line and then use the fn:count like below

count(Records/Record/AddressDetails/HouseAddressDetails/CSVData) will return the count of the node CSVData and you can compare this with RecordCount value..

~SaNv...