cancel
Showing results for 
Search instead for 
Did you mean: 

how to realize the function

Former Member
0 Kudos

hi, there

I will realize a mapping rule.

sender is a char data type with length 8 bytes. after mapping , if the real content is not 8 byte, '0' will be added into the front of string.

for example.

11 --> 00000011

aaa --> 00000aaa

etc.

Maybe the standard function is not satified with the requirement. WOuld you please tell me the realization way. The add-on java mapping program is necessary?

thank you in advance

Best Regards,

Kevin

Accepted Solutions (1)

Accepted Solutions (1)

Shabarish_Nair
Active Contributor
0 Kudos

Try this UDF so that you get the desired result. this will pad the string you pass with the correct zeros.

<i><b>

int len = 8 ;

StringBuffer sBuf= new StringBuffer(a);

while (sBuf.length() < len) {

sBuf.insert(0,' ');

}

result.addValue(sBuf.toString());

</b></i>

Answers (3)

Answers (3)

Former Member
0 Kudos

Try with this UDF with a as input

<b>if(a.length()<8)

{

String str = "";

for(int i=0;i<(8-a.length());i++)

{

str=str+'0';

}

resut.addValue(str+a);

}

else

{

resut.addValue(a);

}</b>

Former Member
0 Kudos

Hi,

Try with FormatNum standard function.

Converts it according to a pattern that you define using the function properties

see the below link

http://help.sap.com/saphelp_nw2004s/helpdata/en/22/e127f28b572243b4324879c6bf05a0/frameset.htm

Regards

Chilla

Former Member
0 Kudos

Hi Kevin,

I checked in the data type for character i did not see char type.Could you please check it and let me know.

Even if you select data type as string you will not get '0' as preeceding value.

Please let me know if you have any queries...............!

Thanks and Regards,

Chandu.

Former Member
0 Kudos

hi, Chandu

thanks a lot for your answer.

Sorry for the wrong decription.

Yes, Actually the string type is default for the field.

Yes, Even i select data type as String i still will not get '0' as preeceding value.

So how to realize the mapping like showed example below.

source target

aa 000000aa

1111 00001111

Best Regards,

Kevin

Former Member
0 Kudos

To accomplish this using standard functionality will be very complex.

You have to use Length, Concat, constants and conditional blocks to accomplish this.

Easiest way would be to create a UDF.

Satish