cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert a value in Mapping

Former Member
0 Kudos

Hi All,

From Idoc in one of the field, the value is coming like " 678" ( with preceding spaces) because it is declared it as INT4 in ECC. this is Zfield.

If the value is coming like this means whi generating the text file with fixed lengths, it is writing with " 678" which shld be like "678"

If i remove the spaces from WE19 and trigger means it is giving correctly only

How to do this

Regards

Accepted Solutions (1)

Accepted Solutions (1)

Satyagadadas
Active Participant
0 Kudos

If I understand correctly replace string should work or you can use UDF to suppress spaces.

Use replacestring with one input as spcaes and another with nospaces

regards,

Satya.

Former Member
0 Kudos

Replace String worked for me

Regards

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi

Using TRIM alone will work

rgds

srini

Former Member
0 Kudos

Vamsi,

Since you are writing a fixed length file two things you need to consider:

a) INT4 is 10 digit representations. So if the value is 678 then from SAP if it comes as leading seven spaces adn 678 then you need to first trim the spaces so that you have value as 678.

b) Now since you have 678 but in the fixed file it should be 10 digits. So if you send the output as 678 then it will fail in content conversion for receiver communication channel. So you may add seven spaces after 678. Now here the length is dynamic. So you need to write a UDF for adding the number of spaces in the end and make the length as 10.

If my understanding is correct and if you want the above approach then your mapping is:

input ---> trim ---> UDF1 --> target

UDF1:

Create a value udf with name as udf1 and one variable 'a'. Add this code:

int len = a.length();

for(int i=0;i<10-len;i++){

a=a+" ";

}

return(a);

I am assuming your lenght in input file is also 10. If not change this number in the 2nd line of the code.

Regards,

---Satish

Former Member
0 Kudos

The best solution would be to use TRIM function if you want to remove the spaces

Edited by: Ravi on Jul 6, 2009 5:29 PM