cancel
Showing results for 
Search instead for 
Did you mean: 

Truncating Leading Zeroes

Former Member
0 Kudos

Hi,

What is the best method to truncate the leading zeroes of an alphanumeric data item? Is there an expression editor function that could do this?

I have come up with a logic involving 3 - 4 actions that could do this for a specific data item. The problem is I have got about 5 different data items in the same transaction that need leading zeroes truncated. Whats the best thing to do here?

Do I need to build a custom action or expression editor function?

Regards,

V M.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Depending on the volume, one trick is to use sql for this sort of thing. For example if you are using SQL server you can create a fixed query like the folowing:

SELECT 
 REPLACE(LTRIM(REPLACE('[Param.1]', '0', ' ')), ' ', '0') AS TRIMMEDVAL

While we are on this subject it occured to me that it would be a nice feature to be able to define custom functions for the link editor. Kinda like the ability to create custom actions.

Edited by: Christian Libich on Nov 4, 2010 5:13 PM

Former Member
0 Kudos

No, we are not using SQL server.

You stole the words out of my mouth. Its sad to know there is no built in fuction that can do this nor the ability to upload a custom function. Hope somebody is listening!

Former Member
0 Kudos

Well, there are equivilants in every database. I think Oracle has something like LTRIM(value, '0')

If your application doesn't use any databases and you are on 12.0 + you could estabish a connection to the neweaver db.

You could also look into and xsl solution using the XSL Transformation action.

I often do this to create/format lists for query filters or similar tasks.

For some background this issue often comes up when pulling data from standard SAP interfaces. In sap Order and Material numbers are typically trimmed automagically by the gui. But when pulling those data elements from sap you get the full monty. This is ok because you often need the full untrimmed value to use with other interfaces, but users still expect the values to be trimmed when displayed. There are a lot of solutions to this issue in regards to the front end (xsl, Javascript, SQL in cases where the data is stored/cached in a local database ) but it would be convienent to have this level of formatting built into the link editor. Maybe even something that accepts a regular expression?

Regards,

Christian

Former Member
0 Kudos

Hi VM,

you can use the MII format function to suppress leading zeros. Use something like this:

format( "0012", "####" )

The result will be "12". "#" is the format sign for numbers without leading zeroes.

Michael

Former Member
0 Kudos

First of all, the data item is alphanumeric (00000A0000BC000123).

Secondly, its a transaction variable.

former_member201407
Participant
0 Kudos

Did u check with abs() function?

Regards

Som

Former Member
0 Kudos

VM,

you can use Transaction properties in place of the strings in MII functions. However, you are right with the alphanumeric values. The format function returns a zero when used with a string that contains non numeric values. So you have to use standard actions (while, for next, repeater) to cut off the prefix.

Michael