DataPort Variables Decimal Places

In a DataPort, if I create Decimal Variables, how can i Change de Decimal Places for each one?

I get one solution, but in FORMAT function how can I Put ‘0’, on empty spaces.

EX: FORMAT(XPTO,14,2) = XPTO, but I want this result 0000000000XPTO,00 How can I put ‘0’??

I tried this

FORMAT(XPTO,9) - OnAfterFormatField(VAR Text : Text[1024])
IF (STRLEN(XPTO) < 9 ) THEN;
XPTO := ‘0’+ XPTO;

But with this, either Rigt align neither 0 in left position appear on my result

I tried this

FORMAT(PADSTR(’’,9- STRLEN(XPTO),‘0’) + XPTO) this is ok for XPTO Text Type variable and works fine

With

XPTO → Width = 9

EX: 123456 result on 000123456

But with decimal variables this does not result.

How can I do the same with decimal variables

ZZZZ → width = 10

EX:54321 result should be 0000054321

Sounds like you are trying to create a fixed format text export file.

Did you try changing the dataport’s FileFormat property to “Fixed”.

The you can set the starting & ending positions of the fields you want to export.

I’ve created these before where the example of what they were looking for had leading zero’s but blanks worked just as well.

You also mention “with decimal variables this is not the result”

But your not showing us what the result was and how you would like it to appear.

If you need the number without the decimal point multiply the # first by 100

Also see how they use padstr and strlen to calc how many 0 will be required if you need to go that path.
http://www.mibuso.com/forum/viewtopic.php?f=23&t=46021

With Fixed Format in DataPort the Field Separator does not work, and I need < ; > separator in my dataport field.

Hello

With this format in my DataPortField

xpto = 7160792

FORMAT(PADSTR(’’,9- STRLEN(XPTO,‘0’) + XPTO)

The result is XPTO = 007160792

Problem:

But this Format only works with Text Fields

On Decimal Fields this format does not Work:

EX:

XPTO1 has Width = 14 <=> 0000000000.0000 (14:4)

XPTO1 = 14.49 €

With this Format : PADSTR(’’,STRLEN(FORMAT(XPTO1)),‘0’) + FORMAT(XPTO1)

The result Should be

XPTO1 = 0000000014.0049

But the result is ; 14.49; not OK

Thanks

It’s odd to me for a format that is “Fixed” to need a field seperator. Isn’t that the whole point of fixed?

Anyway then why not create a variable called Dataportseperator := ‘;’ //assign a semicolon as its value and place it in between each dataport field.

field1
dataportseperator
field2
dataportseperator
field3

etc…

My suggestion is to split the XPTO1 into 2. Part 1 the whole number part 2 the decimal part.

the code below is a sample way that may be used to get the .00XX of the decimal part.

St1:=FORMAT(XPTO1);
IF STRPOS(St1,’.’)> 0 THEN
BEGIN
St2:=COPYSTR(St1,STRPOS(St1,’.’)+1,4);
“Description 2”:=’.’+St2;
IF STRLEN(St2)< 4 THEN
“Description 2”:=’.’+PADSTR(’’,4-STRLEN(St2),‘0’) + St2;
END ELSE
“Description 2” := ‘.0000’;

Get also the padded form of he whole number part

add the two string together.

I believe that should be it

The above seems to be a longer route, you may have much shorter solution anyway.

Where do you put this solution, in wich dataPort session?

And how can I Call Both strings (ST1 + St2) in the dataPort?

this post is all over the place… if your only problem is

“But this Format only works with Text Fields, On Decimal Fields this format does not Work:”

why not just use FORMAT to convert it to text?

MyTextVariable := FORMAT(MyDecimalField);

That is not my problem, but thanks anyway

It was 5 or so posts ago…is this topic solved?

It should be on

- OnBeforeExportRecord()

trigger; where XXX is the name of the table to export from.

After getting St2

Concatenate St1 and St2 into another variable e.g.

St := St1 + St2;

“I am not sure the next step is conventional”, I will check for a more conventional way later

By your decision you can

allocate the above assignment to a redundant text field in the table and have it exported.

if none such field exist; create one temporarily and have it deleted after the export.