Author |
Message
|
CHERIANV |
Posted: Wed Feb 12, 2003 7:08 pm Post subject: Pad string with leading zeros |
|
|
Apprentice
Joined: 15 Feb 2002 Posts: 43 Location: New York
|
Hi,
In ESQL , what is the most efficient way to pad a string that is an input MRM field with leading zeros. |
|
Back to top |
|
 |
lillo |
Posted: Wed Feb 12, 2003 11:46 pm Post subject: |
|
|
Master
Joined: 11 Sep 2001 Posts: 224
|
Try the following:
Code: |
SET OutputRoot.MRM.FIELD = LTRIM('0' FROM InputRoot.MRM.FIELD);
|
Cheers, _________________ Lillo
IBM Certified Specialist - WebSphere MQ |
|
Back to top |
|
 |
jfluitsm |
Posted: Thu Feb 13, 2003 12:51 am Post subject: |
|
|
Disciple
Joined: 24 Feb 2002 Posts: 160 Location: The Netherlands
|
You can fill the padding character in the cwf-layer of this field (under Types).
pre-2.1 using '0' didn't work but x'30' (Unicode for zero) did.
In this way removing (input) and adding (output) the padding character(s) is done by the MRM. _________________ Jan Fluitsma
IBM Certified Solution Designer WebSphere MQ V6
IBM Certified Solution Developer WebSphere Message Broker V6 |
|
Back to top |
|
 |
jas |
Posted: Thu Feb 13, 2003 1:03 am Post subject: |
|
|
 Novice
Joined: 28 Jul 2002 Posts: 12
|
we used the following code when converting from XML (unknown length) to MRM (fixed length)
SET CharLen = LENGTH(InputRoot.XML.FIELD);
SET OutputRoot.MRM.FIELD =
SUBSTRING('000000000000000' || InputRoot.XML.FIELD FROM CharLen FOR LENGTH)
where number of zeroes is according to length of output MRM field |
|
Back to top |
|
 |
jfluitsm |
Posted: Thu Feb 13, 2003 1:42 am Post subject: |
|
|
Disciple
Joined: 24 Feb 2002 Posts: 160 Location: The Netherlands
|
We did the same until we discovered that justify right and padding with x'30' or '0' did the trick for us, saved a lot of coding and for all you don't need to know the length of MRM.FIELD.
Only difference is when XML.FIELD is longer than MRM.FIELD, with your method the value is truncated, when using the MRM for padding you will get an error (field too long). _________________ Jan Fluitsma
IBM Certified Solution Designer WebSphere MQ V6
IBM Certified Solution Developer WebSphere Message Broker V6 |
|
Back to top |
|
 |
|