cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping - UDF

Former Member
0 Kudos

Hi,

Case:

Input Field Value: " 12345-"

Output Value: " - "

if the last character value " -", need to map with "-" and for any value need to map with "+".

I have used "endsWith" function and if condition...its giving some Runtime Exception like "cannot cast decimal value"

Can anybody help me for the same.

-Stallin

Accepted Solutions (1)

Accepted Solutions (1)

former_member200962
Active Contributor
0 Kudos

Input-->endswith(Constant(-)) --> ifWithElse (Constant(-) --> Then; Constant(+) --> Else) --> target

the above is working for me.

Former Member
0 Kudos

@ Abhishek

I have tried the same and executed the same at mapping by using display queue..its working fine there...

but if I executed the same at end to end mapping ( or test tab mapping )...its giving run time exception...can not cast decimal;

-E

former_member200962
Active Contributor
0 Kudos
or test tab mapping

i used source and target fields as decimals (and even string)....the mapping gets executed successfully for me.

You can use the UDF...but i still feel that it should have been done with standard functions.

can you try with " 12345678+" as a input value...its throwing an runtime exception for me.

yes i used something similar....123456- and 123465+

Edited by: abhishek salvi on Jan 17, 2011 12:40 PM

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

How to pick the message based on the field names in the recordset for file 2 file adapter.

Regards,

Chakrapani

Former Member
0 Kudos

Its is not giving any kind of runtime exception FOR ME .

execution is also successful.

Please paste the error for the clear understading

Edited by: vippab on Jan 17, 2011 8:03 AM

Former Member
0 Kudos

@vippab

can you try with " 12345678+" as a input value...its throwing an runtime exception for me.

Former Member
0 Kudos

Hi,

Paste the error you received in the test tab.

Regards,

Pranav

Former Member
0 Kudos

@ Abhishek / Ram

I have used the input value as " 1" ( 13 spaces prefix with 1) and used the same logic you mentioned, getting the same runtime exception'

"Runtime exception when processing target-field mapping /ns0:MT_RDNReceiver/RECORD/ITEM/XCPT_QTY; root message: Exception:[com.sap.aii.mappingtool.tf7.FunctionException: Cannot cast '1' to decimal number] in class com.sap.aii.mappingtool.flib7.Arithm method formatNumber[ 1, java.text.DecimalFormat@674dc, ., com.sap.aii.mappingtool.tf7.rt.Context@558b5349"

\

help me out for the same.

-E

Former Member
0 Kudos

Solved

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

You can use this mapping


Source --> removeContext --> UDF --> Target

UDF type is of context type

Argument: input


for(int a=0;a<input.length;a++){
 String temp = input[a].substring(input[a].length()-1,input[a].length());
if(temp.equals("-"))
	result.addValue("-");
else
	result.addValue("+");
}

Hope this helps,

Mark