
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
tMap Pad String with Leading 0
I have been wrestling with this all day. StringHandling.LPAD(row2.SAP_ID, 6, "0") tests without error in the Expression Builder however isn't inserting the leading 0's in my field. Any suggestions?
Many thanks!
- « Previous Replies
-
- 1
- 2
- Next Replies »

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Pad methods are unavailable from TOS 6.4.1, so I can't try but you can do what you want with:
StringHandling.RIGHT("000000" + row2.code, 6)
It works.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Alllllll day......... Thank you so much!!!!! That did it!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please, don't forget to mark the solution as accepted.
Kudos are also accepted.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
other solution - is add to project routines library StringUtils from Exchange (plus dependencies - Apache common-lang-2.6)
it include many useful function and handle null values more proper than some Talend functions
* StringUtils.leftPad(null, *, *) = null * StringUtils.leftPad("", 3, 'z') = "zzz" * StringUtils.leftPad("bat", 3, 'z') = "bat" * StringUtils.leftPad("bat", 5, 'z') = "zzbat" * StringUtils.leftPad("bat", 1, 'z') = "bat" * StringUtils.leftPad("bat", -1, 'z') = "bat"
and use it in tMap
it work

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i dont know how much zeros i want to add ,if the account number length is 11 than i want to load otherwise i want to add zeros prefix the account number ??how to solve this

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A quick solution is as shown below.
The function used is as shown below where 11 is the length of the output string. If its less than 11, zeros will be padded to the left.
String.format("%1$11s", row1.data).replace(' ', '0')
Warm Regards,
Nikhil Thampi
Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
where is the talend.format option in tmap (string handling i am using talend 7.1)
@nthampi wrote:
A quick solution is as shown below.
The function used is as shown below where 11 is the length of the output string. If its less than 11, zeros will be padded to the left.
String.format("%1$11s", row1.data).replace(' ', '0')Warm Regards,
Nikhil ThampiPlease appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved

- « Previous Replies
-
- 1
- 2
- Next Replies »