FrenkR
26th April 2016, 21:26
in DAL I can use dal.get.object() without declaring table. It is easy to set field values via dal.set.field().
After calling dal.save.object(), I would like to get some field values back from DAL. Is there any function to retrieve data from dal ( something like stpapi.get.field() in AFS ) WITHOUT declaring table and using BaanSQL?
Ajesh
27th April 2016, 05:50
If you want to get the field values from the same Table then you need not execute BaanSQL or any other method, You will get the field values of the same Table which is stored in the buffer.Something like
dal.set.field("tdsls870.pono",pono)
result = dal.save.object("tdsls870")
hold.ttyp = tdsls870.ttyp
FrenkR
4th May 2016, 16:14
But I don't have table declared, because I know table name at compile time. So I need access to this buffer WITHOUT declaring table and using BaanSQL
bhushanchanda
4th May 2016, 17:10
Hi,
Probably, you can try passing the table name to the DAL using export or declaring a global variable.
If you want to access some fields of a table which is going to be known at runtime and field which you know then you can probably use dynamic SQL using the commands sql.parse,sql.select.bind,sql.where.bind,sql.execute,sql.fetch etc.
FrenkR
5th May 2016, 11:15
this works for tables that doesn't have key generator. For tables with generator, e.g. Sales Order, PUR order, etc. you just put data and before dealing with fields, you need KEY first.
Maybe we have to do some brainstorming on initial idea again. Basic question is, does "dal.get.object()" create "accessible" buffer. If yes, then question is how to access it. I hardly believe that this buffer doesn't exist internally(DAL needs it for its operation).
Forget dal.get.object for some time, what is your original requirement? Maybe someone can suggest an alternative solution.
FrenkR
5th May 2016, 15:42
this is original request. adding records to tables via dal.new.object() without table definition and after DAL successfully adds a new record, getting KEY value from this particular "insert".
You mentioned the AFS command of stpapi.get.field, but even in that command you know the domain of the field which you want to extract, you know the field basically and its not hunting in the dark.
But still if you want the value of key field of the record inserted, you need to pass the string to a dynamic sql and then get key fields of that particular table from the "Indices tables" and once you get it then you get the value of the key fields again from a dynamic SQL on the table in which the record was just inserted. Thats all i can think of.
hklett
5th May 2016, 18:52
Maybee this can help
http://www.baanboard.com/baanboard/showthread.php?t=68590
FrenkR
6th May 2016, 02:06
thanks for this one. But here only table "metadata" is described(table structure, names, types).
FrenkR
6th May 2016, 02:18
I will make an example:
long ret
db.retry.point()
ret = dal.new.object("tdsls400")
if (ret = 0) then
dal.set.field("tdsls400.ofbp", "100000001")
ret = dal.save.object("tdsls400") | header is successfully saved
endif
if ret = 0
commit.transaction()
else
rollback.transaction()
endif
| ? question here - how to read "tdsls400.orno" ?
note that there is no declaration, because dal.new.object() doesn't need it:
table ttdsls400
question is, how to access tdsls400 "buffer" to get values, that are filled from DAL. I can't make dynamic SQL because there I have no key of newly inserted record(it is automatically filled by DAL on save() command).
My best shot would be assuming that dal.new.object() must have record buffer. Is there any (hidden) function to access it and read field values?
vahdani
6th May 2016, 19:20
Hi,
you say there is no declaration, because dal.new.object() doesn't need it But you need it yourself: Then just declare the table:rolleyes:
bhushanchanda
6th May 2016, 22:25
Just in case you need, try get.var()
e.g.
domain tcorno
get.var(pid,"tdsls400.orno",orno)
Again, this would work if you have the table name. But you can put checks on orno variable and keep fetching the values from all the required tables until its not empty.
Though, not sure why you do not want to declare the table.
FrenkR
6th May 2016, 22:46
amazing. get.var() did the trick. Thank you :)
Premahari
30th March 2018, 13:32
Hi Iam trying to create sales order using dal. I gave the discount percent. But its not taking the discount percent while calculating the net line amount.
dal.set.field("tdsls401.disc", disc.perc1,1)
dal.set.field("tdsls401.dmth", tddmth.net)