umadevi
14th September 2009, 11:55
Dear All,

Urgent help required from u guys,
i am not able to see the records in session Match receipts(tfacp1131s000)

|******************************************************************************
|* tdpwn0202.2.c 0 VRC B40l c4 live
|* Update Customized Purchase Receipts
|* ajat shatru
|* 2009-08-29
|******************************************************************************
|* Main table tdpwn002 Customized Purchase Receipts, Form Type 4
|******************************************************************************

|****************************** declaration section ***************************
declaration:

table ttdpwn002 | Customized Purchase Receipts
table ttfacp200
table ttdpur040
table ttdpur045
table ttfgld101

extern domain tcorno reno.f,order,receipt
extern domain tcorno reno.t
extern domain tcamnt screen.amnt |,invoice.amt,freight.amt
|extern domain tcinvn invoice.number
|extern domain tcdate invoice.date
extern domain tfgld.leac ledger
string invoice.number(6),invoice.amt(12),freight.amt(12),invoice.date(10),batch(6),year.t(4)
extern domain tfgld.ttyp transaction.type
extern domain tddate tedt.f
long batch.no
extern domain tfgld.bstt stat
|extern domain tfgld.year year.t
extern domain tfgld.prod fprt.f,rprd.f,vprd.f
extern domain tcamnt open.amount
string amount(15)
#pragma used dll ottstpapihand
|****************************** form section **********************************

form.1:
init.form:
get.screen.defaults()

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

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


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

field.reno.f:
when.field.changes:
reno.t = reno.f

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

