cancel
Showing results for 
Search instead for 
Did you mean: 

UDF for Checking the field value

Former Member
0 Kudos

Hi

I want to check the whether the fiels conatins any value or not in mapping ... if not i want to raise the exception using the UDF

DO any one have sample code for writing the UDF

SV

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

String input

int a;

if(input.length<0)

{

a=hello;

}

here string input is the input parameter for the udf i.e the field value.

if the input lenght is less then zero i.e no value for the field we are assigning string hello

to an integer which will throw an exception.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi

i used the UDF

int b = a.length;

if (b == 0)

throw new RuntimeException("Record is Empty");

else

result.addValue (a[0]);

when i tested the mapping in from test tab with out passing any value ...its not throwing any exception

Any idea

SV

Former Member
0 Kudos

Hi Sv

refer the below link:

/people/alessandro.guarneri/blog/2006/01/26/throwing-smart-exceptions-in-xi-graphical-mapping

/people/michal.krawczyk2/blog/2007/04/26/xipi-throwing-generic-exceptions-from-any-type-of-mapping

this will give u some hint.

chirag

Former Member
0 Kudos

Hi SV

what is your requirement first that should br clear.

i am giving you two UDF

1) i have written this uDF for string and comparing the field value XYZ

2) i am entering a string and its returning aa string which starts from the index of your input fixed length

int len = a.length();

String res = "";

String temp = "";

if ( len >= 10)

{

temp = a.substring(0,10);

}

if ( temp.equals("XYZ"))

{

res = temp;

}

else

{

res = "";

}

return res;

=======================================

String fixed = "ABCD";

String res = "";

int index = -1;

index = a.indexOf(fixed);

if (index == -1)

{

res = "NO INDEX FOUND";// or if u wanna set it as null res = "";

}

else

{

res = b.substring(index4,index12);

}

return res;

===

hope these may solve your problem

Thanks

Sandeep sharma

If helpful reward points

Former Member
0 Kudos

Hi,

The following blog is what you are looking for:

[https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/3069] [original link is broken];

just change the ThrowException udf in the blog like:

public void ThrowException(String[] inputfield,ResultList result,Conatiner container){
       if(inputfield.length==0) 
               ExceptionThrower.fire("Filed doesn't contain any value");
       else  
               result.addValue(inputfield[0]);
}

*Reward points if helpful...

--Sankar Choudhury