neeraj_vasudeva
17th December 2002, 17:16
I am new to BaaN. I am displaying a field tiitm001.copr ( data type - double ) on the report, problem is it is being displayed in the following format, let's say the value is 17, then it is being displayed as 17.0000
please let me know as to how can i format this field, so that the display comes as :
A) 17
B) 17.00
and one more doubt Is sprintf function works only for double data type and not for string function ?
I hope I will not have tolink the domain with the field, should i specify the format in the print expression or in the script ???
Please let me know the format for both (A) and (B) case ....
If possible mail me the solution at
neeraj_vasudeva@yahoo.com
evertsen
18th December 2002, 07:54
You have a couple of options but the easiest is: Maintain Reports, Maintain Layouts, Maintain Report Fields for the field in question and uncheck Link with Domain then in Print Format put
A) ZZ
B) ZZVD99
The Baan Help for the Print Format field explains this quite well.
neeraj_vasudeva
18th December 2002, 09:37
Hello,
Well I think i was not able to clearly speciy my requirment previously. Actually in report script i have done coding which tells me the unit measurement of the item , now if the item is of type pieces then i would like to display the tiitm001.copr field without decimal , but if the type is of gram then i would like to display the tiitm001.copr with decimal places ( 2 decimals )
Please let me know how can i do it report script ? I tried using sprintf$() function but was not able to achieve since i do not want to convert this field into string, because i would be using this field further for multiplication purpose.
The solution u gave me displays only 2 figues before decimal where as i would like to display whatever it has.
Paul P
18th December 2002, 09:47
Dear neeraj_vasudeva,
What you can do is use 2 detail layouts or more, eg. one for item in grams and another for item in pcs (use the layout condition field to determine which one is printed based on item unit). Then specify the display format of the field differently in those layouts.
Rgds,
Paul
neeraj_vasudeva
18th December 2002, 11:41
Yaah that is ok, i have already done coding where i have got information about the units factor ...now the question is what woud be the syntax for defining the format of tiitm001.copr , so that it is displayed with 2 decimal places as well as also the format where it is displayed without any decimal.
Paul P
18th December 2002, 13:04
Well then, evertsen already provided you a clue in the right direction. Just add more Z if you're not satisfied with his idea.
evertsen
18th December 2002, 16:38
Well... you could try ZZVDZZ in the print format field but if you always need decimals when type grams (even if decimal value is 0) then you could convert to a string (str$), use edit$ or sprintf$ and then convert back to a double (val).
You could also examine use of ROUND and FORMAT.ROUND.
Unfortunately I don't know of a function that will manipulate the format of a double directly but someone else may.
neeraj_vasudeva
18th December 2002, 16:41
yaah i got the hint that the no. of Z will increase and so the no. of the digits to be displayed will increase. Problem is how do i do it in report script ??? I can assin this print format at design level , but how can i do it in coding, so that it is being reflected dynamically ?
evertsen
18th December 2002, 17:51
try this...
in report script:
declaration:
string str.value
double new.format
detail.1: (or whatever the layout is)
before.layout:
if type = grams then
str.value = edit$(tiitm001.copr, "ZZZVD99")
else
str.value = edit$(tiitm001.copr, "ZZZ")
endif
new.format = val(str.value)
in the layout:
replace tiitm001.copr with new.format
**I corrected this post as suggested by csekhar
csekhar
18th December 2002, 18:49
replace tiitm001.copr with new.format not str.val ...
EdHubbard
21st February 2003, 15:36
I tried to follow your instructions here & I can see how it works but I have come across a problem when implementing it.
On the report field screen ttadv3134s000 it asks for a domain or print format and this seems to over write what you have created in the script.
Is there a way to get around this - as in, make the report script formatting be what appears on the report rather than the report field formatting?
mgakhar
21st February 2003, 21:59
WhU can have the print variable to be of type string. And in yur report script manipulate the value of copr so as to either have a deimal or not. Assign this to the string variable being displayed in the report.
Manish