on 10-07-2009 1:52 AM
All,
I have this requirement:
hi experts,
I have a question in mapping,
Can some1 help me pls:
Scenario: Input to UDF will be 2 Queues Q1 and Q2,
Q1 to hold true/false value
Q2 to hold actual values that need to be passed to target.
1. output should be produced from Q2 depending on the condition @ Q1 as described in the sample below:
q1 | q2 | OUTPUT
________________________________
1 True |JFK |JFK
2 True |Intrnl |Intrnl
3 True |Airport |Airport Drive
4 False |Drive |NY 98787 country
5 True |NY |blablabla
6 False |98787 |
7 False |country |
8 True |blablabla |
Basically look @ Q1 if we have a true followed by a true then put values of Q2 in a separate line in OUTPUT.
If True is followed by 1/more number of False then the values corresponding to that in Q2 should all be concatenated.
Please help me out guys,
I have actually begun coding the UDF but nt able to debug this correctly and facing issues.
Thanks,
Hank
U mentioned how it behaves if true followed by false... fine....
but,
Can u please mention how the concatination will occur if
false followed by false
and
false followed by true.
So then some one can give u the code.. corresepondingly..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I did not understand your requirement clearly.
Will you explain this more clearly
Basically look @ Q1 if we have a true followed by a true then put values of Q2 in a separate line in OUTPUT.
If True is followed by 1/more number of False then the values corresponding to that in Q2 should all be concatenated.
.how does the values are getting populated in OUTPUT
q1 | q2 | OUTPUT
________________________________
1 True |JFK |JFK
2 True |Intrnl |Intrnl
3 True |Airport |Airport Drive
4 False |Drive |NY 98787 country
5 True |NY |blablabla
6 False |98787 |
7 False |country |
8 True |blablabla |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thnk u guys let me put it more clearly:
1. we need to scan values in Q1 2 at a time with this condition,
if Q1<i>==True and Q1[NEXT]==True then in it means that the value in Q2<i> is actually a comment independant hence put Q2<i> in output.
now increment i, and keep repeating the same logic
if a True is Followed by a False ....this is how we need to intepret,
the point where the true started is the START of a comment , the the point until where we keep seeing the LAST false indicates that it is the end of that SINGLE comment and hence needs to be CONCATenated.
like this eg:
String[] q1={"True","True","False","False,"True","True","False"};
String[] q2={"SAP ","PI","7",".0","Is","a powerfull ","tool"};
Note : q1 and q2 will alwys have same # of values
then the output from the UDF should look as follows:[Have a look @ PI 7.0 they wer concatenated from 3 values PI, 7, .0 depending on a T, F, F condition
SAP
ContextChange
PI 7.0
ContextChange
Is
ContextChange
a powerfull tool
Hope ths is clear, thnk u very much guys,
Really appreciate your feeds and help
Hi
Check this udf
int i;
String output = "" ;
for ( i=0;i<q1.length;i++) {
if (q1<i>.equalsIgnoreCase("true")) {
if (q1[i+1].equalsIgnoreCase("true"))
output += q2<i>;
else if (q1[i+1].equalsIgnoreCase("false")){
int j;
output += q2<i>;
for (j=i+1;j<q2.length;j++) {
if (q1[j].equalsIgnoreCase("false"))
output += q2[j];
else
break;
}
i=j;
}
}
}
i--;
if (q1<i>.equalsIgnoreCase("true"))
output += q2<i>;
result.addValue(output);
Regards
Suraj
Thnk u Suraj,
i tried your code,
it concats the entire q2 values to 1 output value which is not what i intended.
1. If q1<i>="T"&&q1[i+1]=="True" then put value of q2<i> into result and put a context change meaning its an independant comment.
2. now v proceed to the next value in q1, chck the same condition, if v find a T, F...F all the comments beginning falling @ the corresponding position in q2 should b concatenated as 1 comment and put in the result.
then it shoud b follwed by a Context change.
In your code you mentioned: if (q1[i+1].equalsIgnoreCase("true"))
but imagine i is equal to q1.length @ a given instant....then i+1 will error out as an out of array index xception.
Can you look into this/
thanks
Hank
Q1 to hold true/false value
Q2 to hold actual values that need to be passed to target.
1. output should be produced from Q2 depending on the condition @ Q1 as described in the sample below:
Your UDF will have many if statements:
if (q1 = True & q2 = JFK)
{return q2;}
if (q1 = True & q2 = Intrnl)
{return q2;}
And so on for each of your 8 conditions......in the last three conditions are you not passing any value to output?
The UDFsample shown above is just for your understanding.....it will need formatting.
Regards,
Abhishek.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.