473,804 Members | 3,156 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

** Problem to print node no using position() fucntion for selective records

1 New Member
Hi Friends,

I am working in SAP XI Platform. In this, we use XSLT Mapping.

I am facing one problem to print in field 'RecordID' starts from 1,2,3 in the target structure for those records received in the target side based on condition

I explain my problem clearly.

My source strucutre (with data) is like below.
--------------------------------
<?xml version="1.0" encoding="UTF-8"?>

<EDS_CAL_XML>
<EDS_PAY_CALEND A>
<CLIENT_ID>1</CLIENT_ID>
<COMPANY>214</COMPANY>
<PAYGROUP>WK2 </PAYGROUP>
<PAY_END_DT>0 5/27/2007</PAY_END_DT>
<PAY_BEGIN_DT>0 5/14/2007</PAY_BEGIN_DT>
<CHECK_DT>06/01/2007</CHECK_DT>
<PERIOD_WEEKS>2 </PERIOD_WEEKS>
<PAY_PERIOD>1 </PAY_PERIOD>
<PAY_PDS_PER_YE AR>26</PAY_PDS_PER_YEA R>
</EDS_PAY_CALENDA >
<EDS_PAY_CALEND A>
<CLIENT_ID>1</CLIENT_ID>
<COMPANY>284</COMPANY>
<PAYGROUP>WK2 </PAYGROUP>
<PAY_END_DT>0 6/03/2007</PAY_END_DT>
<PAY_BEGIN_DT>0 5/28/2007</PAY_BEGIN_DT>
<CHECK_DT>06/08/2007</CHECK_DT>
<PERIOD_WEEKS>1 </PERIOD_WEEKS>
<PAY_PERIOD>2 </PAY_PERIOD>
<PAY_PDS_PER_YE AR>52</PAY_PDS_PER_YEA R>
</EDS_PAY_CALENDA >
</EDS_CAL_XML>

My Target Structure is like below.
-----------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<ns0:PayPeriod_ KCRS xmlns:ns0="http ://ehro.eds.com/KCRS/PayPeriod">
<PayPeriod>
<Recordid>1</Recordid>
<Client_id>1</Client_id>
<Company_code>2 14</Company_code>
<Pay_group>WK 2</Pay_group>
<Payend_date> 05/27/2007</Payend_date>
<Paybegin_date> 05/14/2007</Paybegin_date>
<Check_date>0 6/01/2007</Check_date>
<Period_weeks>2 </Period_weeks>
<Pay_period>1 </Pay_period>
<Pay_periods_pe r_year>26</Pay_periods_per _year>
</PayPeriod>
</ns0:PayPeriod_K CRS>
------------------------------------------

Now, the requirement is, Source Structure may contain any number of records like 2 sample records above. We have to send only those records which are having COMPANY = 214 fields from source to target. Then, in the target side we should print record no in the Recordid field. It should be for the first record = 1, 2nd record = 2 like this.

I use for..each loop to filter records from source for the company code. But, to print recordid i use 'position()' function. When use this function, we get the actual position of the source record in this field.
For examle,
If source records look like below.

Record 1
<COMPANY>214</COMPANY>
Record 2
<COMPANY>284</COMPANY>
Record 3
<COMPANY>314</COMPANY>
Record 4
<COMPANY>214</COMPANY>

When we filter records for Company Code = 214, we will get in the target side Record 1 & 4. When we use position() function we get the output like below

Target Records:

Rec 1:
......
<RecordID> 1</RecordID>
.....
Rec 2:
....
<RecordID>4<Rec ordID>
......

But, we want the output like below. Because, only 2 records matched the condition and we get those records in the output

Rec 1:
......
<RecordID> 1</RecordID>
.....
Rec 2:
....
<RecordID>2<Rec ordID>
......

I tried many ways to achieve this (call-template, param, etc). But they didn't work.

Friends, Kindly help me to solve this problem.

Expecting your reply.

Thank you.
Jegathees P.
Jul 4 '07 #1
0 1137

Sign in to post your reply or Sign up for a free account.

Similar topics

10
5497
by: Fabio | last post by:
Hi everyone, Is there anybody who can suggest me a link where I can find information about 'Persistent linked list' ? I need to implement a linked list where every node is a structure like the following: struct Node { int integer_value;
2
3508
by: Hans-Michael Rupp | last post by:
Hallo! How can find out the postion of a node with a particular content in the nodeset WITHOUT being in the context? I would like have something like <xsl:variable name="position" select="position(/foo/bar)"> of course position() does not work this way. Is there another way to solve this?
1
3753
by: chris yoker | last post by:
hiya, I succesfully return a "nodeList" thru the "xmlDoc.SelectNodes" method. This nodeList is taken from a repetitive, uniform xml doc. I can successfully append a child node at the correct position using the following code: <code> <!--Node inserted into corrrect position in nodeList(0)-->
5
6167
by: reddy | last post by:
I am trying to insert a node into an XMLFile. using XMLTextwriter. My Question is Is it possible to do without using XMLDocument. Because its loading all the the file into memory. I just want to insert in the front. My code is give below. Is it possible to do without using XMLDOcument? Dim masterDoc As String = Request.PhysicalApplicationPath & "PageViews.xml" Dim writer As XmlTextWriter = Nothing
6
1887
by: Eddy C | last post by:
Hi, I'm trying to get the value of another node using the position of another node or the name of the tag. Such that the current node is one of the contacts child nodes sec or prim and doing <xsl:value-of select="//cust/name"/>
4
3039
by: Alfred Taylor | last post by:
I essentially need a countif() function for xsl. Something to where I could do countif(node-set, condition). Rather than try to get too extreme, i decided to just write one for my countif() with the condition hardcoded. (this was also my first venture into creating "functions") Pseudo-code is essentially this: Look at the current node and check the condition. If the condition is true, call our function again with an incremented...
4
11609
by: Phill | last post by:
Here's what I'm doing to make the right context mnue show up based on what node was cliked: private void tvwMenu_MouseUp(object sender, MouseEventArgs e) { //Select Node When Right Clicked & Set Context Menu To Use if( e.Button == MouseButtons.Right ) { TreeNode node = tvwMenu.GetNodeAt( new Point( e.X, e.Y ) ); if( node != null )
22
8050
by: joshc | last post by:
In an interview for an embedded software position recently I was asked to write code, in C, for printing the contents of a linked list backwards. After a few minutes I came up with the recursive solution. Being that recursion is frowned upon in embedded software, the answer was not what the interviewer expected, but alas it was correct. I asked some friends how they would have answered and another answer is to reverse the list and then...
2
2664
by: slizorn | last post by:
hi guys, i need to make a tree traversal algorithm that would help me search the tree.. creating a method to search a tree to find the position of node and to return its pointer value basically i need to read in a text file... shown below H H,E,L E,B,F B,A,C A,null,null
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10575
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9144
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4297
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3816
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.