Currency Format

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
jyoung
Posts: 694
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Currency Format

Post by jyoung »

How do I display a signed(15,4) field in a currency format i.e $1,505.25?
User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Currency Format

Post by Stewart Marshall »

The next EPC will have support Edit Word support.

This allows formatting to be applied to field when it is not in focus.

An edit word similar to

Code: Select all

'  ,   ,   ,  $0.    '
will format the number. You may need to move it to a field with the appropriate number of decimal places.

Regards
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au
jyoung
Posts: 694
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: Currency Format

Post by jyoung »

Good to know.

Until then I got it work by defining the fields with the right number of decimals

Code: Select all

define field(#HoursWorked) type(*SIGNED) length(15) decimals(2)
define field(#GrossBillings) type(*SIGNED) length(15) decimals(2)
define field(#GrossMargin) type(*SIGNED) length(15) decimals(2)
Then when the data is returned from the ServerModule

Code: Select all

#HoursWorked := #WSHRW.Round( HalfDown 2 )
#GrossBillings := #WSBG.Round( HalfDown 2 )
#GrossMargin := #WSGMA.Round( HalfDown 2 )

#HoursWorkedLabel.Caption := #HoursWorked.AsDisplayString( EditCode_N )
#GrossBillingsLabel.Caption := "$" + #GrossBillings.AsDisplayString( EditCode_N )
#GrossMarginLabel.Caption := "$" + #GrossMargin.AsDisplayString( EditCode_N )
User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Currency Format

Post by Stewart Marshall »

Not that I care about a few keystrokes here or there, but there's no need to specify .Caption when populating a label.

The Caption property is the default property, so this will produce the same result.

Code: Select all

#HoursWorkedLabel := #HoursWorked.AsDisplayString( EditCode_N )
Similarly, spin edit and edit have a default property of Value.

Regards
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au
User avatar
moon.gallop
Posts: 1
Joined: Fri Dec 09, 2016 11:37 pm

Re: Currency Format

Post by moon.gallop »

Thanks for sharing the code.
Post Reply