cancel
Showing results for 
Search instead for 
Did you mean: 

Removing preceding zeros

Former Member
0 Kudos

Hi Friends,

It is a outbound PO interface. The vendor number is coming from IDOC and it is being padded with zeros in the PO file. It shouldn’t have any zeros preceding the vendor number. For instance if the Vendor is "800012", the field is being created with 0000800012 as the vendor number when it should be created in the file as “800012”.

Is there any code to remove the preceding zeros before sending it to the target system.

Thanks in Advance,

Meghna.

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi,

Use this peace of code to achicve your requirement

String b= (new Integer (Integer.parseInt(a))).toString();

return b;

Regards

Seshagiri

Former Member
0 Kudos

Seshagiri,

Create a function zerosuppress and take the cache as value and take one argument input.

Import: Java.*;

Add this code:

String output = input.replaceFirst("^0+","");

return output;

Source >udf>output

Ex:

00920>udf>920

00004567>udf>4567

Regards,

---Satish

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

Hi

just do a UDF function.

copy and paste it:

public String DeleteRightZeros(String s_string,Container container){

int i_string;

// convert the string to int.

i_string = Integer.parseInt(a_string);

//convert the int to string

s_string= String.valueOf(i_string);

return s_string;

former_member208856
Active Contributor
0 Kudos

Hi Meghna,

please go in function Arthmetic --> round in Message Mapping,

use message mapping INPUT NO --> ROUND --> Output No

Reward points, if helpful,

Sandeep Kaushik

ranjit_deshmukh
Active Participant
0 Kudos

Hi,

just use the FormatNum function with no values in it

this will solve your problem.

Ranjit

Former Member
0 Kudos

Hi Ranjit,

I used the function 'FormatNum' the result is

Actual value of vendor coming from IDOC (before using the function) is 0001000018

After using the 'FormatNum' function is 1,000,018

I need only numbers '1000018' , no commas in between.

Thanks,

Meghna

ranjit_deshmukh
Active Participant
0 Kudos

Hi,

then use FormatNum with number format just '#'

u can make use of Round function also.

Ranjit

Former Member
0 Kudos

Hello Meghna,

The preceeding zero's are a often faced phenomen in SAP integration scenarios,

SAP uses conversion exits to change in and output values to for dispaly inside SAP.

This also comes into account in integrating standard interfaces as many Function Moduls return numbers formatted that way.

If you have a chance to have influence on your function module use the according conversion exit to remove

the numbers during the call inside SAP as this is a SAP interna.

(Also see this thread about conversion exits for inputs (conversion_exit_alpha_input) and and outputs (conversion_exit_alpha_output)).

Of course also the other way is to write a user defined function, that cuts the leading zero's in XI, but

in my oppion this is moving something away from its cause.

And also that one you have to write by yourself.

With best regards

Sebastian

Former Member
0 Kudos

> It is a outbound PO interface. The vendor number is coming from IDOC and it is being padded with zeros in the PO file. It shouldn’t have any zeros preceding the vendor number. For instance if the Vendor is "800012", the field is being created with 0000800012 as the vendor number when it should be created in the file as “800012”.

> Is there any code to remove the preceding zeros before sending it to the target system.

There is no tcode to remove the zeros.

Let me know the scenario.

Regards,

Sarvesh

Edited by: Sarvesh Singh on Feb 8, 2008 3:21 PM

Former Member
0 Kudos

Hi all,

thanks for your fast reply,

I mean to ask in XI is there any User Defined Function (UDF) Code which can be written (for removing preceding zeros)and map it the 'vendor field'.

Regards,

Meghna.

Former Member
0 Kudos

Hi,

I think you dn't need any UDF for this, you can achieve this by using simple substring function.

For ex: if ur Vendor number is like 000200, then use the substring function to elemenate first three digits. In the properties you can set as starting position 3 and number of characters 3. You will get the output as 200.

Regards

Edited by: Vijaya Lakshmi MV on Feb 8, 2008 10:42 AM

Former Member
0 Kudos

> I mean to ask in XI is there any User Defined Function (UDF) Code which can be written (for removing preceding zeros)and map it the 'vendor field'.

>

There is no Generic Function in XI mapping which removes the Zero but you can write a very-2 small and easy User Defined Function (UDF) to remove the leading zeros.

Logic: Inside the udf code just declare a variable as integer and pass your incoing value to it, it will remove all the leading zeros.

Regards,

Sarvesh

Former Member
0 Kudos

> I think you dn't need any UDF for this, you can achieve this by using simple substring function.

>

> For ex: if ur Vendor number is like 000200, then use the substring function to elemenate first three digits. In the properties you can set as starting position 3 and number of characters 3. You will get the output as 200.

>

Hi,

You never know how may leading zeros are coming, so you can not use substring and hence can not set a fix position as said above. In this case you have to write the UDF.

Regards,

Sarvesh

Former Member
0 Kudos

Hi Sarvesh,

Can you give the UDF code for Removing preceding zeros.

Former Member
0 Kudos

Hi,

Check the links for UDF.

UDF

http://flickr.com/photos/8764045@N06/

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/be05e290-0201-0010-e997-b6e...

Example 1

http://www.flickr.com/photo_zoom.gne?id=544183191&size=o

http://www.flickr.com/photo_zoom.gne?id=544183195&size=o

http://www.flickr.com/photo_zoom.gne?id=544183225&size=o

http://www.flickr.com/photo_zoom.gne?id=544183233&size=o

Example 2

http://www.flickr.com/photo_zoom.gne?id=545133789&size=o

http://www.flickr.com/photo_zoom.gne?id=545133791&size=o

http://www.flickr.com/photo_zoom.gne?id=545133801&size=o

http://www.flickr.com/photo_zoom.gne?id=545133807&size=o

http://www.flickr.com/photo_zoom.gne?id=545133811&size=o

http://www.flickr.com/photo_zoom.gne?id=545138911&size=o

http://www.flickr.com/photo_zoom.gne?id=545138913&size=o

http://www.flickr.com/photo_zoom.gne?id=545138915&size=o

http://www.flickr.com/photo_zoom.gne?id=545138917&size=o

http://www.flickr.com/photo_zoom.gne?id=545138947&size=o

http://www.flickr.com/photo_zoom.gne?id=545138951&size=o

http://www.flickr.com/photo_zoom.gne?id=545005958&size=o

Example 3

http://www.flickr.com/photo_zoom.gne?id=549186611&size=o

http://www.flickr.com/photo_zoom.gne?id=549186651&size=o

http://java.sun.com/j2se/1.5.0/docs/api/

/people/krishna.moorthyp/blog/2006/07/29/documentation-html-editor-in-xi

/people/sap.user72/blog/2006/02/06/xi-mapping-tool-exports

http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm

http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/content.htm

/people/stefan.grube/blog/2005/12/30/test-user-defined-functions-for-the-xi-graphical-mapping-tool-in-developer-studio

http://help.sap.com/bp_bpmv130/Documentation/Operation/MappingXI30.pdf

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d046c490-0201-0010-84b6-9df523cb...

Regards,

Phani

Reward points if Helpful

former_member208856
Active Contributor
0 Kudos

use ROUND Function, it is working fine at my system.

Sandeep Kaushik

Former Member
0 Kudos

hi,

check this code to " trim leading zeroes"

public String trimLeadZero(String a,Container container)

{

int ii = 0;

//Convert string to integer to remove leading zeros.

ii = Integer.parseInt(a);

//Typecast integer back to string.

a = ii+"";

//Return String value.

return a;

}

code to "remove leading zeroes"

public String RemoveLeadingZeros(String a,Container container)

{

String result = "";

if (a == null)

{

result = "";

}

char [ ] chars = a.toCharArray();

int index = 0;

for (; index < a.length(); index++)

{

if (chars[index] != '0')

{

break;

}

}

return (index == 0) ? a : a.substring(index);

}

please reward with necessary points if found helpful.

regards

madhu

Former Member
0 Kudos

Hi,

Here is the code.

int i = Integer.parseInt(a);

a = Integer.toString(i);

return a;

Regards,

Sarvesh

jegathees_waran
Active Participant
0 Kudos

Hi,

There is no tcode to remove preceding zeros. For Example, if IDoc is to inbound to XI and update the data in ABAP table, the system will add automatically preceding zeros. In the opposite case (IDoc to File), if you want to remove leading zeros, you have to do this at the mapping level.

Kind Regards,

Jeg P.