Simplicty and flexibility!


Truncating export data


Started by Karen Miller
Search
You will need to Sign In to be able to add or comment on the forum!

Truncating export data

I'm running a procedure that lists fields that are no more than 50 characters but are made up of jointext fields.  For some reason when I open the data file in excel some of the fields are truncated.  I think it is because I'm using jointext to combine 2 fields and some text.  Any thoughts?


Written by Karen Miller 12/04/17 at 19:25:30 Dataease [{8}]FIVE

Re:Truncating export data

As we don't know how you have created this export field we can only guess:

But Text fields is by default 40 characters long, so if the fields is only 40 characters long it will be truncated.

If you use a temp variable in a DQL it too will be 40 characters long is you don't specify it to be longer.

define "mytext" 255 . 

Will make it max.

In general, copy in the code you try to use as it is easier to know what you are trying to achieve as otherwise we (and the rest of the community) is left at guessing.

You might find it interesting that jointext() is outdated. You can use concat() instead and you can concatenate up to 32 strings into one.

Concat("text1,"Text2","Text3"...."Textn)

It will also accept a variable number of arguments (as a lot of other functions in DE85 do) so you don't have to fill in all 32 ;-)


Written by DataEase 12/04/17 at 21:52:42 Dataease [{8}]FIVE

Re:Truncating export data

When you do things like jointext and concat in a procedure, you are effectively creating a virtual field, and if you look in the body of your procedure, you'll see that field. The field name will be the derivation, and the field length will be some internal default, which in this case looks like 40 chars.

The length of this field will determine the max length you can export. Change it to, say, 100, and  the text will stop being truncated.

Bear in mind that if you compile, the field length will reset.

I only have a copy of DE 6.52 to hand, but I'm sure the following test still applies:

for table ;
  list records 
  shortishField ; -- say around 20 chars
  concat ( "" , shortishField ) .

In this instance, the virtual field called 'concat ( "" , shortishField )' will have a default length of 16 chars.

DataEase does a best guess length based on the last field in the derivation. A longer field, say around 80 chars, used in place of shortishField here, should result in a longer default field. 

So here's a quick trick:

define "tDummy" text 255 .
define "tShortDummy" text 10 .

for table , 
  list records
  shortishField ;
    concat ( shortishField , " " , anotherField , tDummy ) ;
    concat ( shortishField , " " , anotherField , tShortDummy ) .

tDummy is just a text variable of 255 chars in length. No value is assigned to it, which means it gets the default value of an empty string.

As it is the last field in the concat, DE uses its length to work out the length of the default field, which will probably 240 chars.

By contrast, in the second concat above, the default length for the corresponding virtual will only be 40 chars.

Using tDummy this way, you will only get truncated exports if  the combined length exceeds 240 chars, and you'll save development time as you won't have to keep remembering to adjust the field in the body.

Hope that makes sense!


Written by Adrian Jones 24/04/17 at 12:57:50 Dataease [{8}]FIVE

Re:Re:Truncating export data

BTW, don't use tShortDummy -- it's simply there to illustrate how the last field influences the length.


Written by Adrian Jones 24/04/17 at 13:19:02 Dataease [{8}]FIVE
DG3_ForumList