lli-baan
26th July 2002, 10:26
Hi folks

I found this in Baan Help but I need an example. Can anybody help me???

I want to crate a text with a variable. The variable I set in a reportscript.

--------------------------------------------------------------
Variables or expressions that are included in text lines can be expanded or substituted for report purposes. You must set the variable lattr.textexpand=TRUE if you want this to happen. Expressions are internally evaluated by the function expr.compile().

Customers can use variables in texts. For example, "address", "city", "salary" and so on. Customers must be informed about these variables so that they can use them.

Syntax

The following is the syntax for variables and expressions included in text lines:

$variable or #variable

${expression} or #{expression}

When the $ symbol if used, the text moves over to accommodate the expanded variable or expression. When the # symbol is used, the expanded variable or expression overwrites existing text.

Example

The following is an example of text created by using the text manager. The text includes both variables and expressions that can be expanded/substituted for report purposes.

To: $surname $christian name #date , Ede
$address

$ZIP code $city
Dear $christian name:

We have the pleasure of informing you that, as of $date, your salary
has been raised by 5%. For you this implies a gross amount of
${edit( salary + ( salary * 0.05 ), "ZZZZ9,ZZ" )} per month.
Kind regards, $Mgr.

© 1998 Baan Development B.V. All rights reserved

-------------------------------------------------------------------------------

mark_h
26th July 2002, 14:03
All I did to get this to work was to set lattr.textexpand to true in the report script.


field.tdpur040.txta:
before.print:
lattr.textexpand = true
validate.textline()


Then in the purchase order text I could use $tdpur040.orno. So for example I put in the text $tdpur040.orno is long lead material. This allows you to use the report variables in the text.

Hope this helps!

Mark

rmarles
27th January 2005, 19:57
Mark -

Do you have a list of predefined variables that can be expanded upon?
IE (from financial statements:)

$cdat (current date)
$ctim (current time)
$cmpn (company name)
$stds (statement design)

Thanks

mark_h
27th January 2005, 20:28
Not sure if I understand - here are the links to predefined variables on the wiki, one for report (http://www.baanboard.com/programmers_manual_baanerp_help_report_scripts_predefined_variables) and one for scripts (http://www.baanboard.com/programmers_manual_baanerp_help_misc_predefined_variables).

The ones you mentioned I am not familiar with. Are these associated with something specific? You can always run a script in debug mode and use the "L" command to see what all is defined.

Mark

rmarles
27th January 2005, 20:32
Mark

Thanks for the attempt - I have read both those help texts before. Unfortunately they don't really help.

I'm looking for system variables that the system could expand in a report.
For example, the date, the company name, etc.

I looked at one of our financial statments and the header text has the variables mentioned previously attached to them. By printing a statement, I was able to determine what they expanded to.

$cdat (current date)
$ctim (current time)
$cmpn (company name)
$stds (statement design)

I was hoping there were other variables similar.

Thanks!

mark_h
27th January 2005, 21:49
I am not sure these are documented. I searched the wiki and a couple of other places with no success. I do know some of the include files does set some variables and I have never seen documentation on them.

Mark

lbencic
27th January 2005, 22:35
Those variables are available in the Financial Statements because they are declared as external in the Program Script.


|declarations for text manager
extern domain tffst.layt layt
extern domain tffst.ltds ltds
extern domain tffst.stmt stmt
extern domain tffst.stds stds
extern domain tcncmp comp
extern domain tffst.desc cmpn
extern domain tffst.desc cdat
extern domain tffst.desc ctim
extern domain tfgld.user user
extern domain tffst.desc usnm
extern domain tffst.accn accn
extern domain tffst.acds acds
extern domain tffst.subl subl


So, it depends on your calling program. If you declare them as external, or have them in your report script and declared on your Report Input Fields, then you should be able to reference them in the text as $variablename in the text. In theory, anyway, sorry, I have never actually tried.

sudheer
18th October 2012, 11:22
hii mark. . .how would i expand a variable inside the layout
get me the initial declarations to be and also tell me where to use lattr.textexpand and lattr.prline inside program sections.

thanks

mark_h
18th October 2012, 14:51
Your going to have to play with it, we never really used it. But if I recall correctly if you set lattr.textexpand to true - then inside a layout you could use $reportvariable anywhere. I am not sure it matters where you put lattr.textexpand - you can follow the links above to get to the programmers manual and I believe there is an example also.

shah_bs
19th October 2012, 16:30
As Mark mentioned, the lattr.expand = TRUE needs to be placed in the before.program section of the REPORT Script, only once.

Then, the text field needs to be 'painted' in the report layout - for example, in a Sales Invoice, you could have tdsls040.txta in the report layout.

Then, in the TEXT matter of the text of any particular sales order where the variable to be expanded, you would create the text as follows: for example, for printing in a Sales Invoice, you could have text like follow:


These commodities are authorized by the U.S. Government for
export only to ${strip(tcmcs010.dsca)} for use
by ${strip(tccom010.nama)}.


It is assumed that tcmcs010.dsca and tccom010.nama have been read in the PROGRAM script.

Instead of table variables, it is possible to use program variables - obviously, these have to be defined as extern in the PROGRAM script, and included in the field list of the report layout.

Hope this helps.