cancel
Showing results for 
Search instead for 
Did you mean: 

Counting the number of detail records at target side...

Former Member
0 Kudos

Hi

I have a requirement where i need to caluclate the number of detail records formed and add it in trailer section...both at target side...

The output will look like this :

<Detail>

<Field></Field>

</Detail>

<Detail>

<Field></Field>

</Detail>

<Detail>

<Field></Field>

</Detail>

<Trailer>

<Count> 3 </Count>

</Trailer>

Basically, In trailer the Count field will contain the number of Detail records.

Can this be achived by a UDF?? Please help!!!

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Actually teh detail node formation at target depends on a lot of nodes of source side...using Count I have already done it but due to lot of nodes @ source side it becomes kind of a mesh...

Hence I was trying to figure out a way in which if I can count the number of detail nodes at target side I can remove the present mapping...

Corect me if I am wrong but can't we declare this target detail node as global variable and then use 'Count' function to capture its occurence???

P.S : In XI 3.0 we used to have a tab to declare global variables but here in 7.1 we have Functions tab...could anybody tell me how to declare the variable in 7.1?

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi ,

Target details segment occurance depend on a lot of nodes in the source means , first try to identifu the key element in source.

based on that you can count it.

if there is no key element,then use global variable, Global Variable option definelty work it out.

cheers,

Raj

former_member200962
Active Contributor
0 Kudos

Check this blog if you are confused on declaring a grapgical variable in PI7.1:

/people/william.li/blog/2008/02/13/sap-pi-71-mapping-enhancements-series-using-graphical-variable

You can search with keywords "Global Variable" in SDN and you will have the ways to declare it in PI7.1

Regards,

Abhishek.

former_member187339
Active Contributor
0 Kudos

Hi Soumen,

>>Corect me if I am wrong but can't we declare this target detail node as global variable and then use 'Count' function to capture its occurence???

No you can't do that.

I would suggest you to go for one more mapping from target to target MT so that you can count the Details node and put it in trailer. That will be much simpler

Regards

Suraj

Former Member
0 Kudos

Hi Suraj..

Your suggestion makes sense...will do it if ultimately nothing else works out.

Still would try out the global variable way.

Former Member
0 Kudos

Hi,

This is very much possible with global container. You just set a global variable at the Root node.

And at node <Detail> you get this global container and increment it by 1. hence whenever this Detailed node is created it will be incremented by one. At the end for <Trailer> node get this global container value. This will give you the total number of <Detail> node. You need to write UDF to set and get the global container veriable.

Shweta

Former Member
0 Kudos

hi,

There is no need of UDF..

Using the count function will suffice..

Cheers,

Divya

former_member200962
Active Contributor
0 Kudos

The Detail node seems to be on the target side....so you cannot apply any logic on it.

I suppose you have some node on the source side and depending on the occurence of this node your target Detail node is created.

So check for the occurence of this source node....it will be same as that of the Details node....make a count on this source node and map this count to the Count node.

Regards,

Abhishek.

VijayKonam
Active Contributor
0 Kudos

If you can know how many details nodes are being generated while you are at the source message itself, it is possible. You can use counter in between the mapping u use for creating the details node on the right hand side.

VJ

Former Member
0 Kudos

Hi Das,

Use count function.

Detail(change the context to root node) --> count --> trailercount

Regards,

---Satish