By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,078 Members | 2,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,078 IT Pros & Developers. It's quick & easy.

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

P: 1
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_CALENDA>
<CLIENT_ID>1</CLIENT_ID>
<COMPANY>214</COMPANY>
<PAYGROUP>WK2</PAYGROUP>
<PAY_END_DT>05/27/2007</PAY_END_DT>
<PAY_BEGIN_DT>05/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_YEAR>26</PAY_PDS_PER_YEAR>
</EDS_PAY_CALENDA>
<EDS_PAY_CALENDA>
<CLIENT_ID>1</CLIENT_ID>
<COMPANY>284</COMPANY>
<PAYGROUP>WK2</PAYGROUP>
<PAY_END_DT>06/03/2007</PAY_END_DT>
<PAY_BEGIN_DT>05/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_YEAR>52</PAY_PDS_PER_YEAR>
</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>214</Company_code>
<Pay_group>WK2</Pay_group>
<Payend_date>05/27/2007</Payend_date>
<Paybegin_date>05/14/2007</Paybegin_date>
<Check_date>06/01/2007</Check_date>
<Period_weeks>2</Period_weeks>
<Pay_period>1</Pay_period>
<Pay_periods_per_year>26</Pay_periods_per_year>
</PayPeriod>
</ns0:PayPeriod_KCRS>
------------------------------------------

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<RecordID>
......

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<RecordID>
......

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
Share this question for a faster answer!
Share on Google+

Post your reply

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