cancel
Showing results for 
Search instead for 
Did you mean: 

Remove leading with negative values

Former Member
0 Kudos

Hello Expert,

I have requirement in mapping where the QuantityShipped field values coming from the file and after transfomation the below output need to be mapped in the Idoc target filed MENGE. QuantityShipped filed defined as a sting in the datatype.

Input: 000000-18

Output: -18

Since I using the FormatNo function but not getting the required output.

FormatNo function works in case 000000018 so the output comes 18, but in case of -ve values it didn't works.

Please help. Can we acheive it by using without helping UDF?

Regards,

Sameer!

Accepted Solutions (0)

Answers (3)

Answers (3)

RaghuVamseedhar
Active Contributor
0 Kudos

Hi Sameer Khanna,

I have successfully tested this UDF.

public String Negitive(String MENGE, Container container) throws StreamTransformationException{

if(!MENGE.contains("-"))
 {
   return Integer.parseInt(MENGE) + "";
 }else{
   MENGE = MENGE.replaceAll("-","");
   return Integer.parseInt(MENGE) + "-";
 }

}

Regards,

Raghu_Vamsee

Former Member
0 Kudos

Hello Expert,

CORRECTION:

I have requirement in mapping where the QuantityShipped field values coming from the file and after transfomation the below output need to be mapped in the Idoc target filed MENGE. QuantityShipped filed defined as a sting in the datatype.

Input: 000000-18

Output: 18-

Since I'm using the FormatNo function but not getting the required output.

Please help. Can we acheive it by using without helping UDF?

Regards,

Sameer!

former_member200962
Active Contributor
0 Kudos
Input: 000000-18
Output: 18-

Source --> Replacefunction > concat > target

if required you can stuff the FormatNum function between replace and concat

Edited by: abhishek salvi on Jan 21, 2011 11:08 PM

Former Member
0 Kudos

>

> Hello Expert,

>

> I have requirement in mapping where the QuantityShipped field values coming from the file and after transfomation the below output need to be mapped in the Idoc target filed MENGE. QuantityShipped filed defined as a sting in the datatype.

>

> Input: 000000-18

> Output: -18

>

> Since I using the FormatNo function but not getting the required output.

>

> FormatNo function works in case 000000018 so the output comes 18, but in case of -ve values it didn't works.

>

> Please help. Can we acheive it by using without helping UDF?

>

> Regards,

> Sameer!

Try this:

Imports: java.lang.;java.util.;

public void UDF(String input_string,ResultList result,Container container){

String[] temp;

/* delimiter */

String delimiter = "-";

String result;

/* given string will be split by the argument delimiter provided. */

temp = input_string.split(delimiter);

result = delimiter.concat(temp[1])

result.addValue(result);

}

Edited by: spantaleoni on Jan 21, 2011 2:52 PM