jatin_sanghi
19th February 2005, 16:41
Hi All,

is it possible to have multiple entries in a multi occurance form through AFS.

for example....i have to make an AFS script for warehouse adjustmants through "tdilc1120m000", here for -ve value of quantity, i have to search through lots for session tdilc1121s000.

Now the problem i'am facing is it enters one lot value and carries out the calculation, but the next lot is not picked if required.

please let me know..if it is possible....and please give me some clues..regarding that..

regards,
Jatin..

mark_h
20th February 2005, 02:08
I have never tried multiple lots for an adjustment. It should work - post your code and maybe someone will see something you can try. Usually I just limit my adjustment to one lot at a time, but I see no reason you could not insert two lots and then process both.

Mark

gettoritesh
20th February 2005, 14:41
Hi..

Thanx Mark for ur reply..

I'am attaching myscript ..actually i got this script from Baanboard only..

Plz..if anybody has some idea regarding this plz..let me know..

Jatin


string error.msg1(100), error.msg2(100), err.msg(100), error.msg
extern domain tcdate curr.dt
long ret, a, strlen
extern domain tcqiv1 stoc, stoc.diff
extern domain tcmcs.long stockpoints, cur.stock.point, no.of.inserts, neg.corr,pos.corr
extern domain tcqiv1 cum.stock, corrected.stock
extern domain tcqiv1 strs(1000),stks(1000)
extern domain tdltc.clot clot(1000)
extern domain tcdate date(1000),sdat(15),idat, first.date.allowed
extern domain tccuni stun(1000)

|****************************** form section **********************************
|form.1:
|init.form:
| get.screen.defaults()

|****************************** choice section ********************************

choice.cont.process:
on.choice:
read.main.table()

|****************************** field section *********************************
|****************************** function section ******************************



functions:
function read.main.table()
{
db.clear.table(ttdjub930)
curr.dt = date.num()
mfile = "c:\stockdata\"&file.f
ret = client2server(mfile, "d:\tools\stock"&file.f , 1)
a = seq.open("d:\tools\stock"&file.f,"r+")

select tdjub929.*
from tdjub929
where tdjub929.file.f = :file.f
selectdo
endselect

if a >= 1 then
seq.gets(data.str,2000,a)
insert.table()
while not seq.eof(a)
seq.gets(data.str,2000,a)
strlen = len(data.str)
insert.table()
endwhile
endif

seq.close(a)

select tdjub930.*
from tdjub930
where tdjub930._index1 = {:file.f, :curr.dt}
and tdjub930.user = :logname$
selectdo

select tdinv001.stoc
from tdinv001
where tdinv001._index1 = {:tdjub930.cwar, :tdjub930.item}
as set with 1 rows
selectdo
stoc.diff = tdjub930.stoc - tdinv001.stoc
endselect

select ticpr300.*
from ticpr300
where ticpr300._index1 inrange {:tdjub930.item, "", 0} and {:tdjub930.item, "ZZZ", :tdjub930.date}
as set with 1 rows
selectdo
if stoc.diff <> 0 then
insert.stoc.corr()
endif
endselect
endselect

}

function insert.table()
{
if not isspace (data.str(1;17)) then
tdjub930.file.f = file.f
tdjub930.date = curr.dt
tdjub930.item = data.str(2;17)
tdjub930.cwar = tdjub929.cwar
tdjub930.grno = tdjub929.grno
tdjub930.user = logname$
mstoc = data.str(23;41)
tdjub930.stoc = val(mstoc)

db.insert(ttdjub930, db.retry, db.skip.dupl)
commit.transaction()
endif
}


function insert.stoc.corr()
{
if insert.warehouse.header() then
if insert.lines.corr() then
stpapi.end.session("tdilc1121s000")
else
stpapi.end.session("tdilc1121s000")
delete.header.corr()
endif
endif

stpapi.end.session("tdilc1120m000")
}


function domain tcmcs.long insert.warehouse.header()
{
stpapi.put.field("tdilc1120m000", "tdinv100.cprj", " ")
stpapi.put.field("tdilc1120m000", "tdinv100.item", tdjub930.item)
stpapi.put.field("tdilc1120m000", "tdinv100.cntr", " ")
stpapi.put.field("tdilc1120m000", "tdinv100.cwar", tdjub930.cwar)
stpapi.put.field("tdilc1120m000", "tdinv100.idat", str$(curr.dt))
stpapi.put.field("tdilc1120m000", "tdinv100.kowt", str$(etol(tckowt.stc.correction)))
stpapi.put.field("tdilc1120m000", "tdinv100.recd", "")
stpapi.put.field("tdilc1120m000", "tdinv100.comp", "999")
stpapi.put.field("tdilc1120m000", "tdinv100.odat", str$(tdjub930.date))
stpapi.put.field("tdilc1120m000", "tdinv100.pdat", str$(tdjub930.date))
stpapi.put.field("tdilc1120m000", "tdinv100.trdt", str$(tdjub930.date))
stpapi.put.field("tdilc1120m000", "tdinv100.pqan", str$(stoc.diff))

ret = stpapi.insert("tdilc1120m000",true,error.msg)
if not ret then
stpapi.recover("tdilc1120m000",error.msg)
else
stpapi.get.field("tdilc1120m000","tdinv100.wrho",morno)
endif
| stpapi.end.session("tdilc1120m000")

return(ret)

}



function domain tcmcs.long delete.header.corr()
{
stpapi.put.field("tdilc1120m000","tdinv100.wrho",morno)
stpapi.find("tdilc1120m000",err.msg)
ret = stpapi.delete("tdilc1120m000",true, error.msg)
if not ret then
stpapi.recover("tdilc1120m000",error.msg)
endif
return(ret)
}



function domain tcmcs.long insert.lines.corr()
{
no.of.inserts = 0
corrected.stock = 0
stpapi.put.field("tdilc1120m000","tdinv100.wrho",morno)
stpapi.find("tdilc1120m000",error.msg1)
stpapi.handle.subproc("tdilc1120m000","tdilc1121s000","add")
stpapi.continue.process("tdilc1120m000",error.msg2)
if not isspace(error.msg1) or not isspace(error.msg2) then
return(false)
endif
if stoc.diff < 0 then
count.stock.points(abs(stoc.diff))
no.of.inserts = 0
for cur.stock.point = 1 to stockpoints
| stpapi.put.field("tdilc1120m000","tdinv100.wrho",morno)
| stpapi.find("tdilc1120m000",error.msg1)
| stpapi.handle.subproc("tdilc1120m000","tdilc1121s000","add")
| stpapi.continue.process("tdilc1120m000",error.msg2)
| if not isspace(error.msg1) or not isspace(error.msg2) then
| return(false)
| endif
stpapi.put.field("tdilc1121s000","tdilc102.date",str$(date(cur.stock.point)))
stpapi.put.field("tdilc1121s000","tdilc102.stun",stun(1,cur.stock.point))
stpapi.put.field("tdilc1121s000","tdilc102.qstr",str$(-1*strs(cur.stock.point)))
stpapi.put.field("tdilc1121s000","tdilc102.qstk",str$(-1*stks(cur.stock.point)))
stpapi.insert("tdilc1121s000",true,err.msg)
if not isspace(err.msg) then
stpapi.recover("tdilc1121s000",err.msg)
break
else
no.of.inserts = no.of.inserts + 1
endif

stpapi.continue.process("tdilc1121s000", error.msg2)

| stpapi.end.session("tdilc1121s000")
| stpapi.end.session("tdilc1120m000")
endfor
endif
if stoc.diff > 0 then
| stpapi.put.field("tdilc1120m000","tdinv100.wrho",morno)
| stpapi.find("tdilc1120m000",error.msg1)
| stpapi.handle.subproc("tdilc1120m000","tdilc1121s000","add")
| stpapi.continue.process("tdilc1120m000",error.msg2)
| if not isspace(error.msg1) or not isspace(error.msg2) then
| return(false)
| endif
stpapi.put.field("tdilc1121s000", "tdilc102.date", str$(curr.dt))
stpapi.put.field("tdilc1121s000", "tdilc102.qstr", str$(stoc.diff))
stpapi.put.field("tdilc1121s000", "tdilc102.qstk", str$(stoc.diff))
ret = stpapi.insert("tdilc1121s000",true,err.msg)
if not ret then
stpapi.recover("tdilc1121s000",err.msg)
else
no.of.inserts = no.of.inserts + 1
endif
endif

return(no.of.inserts)
}


function count.stock.points(domain tcqiv1 quan)
{
cum.stock = 0
stockpoints = 0
select tdilc101.*
from tdilc101
where tdilc101._index4 inrange {:tdjub930.cwar,"",:tdjub930.item}
and {:tdjub930.cwar, "ZZZZZZ", :tdjub930.item}
order by tdilc101._index4 asc
selectdo

if quan >= tdilc101.strs then
stockpoints = stockpoints + 1
load.stock.point.in.internal.table(stockpoints,tdilc101.strs)
if cum.stock = quan then
break
endif
quan = quan - tdilc101.strs
else
stockpoints = stockpoints + 1
load.stock.point.in.internal.table(stockpoints, quan)
break
endif

| if tdilc101.strs => quan then
| stockpoints = 1
| load.stock.point.in.internal.table(stockpoints, quan)
| break
| else
| stockpoints = 1
| if cum.stock < tdilc101.strs then
| cum.stock = tdilc101.strs
| load.stock.point.in.internal.table(stockpoints, cum.stock)
| endif
|
| endif
endselect
}

function load.stock.point.in.internal.table(domain tcmcs.long rec,domain tcqiv1 new.quan)
{
clot(1,rec) = tdilc101.clot
date(rec) = tdilc101.date
stun(1,rec) = tdilc101.stun
strs(rec) = new.quan
stks(rec) = new.quan
}

function domain tcdate get.stock.point.date()
{
select tdilc101.*
from tdilc101
where tdilc101._index4 inrange {:tdjub930.cwar,"",:tdjub930.item}
and {:tdjub930.cwar, "ZZZZZZ", :tdjub930.item}
order by tdilc101._index4 asc
as set with 1 rows
selectdo
return(tdilc101.date)
endselect

return(date.num())
}

kbartelds
21st February 2005, 11:34
Hi,

I'm very pleased to see my script for stock adjustments is being used. The problem with this script is that it was not intended to be used for items with lot control, however it can be changed so lot control can be used, as you did.

In the function insert.lines.corr() I think you have to add the lot field to the api statements, else it might not get any value. You could also check if all stockpoints for the item are found.

Regards,
Klaas

jatin_sanghi
21st February 2005, 14:10
Hi Klaas,

Thanx for ur reply....
and of course for the help i got from ur script.

I have been ablr to successfully fill multiple entries in the tdilc1121s000 form.
I just added one more AFS ststement

stpapi.continue.process("tdilc1121s000", error.msg)

just b'fore the end of "if" condition stock.diff < 1...

Thanx for ur help..

regards,
Jatin