loveneesh
4th June 2008, 08:59
Thanks NPR,
Here is my code
declaration:
#include <bic_tt>
table ttdwms610 |* ASN Header
table ttdwms611 |* ASN Header - Details
table ttdwms615 |* ASN Lines
table ttdwms616 |* ASN Lines - No. of Packages - Detail
table ttdwms650 |* ASN Header - History
table ttdwms651 |* ASN Header - Details - History
table ttdwms655 |* ASN Lines - History...
table ttdwms656 |* ASN Lines - No. of Packages - Detail - History
table ttdwms600 |* ASN Receiving Parameter
table ttdwms609 |* ASN Log table
table ttdwms608
#define RECORDLN 600
#define RETLN 1500
#define DIM1 1400
#define DIM2 100000
#define PATHLEN 250
|Form Variable
extern domain tcmcs.str80 disp.messg
| THESE ARE THE VARIABLES DEFINED FOR DIFFRENT PATHS
| INITIAL PATHS DEFINED FOR THE FILES
string path.input.o(PATHLEN) | INPUT FILE
string path.proc.o(PATHLEN) | PROCESSED FILE
string path.log.o(PATHLEN) | LOG FILE
| ACTUAL PATHS TO OPEN THE FILES
string path.log.tmp(PATHLEN) | LOG FILE FOR TMP FILE
string path.input(PATHLEN) | INPUT FILE
string path.proc(PATHLEN) | PROCESSED FILE
string bckp.path(PATHLEN) | PROCESSED FILE for backup directory
string ls.path.name(PATHLEN) | LIST COMMAND
string mv.path.name(PATHLEN) | MOVE COMMAND
string cv.path.name(PATHLEN) | MOVE COMMAND
string path.move.o(PATHLEN) | PATH FROM ASN MOVE | POLCUS1O.n
string path.move(PATHLEN) | FILE TO BE MOVED FROM | POLCUS10.n
|FILE NAMES
string file.name(PATHLEN) |FILE NAME VARIABLE
|VARIABLES FOR DIFFRENT FILE POINTERS
long retval,fp,rec.ctr,i, file.ctr, j,file.val ,fp.tmp,fp.log.tmp
|VARIABLE FOR STORING THE RECORD OF THE FILE
string retline(RETLN),file.line(RETLN),current.record(RETLN)
| ARRAY VARIABLE FOR STORING ALL THE DATA OF THE FILE
string str_arr(DIM1,DIM2),file_arr(DIM1,DIM2)
|OTHER REQUIRED VARIABLE
string str_date(12) | STORE TODAY'S DATE
domain tcyesno file.blank | CHECK FOR BLANK FILE
domain tcncmp home.company | EXTRACT THE HOME COMPAY IN THIS
long dd,yy,mm | TEMPORARY VARIABLES FOR DATE/YEAR/MONTH
long ret | RETURN VALUE FOR COMMANDS
| THESE ARE THE VARIABLES DEFINED FOR THE ERROR
domain tcyesno err.hap
domain tcmcs.str80 error.code, x.error.code
|VARIABLES FOR APPL. LOCK
domain tcmcs.str20 lockedkey
domain tcmcs.str12 lockedby
long ret.key
domain tctime curr.time
domain tcdate curr.date
|VARIABLES FOR THE RETRIEVING DATA FROM THE FILE
|Leader Fields - Position 1 to 55 of each record
| string file.duns.number(9), |DUNS Number
string file.plant.code(3), |Plant Code
file.supplier(12), |Supplier Code
file.trans.date(6), |Transaction Date (YYMMDD)
file.trans.time(4), |Transaction Time (HHMM)
file.ship.id(15), |Shipment ID(ASN Number)
| file.ship.item.no(4), |Shipment Item Number
| file.edi.std.indicator(1), |EDI Standard Indicator
file.rec.type(1) |File Record Type
|Data Fields - Record Type 0 - Header
| string file.ship.from(35), |Ship Form Name
string file.pack.list.0(15), |Packing List Number - Record type 0 Zero
file.bill.lading.no(15), |Bill of Lading Number
file.carrier.ref.no(15), |Carrier Reference Number
file.freight.bill.no(30), |Freight Bill Number
| file.ship.century(2), |Ship Date Century
file.ship.date(6), |Ship Date
file.ship.time(4), |Ship Time
| file.arrival.century(2), |Arrival Date Century
file.arrival.date(6), |Arrival Date
file.arrival.time(4), |Arrival Time
file.no.container(7), |No. of Containers
| file.no.container.sign(1), |No. of Containers Sign
file.wght.shipment(11), |Gross Weight of Shipment
| file.wght.shipment.sign(1), |Gross Weight of Shipment Sign
file.wght.uom(2), |Weight Unit of Measure
| file.board.code(2), |Free on Board code
file.scac.code(17), |SCAC Code
| file.ship.equp.type(2), |Shipment Equipment Type
| file.ship.equp.id1(4), |Shipment Equipment ID 1
| file.ship.equp.id2(10), |Shipment Equipment ID 2
| file.spec.hand.code(3), |Special Handling code
| file.hzd.mat.qual(1), |Hazardous Material Qualifier
| file.hzd.mat.code(4), |Hazardous Material Code
file.purpose.code(2), |Purpose Code
| file.pack.list.header(1), |Packing List In Header
file.seq.no(15) |File Sequence No
| file.filler.0(28) |Filler - Record type 0(Zero)
|Data Fields - Record Type 1 - Header
| string file.ship.to.name(35), |Ship To Name
string file.ship.to.code(10) |Ship To Code
| file.ship.to.add1(30), |Ship-to address line 1
| file.ship.to.add2(30), |Ship-to address line 2
| file.ship.to.add3(30), |Ship-to address line 3
| file.ship.to.add4(30), |Ship-to address line 4
| file.ship.to.add5(30), |Ship-to address line 5
| file.ship.to.add6(30) |Ship-to address line 6
| file.filler.1(20) |Filler - Record type 1(One)
|Data Fields - Record Type 2 - Detail
| string file.po(25), |PO Number
| file.release.no(3), |Release Number
string file.item(30), |Part Number
file.vendor.item(30), |Vendor Part Number
file.revision(2), |Revision Number
file.pack.list.2(15), |Packing List Number - Record type 2 Two
file.unit.ship(11), |Units shipped
| file.unit.ship.sign(1), |Units shipped Sign
file.uom(2) |Unit of Measure
| file.item.stat(2), |PO item status
| file.vendor.code2(12), |Vendor code 2
| file.call.off(12), |Call-off reference number
| file.del.loca(15), |Delivery location
| file.po.line(5) |PO Line Item Number
| file.filler.2(80) |Filler - Record type 2(Two)
|Data Fields - Record Type 3 - Detail
| string file.cont.type(5), |Type of container
| string file.unit.cont(11), |Units per container
| string file.unit.cont.sign(1), |Units per container sign
| file.cont.size(5) |Container size
| file.total.cont(5) |Total No of Containers
| file.filler.3(218) |Filler - Record type 3(Three)
|Data Fields - Record Type 4 - Detail
| string file.total.lines(4), |Count of Detail Lines
| string file.filler.4(241) |Filler - Record type 4(Four)
|*********************** variables for table insertion/ Baan Comparison **************
domain tcmcs.str3 plant.code
domain tcmcs.str15 asn.no
domain tcsuno supplier
domain tcorno rec.type
domain tcorno seq.no
domain tcdate trans.date
domain tctime trans.time
domain tcdate ship.date
domain tcdate arrival.date
domain tctime ship.time
domain tctime arrival.time
domain tcmcs.str15 packing.list.no,
bill.lading.no,
carrier.ref.no
domain tcmcs.str30 freight.bill.no
domain tcwght wght.shipment
domain tccuni wght.uom
domain tdwms.purpose purpose.code
domain tdwms.cont no.container
domain tcmcs.str35 ship.to.name
domain tcmcs.str10 ship.to.code
domain tcitem item
domain tdpsc.cpno vendor.item
domain tcmcs.str2 revision
domain tcmcs.str15 pack.list.2
domain tcqiv1 unit.ship
domain tccuni uom
domain tcdate temp.date
domain tcncmp company
domain tcorno m.seqn
domain tcmcs.str17 scac.code
domain tcbool file.load
domain tcorno m.srno
domain tcmcs.str9 table.name
long table.eror
domain tcbool error.found
domain tcsuno m.suno | POLCUS10.n
before.program:
if not initialization() then
exit()
endif
lockedkey = "tdwms6210m002"
ret.key = appl.get.user(lockedkey,lockedby)
| ret.key = appl.set(lockedkey,APPL.EXCL)
if ret.key = 0 then
| appl.get.user(lockedkey,lockedby)
mess("tdwms26210.01",1,lockedby)
|* %s User is using this session.....
end()
endif
|****************************** form section **********************************
form.1:
init.form:
get.screen.defaults()
|****************************** choice section ********************************
choice.cont.process:
on.choice:
lockedkey = "tdwms6210m002"
ret.key = appl.set(lockedkey,APPL.EXCL)
if ret.key <> 0 then
appl.get.user(lockedkey,lockedby)
mess("tdwms26210.01",1,lockedby)
|* %s User is using this session.....
end()
endif
curr.date = date.num()
curr.time = tcqms.dll0001.num.to.time(time.num())
move.valid.files() | POLCUS10.n
read.main.table()
select tdwms608.*
from tdwms608 for update
where tdwms608._index1 = {:curr.date,:curr.time}
selectdo
tdwms608.endt = date.num()
tdwms608.entm = tcqms.dll0001.num.to.time(time.num())
db.update(ttdwms608,db.retry)
commit.transaction()
selectempty
tdwms608.srno = 1
tdwms608.endt = date.num()
tdwms608.entm = tcqms.dll0001.num.to.time(time.num())
db.insert(ttdwms608,db.retry)
commit.transaction()
endselect
display.form.message(form.text$("tdwms26210.16"))
|* Process Complete.
ret.key = appl.delete(lockedkey)
|****************************** function section ******************************
functions:
function domain tcbool initialization()
{
company = get.compnr()
select tdwms600.ncmp
from tdwms600
where tdwms600._index1 = {:company}
selectdo
selectempty
mess("tdwms26102.02",1)
|* Parameters not Defined...
return(false)
endselect
select tdwms601.code
from tdwms601
as set with 1 rows
selectdo
selectempty
mess("tdwms26102.03",1)
|* Validation Codes not Defined....
return(false)
endselect
return(true)
}
function move.valid.files() | POLCUS10.sn
{
db.retry.point()
select tdwms608.*
from tdwms608 for update
where tdwms608._index1 = {:curr.date,:curr.time}
selectdo
| tdwms608.stdt = date.num()
| tdwms608.sttm = tcqms.dll0001.num.to.time(time.num())
| tdwms608.endt = 0
| tdwms608.entm = 0
| db.update(ttdwms608,db.retry)
| commit.transaction()
selectempty
tdwms608.srno = 1
tdwms608.stdt = curr.date
tdwms608.sttm = curr.time
tdwms608.endt = 0
tdwms608.entm = 0
db.insert(ttdwms608,db.retry)
commit.transaction()
endselect
initailize.variables.level1()
| PROCEDURE 1 STARTS
| EXTRACT DIR INFO FROM CSCN PARAMETERS AND CREATE LOG FILE.
| IF LOG FILE IS NOT CREATED THEN END THE PROGRAM AFTER MESSAGE
initial_actions()
if err.hap = tcyesno.yes then
err.hap = tcyesno.no
end()
endif
| PROCEDURE 1 END
| PROCEDURE 2 STARTS
| GET THE FILE NAMES IN THE DIRECTORIES AND STORE IT IN AN FILE.
| GIVE ERROR IF THERE IS SOME PROBLEM
get.filenames.new()
if err.hap = tcyesno.yes then
err.hap = tcyesno.no
seq.close(fp.log.tmp)
| end() | POLCUS10.n
endif
display.form.message(sprintf$(form.text$("tdwms26210.14"),file.ctr))
|* Total Number Of Files : %d
} | POLCUS10.en
function read.main.table()
{
db.retry.point() |LK.N
| curr.date = date.num() | POLCUS10.so
| curr.time = tcqms.dll0001.num.to.time(time.num())
initailize.variables.level1()
|
| | PROCEDURE 1 STARTS
| | EXTRACT DIR INFO FROM CSCN PARAMETERS AND CREATE LOG FILE.
| | IF LOG FILE IS NOT CREATED THEN END THE PROGRAM AFTER MESSAGE
| initial_actions()
| if err.hap = tcyesno.yes then
| err.hap = tcyesno.no
| end()
| endif
| | PROCEDURE 1 END
|
| | PROCEDURE 2 STARTS
| | GET THE FILE NAMES IN THE DIRECTORIES AND STORE IT IN AN FILE.
| | GIVE ERROR IF THERE IS SOME PROBLEM
get.filenames()
if err.hap = tcyesno.yes then
err.hap = tcyesno.no
seq.close(fp.log.tmp)
end()
endif
| display.form.message(sprintf$(form.text$("tdwms26210.14"),file.ctr))
| |* Total Number Of Files : %d
| | PROCEDURE 2 END
| | PROCEDURE 3 STARTS
| | PROCESS EACH FILE ATE AT A TIME, IN A LOOP | POLCUS10.eo
for i = 1 to file.ctr
| db.retry.point() |san |LK.O
display.form.message(sprintf$(form.text$("tdwms26210.15"),i,file.ctr))
|* Processing File No: %d of %d Files
initailize.variables.level2()
file.name = strip$(file_arr(1,i))
| PROCEDURE 3.1 STARTS Validate File Name
| validate.filename() | POLCUS10.o
| copy_files() |#POLCUS02.n
| if err.hap = tcyesno.yes then
| err.hap = tcyesno.no
| | copy_files() |#POLCUS02.o
| dele_files() |#POLCUS02.n
| continue
| endif
| PROCEDURE 3.1 END
| PROCEDURE 3.2 STARTS Read ASN file
asn.read.file()
copy_files() | POLCUS01.n
if err.hap = tcyesno.yes then
err.hap = tcyesno.no
seq.close(fp)
| copy_files() |#POLCUS02.o
dele_files() |#POLCUS02.n
continue
endif
| PROCEDURE 3.2 END
| PROCEDURE 3.3 STARTS
m.suno = "" | POLCUS10.n
for j = 1 to rec.ctr
| db.retry.point() |san
initailize.variables.level3()
current.record = str_arr(1,j)
file.ship.id = current.record(35;15)
asn.no = strip$(shiftl$(file.ship.id))
file.rec.type = current.record(55;1)
if j = 1 then
file.seq.no = current.record(258;15)
seq.no = val(file.seq.no)
file.supplier = current.record(13;12) | POLCUS10.n
supplier = strip$(shiftl$(file.supplier)) | POLCUS10.n
tt.align.according.domain(supplier, supplier, "tcsuno") | POLCUS10.n
endif
rec.type = val(file.rec.type)
on case rec.type
case 0:
get.variables.rec.0() |(Rec type 0 Variables)
break
case 1:
get.variables.rec.1() |(Rec type 1 Variables)
break
case 2:
file.plant.code = current.record(10;3)
file.supplier = current.record(13;12)
file.ship.id = current.record(35;15)
plant.code = strip$(shiftl$(file.plant.code))
| supplier = strip$(shiftl$(file.supplier)) | POLCUS10.o
| tt.align.according.domain(supplier, supplier, "tcsuno") | POLCUS10.o
asn.no = strip$(shiftl$(file.ship.id))
m.suno = strip$(shiftl$(file.supplier)) | POLCUS10.n
tt.align.according.domain(m.suno, m.suno, "tcsuno") | POLCUS10.n
if m.suno <> supplier then
break
endif
assign.file.variables()
populate.table.fields()
break
default:
break
endcase
if error.found then
break
endif
endfor
| PROCEDURE 3.3 END
commit.transaction()
| copy_files() |#POLCUS02.o
dele_files() |#POLCUS02.n
| tdwmsdll0017.sendmail(asn.no,asn.no) | san to finalised
endfor
seq.close(fp.log.tmp)
| PROCEDURE 3 END
commit.transaction()
}
function initailize.variables.level1()
{
ret = set.mem(file_arr,"")
ret = set.mem(str_arr,"")
file.blank = tcyesno.yes
file.ctr = 0
}
function initial_actions()
{
home.company = get.compnr()
select tdwms600.*
from tdwms600
where tdwms600._index1 = {:home.company}
selectdo
path.move.o = tdwms600.mpth
path.input.o = tdwms600.path
path.proc.o = tdwms600.hpth
path.log.o = tdwms600.lpth
endselect
str_date = dte$()
path.log.tmp = concat$("/",strip$(path.log.o),"log")
path.log.tmp = path.log.tmp &"_"& str_date(5;2) & str_date(1;2) & str_date(3;2) & str_date(7;6)
fp.log.tmp = seq.open(path.log.tmp,"w")
if fp.log.tmp < 1 then
mess("tdwms26210.02",1)
|* Unable to Open the base CSCN ASN log file!
err.hap = tcyesno.yes
return
endif
}
function get.filenames()
{
ls.path.name = "ls " & strip$(path.input.o) &" > " & strip$(path.log.o) & "/CSCN_ASN_files"
ret = shell(ls.path.name, 0)
fp.tmp = seq.open(concat$("/",strip$(path.log.o),"CSCN_ASN_files"),"r")
if fp.tmp < 1 then
|ERROR MESSAGE IS : Unable to Open the base log file!
seq.puts(form.text$("tdwms26210.02"),fp.log.tmp)
|* Unable to Open the base CSCN ASN log file!
err.hap = tcyesno.yes
return
endif
while (seq.eof(fp.tmp) = 0)
file.val = seq.gets(file.line,RECORDLN, fp.tmp)
|* To check if any file is available to upload
if (file.val < 0 and file.blank = tcyesno.yes) then
|ERROR MESSAGE IS :No File Available To Upload !
seq.puts(form.text$("tdwms26210.03"),fp.log.tmp)
|* No File Available To Upload !
err.hap = tcyesno.yes
return
else
if file.val = 0 then
file.blank = tcyesno.no
file.ctr = file.ctr + 1
file_arr(1,file.ctr) = file.line
endif
endif
endwhile
if file.ctr = 0 then
|ERROR MESSAGE IS :No Files to Upload!
seq.puts(form.text$("tdwms26210.03"),fp.log.tmp)
|* No File Available To Upload !
err.hap = tcyesno.yes
return
endif
seq.close(fp.tmp)
}
function get.filenames.new()
{
ls.path.name = "ls " & strip$(path.move.o) &" > " & strip$(path.log.o) & "/VALID_ASN_files"
ret = shell(ls.path.name, 0)
fp.tmp = seq.open(concat$("/",strip$(path.log.o),"VALID_ASN_files"),"r")
if fp.tmp < 1 then
|ERROR MESSAGE IS : Unable to Open the base log file!
seq.puts(form.text$("tdwms26210.27"),fp.log.tmp)
|* tdwms26210.27 ????????????????????????????????????????
err.hap = tcyesno.yes
return
endif
while (seq.eof(fp.tmp) = 0)
file.val = seq.gets(file.line,RECORDLN, fp.tmp)
|* To check if any file is available to upload
if (file.val < 0 and file.blank = tcyesno.yes) then
|ERROR MESSAGE IS :No File Available To Upload !
seq.puts(form.text$("tdwms26210.03"),fp.log.tmp)
|* No File Available To Upload !
err.hap = tcyesno.yes
return
else
if file.val = 0 then
file.blank = tcyesno.no
file.ctr = file.ctr + 1
file_arr(1,file.ctr) = file.line
file.name = strip$(file_arr(1,file.ctr))
validate.filename.new()
if err.hap = tcyesno.yes then
err.hap = tcyesno.no
dele_source_files()
continue
endif
asn.read.file.new()
if err.hap = tcyesno.yes then
err.hap = tcyesno.no
seq.close(fp)
dele_source_files()
continue
else
move_source_files()
endif
endif
endif
endwhile
if file.ctr = 0 then
|ERROR MESSAGE IS :No Files to Upload!
seq.puts(form.text$("tdwms26210.03"),fp.log.tmp)
|* No File Available To Upload !
err.hap = tcyesno.yes
return
endif
seq.close(fp.tmp)
}
function initailize.variables.level2()
{
ret = set.mem(str_arr,"")
rec.ctr = 0
plant.code = ""
supplier = ""
asn.no = ""
trans.date = 0
seq.no = 0
packing.list.no = ""
bill.lading.no = ""
carrier.ref.no = ""
freight.bill.no = ""
ship.date = 0
ship.time = 0
arrival.date = 0
arrival.time = 0
no.container = 0
wght.shipment = 0
wght.uom = ""
purpose.code = empty
ship.to.name = ""
ship.to.code = ""
scac.code = ""
}
function asn.read.file.new()
{
|OPEN THE MAIN FILE
path.input = strip$(concat$("/",strip$(path.input.o),file.name))
fp = seq.open(path.move,"r")
rec.ctr = 0
if fp < 1 then
|ERROR MESSGE : Unable to open the input file! File Skipped!
seq.puts(sprintf$(form.text$("tdwms26210.05"),file.name),fp.log.tmp)
|* Unable to open the input file %s! File Skipped!
err.hap = tcyesno.yes
return
endif
while (seq.eof(fp) = 0)
retval = seq.gets(retline,RECORDLN, fp)
if (retval < 0 and file.blank = tcyesno.yes) then
|ERROR MESSAGE IS :Given file is blank!
seq.puts(sprintf$(form.text$("tdwms26210.06"),file.name),fp.log.tmp)
|* Given file %s is blank!
err.hap = tcyesno.yes
return
else
if retval = 0 then
file.blank = tcyesno.no
rec.ctr = rec.ctr + 1
if rec.ctr = 1 then
if not valid.asn.file.new() then
err.hap = tcyesno.yes
return
else
seq.close(fp)
return
endif
endif
| str_arr(1,rec.ctr) = retline
endif
endif
endwhile
seq.close(fp)
}
function domain tcbool valid.asn.file.new() | POLCUS10.sn
{
file.rec.type = retline(55;1)
rec.type = val(file.rec.type)
if rec.type = 0 then
file.plant.code = retline(10;3)
file.supplier = retline(13;12)
file.ship.id = retline(35;15)
asn.no = strip$(shiftl$(file.ship.id))
plant.code = strip$(shiftl$(file.plant.code))
supplier = strip$(shiftl$(file.supplier))
file.trans.date = retline(25;6)
file.trans.time = retline(31;4)
file.seq.no = retline(258;15)
file.purpose.code = retline(255;2)
dd = lval(file.trans.date(5;2))
mm = lval(file.trans.date(3;2))
yy = 2000 + lval(file.trans.date(1;2))
trans.date = date.to.num(yy,mm,dd)
x.error.code = ""
file.load = false
If isspace(asn.no)then
seq.puts(sprintf$(form.text$("tdwms26210.23"),file.name),fp.log.tmp)
|* ASN number is blank, Not valid file %s
return(false)
endif
if isspace(supplier) then
x.error.code = form.text$("tdwms26210.08")
|* Supplier Doesn't exists in BAAN ! File Skipped !
write.log.table()
return(false)
endif
if plant.code <> strip$(tdwms600.plnt) then
x.error.code = form.text$("tdwms26210.07")
|* Plant Code Different from Parameter defination! File Skipped!
write.log.table()
return(false)
endif
if trans.date <= 0 then
x.error.code = form.text$("tdwms26210.24")
|* Transaction Date is Blank in File. File Skipped
write.log.table()
return(false)
endif
trans.time = lval(file.trans.time) * 100
seq.no = val(file.seq.no)
find.seq()
if seq.no = m.seqn then
x.error.code = sprintf$(form.text$("tdwms26210.22"),m.seqn)
|* File is already loaded for Seqn : %s
endif
if seq.no < m.seqn then
x.error.code = sprintf$(form.text$("tdwms26210.13"),m.seqn)
|* Higher Seqn : %s is already Loaded
endif
if not isspace(x.error.code) then
write.log.table()
return(false)
else
return(true)
endif
endif
return(true)
} | POLCUS10.en
function asn.read.file()
{
|OPEN THE MAIN FILE
path.input = strip$(concat$("/",strip$(path.input.o),file.name))
fp = seq.open(path.input,"r")
if fp < 1 then
|ERROR MESSGE : Unable to open the input file! File Skipped!
seq.puts(sprintf$(form.text$("tdwms26210.05"),file.name),fp.log.tmp)
|* Unable to open the input file %s! File Skipped!
err.hap = tcyesno.yes
return
endif
while (seq.eof(fp) = 0)
retval = seq.gets(retline,RECORDLN, fp)
if (retval < 0 and file.blank = tcyesno.yes) then
|ERROR MESSAGE IS :Given file is blank!
seq.puts(sprintf$(form.text$("tdwms26210.06"),file.name),fp.log.tmp)
|* Given file %s is blank!
err.hap = tcyesno.yes
return
else
if retval = 0 then
file.blank = tcyesno.no
rec.ctr = rec.ctr + 1
if rec.ctr = 1 then
if not valid.asn.file() then
err.hap = tcyesno.yes
return
endif
endif
str_arr(1,rec.ctr) = retline
endif
endif
endwhile
seq.close(fp)
}
function domain tcbool valid.asn.file()
{
file.rec.type = retline(55;1)
rec.type = val(file.rec.type)
if rec.type = 0 then
file.plant.code = retline(10;3)
file.supplier = retline(13;12)
file.ship.id = retline(35;15)
asn.no = strip$(shiftl$(file.ship.id))
plant.code = strip$(shiftl$(file.plant.code))
supplier = strip$(shiftl$(file.supplier))
file.trans.date = retline(25;6)
file.trans.time = retline(31;4)
file.seq.no = retline(258;15)
file.purpose.code = retline(255;2)
dd = lval(file.trans.date(5;2))
mm = lval(file.trans.date(3;2))
yy = 2000 + lval(file.trans.date(1;2))
trans.date = date.to.num(yy,mm,dd)
x.error.code = ""
file.load = false
If isspace(asn.no)then
seq.puts(sprintf$(form.text$("tdwms26210.23"),file.name),fp.log.tmp)
|* ASN number is blank, Not valid file %s
return(false)
endif
if plant.code <> strip$(tdwms600.plnt) then
x.error.code = form.text$("tdwms26210.07")
|* Plant Code Different from Parameter defination! File Skipped!
write.log.table()
return(false)
endif
if trans.date <= 0 then
x.error.code = form.text$("tdwms26210.24")
|* Transaction Date is Blank in File. File Skipped
write.log.table()
return(false)
endif
trans.time = lval(file.trans.time) * 100
seq.no = val(file.seq.no)
find.seq()
if seq.no = m.seqn then
x.error.code = sprintf$(form.text$("tdwms26210.22"),m.seqn)
|* File is already loaded for Seqn : %s
endif
if seq.no < m.seqn then
x.error.code = sprintf$(form.text$("tdwms26210.13"),m.seqn)
|* Higher Seqn : %s is already Loaded
endif
if seq.no > m.seqn then
if m.seqn = 0 then
file.load = true
else
if rec.processed() then
x.error.code = sprintf$(form.text$("tdwms26210.11"),m.seqn)
|* Seq.%s Already Processed... Cannot Replace
else
if file.purpose.code = "00" or file.purpose.code = "05" then
cancel.asnn.data()
if m.seqn <> 0 then
x.error.code = sprintf$(form.text$("tdwms26210.20"),m.seqn)
|* Seq.%s moved to Archieve Table - For Add / Replacement
endif
file.load = true
endif
if file.purpose.code = "01" then
cancel.asnn.data()
if m.seqn <> 0 then
x.error.code = sprintf$(form.text$("tdwms26210.19"),m.seqn)
|* Seq.%s moved to Archieve Table - For Deletation
endif
endif
endif
endif
endif
if not isspace(x.error.code) then
write.log.table()
endif
if file.load then
return(true)
else
return(false)
endif
endif
return(true)
}
function copy_files()
{
long ret, ret1
string dat(12)
long file.size,c.time,m.time,a.time |#POLCUS01.n
dat = dte$()
bckp.path = strip$(concat$("/",strip$(path.proc.o),"bkp"))
bckp.path = strip$(concat$("/",strip$(bckp.path),file.name))
path.proc = strip$(concat$("/",strip$(path.proc.o),file.name)) &"_"& dat(5;2) & dat(1;2) & dat(3;2) & dat(7;6)
cv.path.name = "cp " & path.input &" " & bckp.path
| mv.path.name = "mv " & path.input &" " & path.proc |lk.o
mv.path.name = "cp " & path.input &" " & path.proc |lk.n
if file.stat(bckp.path,file.size,c.time,m.time,a.time) <> 0 then |#POLCUS01.n
| ret = shell(cv.path.name, 0) |lk.o |#POLCUS01.o
ret = shell(cv.path.name, 0) |lk.o |#POLCUS01.n
| suspend(90) |lktest
| ret = shell(mv.path.name, 0) |lk.o |#POLCUS01.o
ret = shell(mv.path.name, 0) |lk.o |#POLCUS01.n
| suspend(90) |lktest
endif |#POLCUS01.n
| mv.path.name = "rm " & path.input |lk.n |#POLCUS02.so
| | ret = shell(mv.path.name, 0) |lk.n |#POLCUS01.o
| ret = shell(mv.path.name, 1) |lk.n |#POLCUS01.n
| suspend(80) |lktest
| | ret = shell(cv.path.name, 1) |lk.n
| | ret = shell(mv.path.name, 1) |lk.n
| |#POLCUS02.eo
}
function dele_files() |#POLCUS02.sn
{
mv.path.name = "rm " & path.input
ret = shell(mv.path.name, 0)
| suspend(70) |lktest
} |#POLCUS02.en
function write.log.table()
{
m.srno = 0
select tdwms609.*
from tdwms609
where tdwms609._index1 = {:asn.no,:seq.no}
order by tdwms609._index1 desc
as set with 1 rows
selectdo
m.srno = tdwms609.srno
endselect
m.srno = m.srno + 1
select tdwms609.*
from tdwms609
where tdwms609._index1 = {:asn.no,:seq.no,:m.srno}
selectdo
selectempty
tdwms609.asnn = asn.no
tdwms609.seqn = seq.no
tdwms609.srno = m.srno
tdwms609.rema = x.error.code
tdwms609.date = curr.date
tdwms609.time = curr.time
db.insert(ttdwms609,db.retry)
commit.transaction()
endselect
}
function initailize.variables.level3()
{
item = ""
vendor.item = ""
revision = ""
pack.list.2 = ""
unit.ship = 0
uom = ""
}
function get.variables.rec.0() |(Rec type 0 Variables)
{
file.ship.id = current.record(35;15)
file.pack.list.0 = current.record(91;15)
file.bill.lading.no = current.record(106;15)
file.carrier.ref.no = current.record(121;15)
file.freight.bill.no = current.record(136;30)
file.ship.date = current.record(168;6)
file.ship.time = current.record(174;4)
file.arrival.date = current.record(180;6)
file.arrival.time = current.record(186;4)
file.no.container = current.record(190;7)
file.wght.shipment = current.record(198;11)
file.wght.uom = current.record(210;2)
file.scac.code = current.record(214;17)
file.purpose.code = current.record(255;2)
asn.no = strip$(shiftl$(file.ship.id))
packing.list.no = file.pack.list.0
bill.lading.no = file.bill.lading.no
carrier.ref.no = file.carrier.ref.no
freight.bill.no = file.freight.bill.no
dd = lval(file.ship.date(5;2))
mm = lval(file.ship.date(3;2))
yy = 2000 + lval(file.ship.date(1;2))
ship.date = date.to.num(yy,mm,dd)
if ship.date < 0 then
ship.date = 0
endif
ship.time = lval(file.ship.time) * 100
scac.code = strip$(shiftl$(file.scac.code))
dd = lval(file.arrival.date(5;2))
mm = lval(file.arrival.date(3;2))
yy = 2000 + lval(file.arrival.date(1;2))
arrival.date = date.to.num(yy,mm,dd)
if arrival.date < 0 then
arrival.date = 0
endif
arrival.time = lval(file.arrival.time) * 100
no.container = lval(file.no.container)
wght.shipment = val(file.wght.shipment)
if not isspace(file.wght.uom) then
get.unit.from.unit.master(file.wght.uom,wght.uom)
endif
if not isspace(file.purpose.code) then
on case file.purpose.code
case "00":
purpose.code = tdwms.purpose.new
break
case "01":
purpose.code = tdwms.purpose.delete
break
case "05":
purpose.code = tdwms.purpose.replacement
break
endcase
endif
}
function get.unit.from.unit.master( domain tcmcs.str2 i.cuni,
ref domain tccuni o.cuni)
{
o.cuni = ""
select tdwms605.cuni:o.cuni
from tdwms605
where tdwms605._index1 = {:i.cuni}
selectdo
endselect
}
function get.variables.rec.1() |(Rec type 1 Variables)
{
file.ship.to.code = current.record(91;10)
ship.to.code = file.ship.to.code
}
function assign.file.variables()
{
error.code = ""
file.item = current.record(84;30)
file.vendor.item = current.record(114;30)
file.revision = current.record(144;2)
file.pack.list.2 = current.record(146;15)
file.unit.ship = current.record(161;11)
file.uom = current.record(173;4)
item = strip$(shiftl$(file.item))
tt.align.according.domain(item, item, "tcitem")
vendor.item = strip$(shiftl$(file.vendor.item))
revision = strip$(shiftl$(file.revision))
pack.list.2 = strip$(shiftl$(file.pack.list.2))
unit.ship = val(file.unit.ship)
if not isspace(file.uom) then
get.unit.from.unit.master(file.uom,uom)
endif
}
function populate.table.fields()
{
if purpose.code <> tdwms.purpose.delete then
fill.header()
if error.found then
return
endif
fill.lines()
endif
}
function fill.header()
{
x.error.code = ""
table.name = ""
error.found = false
| select tdwms610.asnn | POLCUS10.o
select tdwms610.asnn,tdwms610.suno,tdwms610.seqn | POLCUS10.n
from tdwms610
where tdwms610._index1 = {:asn.no, :supplier, :seq.no}
selectdo
selectempty
|tdwms610 fields
tdwms610.asnn = asn.no
tdwms610.suno = supplier
tdwms610.seqn = seq.no
tdwms610.tsdt = trans.date
tdwms610.tstm = trans.time
tdwms610.stat = purpose.code
tdwms610.proc = tcyesno.no
tdwms610.updt = curr.date
tdwms610.uptm = curr.time
table.name = "tdwms610"
table.eror = db.insert(ttdwms610,db.retry,db.return.error)
if table.eror <> 0 then
abort.transaction()
x.error.code = form.text$("tdwms26210.26")
|* Error : %s on Table %s
x.error.code = sprintf$(x.error.code,table.eror,table.name)
write.log.table()
error.found = true
return
endif
|tdwms611 fields
tdwms611.asnn = asn.no
tdwms611.suno = supplier
tdwms611.seqn = seq.no
tdwms611.pack = packing.list.no
tdwms611.bill = bill.lading.no
tdwms611.crer = carrier.ref.no
tdwms611.frgh = freight.bill.no
tdwms611.shdt = ship.date
tdwms611.shtm = ship.time
tdwms611.ardt = arrival.date
tdwms611.artm = arrival.time
tdwms611.cont = no.container
tdwms611.wght = wght.shipment
tdwms611.unit = wght.uom
tdwms611.shto = ship.to.code
tdwms611.scac = scac.code
table.name = "tdwms611"
table.eror = db.insert(ttdwms611,db.retry,db.return.error)
if table.eror <> 0 then
abort.transaction()
x.error.code = form.text$("tdwms26210.26")
|* Error : %s on Table %s
x.error.code = sprintf$(x.error.code,str$(db.error.message()),table.name)
write.log.table()
error.found = true
return
endif
commit.transaction()
temp.date = arrival.date
if temp.date = 0 then
temp.date = curr.date
endif
endselect
}
function fill.lines()
{
select tdwms615.item
from tdwms615
where tdwms615._index1 = {:tdwms610.asnn,:tdwms610.suno,:tdwms610.seqn,:pack.list.2,:item}
selectdo
selectempty
tdwms615.asnn = tdwms610.asnn
tdwms615.suno = tdwms610.suno
tdwms615.seqn = tdwms610.seqn
tdwms615.item = item
tdwms615.cpno = vendor.item
tdwms615.plno = pack.list.2
tdwms615.revi = revision
tdwms615.cuni = uom
tdwms615.quan = unit.ship
tdwms615.aqun = unit.ship
tdwms615.pkgs = 1
tdwms615.apkg = 1
tdwms615.proc = tcyesno.no
tdwms615.recp = tcyesno.no
tdwms615.prdt = 0
tdwms615.prtm = 0
tdwms615.vald = tcyesno.no
tdwms615.fcun = file.uom
tdwms615.cont = 0
tdwms615.copo = 0
tdwms615.schn = 0
tdwms615.orno = 0
tdwms615.pono = 0
tdwms615.reno = 0
tdwms615.ecod = ""
tdwms615.eafs = ""
tdwms615.eror = ""
if validate.record(tdwms615.asnn, |Function From DLL tdwmsdll0016
tdwms615.item,
tdwms615.suno,
tdwms615.cuni,
tdwms615.aqun,
temp.date,
false, |FLAG
tdwms615.ecod,
tdwms615.eror,
tdwms615.eafs,
tdwms615.cont,
tdwms615.copo,
tdwms615.schn,
tdwms615.plno) then
tdwms615.vald = tcyesno.yes
endif
tdwms615.aqun = unit.ship
table.name = "tdwms615"
table.eror = db.insert(ttdwms615,db.retry,db.return.error)
if table.eror <> 0 then
abort.transaction()
x.error.code = form.text$("tdwms26210.25")
|* Error : %s on Table %s for Item %s
x.error.code = sprintf$(x.error.code,str$(db.error.message()),table.name,item)
write.log.table()
error.found = true
return
endif
endselect
| commit.transaction()
}
function long rec.processed()
{
m.seqn = 0
select tdwms615.proc,tdwms615.seqn:m.seqn
from tdwms615
where tdwms615._index1 = {:asn.no}
and tdwms615.proc = tcyesno.yes
as set with 1 rows
selectdo
return(true)
selectempty
select tdwms650.seqn:m.seqn,tdwms650.asnn,tdwms650.suno
from tdwms650
where tdwms650._index1 = {:asn.no}
order by tdwms650._index1 desc
as set with 1 rows
selectdo
select tdwms655.proc,tdwms655.seqn
from tdwms655
where tdwms655._index1 = {:tdwms650.asnn,:tdwms650.suno,:m.seqn}
and tdwms655.proc = tcyesno.yes
as set with 1 rows
selectdo
return(true)
endselect
endselect
endselect
return(false)
}
function long find.seq()
{
m.seqn = 0
select tdwms610.seqn:m.seqn
from tdwms610
where tdwms610._index1 = {:asn.no}
as set with 1 rows
selectdo
return(true)
selectempty
select tdwms650.seqn:m.seqn,tdwms650.asnn,tdwms650.suno
from tdwms650
where tdwms650._index1 = {:asn.no}
order by tdwms650._index1 desc
as set with 1 rows
selectdo
return(true)
endselect
endselect
return(false)
}
function cancel.asnn.data()
{
select tdwms610.*
from tdwms610 for update
where tdwms610._index1 = {:asn.no}
selectdo
rcd.ttdwms650 = rcd.ttdwms610
tdwms650.asns = tdwms.arcv.can
tdwms650._compnr = tdwms610._compnr
db.insert(ttdwms650,db.retry,db.skip.dupl)
select tdwms611.*
from tdwms611 for update
where tdwms611._index1 = {:tdwms610.asnn,:tdwms610.suno,:tdwms610.seqn}
selectdo
rcd.ttdwms651 = rcd.ttdwms611
tdwms651._compnr = tdwms611._compnr
db.insert(ttdwms651,db.retry,db.skip.dupl)
db.delete(ttdwms611,db.retry)
endselect
select tdwms615.*
from tdwms615 for update
where tdwms615._index1 = {:tdwms610.asnn,:tdwms610.suno,:tdwms610.seqn}
selectdo
rcd.ttdwms655 = rcd.ttdwms615
tdwms655._compnr = tdwms615._compnr
db.insert(ttdwms655,db.retry,db.skip.dupl)
select tdwms616.*
from tdwms616 for update
where tdwms616._index1 = {:tdwms615.asnn,:tdwms615.suno,:tdwms615.seqn,:tdwms615.plno,:tdwms615.item}
selectdo
rcd.ttdwms656 = rcd.ttdwms616
tdwms656._compnr = tdwms616._compnr
db.insert(ttdwms656,db.retry,db.skip.dupl)
db.delete(ttdwms616,db.retry)
endselect
| rcd.ttdwms655 = rcd.ttdwms615
| tdwms655._compnr = tdwms615._compnr
| db.insert(ttdwms655,db.retry,db.skip.dupl)
db.delete(ttdwms615,db.retry)
endselect
db.delete(ttdwms610,db.retry,db.return.ref.exists)
commit.transaction()
selectempty
m.seqn = 0
endselect
}
function display.form.message(domain tcmcs.str60 mess.desc)
{
string dat(12)
string ndat(15)
disp.messg = ""
dat = dte$()
ndat = dat(3;2) & "-" & dat(1;2) & "-" &dat(5;2) & ":" & dat(7;2) & ":" & dat(9;2) & ":" & dat(11;2)
disp.messg = ndat & "-" & mess.desc
display("disp.messg")
}
function validate.filename()
{
path.input = strip$(concat$("/",strip$(path.input.o),file.name))
if file.name(1;5) <> strip$(tdwms600.file) then
seq.puts(sprintf$(form.text$("tdwms26210.04"),file.name),fp.log.tmp)
|* Invalid File Name %s! File Skipped!
err.hap = tcyesno.yes
return
endif
}
function validate.filename.new()
{
path.move = strip$(concat$("/",strip$(path.move.o),file.name))
if file.name(1;5) <> strip$(tdwms600.file) then
seq.puts(sprintf$(form.text$("tdwms26210.04"),file.name),fp.log.tmp)
|* Invalid File Name %s! File Skipped!
err.hap = tcyesno.yes
return
endif
}
function move_source_files() | POLCUS10.sn
{
long ret, ret1
string dat(12)
long file.size,c.time,m.time,a.time
dat = dte$()
| bckp.path = strip$(concat$("/",strip$(path.proc.o),"bkp"))
| bckp.path = strip$(concat$("/",strip$(bckp.path),file.name))
| path.proc = strip$(concat$("/",strip$(path.proc.o),file.name)) &"_"& dat(5;2) & dat(1;2) & dat(3;2) & dat(7;6)
mv.path.name = "mv " & path.move &" " & path.input
if file.stat(path.move,file.size,c.time,m.time,a.time) = 0 then
| ret = shell(cv.path.name, 0)
ret = shell(mv.path.name, 0)
endif
} | POLCUS10.en
function dele_source_files() |#POLCUS10.sn
{
mv.path.name = "rm " & path.move
ret = shell(mv.path.name, 0)
} |#POLCUS10.en
Here is $BSE/lib/defaults/all
session_timeout:30
use_mbtextconv:1
There is no file bse_vars in $BSE/lib
Thanks in advance