Skip to Content
avatar image
Former Member

Truncating Leading Zeroes

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Nov 04, 2010 at 03:14 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • avatar image
    Former Member
    Nov 04, 2010 at 04:11 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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