cancel
Showing results for 
Search instead for 
Did you mean: 

***UDF not working

Former Member
0 Kudos

Hi all,

My requirement is ,if if the ownership = "", 0, or "O" then don't send else send the original value.

Source value Target

Suppose ownership is 0----


Blank

O----


Blank

-


Blank

Test----


Test

If I pass any other value other than O ,0,"",it should be populated.

For this I wrote a UDF as below.

if ( ! ( inValue[ 0 ].equals("") || inValue[0].equals("O") || inValue[0].equals("0") ) )

{

result.addValue(inValue[0]);

}

else

{

result.addValue("");

}

When I Test this in Test tab ,it is working fine But it is Populating even O ,0 in the database table.

Source Target

this is if I pass O -


>O

0----


>0

This should not happen.

Can any one help me out in this regard.

Thanks,

Srinivasa

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can have a graphical mapping like this. It worked for me .

SourceField
               --- equalsS
Constant[0]  
                           -----    OR                                 
SourceField
               --- equalsS   
Constant[ ]                                  ------OR ------------IF       
                                                                       Constant[ ]-----THEN
                      SourceField                                   SourceField------ELSE
                                     --- equalsS   
                      Constant[O]                                   MAP IT TO THE Target field

Regards,

Laawanya

Answers (4)

Answers (4)

former_member200962
Active Contributor
0 Kudos

Hi,

Instead of UDF apply this logic in your graphical mapping:

If Source = " " OR Source = 0 OR Source = O then map the corresponding target element with a blank constant....else directly pass the value....for this you will need to use 4 constant blocks, 3 EqualS blocks, 2 OR blocks, 1 If-Else block..

Regards,

Abhishek.

SudhirT
Active Contributor
0 Kudos

Hi Pothraju,

Your UDF should work perfectly. Which table it is populating? What is your scenario?

Is this giving outputs "O", "0","" in test tab also?

Thanks!

Former Member
0 Kudos

No under test tab,If I pass O -


Blank

0-------Blank

""----


"".

Where as in the database it is

O -


O

0-----0

"----"

SudhirT
Active Contributor
0 Kudos

Check again if some spaces are also coming with the input file like " O","0 " or " " .If this is the case use trim function before passing the source field value to UDF.

SourceField-----trim---UDF----Target.

Thanks!

Former Member
0 Kudos

yes checked it ,no spaces in between.

SudhirT
Active Contributor
0 Kudos

Just give it a try and run your end to end scenario. whether the table populates again with these values?

Former Member
0 Kudos

try out using exist() function

Former Member
0 Kudos

Hi Srinivasa

Instead of UDF u can use fixValue function along with IF function. You can orchestrate it in such a manner that it pass null for one condition & actual value for other.

Regards

Raj

Former Member
0 Kudos

I did not use this function before.

Can you brief me how to use this in my case.

Former Member
0 Kudos

FixValue creates a local table to perform value mapping.

In this function u can specify ur value ( "", 0 & "O" ). It will give true for these value & false for rest.

So now u can use If function such that it will pass null for true & actual value for else part.

regards

Raj

Former Member
0 Kudos

I am using graphical mapping as below.

Ws(fileld name) same for both source and target.

ws- equals(test function)---

OR

Constant O----


equals(test function)---

OR

Constant 0----


equals(test function)---

OR

Constant ""----


ie if equals=0 or O or" " then poplulate constant []

esle populate WS

error

Cannot insert null in to ws.

then I tried this way:

e if equals=0 or O or" " then poplulate constant ['']

esle populate WS

now error.

Error while parsing or executing XML-SQL document: Error processing request in sax parser: Error when executing statement for table/stored proc. 'SAP_LOC' (structure 'StatementName2'): java.sql.SQLException: ORA-01401: inserted value too large for column .

Former Member
0 Kudos

From ur graphical mapping

give a space to the constant when your if condition gets satisfied i.e to pass space..

kindly check ur hotmail its workin fine

Edited by: ROBIN C on Dec 18, 2008 12:38 PM

Edited by: ROBIN C on Dec 18, 2008 12:50 PM

0 Kudos

What is the output XML in the moni showing.

I think it will show the results as in your test tab.

Check the type of the field in the database and the default value of the field in the database.

Regards,

Krishnaraju