dbinderbr
16th September 2002, 18:08
Hello there,
I am trying to do some unusual programming, but I believe it's possible to do it in tools like I did in another languages.
I intend to take some actions at run-time according to some information and parameters passed by the user.
I'd like to know, for example, if it's possible to declare a variable at run-time or to attribute a value to a table field.
I will try to explain better bellow.
Suppose I can choose any table in the form and write some data to it. For example, I chose the tiitm001 and would like to insert the item "000009".
Using dynamic SQL I could check if the record already exist and do other operations, but, how could I attribute a value to the table field tiitm001.item? Note, until run-time I didnt know which table or field I would treat, so I have to write the instruction table.field = some.value at run-time using the data entered in the form.
Using the variable with the name of the table entered in the form by the user I would be able to take the field names in the ttadv422, but how could I represent this kind of things in the script,
any.table.field.from.ttadv422 = any.data
Is it possible to do it in Baan Tools?
Guillaume.G
16th September 2002, 18:44
It's possible With the AFS Technologie. I make the same developpement what you want.
But with AFS, it's not possible to use the table name but the session which maintain the table (for example tiitm0101m000 for tiitm001)
And it's only possible to update the input field which in the form of the session
And the AFS ''simulate" the standard session.
You can see a copy of form in attach file.
I think it's very good, because the fonctionnal intigrity of the data is ok because the program of the session is executed.
dbinderbr
16th September 2002, 19:45
Thanks Guillaume !!
Can you tell me where I can find documents about AFS technology or just a simple example?
Thanks a lot.
NPRao
16th September 2002, 20:24
Daniel,
You have 2 options -
1. Use AFS as Guillaume suggested. There is a separate section with examples and documents in the forum. Please refer and search at -
AFS/DDC/OLE: Function servers (http://www.baanboard.com/baanboard/forumdisplay.php?s=&forumid=59)
2. Use expression compilers - l.expr(), d.expr(), or s.expr$().
http://www.baanboard.com/programmers_manual_baanerp_help_functions_expressions_runtime_expr_compile
Guillaume.G
17th September 2002, 10:42
Hi Daniel
In the zip file, you find :
- the AFS documentation
- the Script of my session
- the copy of the forms
My session simulate the session for updating data of all tables.
Limitations : it's only for update the data. The insert is impossible at the moment.
An other version of this session reading a xml file which containt the definition of data (session name, index field, field updating and data)
For the AFS you can find lot of information in the thread DDC/AFS/... see the reply of Nprao
Guillaume
Best Regard
dbinderbr
17th September 2002, 15:42
Thanks Guillaume and NPRao !!
I will be evaluating both options to see which one best fits in my case, but, both of them are very useful in many situations !
After trying to use these solutions I will post the results ok.
Thanks a lot.
dbinderbr
18th September 2002, 22:14
Hello there,
I designed two simple sessions and a table to test the ASF functions.
But, I had some problems. It always inserts a blank record !!
I have created a table with the fields listed bellow:
- table: tudcb900
-> Code: tudcb900.codi.o - tcmcs.long
-> Name: tudcb900.nome.o - tcmcs.str50
-> Phone: tudcb900.fone - tcmcs.str15
There are only these fields, no relations, no conditions, no mandatory fields, nothing special at all.
The sessions: one that calls the maintain session of the table mentioned above containing the AFS functions. There are nothing special used in these sessions, the maintain session of the table tudcb900 has a script only with the table declaration, nothing else.
The script that has the AFS functions I have posted as an attachment with the log file generated by the execution.
I dont know what to do... I've tried everything, apparently I wrote the script following percfectly the AFS manual.
Thanks in advance.
Guillaume.G
25th September 2002, 10:20
Hi Daniel
I try your script (with the same table and same script) and the result is good. The AFS insert the record ans in the second pass the message is "the record already exist"
I think that you have not the last version of ttstpapihand.
The minimum solution for use the AFS without bugg is : 126067 and the last solution is 127443.
I have the solution 126067 in my system and is very good.
For know your version of ttstpapihand, you can use the bic_info utility.
Best regard
Guillaume.
dbinderbr
25th September 2002, 22:54
This problem was solved by installing the solution 115279. It has some dependencies, so, probably you'll have to previously install some other solutions.
More details about the journey I had to solve this problem is available in the thread:
6771 (http://www.baanboard.com/baanboard/showthread.php?s=&threadid=6771)
JaapJD
1st October 2002, 14:19
The original question was how to point to fields dynamically at runtime and give them a value.
The first thing you have to know which table fields belong to a table. You can use the rdi.table(.column) functions. Once you know the fieldnames, you can give them a value using the function put.var.
Example:
field.name = "tiitm001.item"
put.var(pid, field.name, "MYVALUE")
Regards,
Jaap
dbinderbr
1st October 2002, 19:56
Hi Jaap !!
Yes, my original question didnt have any relation with AFS but as AFS was also interesting to me, the subject changed completely.
I was still needing the information you have posted !!!
Probably put.var will solve my problem.
Thank you very much.
lsatenstein
3rd October 2002, 22:34
I had the task of having a variable number of items in arrays of data and also of dynamically deciding on a table and doing an insert at run time.
The easy solution.... dynamic sql.
I determined my requirements, allocated memory for the strings that were the sql statements and then did the sql.parse() etc.
Worked out well, and very effective/efficient.
Support for enhancements and changes are easy too.
dbinderbr
4th October 2002, 16:24
Hello Leslie,
I was already using dynamic sql to read the table the user had chosen, it's really the easiest way. But, besides reading the information I also had to write it dynamically to certain fields. In this case, the use of put.var, get.var, etc. together with the dynamic SQL was very useful and pratical.
Have a nice weekend.