-- begin define variables
define o char(800)
define d char(800)
define p_date date
define p_yest date
define site char(10)
define sdate date
define myord char(10)
--end define variables
main
-- begin define records
define ord record
sono char(10)
end record
define dat record
indoc char(10),
apart char(16),
inlots char(18),
cpart char(16),
serln char(18)
end record
-- end define records
-- begin create temp tables
create temp table sonos
(
sono char(10)
)
create temp table tmpship
(
indoc char(10),
apart char(16),
inlots char(18),
cpart char(16),
serln char(18)
)
create temp table tmpall
(
indoc char(10),
apart char(16),
inlots char(18),
cpart char(16),
serln char(18),
fssitecd char(10),
sotadat date
)
--end create temp tables
let p_date = today
let p_yest = today - 20
--begin selecting orders
display "Selecting Orders..."
insert into sonos
select distinct(sono)
from sodetl
where soladat > p_yest
and sono[5,5] not in ('E','M','N')
and sono[4,4] not in ('E')
and sono[3,5] not in ('RA4')
--order by sono
--end selecting orders
-- begin loop to build temp ship table
let o = "select trim(leading from sono) from sonos"
prepare ex_o from o
declare o_curs cursor for ex_o
display "Selecting Top Part and Serial Data..."
foreach o_curs into ord.*
display ord.sono
let myord = ""
let myord = ord.sono #doesn't work
insert into tmpship
select indoc,apart,inlots,cpart,serln
from inbos
where indoc matches "*myord*" #doesn't work
end foreach
-- end loop to build temp ship table
-- begin loop to build ship table with site and dates
let d = "select * from tmpship"
prepare ex_d from d
declare d_curs cursor for ex_d
display "Selecting Sites and Ship Dates..."
foreach d_curs into dat.*
--select distinct fssitecd,sotadat into site,sdate
--from fssps
--where fssps.sono like dat.indoc
--and sotadat >= p_yest
--and dat.apart = fssps.part
display dat.indoc,dat.apart,dat.inlots,dat.cpart,dat.serln
-- if sdate >= p_yest then
-- insert into tmpall
-- (indoc,apart,inlots,cpart,serln,fssitecd,sotadat)
-- values
-- (dat.indoc,dat.apart,dat.inlots,dat.cpart,dat.serln,site,sdate)
-- end if
end foreach
-- end loop to build ship table with site and dates
-- begin transfer from temp to perm table
insert into cmship
select * from tmpall
-- end transfer from temp to perm table
-- begin drop all temp tables
drop table tmpall
drop table tmpship
drop table sonos
-- end drop all temp tables
end main