Display Number Exactly as Entered

Discussions specific to Team Developer 5.2.

Display Number Exactly as Entered

Postby aberndt » Wed Jun 17, 2015 7:29 am

Is there any way to display a number exactly as entered? I have an order form that shows a quantity field, it is a number. Sometimes the number is 68, sometimes it is 67.5. When it is 68, I would like the report to display 68, not 68.0 and when it is 67.5, I'd like it to display 67.5, not 68. Is this possible? Thank you in advance for your help.
aberndt
 
Posts: 32
Joined: Wed Jun 10, 2009 11:38 pm

Re: Display Number Exactly as Entered

Postby FRBhote » Wed Jun 17, 2015 10:07 pm

An unformatted data field should do that.
User avatar
FRBhote
 
Posts: 977
Joined: Mon Jul 07, 2008 7:38 am
Location: Hyderabad, India

Re: Display Number Exactly as Entered

Postby Peter.Hugk » Wed Jun 17, 2015 11:48 pm

We use an own function which just converts the number with the highest possible amount of digits after the decimal point and then removes all Zeros from the right of the string.
Code: Select all
Function: fNumberToStrX
   Description: Wandelt eine Zahl in einen String unter Beibehaltung der Nachkommastellen, indem ein String mit 44 Nachkommastellen
         (Höchstwert lt. TD-Doku) erstellt, und die überzähligen Stellen wieder entfernt werden.
   Returns
      String:
   Parameters
      Number: p_nValue
   Static Variables
   Local variables
      String: sValue
   Actions
      If p_nValue = 0
         Return '0'
      ! Number = up to 44 digits of precision.
      Set sValue = SalNumberToStrX( p_nValue, 44 )
      While SalStrRightX( sValue, 1 ) = '0'
         Set sValue = SalStrLeftX( sValue, SalStrLength( sValue ) - 1 )
      If SalStrRightX( sValue, 1 ) = ',' OR SalStrRightX( sValue, 1 ) = '.'
         Set sValue = SalStrLeftX( sValue, SalStrLength( sValue ) - 1 )
      Return sValue

Primitive, but pragmaticly working.

Regards,
Peter
User avatar
Peter.Hugk
 
Posts: 274
Joined: Mon Feb 18, 2008 12:27 am
Location: Germany

Re: Display Number Exactly as Entered

Postby Charlie » Thu Jun 18, 2015 4:04 am

If I understand correctly, you are referring to how a number is displayed in a report (versus displayed on a screen).

So we are talking about adjusting the format of a number field on a report.

Instead of having the field show a numeric, have it show a string, a result of a function. Format the number to string a certain way if there are decimals, and format another way if there aren't.

Say your input item is "YourNumberValue".

Using the function NumberAbsolute(), you can figure out if YourNumberValue has decimals by doing YourNumberValue - NumberAbsolute(YourNumberValue)

StrIFF( YourNumberValue - NumberAbsolute(YourNumberValue), 'OOPS! ERROR?', NumberToStrPicture(YourNumberValue,'999'), NumberToStrPicture(YourNumberValue,'999.99') )

Something like that. I haven't tried this, nor have I had my coffee yet to start the day ...
Image

Come join us at Dave Rabelink's "Team Developer Community Forum"!
All users of OpenText™ Gupta Development Tools and Databases welcome!
http://tdforum.daverabelink.net/index.php
Charlie
 
Posts: 345
Joined: Mon Mar 10, 2008 5:04 am
Location: New Brunswick, Canada


Return to Team Developer 5.2

Who is online

Users browsing this forum: No registered users and 1 guest