functions:
function process.transaction()
{
long count,retval,tedt,last.found,last.found1,fail.retval,insert.retval,find.retval,year,ret.code,ret,browse.val,retval1,retval5,retval4
long approve.insert,recover,retval2,retval3,recover1
string error.msg(50),error.msg1(50),error1(50),error2(50),dummy.msg(50),message.i(100),process.error.msg(100),err(50)
string error.msg2(50),error.msg3(50),error.msg4(50),error.msg9(50),error.msg10(50),error.approve(50),error.msg8(50),error.msg7(50),error.msg6(50),recover.msg(50)
string error.found(100)
string year1(4),btno(6)
string doc1(15),doc2(15),line1(3),line2(3)
long mm,dd,yy
db.retry.point()

select tdpwn002.*
from tdpwn002 for update
where tdpwn002.reno inrange :reno.f
and :reno.t
and tdpwn002.flag = 2
order by tdpwn002._index1
selectdo
amount = ""
|reno.t = "zzzzzz"
receipt = tdpwn002.reno
order = tdpwn002.orno
tedt = date.num()
num.to.date(tedt, yy, mm, dd )
year = yy+1
transaction.type = "PRM"
stpapi.application.option("tfgld1101m000",1, 1, error.msg1)
stpapi.put.field("tfgld1101m000", "tedt.f", str$(tedt))
stpapi.put.field("tfgld1101m000", "tfgld101.year", str$(year))
ret.code = stpapi.change.view("tfgld1101m000", error.msg1)
stpapi.application.option("tfgld1101m000",1, 14, error.msg1) | 14 to insert new record
stpapi.put.field("tfgld1101m000", "tfgld101.ttyp", transaction.type)
insert.retval = stpapi.insert("tfgld1101m000", true, message.i)
if not insert.retval then
fail.retval = stpapi.recover("tfgld1101m000", dummy.msg)
else

last.found = stpapi.browse.set("tfgld1101m000", "last.set",error1)
if last.found then
stpapi.get.field("tfgld1101m000","tfgld101.year",year1)
stpapi.get.field("tfgld1101m000","tfgld101.btno",btno)
stpapi.get.field("tfgld1101m000","tfgld101.ttyp",tfgld101.ttyp)
stpapi.put.field("tfgld1101m000","tfgld101.year",str$(year))
stpapi.put.field("tfgld1101m000","tfgld101.btno",str$(btno))
stpapi.put.field("tfgld1101m000","tfgld101.ttyp","tfgld101.ttyp")
retval = stpapi.find("tfgld1101m000", error.msg)
retval = stpapi.mark("tfgld1101m000", error.msg)
if retval <> 0 then
select tdpur040.orno,
tdpur040.suno
from tdpur040
where tdpur040.orno = :tdpwn002.orno
selectdo
tdpur040.suno = tdpur040.suno
endselect

stpapi.handle.subproc( "tfgld1101m000", "tfacp1110s000", "add")
stpapi.zoom.option("tfgld1101m000", 1, "tfacp1110s000", error.msg)
stpapi.continue.process("tfacp1110s000", process.error.msg)
browse.val = stpapi.browse.view("tfacp1110s000", "last.view", error.msg)
stpapi.put.field("tfacp1110s000","form.orno",str$(order))
stpapi.put.field("tfacp1110s000", "tfacp200.suno",str$(tdpur040.suno))
stpapi.put.field("tfacp1110s000","screen.amnt",str$(tdpwn002.iamt))
stpapi.put.field("tfacp1110s000","tfacp200.isup",str$(tdpwn002.invn))
stpapi.put.field("tfacp1110s000","tfacp200.orno",str$(order))
stpapi.put.field("tfacp1110s000","tfacp200.disp",str$(receipt))
stpapi.put.field("tfacp1110s000","tfacp200.recd",str$(tdpwn002.rdat))
stpapi.handle.subproc( "tfacp1110s000", "tfacp1230s000", "add")
retval1 = stpapi.insert("tfacp1110s000", true, error.msg2)
if retval1 = 1 then
|last.found1 = stpapi.browse.set("tfacp1110s000", "last.set",error2)
|if last.found1 then
| stpapi.get.field("tfacp1110s000","tfacp200.ttyp",tfacp200.ttyp)
| stpapi.get.field("tfacp1110s000","tfacp200.ninv",doc1)
| stpapi.get.field("tfacp1110s000","tfacp200.line",line1)
| stpapi.get.field("tfacp1110s000","tfacp200.tdoc",tfacp200.tdoc)
| stpapi.get.field("tfacp1110s000","tfacp200.docn",doc2)
| stpapi.get.field("tfacp1110s000","tfacp200.lino",line2)
| stpapi.put.field("tfacp1110s000","tfacp200.ttyp","tfacp200.ttyp")
| stpapi.put.field("tfacp1110s000","tfacp200.ninv","tfacp200.ninv")
| stpapi.put.field("tfacp1110s000","tfacp200.line","tfacp200.line")
| stpapi.put.field("tfacp1110s000","tfacp200.tdoc","tfacp200.tdoc")
| stpapi.put.field("tfacp1110s000","tfacp200.docn","tfacp200.docn")
| stpapi.put.field("tfacp1110s000","tfacp200.lino","tfacp200.lino")
| retval = stpapi.find("tfacp1110s000", error.msg3)
| retval = stpapi.mark("tfacp1110s000", error.msg4)
|if retval = 1 then

|stpapi.continue.process("tfacp1230s000", process.error.msg)
|ret.code = stpapi.change.view("tfacp1230s000", error.msg1)
|stpapi.put.field("tfacp1230s000", "link", str$(etol(tcyesno.no)))
|stpapi.put.field("tfacp1230s000","approve", str$(etol(tcyesno.yes)))

get.receipt.amount()
|stpapi.get.field("tfacp1230s000","receipts",amount)
| open.amount = lval(amount)
if (open.amount = tdpwn002.iamt ) then
stpapi.put.field("tfacp1230s000", "link", str$(etol(tcyesno.yes)))
stpapi.put.field("tfacp1230s000", "approve", str$(etol(tcyesno.yes)))
stpapi.continue.process("tfacp1230s000", error.msg)
if error.msg > "" then
message("Error %s", error.msg)
endif
stpapi.end.session("tfacp1230s000")
else
if (open.amount <> tdpwn002.iamt) then
if ( (open.amount - tdpwn002.iamt) <=1 ) then
stpapi.put.field("tfacp1230s000", "link", str$(etol(tcyesno.yes)))
stpapi.put.field("tfacp1230s000", "approve", str$(etol(tcyesno.no)))

if error.msg > "" then
message("Error %s", error.msg)
endif
stpapi.continue.process("tfacp1230s000", error.msg)
stpapi.handle.subproc("tfacp1230s000", "tfacp1131s000", "add")
stpapi.zoom.option("tfacp1230s000", 1, "tfacp1131s000", error.msg)
retval3 = stpapi.change.view("tfacp1131s000", error.msg)
stpapi.put.field("tfacp1131s000", "tdpur045.matc", str$(2))
retval4 = stpapi.update("tfacp1131s000", true, error.msg)
if not retval4 then
message("Error %s", error.msg)
retval5 = stpapi.recover("tfacp1131s000", recover.msg)
endif
stpapi.end.session("tfacp1131s000")
stpapi.end.session("tfacp1230s000")
else
if ((open.amount - tdpwn002.iamt) = tdpwn002.famt ) then

else
endif
endif
endif
endif


| stpapi.handle.subproc("tfacp1110s000", "tfacp1130s000" , "add")
|stpapi.continue.process("tfacp1130s000", process.error.msg)
|stpapi.end.session("tfacp1130s000") |Match receipts
| stpapi.application.option("tfacp1131s000",1, 48, error.approve)
| stpapi.handle.subproc("tfacp1131s000", "tfacp1133s000" , "add")
| stpapi.put.field("tfacp1133s000","tfacp101.leac","tdpwn002.leac")
| approve.insert = stpapi.update("tfacp1133s000",true,error.msg9)
| if ( approve.insert <> 0 ) then
| tdpwn002.flag = tcyesno.yes
db.update(ttdpwn002, db.retry)
commit.transaction()
stpapi.end.session("tfac1133s000")
stpapi.end.session("tfacp1131s000")
stpapi.end.session("tfacp1230s000")
|endif
| apporove has to be coded
|stpapi.end.session("tfacp1130s000")
stpapi.end.session("tfacp1110s000")
|endif
|endif
else
recover = stpapi.recover("tfacp1110s000", error.msg10)
endif
stpapi.end.session("tfacp1230s000")
stpapi.end.session("tfacp1110s000")


else
endif
endif
endif
stpapi.end.session("tfgld1101m000")
|db.update(ttdpwn002, db.retry)
|count = count + 1
|if count > 50 then
| count = 0
| commit.transaction()
|endif
endselect

commit.transaction()
}
function get.receipt.amount()
{
open.amount = 0
select tdpur045.*
from tdpur045
where tdpur045.suno = :tdpur040.suno |{:supplr}
and tdpur045.orno = :order |tfacp200.orno
|and tdpur045.reno = :tdpwn002.reno
and tdpur045.srnb > 0
and tdpur045.matc <> 2 |*Completely
selectdo
open.amount = open.amount + (tdpur045.amnt - tdpur045.iamt)
|open.amount = open.amount + tdpur045.iamt
endselect
}


Regards,
Uma