cancel
Showing results for 
Search instead for 
Did you mean: 

Substring issue

Former Member
0 Kudos

Hi.

Got an interface where we get a value for bonuses payed out every quarter of the year and every year bonus.

I some time gets a negativ value and from SAP it arrives as follow.

66955.00-

Ofcourse the amonut can differ so it will not be fixed position.

The target system would like to have the value like this.

-66955.00

How will I solve this?

Do I need an UDF and how would it look in that case?

Regards Andreas

Accepted Solutions (0)

Answers (2)

Answers (2)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Andreas,

Here is a mapping without UDF

Regards,

Mark

former_member182412
Active Contributor
0 Kudos

Hi Mark,

Better to put this in UDF because this is a common requirement when we work with IDOCs, because from ERP the minus sign is placed in right side of the amount.

In my project i have created the UDF for this in common function library under common software component and i used it in the all the mappings where i need this requirement.

Regards,

Praveen.

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Praveen,

That maybe true. But I think it is better that this be handled in the backend. A conversion exit can be used on the idoc to shift the - sign.

Regards,

Mark

former_member182412
Active Contributor
0 Kudos

Hi Mark,

I agree with you but some times in ERP they don't want to implement and they say that it is middle ware job.

Regards,

Praveen.

former_member182412
Active Contributor
0 Kudos

Hi Andreas,

Use below UDF

Execution Type : Single Values


public String moveMinusSignToLeft(String amount, Container container) throws StreamTransformationException{

int index = amount.indexOf("-");

        if (index > 0) {

            return ("-" + amount.substring(0, index));

        } else {

            return amount;

        }

}

Regards,

Praveen.