1. John Vanleeuwe
  2. PowerBuilder
  3. Thursday, 25 July 2019 16:22 PM UTC

Hi all,

 

i am trying to implement the saveasasciiformatted function.

we need to export the contents of our datawindow to a ; separated file.

this works just fine, except for the decimals.

 

we would like to force the decimals to be exported as 9999999999.99999 where the . is the decimal separator.

We are located in Europe so our users are using the , comma as decimal separator.

So in the datawindow we "see" the value

 

123456789,12345  => this should be exported as 123456789.12345

1234 => this should be exported as 1234.00000

0,123 => this should be exported as 0.123

 

Bare in mind , i don't want to be reading and processing line by line, unless there's no alternative.

 

i found the dw_1.SetFormat() function which allows me to change the format just before the .saveasciiformattedtext function call.

 

Big question is now , to which format i must set my decimal columns to obtain what i want please ?

 

 

 

TIA

John

John Vanleeuwe Accepted Answer Pending Moderation
  1. Monday, 16 September 2019 10:56 AM UTC
  2. PowerBuilder
  3. # 1

Hi Chris,

 

the appropriate DBMS conversion / formatting commands.  exactly where my problem is right now :)

i need my numbers to be shown as 12.34 or 0.34 

which conversion formatting command can i use , using sybase 11 please ?

 

select price from table_x;

 

should become ... ?

 

TIA

John

Comment
  1. Chris Pollach @Appeon
  2. Monday, 16 September 2019 15:38 PM UTC
Hi John;

Have you tried the "TO_VARCHAR" Function?

FYI: https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.03/en-US/20f226a1751910149edd8969c469d54d.html

Regards ... Chris
  1. Helpful
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Friday, 26 July 2019 12:42 PM UTC
  2. PowerBuilder
  3. # 2

Hi John,

I have Danish regional settings (decimal comma, grouping dot, list separator semicolon).

PowerBuilder's standard functionality has regional settings woven into all conversion to/from strings incl. import/export of text files. So, you have to either

  1. Change regional settings temporarily (often forbidden for regular user due to security) - or -
  2. Transform to text using your own code.

As Chris suggests your SQL database may have more formatting options that require less code than doing the conversions in PowerScript.

CAUTION - Date, Time, and DateTime also depend on regional settings. Especially order of Day and Month varies by country. File exported by one user imported by another user may switch day/month in the date values. Test for it!

CAUTION - Sorting is also impacted. This is important if you use a "ZZZ" row to mark end-of-file. Danish example:

  • ("AA" <  "BB") evaluates to FALSE.
  • ("AA" >  "ZZ") evaluates to TRUE.

HTH /Michael

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 25 July 2019 16:33 PM UTC
  2. PowerBuilder
  3. # 3

Hi John;

  FYI: The SaveAsXxxxx() commands in PB for the DWO just saves the current "Primary Buffer" data "as is". My suggestion would be to create another DWO for exporting. In the 2nd DWO, modify your SQL statement to extract the datum in the format you need for exporting using the appropriate DBMS conversion / formatting commands. That should return the numeric data in as a string data type - exactly as you require.

HTH

Regards ... Chris

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.