obermar
9th December 2010, 17:38
Is there a possibility to print the value of a column field stored in a variable?
In more detail
First I have a "select whinh310.rcno, ... from whinh310 ..."
Then I have a configuration table containing the name of the column + some additional information to be printed e.g. a counter 1,
so whinh310.rcno and 1
Now I would like to print
Counter + content of whinh310.rcno, example 1=REC218998 - is there a possibility/command to print this?
Many thanks in advance
Markus
bdittmar
9th December 2010, 19:48
Is there a possibility to print the value of a column field stored in a variable?
In more detail
First I have a "select whinh310.rcno, ... from whinh310 ..."
Then I have a configuration table containing the name of the column + some additional information to be printed e.g. a counter 1,
so whinh310.rcno and 1
Now I would like to print
Counter + content of whinh310.rcno, example 1=REC218998 - is there a possibility/command to print this?
Many thanks in advance
Markus
Hello,
In reportt script define a variable like:
extern domain tcmcs.str15 vari
and concatenate like:
vari = strip$(str$(counter)&"="&whinh310.rcno)
Regards
obermar
9th December 2010, 23:47
Bernd
thank you for your answer. But I think I described my problem not good enaugh.
For a DMS system I have to write/print certain information (per row ID of the DMS + content of certain table fields) for several sessions to a file. In order to make that really dynamic I would like to have a configuration table that is linking the table columns to a certain number/ID i.e.
Session ID Column
whinh3512m800 1 whinh310.rcno
whinh3512m800 3 whinh310.dino
whinh3512m800 5 whinh310....
In the future I will also have additional sessions that should be maintained in that table too.
Through a dynamic SQL statement (information needed for that is stored in an other config table) I have the content of all table fields available - now I would like to print/write to file using the information I have in the above configuration table.
I read the content of the config table with a select therefore I have the column then in a variable. But the information I have to print is 1="value of column field" therefore I would need a possibility to get the value of the column field in the var. And as it should be really dynamic in order to be able to use the session for all kinds of sessions I would not like to use fix names as in your example as it would not allow me to solve also future requests with simple configuration in the two tables I have.
I could immagine two possible solutions so far - but don't know if it works at all
1) is there a possibility to get the value of a variable stored in a variable?
2) there is the possibility to create the part of e.g. the sprintf$ function that is in () as a string?
Many thanks
Markus
BaanInOhio
10th December 2010, 20:30
Take a look at 'put.var':
extern domain tcmcs.str18 field.name
extern domain tcmcs.str30 field.contents
long ret
field.name = "tdsls040.refa"
field.contents = "this was added using put.var"
ret = put.var(pid, field.name, field.contents)
'pid' is a predefined variable identifying the current session. 'field.contents' can have a different data type than the field in 'field.name'. A conversion is automatically done during the load. You will need additional logic to convert enums and dates. You can determine the type in field in 'field.name' using 'rdi.column'.
You can dynamically read fields using a similar method. Both the 'field.name' and 'field.contents' must be declared external, unless a table field which is declared extern by default.
Hitesh Shah
14th December 2010, 17:45
I could immagine two possible solutions so far - but don't know if it works at all
1) is there a possibility to get the value of a variable stored in a variable?
2) there is the possibility to create the part of e.g. the sprintf$ function that is in () as a string?
Many thanks
Markus
1. Certainly U can do so. Use function expr.compile , s.expr$ , d.expr etc to create and evaluate variables and expressions dynamically. Lots of goods code samples on this board for expr.compile .
2. Certainly u can use may functions (like val , edit , str, date , log etc ) in expr.compile but not the sprintf$ as such . Please see the function help in detail for this .
obermar
21st December 2010, 12:03
Hello Hitesh,
thank you for your help, expr.compile and associated functions are exactly the ones I was looking for