Product: Mapping Manager
Function: @INT()
βArticle Link: http://help.truecommerce.com/en/articles/11180591-mapping-manager-int-function
The Integer function or @INT() - allows for formatting of a particular number to ensure that it fits a minimal length requirement by padding it with 0s with an optional ability to shift the original value to the left.
Decimal Values will lose their decimal place - the result is always that of an Integer (Whole Number)
Input must be a numerical value - does not work with strings
@INT()
@INT(TOKEN,shift,size)
Placement | Parameter | Description |
1st | Token | The desired Token we wish to modify |
2nd | Shift | How many times we should shift the Original Token to the Left before padding |
3rd | Size | The Minimal Length the results should be |
Defining a Minimal Length
The primary purpose of the @INT() function is to ensure that the Token stays a consistent minimal length by padding 0s into the resulting value.
If the Value of the Original Token is greater than the Size defined in the 3rd Parameter then the result will be the same as if the Token was mapped directly (no modification will take place).
Original Value | Desired Sized | Result |
1 | 3 | 001 |
10 | 3 | 010 |
10100 | 3 | 10100 |
Example : Setting the Line # to Minimal of 3
In this example - we need to take the Inbound XML data and ensure that the LineNumber field is at least 3 characters. We can do that by setting the Size to 3 to ensure that if LineNumber is less than 3, it will add 0s to the left of it to meet the minimal sizing requirement.
Sample XML
<Items>
<Item>
<LineNumber>1</LineNumber>
...
</Item>
<Item>
<LineNumber>2</LineNumber>
...
</Item>
<Item>
<LineNumber>3</LineNumber>
...
</Item>
</Items>
Token Mapping
Map: @INT(TOKEN,0,3)
Token (1st Parameter): Desired Business System or Trading Partner field
Shift (2nd Parameter): 0
Size: 3
Results
Since the Sample File has only the 1 digit for each LineNumber the resulting is two padded 0s to the left (001, 002, & 003).
Shifting The Token Placement
The @INT() function also has the ability to shift the original Token Value to the left which will result in the 0s being padded both on the Left and the Right accordingly.
Original Value | Shift Amount | Desired Sized | Result |
1 | 1 | 3 | 010 |
10 | 1 | 3 | 100 |
10100 | 1 | 3 | 10100 |
Example : Shifting to Left One Character
Let's say that the original value for your Line Number is in the ones range (1,2,3) but you need it in the 10s range (10,20,30) - as long as the original value is less than the Size parameter then the original value will be shifted to the left the amount of times marked within the Shift parameter and pad the right with 0s.
Sample XML
<Items>
<Item>
<LineNumber>1</LineNumber>
...
</Item>
<Item>
<LineNumber>2</LineNumber>
...
</Item>
<Item>
<LineNumber>3</LineNumber>
...
</Item>
</Items>
Token Mapping
Map: @INT(TOKEN,1,3)
Token (1st Parameter): Desired Business System or Trading Partner field
Shift (2nd Parameter): 1
Size: 3
Results
Since our Sample File has all three LineNumbers in the ones place and the minimal size was set to 3, the value coming in from the XML File was shifted to the left one and a 0 was padded both on the Left and on the Right resulting in 010, 020 & 030
Common Use Cases
|
Setting Line Number to Minimal Amount |
Converting a 12 Digit GTIN to 14 Digit GTIN |
Creating a UCC-128 |
rev 5/2/2025