Back to forum list… Back to How Do I?...

Can IMAN remove leading zeroes from a string? (4 replies)

Arline Welty
7 years ago
Arline Welty 7 years ago

Hi there,

Not sure if this is possible. The goal is to remove any leading zeroes from a string that represents %INVOICENO field within my transform. The data values can be any kind of string. 

Examples:

000002458-579854

00CM3221

00IV180410091

00000000000N64675

 

Desired results:

2458-579854

CM3221

IV180410091

N64675

I checked the conversion functions page (https://www.realisable.co.uk/support/documentation/iman-user-guide/Reference/ConversionFunctions.htm) which made me think I could handle this easily for a numeric value but I'm not sure if we can cope with a string value. I saw the below work for another person in another context but had trouble translating it to IMAN:

Function trimLeadingChar(0 As String, %INVOICENO As String) As String
Dim lngLC As Long

For lngLC = 1 To Len(%INVOICENO)
If Mid(%INVOICENO, lngLC, 1) Left(0, 1) Then
trimLeadingChar = Right(%INVOICENO, Len(%INVOICENO) - lngLC + 1)
Exit Function
End If
Next lngLC
trimLeadingChar = ""

 

Any ideas are welcome.

Thank you,

Arline

 

Support
7 years ago
Support 7 years ago

Hi Arline,

This should remove leading zeros from any string.

Dim Result
Result = %INVOICENO
 
While Left(Result,1) = "0" AND Result  ""
    Result = Right(Result,Len(Result)-1)
Wend
 
Result
Dim Result
Result = %INVOICENO

While Left(Result,1) = "0" AND Result  ""
    Result = Right(Result,Len(Result)-1)
Wend

Result
Support
7 years ago
Support 7 years ago

Arline, on the part where it says Result "" it should have a less than and a greater than i.e. not equal.

Arline Welty
7 years ago
Arline Welty 7 years ago

You guys are the best. This worked perfectly! ? Thank you so much.

Dim Result
Result = %INVOICENO

While Left(Result,1) = "0" AND Result ""
Result = Right(Result,Len(Result)-1)
Wend

Result

Arline Welty
7 years ago
Arline Welty 7 years ago

Not sure what's up with my paste, but I definitely had "  Result ""  " where you suggested it- thanks again.

Contact

Realisable Software Ltd provides code-free, cost-effective applications integration solutions for SMEs. Our core IMan product is designed to integrate almost any application with a number of Sage solutions and online payment processors.

Looking to purchase IMan, please see our resellers here.

Realisable Software
Ph: +44 (0) 208 123 1017

Copyright © Realisable. All rights reserved.
Realisable is a registered trademark

Close

Request Demo

Realisable Software Ltd provides code-free, cost-effective applications integration solutions for SMEs. Our core IMan product is designed to integrate almost any application with a number of Sage solutions and online payment processors.

Looking to purchase IMan, please see our resellers here.

Realisable Software
Ph: +44 (0) 208 123 1017

Copyright © Realisable. All rights reserved.
Realisable is a registered trademark

Close

Access Downloads

Realisable Software Ltd provides code-free, cost-effective applications integration solutions for SMEs. Our core IMan product is designed to integrate almost any application with a number of Sage solutions and online payment processors.

Looking to purchase IMan, please see our resellers here.

Realisable Software
Ph: +44 (0) 208 123 1017

Copyright © Realisable. All rights reserved.
Realisable is a registered trademark

Close