en@frrom
26th October 2010, 15:12
Can someone help me with the following:

I need to upload data into tables tffam100 & tffam110, and need to also create records in tffam120. In tffam120 I need to find/assemble the correct Asset Distribution Key (DKEY) & Location Key (LKEY).

Does anyone know the correct logic to assemble those field values? Is there a standard Baan DLL function?

Thanks in advance!

SujithKumar
26th October 2010, 20:45
You took me back to memory lines! I did the fixed asset migration from Old Vax system to Baan 5c, including the assets which are partially depreciated - 8 years ago!
1) tffam120.dkey is a running sequence number so you can increment the counter and update it
2) lkey refers to tffam500 (location codes), you can create the locations there and use the key in fam120. I loaded them to a default location first and then through another update split to necessary locations

=== Here are some functions i used 8 years ago
This is the first function, which does Initial load. Initially lkey was set to a default value 98
function update.asset.distribution()
{
long count1
count1 = 20100
select tffam100.*
from tffam100
where not exists ( select tffam120.*
from tffam120
where tffam120.anbr = tffam100.anbr
and tffam120.aext = tffam100.aext)

selectdo
count1 = count1 + 1
tffam120.anbr = tffam100.anbr
tffam120.aext = tffam100.aext
tffam120.dkey = count1
tffam120.comp = 600
tffam120.lkey = 98
tffam120.srce = tffam.srce.inte
tffam120.dqty = 1
db.insert(ttffam120, db.retry)
commit.transaction()
endselect
message("%d", count1)
}

second update, correcting the locations
function update.asset.distr()
{
long count1, count2

db.retry.point()

select tffam120.*, tffam955.*
from tffam120 for update, tffam955
where tffam120._index1 inrange {:anum.f, :suff.f}
and {:anum.t, :suff.t}
and (tffam120.lkey = 138 or tffam120.lkey = 98)
and tffam120.anbr = tffam955.anum
and tffam120.aext = tffam955.suff
selectdo
on case tffam955.edpt
case "5622":
tffam120.lkey = 99
break

case "5624":
case "5643":
tffam120.lkey = 139
break

case "5637":
tffam120.lkey = 100
break

case "5638":
tffam120.lkey = 101
break

case "5645":
tffam120.lkey = 141
break
break
endcase
count1 = count1 + 1
count2 = count2 + 1
db.update(ttffam120, db.retry)
if count1 > 50 then
commit.transaction()
count1 = 0
endif

endselect
commit.transaction()
message("%d", count2)
}