cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Query : Can I get the Number Occurance of a segment

Former Member
0 Kudos

Can I get the Number Occurance of a segment

Source MSG

-


Tree Occurence

**File_Message (1..1)

.....Name (1..1)

.....Sal (1..1)

.....**Details (1..Unbound)

.........MailID (1..1)

.........MobileNO (1..1)

Target MSG

**CountDetails (1..1)

.....Count (1..1)

In Target MSG, I want the number of occurance of the FileDeatils-->Details

if source file is like follow

<?xml version="1.0" encoding="UTF-8"?>

<ns0:File_Message xmlns:ns0="urn:test:ns:ns">

<Nam>John</Nam>

<Sal>2342</Sal>

<Details>

<MailID>John@ABB.com</MailID>

<TelNo>345345345</TelNo>

</Details>

<Details>

<MailID>John1@ABB.com</MailID>

<TelNo>888888888</TelNo>

</Details>

</ns0:File_Message>

I need to get the taget Message as follow

<?xml version="1.0" encoding="UTF-8"?>

<ns0:CountDetails xmlns:ns0="urn:test:ns:ns">

<Count>2</Count>

</ns0:CountDetails>

in Count Tag I should get the number of occurance of Details Tag in source MSG

Can any one help regard this

Thanks is advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Write one advanced user defined function which takes DETAILS as the input.

Code:

for (int i=0, i<a.lenght;i++)

{

result.addValue("");

}

Map the output of this user defined function to COUNT(Node Function).

You will get the number of occurances.

Thanks

Mohan

Former Member
0 Kudos

Thank U Mohan

U have solved my porblem.

I am Using following Pogram It is returning the Number of Occurance.

//write your code here

int i=0;

for (i=0;i<a.length;i++);

result.addValue(String.valueOf(i));

Thanks Once agin

Dhanabal T

Former Member
0 Kudos

Dhana,

Can you just try it out?

DETAILS -> COUNT -> TARGET

Not sure but,

If it works your solution will be too simpler.

Thanks

Mohan

Former Member
0 Kudos

Hai Mohan,

My Real Problem is

I am Using the Scenario File--> XI --IDoc (Using BPM)

File is having the following value

Header Details (one Occurance)

PO(1..Unbound)

for Example that file having 2 PO (Purchase Order) Then I have to split that file in to two files..

and I have to pass that two files to Post Idoc(0rders02) for create sal Order.

That file may have more than one PO

Please give Ur Suggest me on this

Thanks in advance

Dhanabal T

Former Member
0 Kudos

Dhana,

you do not require BPM for this case.

Can you just follow this blog

/people/michal.krawczyk2/blog/2005/12/04/xi-idoc-bundling--the-trick-with-the-occurance-change

if it does not solve your problem then give me your mail id.

I will send the proper document.

Thanks

Mohan

Former Member
0 Kudos

Dear Mohan,

thanks for Ur Reply,

That web log is not opening the Proper Page. I have found he way to split many PO in single..single PO and post to IDOC.

<b>danabwithinu@yahoo.co.in</b>

is my ID for Chat and mail contact. I realy avaiting for Ur mails..

Thanks

Dhanabal T

Answers (1)

Answers (1)

Shabarish_Nair
Active Contributor
0 Kudos

Chk out standard functions in mapping -> Statistic

and assign the count function [input Details node and output target node count]( Returns = Number of fields in a context and do try changing the context to root level ).

if this doesnt work we can write a user defined function

where pass input node details (details node is a)

and use

return a.length;

Former Member
0 Kudos

Thanks Shabarish Vijaykumar,

Yes I have Used the in Statisits->Count

Is doing the Same thing .. Thank U

Regards

Dhanabal