gurmeetmakkar
9th March 2010, 11:16
declaration:
table ttdcus002 | Bar Code Scanning Detail
table ttdcus012 | Bar Code Scanning Detail History
table ttdpur401
table twhinh312
table twhinh310
table ttccom121
extern domain tcorno orno.f fixed
extern domain tcorno orno.t fixed
extern string stl(5000),file(128),file1(100),stl1(5000),stl2(5000),stl3(20,50),stl4(50)
extern long rd.ln
extern domain tcqrd1 wght
extern domain tcmcs.str20 wghts
extern domain tcbool str.run
extern domain tcpono rcln , pono1
extern domain tcmcs.str10 bpid
extern domain tfgld.docn docn
extern domain tcmcs.str10 inv.date,ord.date,chl.date
extern domain tcorno orno
extern domain tcmcs.str20 chno,cstf,dscn,pik
extern domain tcamnt amnt,samt
extern domain tccfrw cfrw,m.cfrw
extern domain tcitem item
extern domain tcqrd1 quan
extern domain tcpric rate
extern domain tfgld.ttyp ttyp
extern domain tfgld.date inv.new.date,ord.new.date,chl.new.date,odat
extern domain tfnum geno,chno1
extern domain whinh.shpm receipt.number
#pragma used dll ottdllbw
#pragma used dll ottdlldisplay
#pragma used dll ottstpapihand
#include <bic_dam>
|****************************** Zoom section ********************************
zoom.from.all:
on.entry:
import("tdcus001.geno",geno)
import("tdcus001.chno",pik)
|****************************** group section **********************************
group.1:
init.group:
get.screen.defaults()
|****************************** field section *********************************
|****************************** function section ******************************
functions:
function extern read.main.table()
{
file="c:\barcode.txt"
file.rd()
}
function file.rd()
{
| string bufr(1) based
long fp|,fp1,buflen
long len1 |idc, idp,
fp = seq.open.local(file, "r",false)
create.progress.indicator( "Processing Bar Code Data" ,PROGRESS.BAR + PROGRESS.STOP )
if fp>=0 then
rd.ln = 100
seq.read.local( stl, rd.ln, fp)
string.scan(stl,"%s|%s",stl1,stl2)
stl1= strip$(shiftl$(stl1))
stl2= strip$(shiftl$(stl2))
ttyp=""
string.scan(stl1,"%s,%d,%s,%s,%s,%s,%s,%s,%s,%f,%f,%s",bpid,docn,inv.date,orno,ord.date,chno,chl.date,cstf,dscn,amnt,samt,cfrw)
bpid=bpid(2;(len(bpid)-1))
geno = docn
str.run = true
long i,j,k|,temp
string ch(1)
i = 1
j=1
len1 = len(stl2)
while str.run
ch=stl2(i;1)
if strip$(shiftl$(ch))=":" then
stl3(1,j) = stl4
stl4 = ""
j = j + 1
else
if asc(strip$(shiftl$(ch)))<>034 then
stl4 = stl4 & ch
endif
endif
if asc(strip$(shiftl$(ch)))=034 then
stl3(1,j) = stl4
str.run = false
endif
i = i + 1
endwhile
for k = 1 to j
string.scan(stl3(1,k),"%s,%d,%f",item,quan,rate)
item = " " & Item
insert.or.update.tdcus002()
insert.tdcus012()
endfor
seq.close.local(fp)
afs.to.generate.automatic.receipt.new()
if strip$(shiftl$(receipt.number))<>"" then
| update.tdcus002()
message("Receipt Number is %s",receipt.number)
endif
endif
}
function insert.or.update.tdcus002()
{
string dat1(2),dat2(2),dat3(4),dat4(8)
string.scan(ord.date,"%s/%s/%s",dat1,dat2,dat3)
dat4= dat1&dat2&dat3
ord.new.date= inputstr.to.date( dat4, "%D002,2" )
string.scan(inv.date,"%s/%s/%s",dat1,dat2,dat3)
dat4= dat1&dat2&dat3
inv.new.date= inputstr.to.date( dat4, "%D002,2" )
string.scan(chl.date,"%s/%s/%s",dat1,dat2,dat3)
dat4= dat1&dat2&dat3
chl.new.date= inputstr.to.date( dat4, "%D002,2" )
select tdcus002.*
from tdcus002 for update
where tdcus002.geno=:geno
and tdcus002.orno=:orno
and tdcus002.odat=:ord.new.date
and tdcus002.bpid=:bpid
and tdcus002.ttyp=:ttyp
and tdcus002.ninv=:docn
and tdcus002.indt=:inv.new.date
and tdcus002.item=:item
selectdo
tdcus002.chno=chno
tdcus002.cstf=cstf
tdcus002.dscn=dscn
tdcus002.amnt=amnt
tdcus002.samt=samt
tdcus002.cfrw=cfrw
tdcus002.quan=quan
tdcus002.pric=rate
db.update(ttdcus002,db.retry)
commit.transaction()
selectempty
tdcus002.geno=geno
tdcus002.orno=orno
tdcus002.odat=ord.new.date
tdcus002.bpid=bpid
tdcus002.ttyp=ttyp
tdcus002.ninv=docn
tdcus002.indt=inv.new.date
tdcus002.chno=chno
tdcus002.cstf=cstf
tdcus002.dscn=dscn
tdcus002.amnt=amnt
tdcus002.samt=samt
tdcus002.cfrw=cfrw
tdcus002.item=item
tdcus002.quan=quan
tdcus002.pric=rate
tdcus002.rcno = receipt.number
db.insert(ttdcus002,db.retry)
commit.transaction()
endselect
}
function insert.tdcus012()
{
domain tcmcs.str20 user
domain tcdate user.date
user.date = utc.num()
odat = utc.num()
user = logname$
string dat1(2),dat2(2),dat3(4),dat4(8)
string.scan(ord.date,"%s/%s/%s",dat1,dat2,dat3)
dat4= dat1&dat2&dat3
ord.new.date= inputstr.to.date( dat4, "%D002,2" )
string.scan(inv.date,"%s/%s/%s",dat1,dat2,dat3)
dat4= dat1&dat2&dat3
inv.new.date= inputstr.to.date( dat4, "%D002,2" )
string.scan(chl.date,"%s/%s/%s",dat1,dat2,dat3)
dat4= dat1&dat2&dat3
chl.new.date= inputstr.to.date( dat4, "%D002,2" )
select tdcus012.*
from tdcus012 for update
where tdcus012.geno=:geno
and tdcus012.orno=:orno
and tdcus012.odat=:ord.new.date
and tdcus012.bpid=:bpid
and tdcus012.ttyp=:ttyp
and tdcus012.ninv=:docn
and tdcus012.indt=:inv.new.date
and tdcus012.item=:item
selectdo
tdcus012.chno=chno
tdcus012.cstf=cstf
tdcus012.dscn=dscn
tdcus012.amnt=amnt
tdcus012.samt=samt
tdcus012.cfrw=cfrw
tdcus012.quan=quan
tdcus012.pric=rate
tdcus012.edat = user.date
tdcus012.user = user
tdcus002.rcno = receipt.number
selectempty
tdcus012.geno=geno
tdcus012.orno=orno
tdcus012.odat=ord.new.date
tdcus012.bpid=bpid
tdcus012.ttyp=ttyp
tdcus012.ninv=docn
tdcus012.indt=inv.new.date
tdcus012.chno=chno
tdcus012.cstf=cstf
tdcus012.dscn=dscn
tdcus012.amnt=amnt
tdcus012.samt=samt
tdcus012.cfrw=cfrw
tdcus012.item=item
tdcus012.quan=quan
tdcus012.pric=rate
tdcus012.edat = user.date
tdcus012.user = user
|tdcus002.rcno = receipt.number
db.insert(ttdcus012,db.retry)
commit.transaction()
endselect
}
function afs.to.generate.automatic.receipt.new()
{
extern long ret,ret1,ret2
extern domain tcmcs.str50 error.msg,number.1
select tdcus002.geno,tdcus002.orno
from tdcus002
where tdcus002.geno = :geno
and tdcus002.orno = :orno
and tdcus002.post = tcyesno.no
group by tdcus002.geno,tdcus002.orno
selectdo
generate.receipt.header()
select tdcus002.*
from tdcus002
where tdcus002.orno = :tdcus002.orno
and tdcus002.geno = :tdcus002.geno
and tdcus002.post = tcyesno.no
selectdo
select tdpur401.*
from tdpur401
where tdpur401.orno=:tdcus002.orno
and tdpur401.item = :tdcus002.item
order by tdpur401.pono desc
as set with 1 rows
selectdo
generate.receipt.line()
selectempty
tdpur401.orno=""
tdpur401.pono=0
tdpur401.sqnb=0
endselect
selectempty
endselect
selectempty
message("This Purchase Order does not exist or Already Posted")
endselect
}
function check.transporter.code()
{
select tcmcs080.cfrw
from tcmcs080
where tcmcs080.cfrw = :cfrw
selectdo
m.cfrw = cfrw
selectempty
m.cfrw = ""
endselect
}
function generate.receipt.header()
{
select whinh310.*
from whinh310 for update
as set with 1 rows
selectdo
select tccom121.* from tccom121
where tccom121.sfbp = :tdcus002.bpid
selectempty
message("Ship-from Roles are not defined for BP %S",tdcus002.bpid)
choice.again()
selectdo
whinh310.shda = tccom121.cadr
endselect
dal.new.object("whinh310")
|dal.set.field("whinh310.rcno", receipt.number)
dal.set.field("whinh310.sfbp",tdcus002.bpid)
dal.set.field("whinh310.conf",tcyesno.no)
dal.set.field("whinh310.dino", tdcus002.chno)
dal.set.field("whinh310.pddt",odat)
dal.set.field("whinh310.crdt",odat)
dal.set.field("whinh310.einv.l",tdcus002.chno)
dal.set.field("whinh310.invd.l",odat)
ret = dal.save.object("whinh310")
if ret< 0 then
ret=dal.get.error.message(error.msg )
message("Error......!%s",error.msg)
else
commit.transaction()
endif
receipt.number = whinh310.rcno
endselect
}
function generate.receipt.line()
{
dal.new.object("whinh312")
rcln = rcln + 1
pono1 = pono1 + 1
whinh312.oset = 1
dal.set.field("whinh312.rcno", receipt.number)
dal.set.field("whinh312.rcln", rcln)
dal.set.field("whinh312.oorg", whinh.oorg.purchase)
dal.set.field("whinh312.orno", tdcus002.orno)
dal.set.field("whinh312.oset", whinh312.oset)
dal.set.field("whinh312.pono", tdpur401.pono)
whinh312.seqn= 1
whinh312.psun = "nos"
dal.set.field("whinh312.seqn", whinh312.seqn)
dal.set.field("whinh312.sfbp", tdcus002.bpid)
dal.set.field("whinh312.item", tdcus002.item)
dal.set.field("whinh312.rcun", whinh312.psun)
dal.set.field("whinh312.qrcr", tdcus002.quan)
dal.set.field("whinh312.qrec", tdcus002.quan)
dal.set.field("whinh312.psqr", tdcus002.quan)
dal.set.field("whinh312.psqu", tdcus002.quan)
dal.set.field("whinh312.psun", whinh312.psun)
dal.set.field("whinh312.psno", tdcus002.chno)
whinh312.cwar = "SM0000"
whinh312.rclo = "REC"
dal.set.field("whinh312.cwar", whinh312.cwar)
dal.set.field("whinh312.rclo", whinh312.rclo)
dal.set.field("whinh312.lsta", whinh.lstc.received)
dal.set.field("whinh312.cmpl", tcyesno.no)
dal.set.field("whinh312.fire", tcyesno.no)
dal.set.field("whinh312.conf", tcyesno.no)
dal.set.field("whinh312.insp", tcyesno.no)
dal.set.field("whinh312.cdck", tcyesno.no)
dal.set.field("whinh312.cdcr", tcyesno.no)
dal.set.field("whinh312.dmse", whinh.dmse.not.appl)
dal.set.field("whinh312.arej", tcyesno.no)
dal.set.field("whinh312.ardt", odat)
dal.set.field("whinh312.trdt",odat)
dal.set.field("whinh312.blck",tcyesno.no)
dal.set.field("whinh312.logn", "baan")
ret1 = dal.save.object("whinh312")
commit.transaction()
if ret1< 0 then
ret2=dal.get.error.message(error.msg)
message("Error......!%s",error.msg)
commit.transaction()
else
commit.transaction()
endif
}
function update.tdcus002()
{
select tdcus002.orno,tdcus002.post,tdcus002.rcno
from tdcus002 for update
where tdcus002.orno=:orno
and tdcus002.post=tcyesno.no
selectdo
tdcus002.rcno = receipt.number
tdcus002.post=tcyesno.yes
db.update(ttdcus002,db.retry)
commit.transaction()
endselect
}
function check.quantity()
{
if tdcus002.quan > val(number.1) then
message("Quantity of Item %s is exceeded in PO %s and line No %d",strip$(shiftl$(tdcus002.item)),tdpur401.orno,tdpur401.pono)
endif
}