VTCSdude
23rd May 2007, 15:38
in "Maintain Table Fields" each field is given a number in addition to a a Field Name. Is there a way to access the table data using the number.
E.g. Say I have table tilit030.
Is there a way to access the 9th field in tilit030 in a script by doing something similar to tilit030[9]?
Let me know.
mark_h
23rd May 2007, 16:15
Are you talking in a baan script? I am not aware of anything that would work like you suggested. But if you have the table and the number you could look up the table name and number on ttadv422, then use dynamic sql to build your query.
VTCSdude
23rd May 2007, 17:36
Yeah I do mean in a script. Basically I have 25 fields and in some cases they aren't all used. So to determine where the cut off is I want to be able to write a while loop to check field1-field25, instead of having to write each an individual if then to check if they are blank.
I can do it by using ifs to check every single element, just if I could reference the elements by number I could write cleaner code.
george7a
23rd May 2007, 17:51
Hi,
As Mark suggested, you can write a dynamic SQL (http://www.baanboard.com/programmers_manual_baanerp_help_functions_database_handling_dynamic_sql) to get all the field names depending on ttadv422 (Table Fields). After each fetch the SQL will return the field name and you can check if it is empty or not in a loop.
- George
NPRao
23rd May 2007, 22:24
I differ with Mark and George's suggestion, that you would then have to do the Package Combination & VRC based search where the table definition is present and its present, expired or not found.
I suggest to use the functions - rdi.table() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_runtime_dictionary_information_rdi_table) to get the number of columns, then use a for loop, with rdi.table.column() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_runtime_dictionary_information_rdi_table_column) to get the column name to go through all the fields or else just use the rdi.table.column() with a number to get the table-field-name and its properties and build your query string for the dynamic sql. In that way you do not have to worry about the VRC search algorithm for Table Definition based on current Package Combination.
Hitesh Shah
24th May 2007, 15:48
If u need ready code for such functions , u can go through rdi functions for general table routines (http://www.baanboard.com/baanboard/showthread.php?t=24217&highlight=tblfl).
If I recollect it , actual column offset for the table starts from 5 (comparing with 1 in ttadv422) . U can debug the functions in the code. to get accurate info.
vahdani
24th May 2007, 16:50
Hi VTCSDude!
I see you are new to the forum. I was just wondering if you are also a newbie in Baan programming. In that case maybe you are not aware of the possibility of defining array fields in Baan tables.:rolleyes: An array field is the standard solution in Baan for your kind of requirement. Your define a field say tilit030.amnt with a depth of 25. then you can use this field in your script as follows:
select amnt
from tilit030
where ......
selectdo
tot.amount = 0
for i = 1 to 25
tot.amount = tot.amount + tilit030.amnt(i)
if tilit030.amnt(i) = 0 then
break
endif
endfor
endselect
VTCSdude
24th May 2007, 21:09
Yeah, Im basically a newb. I'm doing some work in BaaN for a summer job between semesters at Virginia Tech.
I'm really most firmiliar with C++, PHP, and the .Net languages. So BaaN scripting is a little different for me, I'm learning though. Thanks for all the help.
kathuria
25th May 2007, 16:00
Hi,
That is not possible in baan like other $GL language. You can find each and every syntex of SQL statement in baan standard help. This help is very good for BaaN SQL.
Regards,
Sanjay