BizTalk Server - Padding zeros in map-How to?

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server > August 2007 > Padding zeros in map-How to?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Padding zeros in map-How to?
Gurvinder

2007-08-10, 1:18 pm

Hi All,

I have cost value and it comes as 12345 and i want to make it 123.45 and i
am able to do that. But if value come like 12 or only 1 then i have to pad
zero before it if i want to insert .(dot) before last 2 numbers for ex
if I get 1 and i want it to look .01 how can i do that in map. may be
cheking lenght of in comming string/number and padding zero before it I dont
know how to pad '0'

Any help appriciated.

Thanks,
Gurvinder
Jan Eliasen

2007-08-10, 7:18 pm

On Fri, 10 Aug 2007 07:10:06 -0700, Gurvinder
<Gurvinder@discussions.microsoft.com> wrote:

>I have cost value and it comes as 12345 and i want to make it 123.45 and i
>am able to do that. But if value come like 12 or only 1 then i have to pad
>zero before it if i want to insert .(dot) before last 2 numbers for ex
>if I get 1 and i want it to look .01 how can i do that in map. may be
>cheking lenght of in comming string/number and padding zero before it I dont
>know how to pad '0'

Have a custom scripting functoid that is a C# script, and have this
code:
public void pad(string param)
{
string str = param.PadLeft(5, '0');
str = str.Insert(3, ".");
MessageBox.Show(str);
}

Maybe it needs more code... do you want 000.01 or just .01 ?

--
eliasen, representing himself and not the company he works for.

Private blog: http://blog.eliasen.dk

Private email: jan@eliasen.dk
Gurvinder

2007-08-13, 1:19 pm

i want .01

pls help


"Jan Eliasen" wrote:

> On Fri, 10 Aug 2007 07:10:06 -0700, Gurvinder
> <Gurvinder@discussions.microsoft.com> wrote:
>
> Have a custom scripting functoid that is a C# script, and have this
> code:
> public void pad(string param)
> {
> string str = param.PadLeft(5, '0');
> str = str.Insert(3, ".");
> MessageBox.Show(str);
> }
>
> Maybe it needs more code... do you want 000.01 or just .01 ?
>
> --
> eliasen, representing himself and not the company he works for.
>
> Private blog: http://blog.eliasen.dk
>
> Private email: jan@eliasen.dk
>

Jan Eliasen

2007-08-14, 1:18 am

On Mon, 13 Aug 2007 07:56:03 -0700, Gurvinder
<Gurvinder@discussions.microsoft.com> wrote:

>i want .01

Replace the code with this:

string str = this.padTextBox.Text.PadLeft(5, '0');
str = str.Insert(3, ".");
str = str.TrimStart('0');

--
eliasen, representing himself and not the company he works for.

Private blog: http://blog.eliasen.dk

Private email: jan@eliasen.dk
Gurvinder

2007-08-15, 7:17 pm

other way i can think of doing is divide by 100 and in database use precision
up to 2 places (if 0/100 type)

"Jan Eliasen" wrote:

> On Mon, 13 Aug 2007 07:56:03 -0700, Gurvinder
> <Gurvinder@discussions.microsoft.com> wrote:
>
> Replace the code with this:
>
> string str = this.padTextBox.Text.PadLeft(5, '0');
> str = str.Insert(3, ".");
> str = str.TrimStart('0');
>
> --
> eliasen, representing himself and not the company he works for.
>
> Private blog: http://blog.eliasen.dk
>
> Private email: jan@eliasen.dk
>

Gurvinder

2007-08-15, 7:17 pm

but if i have to add/padd zeros then your approach is best to it

"Gurvinder" wrote:

> Hi All,
>
> I have cost value and it comes as 12345 and i want to make it 123.45 and i
> am able to do that. But if value come like 12 or only 1 then i have to pad
> zero before it if i want to insert .(dot) before last 2 numbers for ex
> if I get 1 and i want it to look .01 how can i do that in map. may be
> cheking lenght of in comming string/number and padding zero before it I dont
> know how to pad '0'
>
> Any help appriciated.
>
> Thanks,
> Gurvinder

Jan Eliasen

2007-08-15, 7:17 pm

On Wed, 15 Aug 2007 11:44:06 -0700, Gurvinder
<Gurvinder@discussions.microsoft.com> wrote:

>other way i can think of doing is divide by 100 and in database use precision
>up to 2 places (if 0/100 type)

That will probably work as well.

--
eliasen, representing himself and not the company he works for.

Private blog: http://blog.eliasen.dk

Private email: jan@eliasen.dk
Jan Eliasen

2007-08-15, 7:17 pm

On Wed, 15 Aug 2007 11:44:06 -0700, Gurvinder
<Gurvinder@discussions.microsoft.com> wrote:

>other way i can think of doing is divide by 100 and in database use precision
>up to 2 places (if 0/100 type)

... but I probably wouldn't go that way - I would use my suggestion. I
wouldn't change the database layout for that... what is it is changed
back at some point? If another develoepr doesn't want the restriction
in the database, or the database is overwriten by a Service Pack for
the sytem or something like that... With my solution, it will work at
all times.

--
eliasen, representing himself and not the company he works for.

Private blog: http://blog.eliasen.dk

Private email: jan@eliasen.dk
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com