on 08-23-2015 11:48 AM
Hi all.
Am doubting how to build the logic for the mapping of a string function when it is null .
In my scenario what is happening is we are getting field name as usrid in the which i have pass first character of usrid and pass to target field .
And when it is empty it has to pull the first char of usrid _long and when it is null it should pass null.
So for that i have written a code as below .
But what is happening here is when am passing it to target field values are been suppress, I think it is due context handling , but both fields are from same segment E1P0105 .
please help me out in these !!!
Best regards,
vijender
Hi Vijender,
If you add mapWithDefault for the two fields (USRID and USRID_LONG) just before you pass it into your UDF, your mapping should work.
Regards,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mark ,
Please find the attachment as below and in the which am getting error .
And both the fields are from same segment i.e. E1P0105 and when am handling with map with default it is throwing this error and with out the map with default means values are been suppressed for this two fields .
Best regards,
vijender
Hi Vijender,
Pls share Input Q for both Source fields.
I Suggest you to break the code in steps and test with simple / few records in Input
1. First check with 2-3 values of USRID present
2. USRID and UDRID_LONG present
3. One of USRID is absent
so on..
So you will come to know in which case this is failing and you can correct the code accordingly
Regards,
Azhar
Okay - Suppress comes in - suppress goes out... but the udf is looking fine.
Can you show us the output of your trace when when testing the message?
What is the target field? Is this a variable?
Another thing you can try: add "mapWithDefault" before the udf. At least, that would make sure, that your udf always get a value.
Hi Vijender,
Please find below the sample test case which I have done with the above mentioned code:
validate udf code:
String result="";
if(USRID.length()>=1)
result=USRID.substring(0,1);
else if(USRID_LONG.length()>=1)
result=USRID_LONG.substring(0,1);
return result;
Can you check from your end and let me know the screenshots of the issue if you still facing any
Hi Vijender,
code snippet is looking good. Can you please let me know the screenshot of the display queue values of the inputs that you are trying to pass this udf.
Also, are you using any other graphical functions besides this udf, in the population logic of the target field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vijender,
your udf looks fine on a quick view. Can't tell why it's not working.
But have you considered to use standard functions instead?
It will be a bit complex-looking, but actually do the same.
I think, it should be solvable with IF, EQUALSS, ISNIL, NOT and SUBSTRING:
Just try this (hope this is understandable):
USERID-------->EQUALSS("")->NOT-->
-------->ISNIL------->NOT-->AND--->IF --->targetfield
--------------->SUBSTRING(0,1)---->then
USERID_LONG---------->SUBSTRING(0,1)---->else
In case USERID_LONG can also be initial, you got to add the IF and comparission there as well.
Hope this helps,
Heiko
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
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.