tMap Pad String with Leading 0

Four Stars

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!

Fifteen Stars TRF
Fifteen Stars

Re: tMap Pad String with Leading 0

Strange! Did you check using tLogRow or something else? Can you share your component configuration?

TRF
Four Stars

Re: tMap Pad String with Leading 0

1.png

Fifteen Stars TRF
Fifteen Stars

Re: tMap Pad String with Leading 0

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.

 


TRF
Four Stars

Re: tMap Pad String with Leading 0

Alllllll day.........    Thank you so much!!!!!   That did it!

Fifteen Stars TRF
Fifteen Stars

Re: tMap Pad String with Leading 0

You're welcome.
Please, don't forget to mark the solution as accepted.
Kudos are also accepted.

TRF
Forteen Stars

Re: tMap Pad String with Leading 0

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

 

 

-----------

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch