jatin_sanghi
28th February 2005, 17:50
Sir,
I have made an PO upload session...it was working well for direct store purchases as well as central warehouse purchases...
but after adding the dept. loop in my script, the lines stopped to be uploaded..while all other subprocesses are workinh fine...
the scripts doesn't insert tdpur4105s000
and this problem persistes even when i revert back...
plz..help me...
Jatin..
|******************************************************************************
|* tdjub9918mpol 0 VRC B40C c4 jol
|* Upload purchase orders
|* Vivek Bhatt
|* 2005-02-17
|******************************************************************************
|* Main table tdjub906 Preffered supplier by item, Form Type 4
|******************************************************************************
|****************************** declaration section ***************************
declaration:
#pragma nowarnings
#pragma used dll ottstpapihand
table ttdjub906 | Preffered supplier by item
table ttccom020
table ttdpur040
table ttdjub907
table ttcmcs003
table ttdjub983
table ttdjub910
extern domain tcitem item.f
extern domain tcitem item.t
extern domain tcsuno suno.f
extern domain tcsuno suno.t
extern domain tcmcs.str10 dept.f
extern domain tcmcs.str10 dept.t
string errmsg(80), morno(6), mpono(4)
extern long ctr, ret, pono
extern domain tcyesno gen.dsp
extern domain tcqiv1 oqty
extern domain tcgrno series
|****************************** form section **********************************
form.1:
init.form:
get.screen.defaults()
|****************************** choice section ********************************
choice.cont.process:
on.choice:
if gen.dsp = tcyesno.no then
read.main.table()
| db.clear.table(ttdjub907, 0)
else
read.main.table1()
db.clear.table(ttdjub907, 0)
endif
|****************************** field section *********************************
field.suno.f:
when.field.changes:
suno.t = suno.f
field.item.f:
when.field.changes:
item.t = item.f
|****************************** function section ******************************
functions:
function read.main.table()
{
select tccom020.*
from tccom020
where tccom020._index1 inrange {:suno.f}
and {:suno.t}
order by tccom020._index1
selectdo
morno = " "
pono = 0
ctr = 1
select tdjub983.*
from tdjub983
where tdjub983._index1 inrange {"", "ATTR2", :dept.f} and {"ZZZ", "ATTR2", :dept.t}
order by tdjub983._index1
selectdo
get.series()
select tdjub906.*
from tdjub906 for update
where tdjub906._index3 inrange {0, :tdjub983.atcd, ""}
and {999999, :tdjub983.atcd, "ZZZZZZZZZZZZZZZZ"}
and tdjub906.suno = :tccom020.suno
selectdo
oqty = tdjub906.cwh.qty + (tdjub906.kor.qty - tdjub906.aloc.kor) + (tdjub906.jpn.qty - tdjub906.aloc.jpn) + (tdjub906.ind.qty - tdjub906.aloc.ind)
insert_order()
stpapi.end.session("tdind0271s000")
stpapi.end.session("tdpur4101m000")
oqty = 0
tdjub906.orno = lval(morno)
tdjub906.odat = date.num()
db.update(ttdjub906, db.retry)
commit.transaction()
endselect
stpapi.end.session("tdpur4105s000")
stpapi.end.session("tdpur4101m000")
endselect
endselect
}
function read.main.table1()
{
select tccom020.*
from tccom020
where tccom020._index1 inrange {:suno.f}
and {:suno.t}
order by tccom020._index1
selectdo
select tdjub983.*
from tdjub983
where tdjub983._index1 inrange {"", "ATTR2", :dept.f} and {"ZZZ", "ATTR2", :dept.t}
order by tdjub983._index1
selectdo
get.series()
select tcmcs003.*
from tcmcs003
where ((tcmcs003._index1 = {"KOR"})
or (tcmcs003._index1 = {"IND"})
or (tcmcs003._index1 = {"JPN"})
or (tcmcs003._index1 = {"CWH"}))
order by tcmcs003._index1
selectdo
morno = " "
pono = 0
ctr = 1
select tdjub907.*
from tdjub907
where tdjub907._index1 = {:tccom020.suno, :tcmcs003.cwar}
and tdjub907.dept = :tdjub983.atcd
selectdo
insert_order1()
stpapi.end.session("tdind0271s000")
stpapi.end.session("tdpur4101m000")
| tdjub907.oqty = oqty
| tdjub907.orno = lval(morno)
| tdjub907.odat = date.num()
| db.update(ttdjub907, db.retry)
| commit.transaction()
oqty = 0
endselect
stpapi.end.session("tdpur4105s000")
stpapi.end.session("tdpur4101m000")
endselect
endselect
endselect
}
function void insert_order()
{
if ctr = 1 then
stpapi.put.field("tdpur4101m000", "tdpur040.orno", str$(series))
stpapi.put.field("tdpur4101m000", "tdpur040.suno", str$(tccom020.suno))
stpapi.put.field("tdpur4101m000", "tdpur040.cotp", "M2S")
stpapi.put.field("tdpur4101m000", "tdpur040.comp", "150")
stpapi.put.field("tdpur4101m000", "tdpur040.odat", str$(date.num()))
stpapi.handle.subproc("tdpur4101m000", "tdpurl102s002", "add")
stpapi.insert("tdpurl102s002", true, errmsg)
stpapi.end.session("tdpurl102s002")
stpapi.put.field("tdpur4101m000", "tdpur040.ddat", str$(date.num()))
stpapi.insert("tdpur4101m000",true,errmsg)
stpapi.get.field("tdpur4101m000", "tdpur040.orno", morno)
stpapi.end.session("tdpur4101m000")
ctr = 0
endif
pono = lval(mpono) + 1
mpono = str$(pono)
stpapi.put.field("tdpur4101m000","tdpur040.orno", morno)
stpapi.find("tdpur4101m000", errmsg)
if isspace(errmsg) then
stpapi.handle.subproc("tdpur4101m000", "tdpur4105s000", "add")
stpapi.continue.process("tdpur4101m000",errmsg)
if isspace(errmsg) then
| stpapi.put.field("tdpur4105s000","tdpur041.pono", mpono)
stpapi.put.field("tdpur4105s000","tdpur041.item", tdjub906.item)
stpapi.put.field("tdpur4105s000","tdpur041.cwar","CWH")
stpapi.put.field("tdpur4105s000","tdpur041.oqua",str$(oqty))
stpapi.handle.subproc("tdpur4105s000", "tdind0271s000", "add")
stpapi.put.field("tdind0271s000", "tdind020.bdat", str$(date.num()))
stpapi.put.field("tdind0271s000", "tdind020.exci", str$(etol(tcyesno.no)))
stpapi.put.field("tdind0271s000", "tdind020.svyn", str$(etol(tcyesno.no)))
stpapi.put.field("tdind0271s000", "tdind020.ocyn", str$(etol(tcyesno.no)))
stpapi.insert("tdind0271s000", true, errmsg)
stpapi.end.session("tdind0271s000")
ret = stpapi.insert("tdpur4105s000", true, errmsg)
if not ret then
stpapi.recover("tdpur4105s000", errmsg)
endif
stpapi.end.session("tdind0271s000")
if isspace(errmsg) then
stpapi.end.session("tdpur4105s000")
endif
endif
endif
}
function void insert_order1()
{
if ctr = 1 then
stpapi.put.field("tdpur4101m000", "tdpur040.orno", str$(series))
stpapi.put.field("tdpur4101m000", "tdpur040.suno", str$(tdjub907.suno))
stpapi.put.field("tdpur4101m000", "tdpur040.cotp", "DIT")
stpapi.put.field("tdpur4101m000", "tdpur040.comp", "150")
stpapi.put.field("tdpur4101m000", "tdpur040.odat", str$(date.num()))
stpapi.handle.subproc("tdpur4101m000", "tdpurl102s002", "add")
stpapi.insert("tdpurl102s002", true, errmsg)
stpapi.end.session("tdpurl102s002")
stpapi.put.field("tdpur4101m000", "tdpur040.ddat", str$(date.num()))
stpapi.insert("tdpur4101m000",true,errmsg)
stpapi.get.field("tdpur4101m000", "tdpur040.orno", morno)
stpapi.end.session("tdpur4101m000")
ctr = 0
endif
pono = lval(mpono) + 1
mpono = str$(pono)
stpapi.put.field("tdpur4101m000","tdpur040.orno", morno)
stpapi.find("tdpur4101m000", errmsg)
if isspace(errmsg) then
stpapi.handle.subproc("tdpur4101m000", "tdpur4105s000", "add")
stpapi.continue.process("tdpur4101m000",errmsg)
if isspace(errmsg) then
stpapi.put.field("tdpur4105s000","tdpur041.pono", mpono)
stpapi.put.field("tdpur4105s000","tdpur041.item", tdjub907.item)
stpapi.put.field("tdpur4105s000","tdpur041.cwar",tdjub907.cwar)
stpapi.put.field("tdpur4105s000","tdpur041.oqua",str$(tdjub907.oqty))
stpapi.handle.subproc("tdpur4105s000", "tdind0271s000", "add")
stpapi.put.field("tdind0271s000", "tdind020.bdat", str$(date.num()))
stpapi.put.field("tdind0271s000", "tdind020.exci", str$(etol(tcyesno.no)))
stpapi.put.field("tdind0271s000", "tdind020.svyn", str$(etol(tcyesno.no)))
stpapi.put.field("tdind0271s000", "tdind020.ocyn", str$(etol(tcyesno.no)))
stpapi.insert("tdind0271s000", true, errmsg)
stpapi.end.session("tdind0271s000")
ret = stpapi.insert("tdpur4105s000", true, errmsg)
if not ret then
stpapi.recover("tdpur4105s000", errmsg)
endif
stpapi.end.session("tdind0271s000")
if isspace(errmsg) then
stpapi.end.session("tdpur4105s000")
endif
endif
endif
}
function get.series()
{
select tdjub910.series
from tdjub910
where tdjub910._index2 = {:tdjub983.atcd}
as set with 1 rows
selectdo
series = tdjub910.series
endselect
}
I have made an PO upload session...it was working well for direct store purchases as well as central warehouse purchases...
but after adding the dept. loop in my script, the lines stopped to be uploaded..while all other subprocesses are workinh fine...
the scripts doesn't insert tdpur4105s000
and this problem persistes even when i revert back...
plz..help me...
Jatin..
|******************************************************************************
|* tdjub9918mpol 0 VRC B40C c4 jol
|* Upload purchase orders
|* Vivek Bhatt
|* 2005-02-17
|******************************************************************************
|* Main table tdjub906 Preffered supplier by item, Form Type 4
|******************************************************************************
|****************************** declaration section ***************************
declaration:
#pragma nowarnings
#pragma used dll ottstpapihand
table ttdjub906 | Preffered supplier by item
table ttccom020
table ttdpur040
table ttdjub907
table ttcmcs003
table ttdjub983
table ttdjub910
extern domain tcitem item.f
extern domain tcitem item.t
extern domain tcsuno suno.f
extern domain tcsuno suno.t
extern domain tcmcs.str10 dept.f
extern domain tcmcs.str10 dept.t
string errmsg(80), morno(6), mpono(4)
extern long ctr, ret, pono
extern domain tcyesno gen.dsp
extern domain tcqiv1 oqty
extern domain tcgrno series
|****************************** form section **********************************
form.1:
init.form:
get.screen.defaults()
|****************************** choice section ********************************
choice.cont.process:
on.choice:
if gen.dsp = tcyesno.no then
read.main.table()
| db.clear.table(ttdjub907, 0)
else
read.main.table1()
db.clear.table(ttdjub907, 0)
endif
|****************************** field section *********************************
field.suno.f:
when.field.changes:
suno.t = suno.f
field.item.f:
when.field.changes:
item.t = item.f
|****************************** function section ******************************
functions:
function read.main.table()
{
select tccom020.*
from tccom020
where tccom020._index1 inrange {:suno.f}
and {:suno.t}
order by tccom020._index1
selectdo
morno = " "
pono = 0
ctr = 1
select tdjub983.*
from tdjub983
where tdjub983._index1 inrange {"", "ATTR2", :dept.f} and {"ZZZ", "ATTR2", :dept.t}
order by tdjub983._index1
selectdo
get.series()
select tdjub906.*
from tdjub906 for update
where tdjub906._index3 inrange {0, :tdjub983.atcd, ""}
and {999999, :tdjub983.atcd, "ZZZZZZZZZZZZZZZZ"}
and tdjub906.suno = :tccom020.suno
selectdo
oqty = tdjub906.cwh.qty + (tdjub906.kor.qty - tdjub906.aloc.kor) + (tdjub906.jpn.qty - tdjub906.aloc.jpn) + (tdjub906.ind.qty - tdjub906.aloc.ind)
insert_order()
stpapi.end.session("tdind0271s000")
stpapi.end.session("tdpur4101m000")
oqty = 0
tdjub906.orno = lval(morno)
tdjub906.odat = date.num()
db.update(ttdjub906, db.retry)
commit.transaction()
endselect
stpapi.end.session("tdpur4105s000")
stpapi.end.session("tdpur4101m000")
endselect
endselect
}
function read.main.table1()
{
select tccom020.*
from tccom020
where tccom020._index1 inrange {:suno.f}
and {:suno.t}
order by tccom020._index1
selectdo
select tdjub983.*
from tdjub983
where tdjub983._index1 inrange {"", "ATTR2", :dept.f} and {"ZZZ", "ATTR2", :dept.t}
order by tdjub983._index1
selectdo
get.series()
select tcmcs003.*
from tcmcs003
where ((tcmcs003._index1 = {"KOR"})
or (tcmcs003._index1 = {"IND"})
or (tcmcs003._index1 = {"JPN"})
or (tcmcs003._index1 = {"CWH"}))
order by tcmcs003._index1
selectdo
morno = " "
pono = 0
ctr = 1
select tdjub907.*
from tdjub907
where tdjub907._index1 = {:tccom020.suno, :tcmcs003.cwar}
and tdjub907.dept = :tdjub983.atcd
selectdo
insert_order1()
stpapi.end.session("tdind0271s000")
stpapi.end.session("tdpur4101m000")
| tdjub907.oqty = oqty
| tdjub907.orno = lval(morno)
| tdjub907.odat = date.num()
| db.update(ttdjub907, db.retry)
| commit.transaction()
oqty = 0
endselect
stpapi.end.session("tdpur4105s000")
stpapi.end.session("tdpur4101m000")
endselect
endselect
endselect
}
function void insert_order()
{
if ctr = 1 then
stpapi.put.field("tdpur4101m000", "tdpur040.orno", str$(series))
stpapi.put.field("tdpur4101m000", "tdpur040.suno", str$(tccom020.suno))
stpapi.put.field("tdpur4101m000", "tdpur040.cotp", "M2S")
stpapi.put.field("tdpur4101m000", "tdpur040.comp", "150")
stpapi.put.field("tdpur4101m000", "tdpur040.odat", str$(date.num()))
stpapi.handle.subproc("tdpur4101m000", "tdpurl102s002", "add")
stpapi.insert("tdpurl102s002", true, errmsg)
stpapi.end.session("tdpurl102s002")
stpapi.put.field("tdpur4101m000", "tdpur040.ddat", str$(date.num()))
stpapi.insert("tdpur4101m000",true,errmsg)
stpapi.get.field("tdpur4101m000", "tdpur040.orno", morno)
stpapi.end.session("tdpur4101m000")
ctr = 0
endif
pono = lval(mpono) + 1
mpono = str$(pono)
stpapi.put.field("tdpur4101m000","tdpur040.orno", morno)
stpapi.find("tdpur4101m000", errmsg)
if isspace(errmsg) then
stpapi.handle.subproc("tdpur4101m000", "tdpur4105s000", "add")
stpapi.continue.process("tdpur4101m000",errmsg)
if isspace(errmsg) then
| stpapi.put.field("tdpur4105s000","tdpur041.pono", mpono)
stpapi.put.field("tdpur4105s000","tdpur041.item", tdjub906.item)
stpapi.put.field("tdpur4105s000","tdpur041.cwar","CWH")
stpapi.put.field("tdpur4105s000","tdpur041.oqua",str$(oqty))
stpapi.handle.subproc("tdpur4105s000", "tdind0271s000", "add")
stpapi.put.field("tdind0271s000", "tdind020.bdat", str$(date.num()))
stpapi.put.field("tdind0271s000", "tdind020.exci", str$(etol(tcyesno.no)))
stpapi.put.field("tdind0271s000", "tdind020.svyn", str$(etol(tcyesno.no)))
stpapi.put.field("tdind0271s000", "tdind020.ocyn", str$(etol(tcyesno.no)))
stpapi.insert("tdind0271s000", true, errmsg)
stpapi.end.session("tdind0271s000")
ret = stpapi.insert("tdpur4105s000", true, errmsg)
if not ret then
stpapi.recover("tdpur4105s000", errmsg)
endif
stpapi.end.session("tdind0271s000")
if isspace(errmsg) then
stpapi.end.session("tdpur4105s000")
endif
endif
endif
}
function void insert_order1()
{
if ctr = 1 then
stpapi.put.field("tdpur4101m000", "tdpur040.orno", str$(series))
stpapi.put.field("tdpur4101m000", "tdpur040.suno", str$(tdjub907.suno))
stpapi.put.field("tdpur4101m000", "tdpur040.cotp", "DIT")
stpapi.put.field("tdpur4101m000", "tdpur040.comp", "150")
stpapi.put.field("tdpur4101m000", "tdpur040.odat", str$(date.num()))
stpapi.handle.subproc("tdpur4101m000", "tdpurl102s002", "add")
stpapi.insert("tdpurl102s002", true, errmsg)
stpapi.end.session("tdpurl102s002")
stpapi.put.field("tdpur4101m000", "tdpur040.ddat", str$(date.num()))
stpapi.insert("tdpur4101m000",true,errmsg)
stpapi.get.field("tdpur4101m000", "tdpur040.orno", morno)
stpapi.end.session("tdpur4101m000")
ctr = 0
endif
pono = lval(mpono) + 1
mpono = str$(pono)
stpapi.put.field("tdpur4101m000","tdpur040.orno", morno)
stpapi.find("tdpur4101m000", errmsg)
if isspace(errmsg) then
stpapi.handle.subproc("tdpur4101m000", "tdpur4105s000", "add")
stpapi.continue.process("tdpur4101m000",errmsg)
if isspace(errmsg) then
stpapi.put.field("tdpur4105s000","tdpur041.pono", mpono)
stpapi.put.field("tdpur4105s000","tdpur041.item", tdjub907.item)
stpapi.put.field("tdpur4105s000","tdpur041.cwar",tdjub907.cwar)
stpapi.put.field("tdpur4105s000","tdpur041.oqua",str$(tdjub907.oqty))
stpapi.handle.subproc("tdpur4105s000", "tdind0271s000", "add")
stpapi.put.field("tdind0271s000", "tdind020.bdat", str$(date.num()))
stpapi.put.field("tdind0271s000", "tdind020.exci", str$(etol(tcyesno.no)))
stpapi.put.field("tdind0271s000", "tdind020.svyn", str$(etol(tcyesno.no)))
stpapi.put.field("tdind0271s000", "tdind020.ocyn", str$(etol(tcyesno.no)))
stpapi.insert("tdind0271s000", true, errmsg)
stpapi.end.session("tdind0271s000")
ret = stpapi.insert("tdpur4105s000", true, errmsg)
if not ret then
stpapi.recover("tdpur4105s000", errmsg)
endif
stpapi.end.session("tdind0271s000")
if isspace(errmsg) then
stpapi.end.session("tdpur4105s000")
endif
endif
endif
}
function get.series()
{
select tdjub910.series
from tdjub910
where tdjub910._index2 = {:tdjub983.atcd}
as set with 1 rows
selectdo
series = tdjub910.series
endselect
}