QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:td
:TCMOD:sls
:TFLNO:401
:SCPAC:td
:SCMOD:sls
:SFLNO:045
:ICOD:D
:QURY:START
	 If tdsls045.oqua =  0 and tdsls045.amnt =  0 then  
 	 	 | *  Lines with ordered quantity and order amount zero  
 	 	 | *  are not converted to Target.  
 	 	 continue  
 	 endif  
 	 read.sales.order.and.order.type.data()  
 	 g.total.line =  false  
 	 | *  Insert Order Line  
 	 | *************************************************************   
 	 | *  The following line types will be converted in tdsls401 in  
 	 | *  the next cases:  
 	 | *  1. Only one record in tdsls045 with srnb =  0:  
 	 | *  	 	 	 1 order line (sqnb 0)  
 	 | *  2. Record in tdsls045 with srnb >  0:  
 	 | *  	 	 	 1 total line (sqnb 0)  
 	 | *  	 	 	 1 detail line (sqnb 1)  
 	 | *  	 	 	 1 backorder line (sqnb 2) etc  
 	 | *  401 -  Total lines will be converted with dump1  
 	 | *  401 -  Detail lines (sqnb =  0) will be converted with dump1  
 	 | *  401 -  Backorder lines (sqnb >  0) will be converted with dump1  
 	 | *  402 -  Linked order line data will be converted with dump2  
 	 | *  406 -  Actual order lines (tdsls045.date <>  0) will be converted  
 	 | *  	 with dump3  
 	 | *  tcibd410 -  Lot and serial set for the actual delivery lines dump5  
 	 | *  tcibd411 -  Lot and serial set detail for the actual delivery lines dump6  
 	 | *  409 -  actual cogs record belongning to the actual delivery line dump7  
 	 | *************************************************************   
 	 if g.ilc.implemented then 	 	 | #  800 -  143063  
 	 	 migrate.outbound.data.to.sales.order.deliveries()  
 	 	 | *  This function will perform a dump1 and dump2  
 	 	 | *  for each tdilc401 record.  
 	 else 	 	 	 	 	 | #  800 -  143063.en  
 	 	 dump 1 | *  tdsls401 (convert detail or backorder record)  
 	 	 if convert.linked.order.line.data() then  
 	 	 	 dump 2 | *  tdsls402 (linked order line data)  
 	 	 endif  
 	 endif 	 	 	 	 	 | #  800 -  143063.n  
 	 | *  tdsls401 Insert Total Line record:  
 	 | *  When there is more than one delivery line, then there is a  
 	 | *  backorder line, so a total line must be created. But also when no  
 	 | *  backorder line is present but the backorder quantity <>  0 then a  
 	 | *  backorder is expected and a total line will be created.  
 	 | *  For a Total line no linked order line data will be inserted.  
 	 if tdsls045.srnb =  0 and total.line.required() then  
 	 	 g.total.line =  true  
 	 	 get.total.line.values()  
 	 	 dump 1 | *  tdsls401 Sales order line  
 	 	 g.total.line =  false  
 	 endif  
 	 | *  Insert an Actual Delivery record when the (actual) delivery date  
 	 | *  is filled.  
 | 	 if tdsls045.ddat <>  0 then 	 	 	 | #  800 -  143063.o  
 	 	 	 	 	 	 	 | #  800 -  143063.sn  
 	 if tdsls045.ddat <>  0 and not g.ilc.implemented then  
 	 | *  For ilc implemented the actual deliveries for the delivered  
 	 | *  outbound advices are handled in function  
 	 | *  migrate.outbound.data.to.sales.order.deliveries  
 	 	 	 	 	 	 	 | #  800 -  143063.en  
 	 	 dump.actual.delivery() 	 	 	 | #  sp1.n  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:td
:TCMOD:sls
:TFLNO:401
:SCPAC:td
:SCMOD:sls
:SFLNO:045
:ICOD:S
:QURY:START
select 	 tdsls045.*  , tdsls041.*
from 	 tdsls045, tdsls041
where 	 tdsls041._index1 =  { 	 tdsls045.orno,  
 	 	 	 	 tdsls045.pono}
order by tdsls045._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:td
:TCMOD:sls
:TFLNO:401
:SCPAC:td
:SCMOD:sls
:SFLNO:045
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:td
:TCMOD:sls
:TFLNO:451
:SCPAC:td
:SCMOD:sls
:SFLNO:051
:ICOD:D
:QURY:START
	 read.sales.order.header.history()  
 	 convert.tax()  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:td
:TCMOD:sls
:TFLNO:451
:SCPAC:td
:SCMOD:sls
:SFLNO:051
:ICOD:S
:QURY:START
select 	 tdsls051.*
from 	 tdsls051
order by tdsls051._index1 desc
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:td
:TCMOD:sls
:TFLNO:451
:SCPAC:td
:SCMOD:sls
:SFLNO:051
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:000
:SCPAC:ct
:SCMOD:cat
:SFLNO:001
:ICOD:D
:QURY:START


var.tfcat000.indt =  utc(0, 0)  
 var.tfcat000.dsca =  form.text$("bcstc00035") | *  Actual Set  
 dump 1  
 var.tfcat000.indt =  utc(date.num(), time.num())  
 var.tfcat000.dsca =  form.text$("bcstc00036") | *  Converted from Baan IVc4  
 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:000
:SCPAC:ct
:SCMOD:cat
:SFLNO:001
:ICOD:S
:QURY:START


select ctcat001
from ctcat001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:000
:SCPAC:ct
:SCMOD:cat
:SFLNO:001
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:004
:SCPAC:ct
:SCMOD:cat
:SFLNO:050
:ICOD:D
:QURY:START


	 on case ctcat050.cpor  
 	 	 case ctcat.cpor.bdev:  
 	 	 	 var.tfcat004.cpor =  1 	 	 | tfcat.cpor.odev  
 	 	 	 break  
 	 	 case ctcat.cpor.vdev:  
 	 	 	 var.tfcat004.cpor =  2 	 	 |tfcat.cpor.cdev  
 	 	 	 break  
 	 	 case ctcat.cpor.udev:  
 	 	 	 var.tfcat004.cpor =  3 	 	 |tfcat.cpor.ouco  
 	 	 	 break  
 	 	 case ctcat.cpor.cfix:  
 	 	 	 var.tfcat004.cpor =  4 	 	 |tfcat.cpor.cfix  
 	 	 	 break  
 	 	 case ctcat.cpor.call:  
 	 	 	 var.tfcat004.cpor =  5 | 	 	 tfcat.cpor.call  
 	 	 	 break  
 	 endcase  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:004
:SCPAC:ct
:SCMOD:cat
:SFLNO:050
:ICOD:S
:QURY:START


select 	 ctcat050.*
from ctcat050
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:004
:SCPAC:ct
:SCMOD:cat
:SFLNO:050
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:210
:SCPAC:ct
:SCMOD:cat
:SFLNO:220
:ICOD:D
:QURY:START


	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:210
:SCPAC:ct
:SCMOD:cat
:SFLNO:220
:ICOD:S
:QURY:START


select 	 ctcat220.*
from ctcat220
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:210
:SCPAC:ct
:SCMOD:cat
:SFLNO:220
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:211
:SCPAC:ct
:SCMOD:cat
:SFLNO:221
:ICOD:D
:QURY:START


	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:211
:SCPAC:ct
:SCMOD:cat
:SFLNO:221
:ICOD:S
:QURY:START


select 	 ctcat221.*
from ctcat221
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:211
:SCPAC:ct
:SCMOD:cat
:SFLNO:221
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:220
:SCPAC:ct
:SCMOD:cat
:SFLNO:210
:ICOD:D
:QURY:START


	 on case ctcat210.rtyp  
 	 	 case ctcat.rtyp.performance:  
 	 	 	 var.tfcat220.pqan =  ctcat210.perf  
 	 	 	 break  
 	 	 case ctcat.rtyp.balance:  
 	 	 	 var.tfcat220.pqan =  0.0  
 	 	 	 break  
 	 	 case ctcat.rtyp.allocation:  
 	 	 	 var.tfcat220.pqan =  ctcat210.yper  
 	 	 	 break  
 	 endcase  
 	 	  
 	 if ctcat210.pdfa <=  1 then  
 	 	 var.tfcat220.pdpe =  ctcat210.pdfa *  100  
 	 else  
 	 	 if ctcat210.year <>  prev.year then  
 	 	 	 select 	 count( *  ):no.of.periods  
 	 	 	 from 	 tfgld005  
 	 	 	 where 	 tfgld005.ptyp =  tfgld.ptyp.financial  
 	 	 	 and 	 tfgld005.year =  :ctcat210.year  
 	 	 	 and 	 tfgld005.corr =  tcyesno.no  
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 endselect  
 	 	 	 prev.year =  ctcat210.year  
 	 	 	 var.tfcat220.pdpe =  (ctcat210.pdfa *  100) /  no.of.periods  
 	 	 endif  
 	 endif  
 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:220
:SCPAC:ct
:SCMOD:cat
:SFLNO:210
:ICOD:S
:QURY:START


select 	 ctcat210.*
from ctcat210
order by ctcat210.year
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:220
:SCPAC:ct
:SCMOD:cat
:SFLNO:210
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:221
:SCPAC:ct
:SCMOD:cat
:SFLNO:215
:ICOD:D
:QURY:START
	 	 	 	 	 | #  203100.sn  
 	 hold.ncmp =  ctcat215.ncmp  
 	 hold.dtyp =  ctcat215.dtyp  
 	 hold.dimx =  ctcat215.dimx  
 	 hold.refu =  ctcat215.refu  
 	 	 	 	 	 | #  203100.en  
 	 on case ctcat215.ityp  
 	 	 case ctcat.ityp.cw.emno:  
 	 	 	 var.tfcat221.kihr =  2 	 	 |tfcat.kihr.man  
 	 	 	 var.tfcat221.hoco =  1 	 	 |tfcat.hoco.cwoc  
 	 	 	 break  
 	 	 case ctcat.ityp.cw.mcno:  
 	 	 	 var.tfcat221.kihr =  1 	 	 |tfcat.kihr.machine  
 	 	 	 var.tfcat221.hoco =  1 	 	 |tfcat.hoco.cwoc  
 	 	 	 break  
 	 	 case ctcat.ityp.emno:  
 	 	 	 var.tfcat221.kihr =  2 	 	 |tfcat.kihr.man  
 	 	 	 var.tfcat221.hoco =  2 	 	 |tfcat.hoco.emno  
 	 	 	 break  
 	 	 case ctcat.ityp.mcno:  
 	 	 	 var.tfcat221.kihr =  1 	 	 |tfcat.kihr.machine  
 	 	 	 var.tfcat221.hoco =  3 	 	 |tfcat.hoco.mcno  
 	 	 	 break  
 	 	 case ctcat.ityp.rou.emno:  
 	 	 	 var.tfcat221.kihr =  2 	 	 |tfcat.kihr.man  
 	 	 	 var.tfcat221.hoco =  5 	 	 |tfcat.hoco.mtan  
 	 	 	 break  
 	 	 case ctcat.ityp.rou.mcno:  
 	 	 	 var.tfcat221.kihr =  1 	 	 |tfcat.kihr.machine  
 	 	 	 var.tfcat221.hoco =  5 	 	 |tfcat.hoco.mtan  
 	 endcase  
 	 	 	 	 	 	 | #  203100.sn  
 	 sern.count =  0  
 	 if ctcat215.sern =  0 then  
 	 	 sern.count =  get.highest.count.of.sern()  
 	 	 var.tfcat221.sern =  sern.count +  1  
 	 else  
 	 	 var.tfcat221.sern =  ctcat215.sern  
 	 endif 	  
 	 	 	 	 	 	 | #  203100.en  
 	 dump 1  
 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:221
:SCPAC:ct
:SCMOD:cat
:SFLNO:215
:ICOD:S
:QURY:START
select 	 ctcat215.*
from ctcat215
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:221
:SCPAC:ct
:SCMOD:cat
:SFLNO:215
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:240
:SCPAC:ct
:SCMOD:cat
:SFLNO:320
:ICOD:D
:QURY:START


	 if ctcat320.budg =  ctcat001.budg then  
 	 	 select 	 ctcat330.post  
 	 	 from 	 ctcat330  
 	 	 where 	 ctcat330._index1 =  {:ctcat320.year,  
 	 	 	 	 	 :ctcat320.prod,  
 	 	 	 	 	 :ctcat320.dtyp,  
 	 	 	 	 	 :ctcat320.dimx}  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 if ctcat330.post =  empty then  
 	 	 	 	 var.tfcat240.post =  tcyesno.no  
 	 	 	 else  
 	 	 	 	 var.tfcat240.post =  ctcat330.post  
 	 	 	 endif  
 	 	 selectempty  
 	 	 	 var.tfcat240.post =  tcyesno.no  
 	 	 endselect  
 	 else  
 	 	 var.tfcat240.post =  tcyesno.no  
 	 endif  
 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:240
:SCPAC:ct
:SCMOD:cat
:SFLNO:320
:ICOD:S
:QURY:START


select 	 ctcat320.*
from ctcat320
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:240
:SCPAC:ct
:SCMOD:cat
:SFLNO:320
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:400
:SCPAC:ct
:SCMOD:cat
:SFLNO:400
:ICOD:D
:QURY:START


	 var.tfcat400.igld =  tcyesno.no  
 	 var.tfcat400.icat =  tcyesno.no  
 	 var.tfcat400.ifbs =  tcyesno.no  
 	 var.tfcat400.pdpe =  0.0  
 	 select ctcat015.rtyp  
 	 from ctcat015  
 	 where ctcat015._index1 =  {:ctcat400.sdty,  
 	 	 	 	 :ctcat400.sdim,  
 	 	 	 	 :ctcat400.sref}  
 	 as set with 1 rows  
 	 selectdo  
 	 	 if ctcat015.rtyp =  ctcat.rtyp.allocation then  
 	 	 	 var.tfcat400.pdpe =  100  
 	 	 else  
 	 	 	 var.tfcat400.pdpe =  0.0  
 	 	 endif  
 	 endselect  
 	 on case ctcat400.fvfp  
 	 	 case ctcat.fvfi.full:  
 	 	 	 var.tfcat400.valp =  3  
 	 	 	 break  
 	 	 case ctcat.fvfi.variable:  
 	 	 	 var.tfcat400.valp =  2  
 	 	 	 break  
 	 	 case ctcat.fvfi.fix:  
 	 	 	 var.tfcat400.valp =  1  
 	 	 	 break  
 	 	 default:  
 	 	 	 var.tfcat400.valp =  3  
 	 endcase  
 	 if ctcat400.cint =  tcyesno.yes then  
 	 	 var.cini =  1 	 | *  tfcat.cini  
 	 else  
 	 	 var.cini =  4 	 | *  tfcat.none  
 	 endif  
 	 if ctcat400.cint =  tcyesno.yes then  
 	 	 var.tfcat400.ifbs =  tcyesno.yes  
 	 endif  
 dump 400
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:400
:SCPAC:ct
:SCMOD:cat
:SFLNO:400
:ICOD:S
:QURY:START


select 	 ctcat400.*
from 	 ctcat400
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:400
:SCPAC:ct
:SCMOD:cat
:SFLNO:400
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:400
:SCPAC:ct
:SCMOD:cat
:SFLNO:401
:ICOD:D
:QURY:START


	 var.tfcat400.igld =  tcyesno.no  
 	 var.tfcat400.icat =  tcyesno.no  
 	 var.tfcat400.ifbs =  tcyesno.no  
 	 var.tfcat400.pdpe =  0.0  
 	 select 	 ctcat400.disb,ctcat400.coca,  
 	 	 ctcat400.slea,ctcat400.cint  
 	 from ctcat400  
 	 where ctcat400._index1 =  {:ctcat401.year,  
 	 	 	 	 :ctcat401.budg,  
 	 	 	 	 :ctcat401.tdty,  
 	 	 	 	 :ctcat401.tdim,  
 	 	 	 	 :ctcat401.tref,  
 	 	 	 	 :ctcat401.tlea,  
 	 	 	 	 :ctcat401.sdty,  
 	 	 	 	 :ctcat401.sdim,  
 	 	 	 	 :ctcat401.sref,  
 	 	 	 	 :ctcat401.sern}  
 	 as set with 1 rows  
 	 selectdo  
 	 	 var.tfcat400.disb =  ctcat400.disb  
 	 	 var.tfcat400.coca =  ctcat400.coca  
 	 	 var.tfcat400.slea =  ctcat400.slea  
 	 	 var.tfcat400.dvar =  ctcat400.tpor  
 	 	 if ctcat400.cint =  tcyesno.yes then  
 	 	 	 var.cini =  1 	 | *  tfcat.cini.fbs  
 	 	 else  
 	 	 	 var.cini =  4 	 | *  tfcat.cini.none  
 	 	 endif  
 	 	 if ctcat400.cint =  tcyesno.yes then  
 	 	 	 var.tfcat400.ifbs =  tcyesno.yes  
 	 	 endif  
 	 	 on case ctcat400.fvfp  
 	 	 	 case ctcat.fvfi.full:  
 	 	 	 	 var.tfcat400.valp =  3  
 	 	 	 	 break  
 	 	 	 case ctcat.fvfi.variable:  
 	 	 	 	 var.tfcat400.valp =  2  
 	 	 	 	 break  
 	 	 	 case ctcat.fvfi.fix:  
 	 	 	 	 var.tfcat400.valp =  1  
 	 	 	 	 break  
 	 	 	 default:  
 	 	 	 	 var.tfcat400.valp =  3  
 	 	 endcase  
 	 endselect  
 	 select ctcat015.rtyp  
 	 from ctcat015  
 	 where ctcat015._index1 =  {:ctcat401.sdty,  
 	 	 	 	 :ctcat401.sdim,  
 	 	 	 	 :ctcat401.sref}  
 	 as set with 1 rows  
 	 selectdo  
 	 	 if ctcat015.rtyp =  ctcat.rtyp.allocation then  
 	 	 	 var.tfcat400.pdpe =  ctcat401.pdfa  
 	 	 else  
 	 	 	 var.tfcat400.pdpe =  0.0  
 	 	 endif  
 	 endselect  
 	 dump 401
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:400
:SCPAC:ct
:SCMOD:cat
:SFLNO:401
:ICOD:S
:QURY:START


select 	 ctcat401.*
from 	 ctcat401
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:400
:SCPAC:ct
:SCMOD:cat
:SFLNO:401
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:400
:SCPAC:ct
:SCMOD:cat
:SFLNO:500
:ICOD:D
:QURY:START


	 var.tfcat400.igld =  tcyesno.no  
 	 var.tfcat400.icat =  tcyesno.no  
 	 var.tfcat400.ifbs =  tcyesno.no  
 	 var.tfcat400.pdpe =  0.0  
 	 select ctcat015.rtyp  
 	 from ctcat015  
 	 where ctcat015._index1 =  {:ctcat500.sdty,  
 	 	 	 	 :ctcat500.sdim,  
 	 	 	 	 :ctcat500.sref}  
 	 as set with 1 rows  
 	 selectdo  
 	 	 if ctcat015.rtyp =  ctcat.rtyp.allocation then  
 	 	 	 var.tfcat400.pdpe =  ctcat500.pdfa  
 	 	 else  
 	 	 	 var.tfcat400.pdpe =  0  
 	 	 endif  
 	 endselect  
 	 on case ctcat500.fvfp  
 	 	 case ctcat.fvfi.full:  
 	 	 	 var.tfcat400.valp =  3 	 | *  tfcat.valp.total  
 	 	 	 break  
 	 	 case ctcat.fvfi.variable:  
 	 	 	 var.tfcat400.valp =  2 	 | *  tfcat.valp.variable  
 	 	 	 break  
 	 	 case ctcat.fvfi.fix:  
 	 	 	 var.tfcat400.valp =  1 	 | *  tfcat.valp.fixed  
 	 	 	 break  
 	 	 default:  
 	 	 	 var.tfcat400.valp =  3  
 	 endcase  
 	 if ctcat500.cint =  tcyesno.yes then  
 	 	 var.cini =  2 	 | *  tfcat.cini.cat  
 	 else  
 	 	 var.cini =  4 	 | *  tfcat.cini.none  
 	 endif  
 	 if ctcat500.cint =  tcyesno.yes then  
 	 	 var.tfcat400.icat =  tcyesno.yes  
 	 endif  
 	 dump 500
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:400
:SCPAC:ct
:SCMOD:cat
:SFLNO:500
:ICOD:S
:QURY:START


select 	 ctcat500.*
from 	 ctcat500
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:400
:SCPAC:ct
:SCMOD:cat
:SFLNO:500
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:412
:SCPAC:ct
:SCMOD:cat
:SFLNO:412
:ICOD:D
:QURY:START


	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:412
:SCPAC:ct
:SCMOD:cat
:SFLNO:412
:ICOD:S
:QURY:START


select 	 ctcat412.*
from ctcat412
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:cat
:TFLNO:412
:SCPAC:ct
:SCMOD:cat
:SFLNO:412
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:000
:SCPAC:ct
:SCMOD:cat
:SFLNO:001
:ICOD:D
:QURY:START


	 var.tffbs000.indt =  utc(0, 0)  
 	 var.str.tffbs000.dsca =  form.text$("bcstc00035") | *  Actual Set  
 	 dump 1  
 	 var.tffbs000.indt =  utc(date.num(), time.num())  
 	 var.str.tffbs000.dsca =  form.text$("bcstc00036") | *  Converted from Baan IVc4  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:000
:SCPAC:ct
:SCMOD:cat
:SFLNO:001
:ICOD:S
:QURY:START


select 	 ctcat001.*
from ctcat001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:000
:SCPAC:ct
:SCMOD:cat
:SFLNO:001
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:003
:SCPAC:tf
:SCMOD:fbs
:SFLNO:003
:ICOD:D
:QURY:START


	 select 	 ctcat110.budg  
 	 from 	 ctcat110  
 	 where 	 ctcat110.budg =  :tffbs003.budg  
 	 as set with 1 rows  
 	 selectdo  
 	 	 var.tffbs003.sdbu =  tcyesno.yes  
 	 selectempty  
 	 	 var.tffbs003.sdbu =  tcyesno.no  
 	 endselect  
 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:003
:SCPAC:tf
:SCMOD:fbs
:SFLNO:003
:ICOD:S
:QURY:START


select tffbs003.*
from tffbs003
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:003
:SCPAC:tf
:SCMOD:fbs
:SFLNO:003
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:005
:SCPAC:tf
:SCMOD:fbs
:SFLNO:101
:ICOD:D
:QURY:START


	 select tffbs003.*   
 	 from tffbs003  
 	 where tffbs003._index1 =  {:tffbs101.budg}  
 	 as set with 1 rows  
 	 selectdo  
 	 	 if not isspace(tffbs003.pbud) then  
 	 	 	 var.tffbs005.pbyr =  tffbs101.year  
 	 	 else  
 	 	 	 var.tffbs005.pbyr =  0  
 	 	 endif  
 	 	 if not isspace(tffbs003.cobu) then  
 	 	 	 var.tffbs005.cbyr =  tffbs101.year  
 	 	 else  
 	 	 	 var.tffbs005.cbyr =  0  
 	 	 endif  
 	 	 if not isspace(tffbs003.dbud) then  
 	 	 	 var.tffbs005.dbyr =  tffbs101.year  
 	 	 else  
 	 	 	 var.tffbs005.dbyr =  0  
 	 	 endif  
 	 	 select 	 ctcat016.defi  
 	 	 from 	 ctcat016  
 	 	 where 	 ctcat016._index1 =  {:tffbs101.year, :tffbs101.budg}  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 endselect  
 endselect  
 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:005
:SCPAC:tf
:SCMOD:fbs
:SFLNO:101
:ICOD:S
:QURY:START


select tffbs101.budg,tffbs101.year
from tffbs101
group by tffbs101.year,tffbs101.budg
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:005
:SCPAC:tf
:SCMOD:fbs
:SFLNO:101
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:010
:SCPAC:ct
:SCMOD:cat
:SFLNO:002
:ICOD:D
:QURY:START


	 | *  Dump records from ctcat002  
 	 on case 	 ctcat002.dtyp  
 	 	 case 	 1:  
 	 	 	 var.tffbs010.adt1 =  1  
 	 	 	 var.tffbs010.adt2 =  2  
 	 	 	 var.tffbs010.adt3 =  2  
 	 	 	 var.tffbs010.adt4 =  2  
 	 	 	 var.tffbs010.adt5 =  2  
 	 	 	 break  
 	 	 case 	 2:  
 	 	 	 var.tffbs010.adt1 =  2  
 	 	 	 var.tffbs010.adt2 =  1  
 	 	 	 var.tffbs010.adt3 =  2  
 	 	 	 var.tffbs010.adt4 =  2  
 	 	 	 var.tffbs010.adt5 =  2  
 	 	 	 break  
 	 	 case 	 3:  
 	 	 	 var.tffbs010.adt1 =  2  
 	 	 	 var.tffbs010.adt2 =  2  
 	 	 	 var.tffbs010.adt3 =  1  
 	 	 	 var.tffbs010.adt4 =  2  
 	 	 	 var.tffbs010.adt5 =  2  
 	 	 	 break  
 	 	 case 	 4:  
 	 	 	 var.tffbs010.adt1 =  2  
 	 	 	 var.tffbs010.adt2 =  2  
 	 	 	 var.tffbs010.adt3 =  2  
 	 	 	 var.tffbs010.adt4 =  1  
 	 	 	 var.tffbs010.adt5 =  2  
 	 	 	 break  
 	 	 case 	 5:  
 	 	 	 var.tffbs010.adt1 =  2  
 	 	 	 var.tffbs010.adt2 =  2  
 	 	 	 var.tffbs010.adt3 =  2  
 	 	 	 var.tffbs010.adt4 =  2  
 	 	 	 var.tffbs010.adt5 =  1  
 	 	 	 break  
 	 endcase  
 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:010
:SCPAC:ct
:SCMOD:cat
:SFLNO:002
:ICOD:S
:QURY:START


select 	 ctcat002.*
from ctcat002
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:010
:SCPAC:ct
:SCMOD:cat
:SFLNO:002
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:011
:SCPAC:ct
:SCMOD:cat
:SFLNO:003
:ICOD:D
:QURY:START


	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:011
:SCPAC:ct
:SCMOD:cat
:SFLNO:003
:ICOD:S
:QURY:START


select 	 ctcat003.*
from ctcat003
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:011
:SCPAC:ct
:SCMOD:cat
:SFLNO:003
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:012
:SCPAC:ct
:SCMOD:cat
:SFLNO:004
:ICOD:D
:QURY:START


	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:012
:SCPAC:ct
:SCMOD:cat
:SFLNO:004
:ICOD:S
:QURY:START


select 	 ctcat004.*
from ctcat004
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:012
:SCPAC:ct
:SCMOD:cat
:SFLNO:004
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:020
:SCPAC:ct
:SCMOD:cat
:SFLNO:010
:ICOD:D
:QURY:START


	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:020
:SCPAC:ct
:SCMOD:cat
:SFLNO:010
:ICOD:S
:QURY:START


select 	 ctcat010.*
from ctcat010
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:020
:SCPAC:ct
:SCMOD:cat
:SFLNO:010
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:021
:SCPAC:ct
:SCMOD:cat
:SFLNO:021
:ICOD:D
:QURY:START


	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:021
:SCPAC:ct
:SCMOD:cat
:SFLNO:021
:ICOD:S
:QURY:START


select 	 ctcat021.*
from ctcat021
where 	 ctcat021.mult <=  1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:021
:SCPAC:ct
:SCMOD:cat
:SFLNO:021
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:030
:SCPAC:ct
:SCMOD:cat
:SFLNO:015
:ICOD:D
:QURY:START


	 | *  Dump records from ctcat015  
 	 on case ctcat015.rtyp  
 	 case ctcat.rtyp.performance:  
 	 	 	 var.tffbs030.rtyp =  2 	 | *  tfffbs.rtyp.quan  
 	 	 	 var.tffbs030.slea =  empty.string(1;12)  
 	 	 	 var.tffbs030.pdpa =  2 	 | *  tcyesno.no  
 	 	 	 break  
 	 	 case ctcat.rtyp.balance:  
 	 	 	 var.tffbs030.rtyp =  1 	 | *  tffbs.rtyp.amount  
 	 	 	 var.tffbs030.slea =  ctcat015.leac  
 	 	 	 var.tffbs030.pdpa =  2 	 | *  tcyesno.no  
 	 	 	 break  
 	 	 case ctcat.rtyp.allocation:  
 	 	 	 var.tffbs030.rtyp =  2 	 | *  tffbs.rtyp.quan  
 	 	 	 var.tffbs030.slea =  empty.string(1;12)  
 	 	 	 var.tffbs030.pdpa =  1 	 | *  tcyesno.yes  
 	 	 	 break  
 	 endcase  
 	 on case ctcat015.kopl  
 	 	 case ctcat.kopl.progressive:  
 	 	 	 var.tffbs030.ptyp =  1 	 | *  tfffbs.ptyp.progressive  
 	 	 	 break  
 	 	 case ctcat.kopl.retrograde:  
 	 	 	 var.tffbs030.ptyp =  2 	 | *  tffbs.ptyp.retrograde  
 	 	 	 break  
 	 endcase  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:030
:SCPAC:ct
:SCMOD:cat
:SFLNO:015
:ICOD:S
:QURY:START


select 	 ctcat015.*
from ctcat015
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:030
:SCPAC:ct
:SCMOD:cat
:SFLNO:015
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:040
:SCPAC:ct
:SCMOD:cat
:SFLNO:014
:ICOD:D
:QURY:START


	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:040
:SCPAC:ct
:SCMOD:cat
:SFLNO:014
:ICOD:S
:QURY:START


select 	 ctcat014.*
from ctcat014
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:040
:SCPAC:ct
:SCMOD:cat
:SFLNO:014
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:041
:SCPAC:ct
:SCMOD:cat
:SFLNO:012
:ICOD:D
:QURY:START


	 on case ctcat012.lasu  
 	 	 case ctcat.lasu.leac:  
 	 	 	 var.tffbs041.ltyp =  1 	 | *  tffbs.ltyp.leac  
 	 	 	 break  
 	 	 case ctcat.lasu.sum:  
 	 	 	 var.tffbs041.ltyp =  2 	 | *  tffbs.ltyp.sum  
 	 	 	 break  
 	 endcase  
 	 | *  Dump records from ctcat012  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:041
:SCPAC:ct
:SCMOD:cat
:SFLNO:012
:ICOD:S
:QURY:START


select 	 ctcat012.*
from ctcat012
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:041
:SCPAC:ct
:SCMOD:cat
:SFLNO:012
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:042
:SCPAC:ct
:SCMOD:cat
:SFLNO:013
:ICOD:D
:QURY:START


	 | *  Dump records from ctcat013  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:042
:SCPAC:ct
:SCMOD:cat
:SFLNO:013
:ICOD:S
:QURY:START


select 	 ctcat013.*
from ctcat013
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:042
:SCPAC:ct
:SCMOD:cat
:SFLNO:013
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:100
:SCPAC:tf
:SCMOD:fbs
:SFLNO:101
:ICOD:D
:QURY:START
if tffbs101.prod =  1 then  
 	 	 var.fill.tffbs100 =  true  
 	 else  
 	 	 var.fill.tffbs100 =  false  
 	 endif 	  
 	  
 	 if var.fill.tffbs100 =  true then  
 	 	 select 	 sum (tffbs101.qan2):var.dbl.sum.qan2,  
 	 	 	 sum (tffbs101.qan1):var.dbl.sum.qan1,  
 	 	 	 sum (tffbs101.amnt):var.dbl.sum.amnt  
 	 	 	  
 	 	 from 	 tffbs101  
 	 	 where 	 tffbs101._index1 =  {:tffbs101.year,  
 	 	 	 	 	 :tffbs101.budg,  
 	 	 	 	 	 :tffbs101.leac,  
 	 	 	 	 	 :tffbs101.dim1,  
 	 	 	 	 	 :tffbs101.dim2,  
 	 	 	 	 	 :tffbs101.dim3,  
 	 	 	 	 	 :tffbs101.dim4,  
 	 	 	 	 	 :tffbs101.dim5}  
 	  
 	 	 selectdo  
 	 	  
 	 	 	 dump 1  
 	 	 endselect  
 	 endif  
 	 if isspace(tffbs101.leac) then  
 	 	 var.tffbs101.stam =  0  
 	 else  
 	 	 var.tffbs101.stam =  tffbs101.amnt  
 	 endif  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:100
:SCPAC:tf
:SCMOD:fbs
:SFLNO:101
:ICOD:S
:QURY:START
select 	 tffbs101.*
from 	 tffbs101
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:100
:SCPAC:tf
:SCMOD:fbs
:SFLNO:101
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:110
:SCPAC:ct
:SCMOD:cat
:SFLNO:110
:ICOD:D
:QURY:START


	 if ctcat110.gful <>  0 then  
 	 	 var.tffbs110.brat =  ctcat110.pful /  ctcat110.gful  
 	 else  
 	 	 var.tffbs110.brat =  0  
 	 endif  
 	 | *  Dump records from ctcat110  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:110
:SCPAC:ct
:SCMOD:cat
:SFLNO:110
:ICOD:S
:QURY:START


select 	 ctcat110.*
from ctcat110
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:110
:SCPAC:ct
:SCMOD:cat
:SFLNO:110
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:111
:SCPAC:ct
:SCMOD:cat
:SFLNO:120
:ICOD:D
:QURY:START


	 | *  Dump records from ctcat120  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:111
:SCPAC:ct
:SCMOD:cat
:SFLNO:120
:ICOD:S
:QURY:START


select 	 ctcat120.*
from ctcat120
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:111
:SCPAC:ct
:SCMOD:cat
:SFLNO:120
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:120
:SCPAC:ct
:SCMOD:cat
:SFLNO:111
:ICOD:D
:QURY:START


	 | *  Dump records from ctcat111  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:120
:SCPAC:ct
:SCMOD:cat
:SFLNO:111
:ICOD:S
:QURY:START


select 	 ctcat111.*
from ctcat111
where ctcat111.refu <>  ""
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:120
:SCPAC:ct
:SCMOD:cat
:SFLNO:111
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:121
:SCPAC:ct
:SCMOD:cat
:SFLNO:121
:ICOD:D
:QURY:START


	 | *  Dump records from ctcat121  
 	 var.tffbs121.pdpe =  0.0  
 	 select 	 ctcat015.rtyp  
 	 from 	 ctcat015  
 	 where 	 ctcat015._index1 =  {:ctcat121.dtyp,  
 	 	 	 	 :ctcat121.dimx,  
 	 	 	 	 :ctcat121.refu}  
 	 as set with 1 rows  
 	 selectdo  
 	 	 if ctcat015.rtyp =  ctcat.rtyp.allocation then  
 	 	 	 var.tffbs121.pdpe =  ctcat121.pdfa *  100  
 	 	 else  
 	 	 	 var.tffbs121.pdpe =  0.0  
 	 	 endif  
 	 endselect  
 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:121
:SCPAC:ct
:SCMOD:cat
:SFLNO:121
:ICOD:S
:QURY:START


select 	 ctcat121.*
from ctcat121
where ctcat121.refu <>  ""
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:121
:SCPAC:ct
:SCMOD:cat
:SFLNO:121
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:130
:SCPAC:ct
:SCMOD:cat
:SFLNO:130
:ICOD:D
:QURY:START


	 | *  Dump records from ctcat130  
 	 	 	  
 	 var.cprj =  string.set$(" ",9)  
 	 var.tffbs130.item =  segment.item.code(ctcat130.item,var.cprj)  
 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:130
:SCPAC:ct
:SCMOD:cat
:SFLNO:130
:ICOD:S
:QURY:START


select 	 ctcat130.*
from ctcat130
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:130
:SCPAC:ct
:SCMOD:cat
:SFLNO:130
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:131
:SCPAC:ct
:SCMOD:cat
:SFLNO:131
:ICOD:D
:QURY:START


	 | *  Dump records from ctcat131  
 	 if not get.cost.components(bcorig.ticpr, ctcat131.cpcp,"", o.err.mess) then  
 	 	 var.tffbs131.cpcp =  bcstc006.cost  
 	 else  
 	 	 var.tffbs131.cpcp =  empty.string(1;8)  
 	 endif  
 	 	  
 	 on case ctcat131.oprt  
 	 	 case tioprt.wages:  
 	 	 	 var.tffbs131.orty =  1 	 | *  tcorty.labor  
 	 	 	 break  
 	 	 case tioprt.machine:  
 	 	 	 var.tffbs131.orty =  2 	 | *  tcorty.machine  
 	 	 	 break  
 	 	 case tioprt.overhead:  
 	 	 	 if ctcat131.cmoh =  tccmoh.man.hrs then  
 	 	 	 	 var.tffbs131.orty =  3 	 | *  tcorty.oh.on.man  
 	 	 	 else  
 	 	 	 	 var.tffbs131.orty =  4 	 | *  tcorty.oh.on.mach  
 	 	 	 endif  
 	 	 	 break  
 	 endcase  
 	 if ctcat131.vafi =  tivafi.var then  
 	 	 var.tffbs131.vaco =  1 	 | *  tcyesno.yes  
 	 else  
 	 	 var.tffbs131.vaco =  2 	 | *  tcyesno.no  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:131
:SCPAC:ct
:SCMOD:cat
:SFLNO:131
:ICOD:S
:QURY:START


select 	 ctcat131.*
from ctcat131
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:tf
:TCMOD:fbs
:TFLNO:131
:SCPAC:ct
:SCMOD:cat
:SFLNO:131
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:000
:SCPAC:ti
:SCMOD:cpr
:SFLNO:000
:ICOD:D
:QURY:START
	 | *  set fixed costs included fields 	 | #  CNT.sn  
 	 var.include.fixed.costs =  include.fixed.costs(ticpr000.cpty)  
 	 	 	 	 	 	 | #  CNT.en  
 	 var.ticpr000.indt =  utc(0,0)  
 	 var.ticpr000.dsca =  form.text$("bcstc00035") 	 | *  Actual Set  
 	 Dump 1  
 	  
 	 var.ticpr000.indt =  utc(date.num(), time.num())  
 	 var.ticpr000.dsca =  form.text$("bcstc00036") 	 | *  Converted from BaanIVc4  
 	 Dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:000
:SCPAC:ti
:SCMOD:cpr
:SFLNO:000
:ICOD:S
:QURY:START
select ticpr000.*
from ticpr000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:000
:SCPAC:ti
:SCMOD:cpr
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:110
:SCPAC:ti
:SCMOD:cpr
:SFLNO:110
:ICOD:D
:QURY:START

	 | *  set variable /  fixed costs 	 	 	 | #  CNT.sn  
 	 if ticpr110.vafi =  tivafi.var then  
 	 	 var.ticpr110.vaco =  tcyesno.yes  
 	 else  
 	 	 var.ticpr110.vaco =  tcyesno.no  
 	 endif 	 	 	 	 	 	 | #  CNT.en  
 	  
 	 | *  currency, calc. method 	  
 	 if ticpr110.kocl =  tckocl.charge then  
 	 	 var.ticpr110.ccur =  hold.ccur  
 	 	 var.ticpr110.cmth =  ticpr110.cmth  
 	 else  
 	 	 var.ticpr110.ccur =  ""                                  
 	 	 var.ticpr110.cmth =  ltoe(0)  
 	 endif  
 	  
 	 fill.var.ticpr110.cpch("ticpr110") 	 	 | *  surcharge amount  
 	 fill.var.ticpr110.chpr("ticpr110") 	 	 | *  surcharge percentage  
 	 fill.var.ticpr110.chcp(ticpr110.chcp) 	 | *  cost components  
 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:110
:SCPAC:ti
:SCMOD:cpr
:SFLNO:110
:ICOD:S
:QURY:START

select 	 ticpr110.*  	 | *  Surcharges by Item Group
from 	 ticpr110
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:110
:SCPAC:ti
:SCMOD:cpr
:SFLNO:110
:ICOD:X
:QURY:START

  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:110
:SCPAC:ti
:SCMOD:cpr
:SFLNO:130
:ICOD:D
:QURY:START

	 | *  set variable /  fixed costs 	 	 | #  CNT.sn  
 	 if ticpr130.vafi =  tivafi.var then  
 	 	 var.ticpr110.vaco =  tcyesno.yes  
 	 else  
 	 	 var.ticpr110.vaco =  tcyesno.no  
 	 endif 	 	 	 	 	 | #  CNT.en  
 	  
 	 	  
 	 | *  currency and surcharge method  
 	 if ticpr130.kocl =  tckocl.charge then  
 	 	 var.ticpr110.ccur =  hold.ccur  
 	 	 var.ticpr110.cmth =  ticpr130.cmth  
 	 else  
 	 	 var.ticpr110.ccur =  ""                             
 	 	 var.ticpr110.cmth =  ltoe(0)  
 	 endif  
 	  
 	 var.ticpr110.item =  segment.item.code (ticpr130.item, "")                                                                                                          
 	 var.ticpr110.cwar (1;6) =  empty.string (1;6)  
 	 var.ticpr110.citg (1;6) =  empty.string (1;6)  
 	  
 	 fill.var.ticpr110.cpch("ticpr130") 	 	 | *  surcharge amount  
 	 fill.var.ticpr110.chpr("ticpr130") 	 	 | *  surcharge percentage  
 	 fill.var.ticpr110.chcp(ticpr130.chcp) 	 | *  cost components 	  
 	  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:110
:SCPAC:ti
:SCMOD:cpr
:SFLNO:130
:ICOD:S
:QURY:START

select 	 ticpr130.*  	 | *  Surcharges by Item
from 	 ticpr130
where 	 ticpr130.cntr =  ""                                           	                                          | *                                           no container item
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:110
:SCPAC:ti
:SCMOD:cpr
:SFLNO:130
:ICOD:X
:QURY:START

  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:150
:SCPAC:ti
:SCMOD:cpr
:SFLNO:150
:ICOD:D
:QURY:START

	 	 	 	 	 	 | #  CNT.sn  
 	 | *  set vaco: variable or fixed costs  
 	 var.ticpr150.vaco =  variable.costs(ticpr150.vafi)  
 	 	  
 	 | *  set orty: Type of Opration Costs  
 	 var.ticpr150.orty =  set.orty(ticpr150.oprt, ticpr150.cmoh)  
 	 	 	 	 	 	 | #  CNT.en  
 	 | *  fill multi -  currency field  
 	 for element =  1 to 3  
 	 	 var.ticpr150.rate(element) =  fill.mc.field.double(  
 	 	 	 	 ticpr150.rate, | #  CNT.chng  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 endfor  
 	 ret.val =  get.cost.components(bcorig.ticpr,ticpr150.cpcp, "", err.mess)                                                                                            
 	  
 	 dump 1  
 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:150
:SCPAC:ti
:SCMOD:cpr
:SFLNO:150
:ICOD:S
:QURY:START

select 	 ticpr150.*  	 | *  Operation Rates
from 	 ticpr150
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:150
:SCPAC:ti
:SCMOD:cpr
:SFLNO:150
:ICOD:X
:QURY:START

  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:150
:SCPAC:ti
:SCMOD:pcs
:SFLNO:130
:ICOD:D
:QURY:START

	 	 	 	 	 	 | #  CNT.sn  
 	 | *  set vaco: variable or fixed costs  
 	 var.ticpr150.vaco =  variable.costs(tipcs130.vafi)  
 	 	  
 	 | *  set orty: Type of Opration Costs  
 	 var.ticpr150.orty =  set.orty(tipcs130.oprt, tipcs130.cmoh)  
 	 	 	 	 	 	 | #  CNT.en  
 	 | *  get budget code  
 	 var.ticpr150.cprj =  get.budget.code(  
 	 	 	 	 	 tipcs130.cbdg,  
 	 	 	 	 	 tipcs130.bccd)  
 	  
 	 | *  fill multi currency field  
 	 for element =  1 to 3  
 	 	 var.ticpr150.rate(element) =  fill.mc.field.double(  
 	 	 	 	 tipcs130.rate,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 endfor  
 	 ret.val =  get.cost.components(bcorig.ticpr,tipcs130.cpcp, "", err.mess)                                                            
 	 dump 7  
 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:150
:SCPAC:ti
:SCMOD:pcs
:SFLNO:130
:ICOD:S
:QURY:START

select 	 tipcs130.*  	 | *  Operation Rates by Budget
from 	 tipcs130
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:150
:SCPAC:ti
:SCMOD:pcs
:SFLNO:130
:ICOD:X
:QURY:START

  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:150
:SCPAC:ti
:SCMOD:pcs
:SFLNO:300
:ICOD:D
:QURY:START

	 	 	 	 	 	 	 | #  CNT.sn  
 	 | *  set vaco: variable or fixed costs  
 	 var.ticpr150.vaco =  variable.costs(tipcs300.vafi)  
 	 	  
 	 | *  set orty: Type of Opration Costs  
 	 var.ticpr150.orty =  set.orty(tipcs300.oprt, tipcs300.cmoh)  
 	 	 	 	 	 	 	 | #  CNT.sn  
 	 | *  fil multi currency field 	 	  
 	 for element =  1 to 3  
 	 	 var.ticpr150.rate(element) =  fill.mc.field.double(  
 	 	 	 	 tipcs300.rate, 	 | #  CNT.canged  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 endfor  
 	 ret.val =  get.cost.components(bcorig.ticpr,tipcs300.cpcp, "", err.mess)                                                                                            
 	 dump 4
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:150
:SCPAC:ti
:SCMOD:pcs
:SFLNO:300
:ICOD:S
:QURY:START

select 	 tipcs300.*  	 | *  Operates Rates by Project
from 	 tipcs300
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:150
:SCPAC:ti
:SCMOD:pcs
:SFLNO:300
:ICOD:X
:QURY:START

  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:cpr
:SFLNO:200
:ICOD:D
:QURY:START
	  
 	 | *  New item  
 	 if ticpr200.cpcc <>  var.cpcc or  
 	 ticpr200.item <>  prev.item then  
 	 	 | *  dump (aggrated) data for previous calculation code, item  
 	 	 if not isspace(var.item ) then  
 	 	 	 dump.2.ticpr201()  
 	 	 	 dump.1.ticpr200.aggr.cpcp()  
 	 	 	 dump.9.ticpr240.aggr.cpcp()  
 	 	 	  
 	 	 	 | *  dump ticpr206 (Cost Comp Struct) only for  
 	 	 	 | *  standard calc. code. Only once per Item.  
 	 	 	 if (var.cpcc =  ticpr000.sccc) and  
 	 	 	 (ticpr200.item <>  prev.item) then  
 	 	 	 	 dump.8.ticpr206.aggr.cpcp()  
 	 	 	 endif  
 	 	 endif  
 	  
 	 	 | *  no cost prices for Subcontracting Items  
 	 	 if tmp.kitm =  tckitm.subcontracting then  
 	 	 	 continue  
 	 	 endif  
 	 	  
 	 	 | *  initialize for new item  
 	 	 if ticpr200.item <>  var.item then  
 	 	 	 get.aggr.cpcp(tmp.kitm, tmp.citg, tmp.cpcp)  
 	 	 endif  
 	  
 	 	 | *  fill Surcharges by item flag  
 	 	 fill.var.spit.for.ticpr201(  
 	 	 	 	 ticpr200.cpcc,  
 	 	 	 	 ticpr200.item)  
 	 	  
 	 	 | *  initialize aggregates when new item or new calc code.  
 	 	 init.aggr.amnts.and.nuni()  
 	 endif  
 	  
 	 | *  no cost prices for Subcontracting Items  
 	 if tmp.kitm =  tckitm.subcontracting then  
 	 	 continue  
 	 endif  
 	  
 	 | *  fill values to be used in dump  
 	 var.cpcc =  ticpr200.cpcc  
 	 var.item =  segment.item.code (ticpr200.item,"")  
 | 	 var.amnt =  ticpr200.amnt 	 	 	 | #  MCR.o  
 	 for element =  1 to 3 	 	 	 	 | #  MCR.sn  
 | 	 	 var.amnt(element) =  fill.mc.field.double(ticpr200.amnt, | #  CNT.o  
 	 	 var.amnt(element) =  fill.mc.field.double(ticpr200.famt, | #  CNT.n  
 	 	 	 	 	 	 	 element,  
 	 	 	 	 	 	 	 0.0)  
 	 endfor 	 	 	 	 	 	 | #  MCR.en 	  
 	  
 	 var.amnt.fixed 	 =  ticpr200.famt -  ticpr200.mamt 	 | #  CNT.n  
 	 var.amnt.var 	 =  ticpr200.mamt 	 	 	 | #  CNT.n  
 	 var.nuni =  ticpr200.nuni  
 	 get.cost.components(bcorig.ticpr, ticpr200.cpcp, "", tmp.errmess)                                                                                                                                                                                                                                                                                                                                
 	 var.cpcp =  bcstc006.cost  
 	 prev.item =  ticpr200.item 	 | *  in Baan IV format  
 	  
 	  
 	 | *  write detailed lines and aggregate  
 	 dump.3.ticpr205.det.cpcp()  
 	 if detailed.cpcp(tmp.kitm, tmp.citg, ticpr200.cpcp) then  
 	 	 dump.1.ticpr200.eff.cpcp()  
 	 	 dump.9.ticpr240.eff.cpcp()  
 	 	 | *  dump ticpr206 (Cost Comp Struct) only for  
 	 	 | *  standard calc. code  
 	 	 if var.cpcc =  ticpr000.sccc then  
 	 	 	 dump.8.ticpr206.eff.cpcp()  
 	 	 endif  
 	 else  
 	 	 | *  aggregate the amounts and unit on the 3 aggr. cost components 	 	  
 	 	 for element =  1 to 3 	 	 	 	 | #  MCR.sn  
 	 	 	 var.ticpr200.amnt(element) =  fill.mc.field.double(  
 | 	 	 	 	 	 	 	 ticpr200.amnt, 	 	 | #  CNT.o  
 	 	 	 	 	 	 	 ticpr200.famt, 	 	 | #  CNT.n  
 	 	 	 	 	 	 	 element,  
 	 	 	 	 	 	 	 0.0)  
 	 	 endfor 	 	 	 	 	 	 | #  MCR.en  
 	 	  
 	 	 aggr.amount( 	 | ticpr200.amnt, 	 | #  MCR.o  
 	 	 	 	 var.ticpr200.amnt, 	 | #  MCR.n  
 	 	 	 	 var.amnt.var, 	 	 | #  CNT.n  
 	 	 	 	 var.amnt.fixed, 	 	 | #  CNT.n  
 	 	 	 	 ticpr200.nuni,  
 	 	 	 	 ticpr010.cref,  
 	 	 	 	 tmp.kitm)  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:cpr
:SFLNO:200
:ICOD:F
:QURY:START
	 | *  dump aggregated data for last item  
 	 dump.2.ticpr201()  
 	 dump.1.ticpr200.aggr.cpcp()  
 	 dump.9.ticpr240.aggr.cpcp()  
 	  
 	 | *  dump ticpr206 (Cost Comp Struct) only for  
 	 | *  standard calc. code  
 	 if var.cpcc =  ticpr000.sccc then  
 	 	 dump.8.ticpr206.aggr.cpcp()  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:cpr
:SFLNO:200
:ICOD:S
:QURY:START
select ticpr200.*  ,  
 	 ticpr010.cref,  
 	 tiitm001.kitm:tmp.kitm,  
 	 tiitm001.citg:tmp.citg,  
 	 tiitm001.cpcp
from 	 ticpr200, ticpr010, tiitm001
where 	 ticpr010.cpcp =  ticpr200.cpcp  
 and 	 tiitm001.item =  ticpr200.item  
 and 	 ticpr200.cntr =  ""   |  *                                                                         no container items
order by ticpr200._index1 	 | *  Sort by Calc.Code, Item
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:cpr
:SFLNO:200
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:cpr
:SFLNO:300
:ICOD:D
:QURY:START
	  
 	 | *  New item , Indt  
 	 if ticpr300.item <>  prev.item or  
 	 ticpr300.indt <>  var.indt then  
 	 	 | *  dump (aggrated) data for previous calculation code, item  
 	 	 if not isspace(var.item ) then  
 	 	 	 dump.5.ticpr301()  
 	 	 	 dump.4.ticpr300.aggr.cpcp()  
 	 	 	 dump.10.ticpr340.aggr.cpcp()  
 	 	 	 dump.7.ticpr306.aggr.cpcp()  
 	 	 endif  
 	  
 	 	 | *  no cost prices for Subcontracting Items  
 	 	 if tmp.kitm =  tckitm.subcontracting then  
 	 	 	 continue  
 	 	 endif  
 	 	  
 	 	 | *  initialize for new item  
 	 	 if ticpr300.item <>  prev.item then  
 	 	 	 get.aggr.cpcp(tmp.kitm, tmp.citg, tmp.cpcp)  
 	 	 endif  
 	 	  
 	 	 | *  fill Surcharges by item flag  
 	 	 fill.var.spit.for.ticpr301(  
 	 	 	 	 ticpr300.item,  
 	 	 	 	 ticpr300.indt)  
 	  
 	 	 | *  intialize aggregates for new item /  indt  
 	 	 init.aggr.amnts.and.nuni()  
 	 endif  
 	  
 	 | *  no cost prices for Subcontracting Items  
 	 if tmp.kitm =  tckitm.subcontracting then  
 	 	 continue  
 	 endif  
 	  
 	  
 	 | *  fill values to be used in dump  
 	 var.cpcc =  ""                                                                                                                                                                                                                                                                                                                                
 	 var.item =  segment.item.code (ticpr300.item,"")  
 | 	 var.amnt =  ticpr300.amnt 	 	 | #  MCR.o  
 	 for element =  1 to 3 	 	 	 | #  MCR.sn  
 	 	 var.amnt(element) =  fill.mc.field.double(ticpr300.amnt ,  
 	 	 	 	 	 	 	 element,  
 	 	 	 	 	 	 	 0.0)  
 	 endfor 	 	 	 	 	 | #  MCR.en  
 	 var.amnt.fixed 	 =  ticpr300.famt -  ticpr300.mamt 	 | #  CNT.n  
 	 var.amnt.var 	 =  ticpr300.mamt 	 	 | #  CNT.n  
 	  
 	 | *  famt and mamt are sometimes both empty 	 | #  CNT1.sn  
 	 if isspace(ticpr300.cpty) or 	 	 	 	  
 	 	 (ticpr300.famt =  0.0 and ticpr300.mamt =  0.0 and ticpr300.amnt <>  0.00)  
 	 then  
 	 	 var.amnt.var =  var.amnt(1)  
 	 endif 	 	 	 	 	 	 | #  CNT1.en  
 	 	  
 	 var.nuni =  ticpr300.nuni  
 	 get.cost.components(bcorig.ticpr, ticpr300.cpcp, "", tmp.errmess)                                                                                                                                                                                                                                                                                                                                
 	 var.cpcp =  bcstc006.cost  
 	 var.indt =  ticpr300.indt  
 	 prev.item =  ticpr300.item  
 	  
 	 | *  write detailed lines and aggregated.  
 	 dump.6.ticpr305.det.cpcp()  
 	 if detailed.cpcp(tmp.kitm, tmp.citg, ticpr300.cpcp) then  
 	 	 dump.4.ticpr300.eff.cpcp()  
 	 	 dump.10.ticpr340.eff.cpcp()  
 	 	 dump.7.ticpr306.eff.cpcp()  
 	 else  
 	 	 | *  aggregate the amounts and unit on the 3 aggr. cost components  
 	 	 | *  and add the cpcp to the Item's Cost Component Structure  
 	 	 for element =  1 to 3 	 	 	 | #  MCR.sn  
 	 	 	 var.ticpr300.amnt(element) =  fill.mc.field.double(  
 	 	 	 	 	 	 	 ticpr300.amnt,  
 	 	 	 	 	 	 	 	 element,  
 	 	 	 	 	 	 	 	 0.0)  
 	 	 endfor 	 	 	 	 	 | #  MCR.en  
 	 	 aggr.amount( 	 | ticpr300.amnt, 	 | #  MCR.o  
 	 	 	 	 var.ticpr300.amnt, 	 | #  MCR.n  
 	 	 	 	 var.amnt.var, 	 	 | #  CNT.n  
 	 	 	 	 var.amnt.fixed, 	 	 | #  CNT.n  
 	 	 	 	 ticpr300.nuni,  
 	 	 	 	 ticpr010.cref,  
 	 	 	 	 tmp.kitm)  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:cpr
:SFLNO:300
:ICOD:F
:QURY:START
	 | *  dump aggregated data for last item  
 	 dump.5.ticpr301()  
 	 dump.4.ticpr300.aggr.cpcp()  
 	 dump.7.ticpr306.aggr.cpcp()  
 	 dump.10.ticpr340.aggr.cpcp()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:cpr
:SFLNO:300
:ICOD:S
:QURY:START
select ticpr300.*  ,  
 	 ticpr010.cref,  
 	 tiitm001.kitm:tmp.kitm,  
 	 tiitm001.citg:tmp.citg,  
 	 tiitm001.cpcp:tmp.cpcp
from 	 ticpr300, ticpr010, tiitm001
where 	 ticpr010.cpcp =  ticpr300.cpcp  
 and 	 ticpr300.item =  tiitm001.item  
 and 	 ticpr300.cntr =  ""                                                                                                                                                                 	                                                                                                                                                                  |  *                                                                                                                                                                 no container items
order by ticpr300._index1 	 | *  Sort by Item, indt
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:cpr
:SFLNO:300
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:pcs
:SFLNO:150
:ICOD:D
:QURY:START
	 	 	 	 	 	  
 	 tmp.item =  get.part.item.code( tipcs150.cbdg,  
 	 	 	 	 	 tipcs150.bccd,  
 	 	 	 	 	 tipcs150.ccpc)  
 	 | *  New item  
 	 if tmp.item <>  var.item then  
 	 	 | *  dump for previous item  
 	 	 if not isspace(var.item ) then  
 	 	 	 dump.2.ticpr201()  
 	 	 	 dump.1.ticpr200.aggr.cpcp()  
 	 	 	 dump.9.ticpr240.aggr.cpcp()  
 	 	 	 dump.8.ticpr206.aggr.cpcp()  
 	 	 endif  
 	  
 	 	 | *  initialize for new item  
 	 	 | *  get item type and item group  
 	 	 get.calc.part.type.group(  
 	 	 	 tipcs150.cbdg,  
 	 	 	 tipcs150.ccpc,  
 	 	 	 tmp.kitm, tmp.citg, tmp.cpcp)  
 	  
 	 	 | *  no cost prices for Subcontracting Items  
 	 	 if tmp.kitm =  tckitm.subcontracting then  
 	 	 	 continue  
 	 	 endif  
 	  
 	 	 | *  initialized arrays 	  
 	 	 get.aggr.cpcp(tmp.kitm, tmp.citg, tmp.cpcp)  
 	 	 init.aggr.amnts.and.nuni()  
 	 	  
 	 endif  
 	  
 	 | *  no cost prices for Subcontracting Items  
 	 if tmp.kitm =  tckitm.subcontracting then  
 	 	 continue  
 	 endif  
 	  
 	 | *  fill values to be used in dump 	  
 	 var.cpcc =  ticpr000.sccc | *  Calc. code already in item code  
 	 var.item =  tmp.item  
 | 	 var.amnt =  tipcs150.amnt 	 	 | #  MCR.o  
 	 for element =  1 to 3 	 	 	 | #  MCR.sn  
 	 	 var.amnt(element) =  fill.mc.field.double(  
 | 	 	 	 	 	 	 tipcs150.amnt, 	 | #  CNT.o  
 	 	 	 	 	 	 tipcs150.famt, 	 | #  CNT.n  
 	 	 	 	 	 	 element,  
 	 	 	 	 	 	 0.0)  
 	 endfor 	 	 	 	 	 | #  MCR.en  
 	 var.amnt.fixed 	 =  tipcs150.famt -  tipcs150.mamt 	 | #  CNT.n  
 	 var.amnt.var 	 =  tipcs150.mamt 	 	 	 | #  CNT.n  
 	  
 	 var.nuni =  tipcs150.nuni  
 	 get.cost.components(bcorig.ticpr, tipcs150.cpcp, "", tmp.errmess)                                                                                                                                                                                                                                                                                                                                
 	 var.cpcp =  bcstc006.cost  
 	  
 	  
 	 | *  write details and aggregate  
 	 dump.3.ticpr205.det.cpcp()  
 	 if detailed.cpcp(tmp.kitm, tmp.citg, tipcs150.cpcp) then  
 	 	 dump.1.ticpr200.eff.cpcp()  
 	 	 dump.9.ticpr240.eff.cpcp()  
 	 	 dump.8.ticpr206.eff.cpcp()  
 	 else  
 	 	 | *  aggregate the amounts and unit on the 3 aggr. cost components  
 	 	 for element =  1 to 3 	 	 | #  MCR.sn  
 	 	 	 var.tipcs150.amnt(element) =  fill.mc.field.double(  
 | 	 	 	 	 	 	 	 tipcs150.amnt, 	 | #  CNT.o  
 	 	 	 	 	 	 	 tipcs150.famt, 	 	 | #  CNT.n  
 	 	 	 	 	 	 	 element,  
 	 	 	 	 	 	 	 0.0)  
 	 	 endfor 	 	 	 	 | #  MCR.en  
 	 	 var.amnt.fixed 	 =  tipcs150.famt -  tipcs150.mamt 	 | #  CNT.n  
 	 	 var.amnt.var 	 =  tipcs150.mamt 	 	 	 | #  CNT.n  
 	 	 aggr.amount( |tipcs150.amnt, 	 | #  MCR.o  
 	 	 	 var.tipcs150.amnt, | #  MCR.n  
 	 	 	 var.amnt.var, 	 	 | #  CNT.n  
 	 	 	 var.amnt.fixed, 	 	 | #  CNT.n  
 	 	 	 tipcs150.nuni,  
 	 	 	 ticpr010.cref,  
 	 	 	 tmp.kitm)  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:pcs
:SFLNO:150
:ICOD:F
:QURY:START
	 | *  dump for last item  
 	 dump.2.ticpr201()  
 	 dump.1.ticpr200.aggr.cpcp()  
 	 dump.9.ticpr240.aggr.cpcp()  
 	 dump.8.ticpr206.aggr.cpcp()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:pcs
:SFLNO:150
:ICOD:S
:QURY:START
select 	 tipcs150.*  , 	 | *  Cost Price Calculation Parts (Budgets)  
 	 ticpr010.cref
from 	 tipcs150, ticpr010
where 	 ticpr010.cpcp =  tipcs150.cpcp
order by tipcs150._index1 | *  new item code, cpcp
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:pcs
:SFLNO:150
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:pcs
:SFLNO:350
:ICOD:D
:QURY:START
	 tmp.cprj =  get.ti.project(tipcs350.cprj)  
 	 tmp.item =  segment.item.code (tipcs350.item, tmp.cprj)  
 	  
 	 | *  New item  
 	 if tmp.item <>  var.item then  
 	 	 | *  dump for previous item  
 	 	 if not isspace(var.item ) then  
 	 	 	 dump.2.ticpr201()  
 	 	 	 dump.1.ticpr200.aggr.cpcp()  
 	 	 	 dump.8.ticpr206.aggr.cpcp()  
 	 	 	 dump.9.ticpr240.aggr.cpcp()  
 	 	 	  
 	 	 	 | *  also create Standard Cost Price  
 	 	 	 dump.5.ticpr301()  
 	 	 	 dump.4.ticpr300.aggr.cpcp()  
 	 	 	 dump.7.ticpr306.aggr.cpcp()  
 	 	 	 dump.10.ticpr340.aggr.cpcp()  
 	 	 endif  
 	  
 	 	 | *  initialize for new item  
 	 	 get.item.type.group(tipcs350.cprj, tipcs350.item, tmp.kitm, tmp.citg, tmp.cpcp)  
 	 	  
 	 	 | *  no cost prices for Subcontracting Items  
 	 	 if tmp.kitm =  tckitm.subcontracting then  
 	 	 	 continue  
 	 	 endif  
 	 	  
 	 	 get.aggr.cpcp(tmp.kitm, tmp.citg, tmp.cpcp)  
 	 	 init.aggr.amnts.and.nuni()  
 	 	  
 	 endif  
 	  
 	 | *  no cost prices for Subcontracting Items  
 	 if tmp.kitm =  tckitm.subcontracting then  
 	 	 continue  
 	 endif  
 	  
 	 | *  Initialize for new project  
 	 if tipcs350.cprj <>  prev.cprj then  
 	 	 | *  no intialization 	 	  
 	 endif  
 	  
 	 | *  fill values to be used in dump  
 	 var.cpcc =  ticpr000.sccc | *  No Calc. Code in tipcs350  
 	 var.item =  tmp.item  
 | 	 var.amnt =  tipcs350.amte 	 | #  MCR.o  
 	 for element =  1 to 3 	 	 | #  MCR.sn  
 	 	 var.amnt(element) =  fill.mc.field.double(  
 	 	 	 	 	 	 tipcs350.amte,  
 	 	 	 	 	 	 element,  
 	 	 	 	 	 	 0.0)  
 	 endfor 	 	 	 	 | #  MCR.en  
 	  
 	 var.amnt.fixed 	 =  tipcs350.fame -  tipcs350.mame 	 | #  CNT.n  
 	 var.amnt.var 	 =  tipcs350.mame 	 	 	 | #  CNT.n  
 	  
 	 | *  fame and mame are sometimes both empty 	 | #  CNT1.sn  
 	 if isspace(tipcs350.cpty) or 	 	 	 	  
 	 	 (tipcs350.fame =  0.0 and tipcs350.mame =  0.0 and tipcs350.amte <>  0.00)  
 	 then  
 	 	 var.amnt.var =  var.amnt(1)  
 	 endif 	 	 	 	 	 	 | #  CNT1.en  
 	 	  
 	  
 	 var.nuni =  tipcs350.nune  
 	 get.cost.components(bcorig.ticpr, tipcs350.cpcp, "", tmp.errmess)                                                                                                                                                                                                                                                                                                                                
 	 var.cpcp =  bcstc006.cost  
 	  
 	 | *  dump details and aggrate  
 	 dump.3.ticpr205.det.cpcp()  
 	 dump.6.ticpr305.det.cpcp()  
 	 if detailed.cpcp(tmp.kitm, tmp.citg, tipcs350.cpcp) then  
 	 	 dump.1.ticpr200.eff.cpcp() 	 	  
 	 	 dump.8.ticpr206.eff.cpcp()  
 	 	 dump.9.ticpr240.eff.cpcp()  
 	  
 	 	 dump.4.ticpr300.eff.cpcp()  
 	 	 dump.7.ticpr306.eff.cpcp()  
 	 	 dump.10.ticpr340.eff.cpcp()  
 	 	  
 	 else  
 	 	 | *  aggregate the amounts and unit on the 3 aggr. cost components  
 	 	 for element =  1to 3 	 	 	 | #  MCR.sn  
 	 	 	 var.tipcs350.amte(element) =  fill.mc.field.double(  
 	 	 	 	 	 	 	 tipcs350.amte,  
 	 	 	 	 	 	 	 	 element,  
 	 	 	 	 	 	 	 	 0.0) 	 	  
 	 	 endfor 	 	 	 	 	 | #  MCR.en  
 	 	 var.amnt.fixed 	 =  tipcs350.fame -  tipcs350.mame 	 | #  CNT.n  
 	 	 var.amnt.var 	 =  tipcs350.mame 	 	 	 | #  CNT.n  
 	 	 aggr.amount( 	 |tipcs350.amte, 	 | #  MCR.o  
 	 	 	 	 var.tipcs350.amte, 	 | #  MCR.n  
 	 	 	 	 var.amnt.var, 	 	 | #  CNT.n  
 	 	 	 	 var.amnt.fixed, 	 	 | #  CNT.n  
 	 	 	 	 tipcs350.nune,  
 	 	 	 	 ticpr010.cref,  
 	 	 	 	 tmp.kitm)  
 	 endif  
 	  
 	 | *  save project  
 	 prev.cprj =  tipcs350.cprj
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:pcs
:SFLNO:350
:ICOD:F
:QURY:START
	 | *  dump for last item  
 	 dump.2.ticpr201()  
 	 dump.1.ticpr200.aggr.cpcp()  
 	 dump.8.ticpr206.aggr.cpcp()  
 	 dump.9.ticpr240.aggr.cpcp()  
 	  
 	 | *  also create Standard Cost Price  
 	 dump.5.ticpr301()  
 	 dump.4.ticpr300.aggr.cpcp()  
 	 dump.7.ticpr306.aggr.cpcp()  
 	 dump.10.ticpr340.aggr.cpcp()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:pcs
:SFLNO:350
:ICOD:S
:QURY:START
select 	 tipcs350.*  , ticpr010.cref 	 	 | *  Cost Price Customized Items
from 	 tipcs350, ticpr010
where 	 ticpr010.cpcp =  tipcs350.cpcp
order by tipcs350._index1 | *  cprj, item, cpcp =  new item code, cpcp
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:pcs
:SFLNO:350
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:220
:SCPAC:ti
:SCMOD:cpr
:SFLNO:220
:ICOD:D
:QURY:START

	 var.ticpr220.vaco =  variable.costs(ticpr220.vafi)  
 	  
 	 if (ticpr220.cmth =  tccmth.amount) then  
 	 |var.ticpr220.cpch =  ticpr220.cpch 	 	 	 	 | #  MCR.o  
 	 	 for element =  1 to 3 	 	 	 	 	 	 | #  MCR.sn  
 	 	 	 var.ticpr220.cpch(element) =  fill.mc.field.double(  
 	 	 	 	 	 	 	 	 ticpr220.cpch,  
 	 	 	 	 	 	 	 	 element,  
 	 	 	 	 	 	 	 	 0.0)  
 	 	 endfor 	 	 	 	 	 	 	 | #  MCR.en  
 	 	 var.ticpr220.chpr =  0  
 	 else  
 	 	 |var.ticpr220.cpch =  0 	 	 	 	 	 | #  MCR.o  
 	 	 var.ticpr220.cpch (1) =  0.0 	 	 	 	 	 | #  MCR.sn  
 	 	 var.ticpr220.cpch (2) =  0.0  
 	 	 var.ticpr220.cpch (3) =  0.0 	 	 	 	 	 | #  MCR.en  
 	 	 |var.ticpr220.chpr =  ticpr220.cpch 	 	 	 	 | #  MCR.o  
 	 	 var.ticpr220.chpr =  fill.mc.field.double(ticpr220.cpch,1,0.0) | #  MCR.n  
 	 endif 	  
 	 	  
 	 | *  no cost component for total lines  
 	 if (ticpr220.kocl =  tckocl.total or ticpr220.kocl =  tckocl.cumulate) then  
 	 	 var.ticpr220.chcp =  ""                                  
 	 else  
 	 	 get.cost.components(bcorig.ticpr, ticpr220.chcp, "", tmp.errmess)                                  
 	 	 var.ticpr220.chcp =  bcstc006.cost  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:220
:SCPAC:ti
:SCMOD:cpr
:SFLNO:220
:ICOD:S
:QURY:START

select 	 ticpr220.*
from 	 ticpr220
where 	 ticpr220.cntr =  ""
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:220
:SCPAC:ti
:SCMOD:cpr
:SFLNO:220
:ICOD:X
:QURY:START

  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:320
:SCPAC:ti
:SCMOD:cpr
:SFLNO:320
:ICOD:D
:QURY:START
	 | *  set vaco: variable or fixed costs  
 	 var.ticpr320.vaco =  variable.costs(ticpr320.vafi)  
 	  
 	 | *  no cost component for total lines  
 	 if (ticpr320.kocl =  tckocl.total or ticpr320.kocl =  tckocl.cumulate) then  
 	 	 bcstc006.cost =  empty.string (1;8)  
 	 else  
 	 	 get.cost.components(bcorig.ticpr, ticpr320.chcp, "", tmp.errmess)                                            
 	 endif  
 	 if (ticpr320.cmth =  tccmth.amount) then  
 	 	 |var.ticpr320.cpch =  ticpr320.cpch 	 	 	 	 | #  MCR.o  
 	 	 for element =  1 to 3 	 	 	 	 	 | #  MCR.sn  
 	 	 	 var.ticpr320.cpch(element) =  fill.mc.field.double(  
 	 	 	 	 	 	 	 	 ticpr320.cpch,  
 	 	 	 	 	 	 	 	 element,  
 	 	 	 	 	 	 	 	 0.0)  
 	 	 endfor 	 	 	 	 	 	 	 | #  MCR.en  
 	 	 var.ticpr320.chpr =  0 	 	 	 	  
 	 else  
 	 	 |var.ticpr320.cpch =  0 	 	 	 	 	 | #  MCR.o  
 	 	 |var.ticpr320.chpr =  ticpr320.cpch 	 	 	 	 | #  MCR.o  
 	 	 var.ticpr320.cpch (1) =  0.0 	 	 	 	 	 | #  MCR.sn  
 	 	 var.ticpr320.cpch (2) =  0.0  
 	 	 var.ticpr320.cpch (3) =  0.0 	 	  
 	 	 var.ticpr320.chpr =  fill.mc.field.double(ticpr320.cpch,1,0.0) | #  MCR.en  
 	 endif 	  
 	 	 	 	 	 	 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:320
:SCPAC:ti
:SCMOD:cpr
:SFLNO:320
:ICOD:S
:QURY:START
select 	 ticpr320.*
from 	 ticpr320
where 	 ticpr320.cntr =  ""                   	                   |*                    no container items
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:cpr
:TFLNO:320
:SCPAC:ti
:SCMOD:cpr
:SFLNO:320
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:000
:SCPAC:ti
:SCMOD:pcs
:SFLNO:000
:ICOD:D
:QURY:START
	  
 	 | *  set fixed costs included fields  
 	 var.include.fixed.costs =  include.fixed.costs(tipcs000.cpty)  
 	  
 	 var.tipcs000.indt =  utc(0,0)  
 	 var.tipcs000.dsca =  form.text$("bcstc00035")  
 	 | *  Actual Set  
 	 dump 1  
 	  
 	 var.tipcs000.indt =  utc(date.num(), time.num())  
 	 var.tipcs000.dsca =  form.text$("bcstc00036")  
 	 | *  Converted from BaanIVc4  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:000
:SCPAC:ti
:SCMOD:pcs
:SFLNO:000
:ICOD:S
:QURY:START
select 	 tipcs000.*
from 	 tipcs000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:000
:SCPAC:ti
:SCMOD:pcs
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:320
:SCPAC:ti
:SCMOD:pcs
:SFLNO:140
:ICOD:D
:QURY:START

	 | *  set vaco: variable or fixed costs  
 	 var.tipcs320.vaco =  variable.costs(tipcs140.vafi)  
 	  
 	 | *  Determine new project code.  
 	 var.tipcs320.cprj =  get.budget.code(tipcs140.cbdg, tipcs140.bccd)  
 	 | *  Determine new cost component.  
 	 return.value =  get.cost.components(  
 	 	 	 	 	 bcorig.ticpr,  
 	 	 	 	 	 tipcs140.chcp,  
 	 	 	 	 	 "",                                                                  
 	 	 	 	 	 error.message)  
 	 var.tipcs320.chcp =  bcstc006.cost  
 	 | *  Determine Surcharge Amount and Surcharge Percentage.  
 	 if (tipcs140.cmth =  tccmtd.amount) then  
 	 	 |var.tipcs320.cpch =  tipcs140.cpch 	 	 | #  MCR.o  
 	 	 var.tipcs320.cpch(1) =  fill.mc.field.double(tipcs140.cpch,1) 	 | #  MCR.sn  
 	 	 var.tipcs320.cpch(2) =  fill.mc.field.double(tipcs140.cpch,2)  
 	 	 var.tipcs320.cpch(3) =  fill.mc.field.double(tipcs140.cpch,3) 	 | #  MCR.en  
 	 	 var.tipcs320.chpr =  0  
 	 else  
 	 	 |var.tipcs320.cpch =  0 	 	 | #  MCR.o  
 	 	 var.tipcs320.cpch(1) =  0.0 	 	 | #  MCR.sn  
 	 	 var.tipcs320.cpch(2) =  0.0  
 	 	 var.tipcs320.cpch(3) =  0.0 	 	 | #  MCR.en  
 	 	 | var.tipcs320.chpr =  tipcs140.cpch 	 	 	 	 | #  MCR.o  
 	 	 var.tipcs320.chpr =  fill.mc.field.double(tipcs140.cpch,1) 	 | #  MCR.n  
 	 endif  
 | #  800 -  141372.sn  
 	 | *  Variable Cost should be No when Calculation Line Type  
 	 | *  is not equal to Surcharge.  
 	 if tipcs140.kocl <>  tckocl.charge then  
 	 	 var.tipcs320.vaco =  tcyesno.no  
 	 	 var.tipcs320.chpr =  0.0  
 	 	 var.tipcs320.ccur =  ""                                      
 	 	 var.tipcs320.cmth =  ltoe(0)  
 	 else  
 	 	 var.tipcs320.vaco =  tcyesno.yes  
 	 	 var.tipcs320.ccur =  hold.ccur  
 	 	 var.tipcs320.cmth =  tipcs140.cmth  
 	 endif  
 | #  800 -  141372.en  
 | #  800 -  141359.sn  
 	 | *  Use variable to migrate the field, because otherwise this  
 	 | *  field is not handled correctly when it is empty.  
 | 	 var.tipcs320.cmth =  etol(tipcs140.cmth)  
 | #  800 -  141359.en  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:320
:SCPAC:ti
:SCMOD:pcs
:SFLNO:140
:ICOD:S
:QURY:START

select 	 tipcs140.*
from 	 tipcs140
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:320
:SCPAC:ti
:SCMOD:pcs
:SFLNO:140
:ICOD:X
:QURY:START

  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:320
:SCPAC:ti
:SCMOD:pcs
:SFLNO:320
:ICOD:D
:QURY:START

	  
 	 | *  set vaco: variable or fixed costs  
 	 var.tipcs320.vaco =  variable.costs(tipcs320.vafi)  
 	  
 	 | *  Determine new project code.  
 	 var.tipcs320.cprj =  get.ti.project(tipcs320.cprj)  
 	  
 	 | *  Determine new cost component.  
 	 return.value =  get.cost.components(  
 	 	 	 	 	 bcorig.ticpr,  
 	 	 	 	 	 tipcs320.chcp,  
 	 	 	 	 	 "",                                                                  
 	 	 	 	 	 error.message)  
 	 var.tipcs320.chcp =  bcstc006.cost  
 	  
 	 | *  Determine Surcharge Amount and Surcharge Percentage.  
 	 if (tipcs320.cmth =  tccmtd.amount) then  
 	 	 |var.tipcs320.cpch =  tipcs320.cpch 	 	 	 	 | #  MCR.o  
 	 	 var.tipcs320.cpch(1) =  fill.mc.field.double(tipcs320.cpch,1) 	 | #  MCR.sn  
 	 	 var.tipcs320.cpch(2) =  fill.mc.field.double(tipcs320.cpch,2)  
 	 	 var.tipcs320.cpch(3) =  fill.mc.field.double(tipcs320.cpch,3) 	 | #  MCR.en 	  
 	 	 var.tipcs320.chpr =  0  
 	 else  
 	 	 |var.tipcs320.cpch =  0 	 | #  MCR.o  
 	 	 var.tipcs320.cpch(1) =  0.0 	 | #  MCR.sn  
 	 	 var.tipcs320.cpch(2) =  0.0  
 	 	 var.tipcs320.cpch(3) =  0.0 	 | #  MCR.en  
 	 	 | var.tipcs320.chpr =  tipcs320.cpch  
 	 	 var.tipcs320.chpr =  fill.mc.field.double(tipcs320.cpch,1) 	 | #  MCR.n  
 	 endif  
 	 	  
 	 | *  Variable Cost should be No when Calculation Line Type  
 	 | *  is not equal to Surcharge.  
 	 if tipcs320.kocl <>  tckocl.charge then  
 	 	 var.tipcs320.vaco =  tcyesno.no  
 	 	 var.tipcs320.chpr =  0.0  
 	 	 var.tipcs320.ccur =  ""                                      
 	 	 var.tipcs320.cmth =  ltoe(0)  
 	 else  
 	 	 var.tipcs320.vaco =  tcyesno.yes  
 	 	 var.tipcs320.ccur =  hold.ccur  
 	 	 var.tipcs320.cmth =  tipcs320.cmth  
 	 endif  
 	 	  
 | #  800 -  141359.sn  
 	 | *  Use variable to migrate the field, because otherwise this  
 	 | *  field is not handled correctly when it is empty.  
 | 	 var.tipcs320.cmth =  etol(tipcs320.cmth)  
 | #  800 -  141359.en  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:320
:SCPAC:ti
:SCMOD:pcs
:SFLNO:320
:ICOD:S
:QURY:START

select 	 tipcs320.*
from 	 tipcs320
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:320
:SCPAC:ti
:SCMOD:pcs
:SFLNO:320
:ICOD:X
:QURY:START

  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:350
:SCPAC:ti
:SCMOD:pcs
:SFLNO:150
:ICOD:D
:QURY:START

	 return.value =  get.cost.components(  
 	 	 	 	 	 bcorig.ticpr,  
 	 	 	 	 	 tipcs150.cpcp,  
 	 	 	 	 	 "",                                                                
 	 	 	 	 	 error.message)  
 	  
 	 | *  Construct new project code and new item code.  
 	 var.tipcs350.cprj =  get.budget.code(tipcs150.cbdg,  
 	 	 	 	 	 tipcs150.bccd)  
 	 var.tipcs350.item =  segment.item.code(tipcs150.ccpc,  
 	 	 	 	 	 var.tipcs350.cprj)  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:350
:SCPAC:ti
:SCMOD:pcs
:SFLNO:150
:ICOD:S
:QURY:START

select 	 tipcs150.*
from 	 tipcs150
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:350
:SCPAC:ti
:SCMOD:pcs
:SFLNO:150
:ICOD:X
:QURY:START

  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:350
:SCPAC:ti
:SCMOD:pcs
:SFLNO:350
:ICOD:D
:QURY:START

	 return.value =  get.cost.components(  
 	 	 	 	 	 bcorig.ticpr,  
 	 	 	 	 	 tipcs350.cpcp,  
 	 	 	 	 	 "",                                                                
 	 	 	 	 	 error.message)  
 	 | *  Construct new project code and new item code.  
 	 var.tipcs350.cprj =  get.ti.project(tipcs350.cprj)  
 	 var.tipcs350.item =  segment.item.code(tipcs350.item, var.tipcs350.cprj)  
 	 | *  fame and mame are sometimes both empty 	 | #  CNT1.sn  
 	 if isspace(tipcs350.cpty) or 	 	 	 	  
 	 	 (tipcs350.fame =  0.0 and tipcs350.mame =  0.0 and tipcs350.amte <>  0.00)  
 	 then  
 	 	 tipcs350.fame =  tipcs350.amte  
 	 	 tipcs350.mame =  tipcs350.amte  
 	 endif 	 	 	 	 	 	 | #  CNT1.en  
 	  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:350
:SCPAC:ti
:SCMOD:pcs
:SFLNO:350
:ICOD:S
:QURY:START

select tipcs350.*
from tipcs350
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:350
:SCPAC:ti
:SCMOD:pcs
:SFLNO:350
:ICOD:X
:QURY:START

  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:360
:SCPAC:ti
:SCMOD:pcs
:SFLNO:160
:ICOD:D
:QURY:START

	 return.value =  get.cost.components(  
 	 	 	 	 bcorig.ticpr,  
 	 	 	 	 tipcs160.cpcp,  
 	 	 	 	 "",                                        
 	 	 	 	 error.message)  
 	 | *  Construct new project code.  
 	 var.tipcs360.cprj =  get.budget.code(tipcs160.cbdg,  
 	 	 	 	 tipcs160.bccd)  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:360
:SCPAC:ti
:SCMOD:pcs
:SFLNO:160
:ICOD:S
:QURY:START

select 	 tipcs160.*
from 	 tipcs160
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:360
:SCPAC:ti
:SCMOD:pcs
:SFLNO:160
:ICOD:X
:QURY:START

  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:360
:SCPAC:ti
:SCMOD:pcs
:SFLNO:360
:ICOD:D
:QURY:START

	 return.value =  get.cost.components(  
 	 	 	 	 bcorig.ticpr,  
 	 	 	 	 tipcs360.cpcp,  
 	 	 	 	 "",                                  
 	 	 	 	 error.message)  
 	 | *  Construct new project code.  
 	 var.tipcs360.cprj =  get.ti.project(tipcs360.cprj)  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:360
:SCPAC:ti
:SCMOD:pcs
:SFLNO:360
:ICOD:S
:QURY:START

select 	 tipcs360.*
from 	 tipcs360
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:ti
:TCMOD:pcs
:TFLNO:360
:SCPAC:ti
:SCMOD:pcs
:SFLNO:360
:ICOD:X
:QURY:START

  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:wh
:TCMOD:inr
:TFLNO:110
:SCPAC:td
:SCMOD:inv
:SFLNO:700
:ICOD:D
:QURY:START

	 hold.tdinv700.trdt =  tdinv700.trdt  
 | 	 var.whinr110.trdt =  utc(tdinv700.trdt, tdinv700.trtm) 	 | #  800 -  142000.o  
 | 	 var.whinr110.seqn =  tdinv700.sern +  1 	 	 	 | #  800 -  142000.o  
 	 var.whinr110.trdt =  utc(tdinv700.trdt, 0) 	 	 	 | #  800 -  142000.sn  
 	 if check1.trdt <>  tdinv700.trdt then  
 	 	 check1.trdt =  tdinv700.trdt  
 	 	 var.whinr110.seqn =  1  
 	 else  
 	 	 var.whinr110.seqn =  var.whinr110.seqn +  1  
 	 endif  
 	 	 	 	 	 	 	 	 	 | #  800 -  142000.en  
 	 if hold.item <>  tdinv700.item or  
 	 hold.cwar <>  tdinv700.cwar then  
 	 	 var.whinr110.seqn =  1 	 	 	 	 	 | #  800 -  142000.n  
 	 	 var.whinr110.qhnd =  0.0 	 	 	 | #  800 -  142486.n  
 	 	 if hold.negative >  0 then  
 	 	 	 var.whwmd255.coqu =  hold.negative  
 	 	 	 dump 13  
 	 	 	 hold.negative =  0.0  
 	 	 endif  
 	 	 if tdinv700.item <>  hold.item then  
 	 	 	 select tiitm001.stva, tiitm001.ltcp  
 	 	 	 from 	 tiitm001  
 	 	 	 where 	 tiitm001._index1 =  {:tdinv700.item}  
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 endselect  
 	 	 endif  
 	 	 if tiitm001.stva =  tcstva.stnd.copr then  
 	 	 	 var.whinr110.valm =  1 | *  ftp  
 	 	 else  
 	 	 	 var.whinr110.valm =  5 | *  lot  
 	 	 endif  
 	 	 hold.item =  tdinv700.item  
 	 	 hold.cwar =  tdinv700.cwar  
 	 	 select tdinv001.stoc, tdinv001.hstb, tdinv001.hstd  
 	 	 from 	 tdinv001  
 	 	 where 	 tdinv001._index1 =  {:hold.cwar, :hold.item}  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 selectempty  
 	 	 	 tdinv001.stoc =  0.0  
 	 	 	 tdinv001.hstb =  0.0  
 	 	 	 tdinv001.hstd =  0  
 	 	 endselect  
 	 	 var.whina112.qskt =  0.0  
 	 	 to.be.received =  0.0  
 	 	 issued =  0.0  
 	 	 i =  0  
 	 	 dummy.receipt.qty =  0.0  
 	 	 dummy.array.nr =  0  
 	 	 receipt.counter =  0  
 	 	 set.mem(arr.whina112.trdt, "")                                                                                                                                                                                                                                                                                        
 	 	 set.mem(arr.whina112.seqn, 0)  
 	 	 set.mem(arr.whina112.qskt, 0.0)  
 	 	 select tdinv700._index1,  
 	 	 	 tdinv700.quan:curr.quan,  
 	 	 	 tdinv700.kost:curr.kost  
 	 	 from 	 tdinv700, tcmcs003  
 	 	 where 	 tdinv700._index1 =  {:hold.item, "", :hold.cwar}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
 	 	 and 	 tdinv700.trdt >=  :tdinv001.hstd  
 	 	 and 	 tcmcs003._index1 =  {tdinv700.cwar}  
 	 	 and 	 tcmcs003.typw <>  tctypw.transito  
 	 	 and 	 tdinv700.cntr =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
 	 	 order by tdinv700._index1  
 	 	 selectdo  
 	 	 	 	 	 	 	 	 	 	 	 | #  800 -  142000.sn  
 	 	 	 if check2.item <>  tdinv700.item or  
 	 	 	 check2.cwar <>  tdinv700.cwar or  
 	 	 	 check2.trdt <>  tdinv700.trdt then  
 	 	 	 	 check2.item =  tdinv700.item  
 	 	 	 	 check2.cwar =  tdinv700.cwar  
 	 	 	 	 check2.trdt =  tdinv700.trdt  
 	 	 	 	 check.seqn =  1  
 	 	 	 else  
 	 	 	 	 check.seqn =  check.seqn +  1  
 	 	 	 endif  
 	 	 	 	 	 	 	 	 	 	 	 | #  800 -  142000.en  
 	 	 	 if (curr.kost =  tckost.stc.correction and curr.quan >  0) or  
 	 	 	 ((curr.kost =  tckost.pur.receipt or  
 	 	 	 curr.kost =  tckost.prd.receipt or  
 	 	 	 curr.kost =  tckost.rpl.receipt) and curr.quan >  0) or  
 	 	 	 ((curr.kost =  tckost.sls.delivery or  
 	 	 	 curr.kost =  tckost.prd.mat.issue or  
 	 	 	 curr.kost =  tckost.rpl.delivery) and curr.quan <  0) or  
 	 	 	 (curr.kost =  tckost.stc.transfer and curr.quan >  0) then  
 	 	 	 	 to.be.received =  to.be.received +  abs(curr.quan)  
 	 	 	 	 i =  i +  1  
 	 	 	 	 if i >  array.len then  
 	 	 	 	 	 array.len =  array.len +  100  
 	 	 	 	 	 alloc.mem(arr.whina112.trdt, 22, array.len)  
 	 	 	 	 	 alloc.mem(arr.whina112.seqn, array.len)  
 	 	 	 	 	 alloc.mem(arr.whina112.qskt, array.len)  
 	 	 	 	 endif  
 | 	 	 	 	 arr.whina112.trdt(1,i) =  utc(tdinv700.trdt, tdinv700.trtm) 	 | #  800 -  142000.o  
 	 	 	 	 arr.whina112.trdt(1,i) =  utc(tdinv700.trdt, 0) 	 	 	 | #  800 -  142000.n  
 | 	 	 	 	 arr.whina112.seqn(i) =  tdinv700.sern +  1 	 	 	 | #  800 -  142000.o  
 	 	 	 	 arr.whina112.seqn(i) =  check.seqn 	 	 	 	 | #  800 -  142000.n  
 	 	 	 	 arr.whina112.qskt(i) =  abs(curr.quan)  
 	 	 	 else  
 	 	 	 	 issued =  issued +  abs(curr.quan)  
 	 	 	 endif  
 	 	 selecteos  
 	 	 	 onhand.inventory =  max(tdinv001.hstb +  to.be.received -  issued,  
 	 	 	 	 	 	 	 tdinv001.stoc)  
 	 	 	 if onhand.inventory >  to.be.received -  issued then  
 	 	 	 	 | *  create dummy receipt  
 	 	 	 	 dummy.receipt.qty =  onhand.inventory -   
 	 	 	 	 	 	 	 	 to.be.received +  issued  
 	 	 	 	 to.be.received =  to.be.received +  dummy.receipt.qty  
 	 	 	 	 i =  i +  1  
 	 	 	 	 if i >  array.len then  
 	 	 	 	 	 array.len =  array.len +  100  
 	 	 	 	 	 alloc.mem(arr.whina112.trdt, 22, array.len)  
 	 	 	 	 	 alloc.mem(arr.whina112.seqn, array.len)  
 	 	 	 	 	 alloc.mem(arr.whina112.qskt, array.len)  
 	 	 	 	 endif  
 | 	 	 	 	 arr.whina112.trdt(1,i) =  utc(tdinv700.trdt, tdinv700.trtm) 	 | #  800 -  142000.o  
 	 	 	 	 arr.whina112.trdt(1,i) =  utc(tdinv700.trdt, 0) 	 	 	 | #  800 -  142000.n  
 	 	 	 	 arr.whina112.seqn(i) =  999 	 | *  take care  
 	 	 	 	 arr.whina112.qskt(i) =  dummy.receipt.qty  
 	 	 	 	 dummy.array.nr =  i  
 	 	 	 endif  
 	 	 endselect  
 	 	 i =  1  
 	 	 prev.sern =  0  
 	 endif  
 	 if hold.tdinv700.trdt <  tdinv001.hstd then  
 	 	 continue  
 	 endif  
 	  
 	 var.whinr110.qstk =  tdinv700.quan  
 	 var.whinr110.bpid =  empty()  
 	 var.whinr110.pono =  tdinv700.pono  
 	 var.whinr110.srnb =  0  
 	 on case tdinv700.koor  
 	 case tckoor.act.pur:  
 	 	 if not get.business.partner(tdinv700.rlcd, bcstc.orgn.suno, o.mess) then  
 	 	 	 var.whinr110.bpid =  bcstc008.bpid  
 	 	 endif  
 	 	 break  
 	 case tckoor.act.sls:  
 	 	 if not get.business.partner(tdinv700.rlcd, bcstc.orgn.cuno, o.mess) then  
 	 	 	 var.whinr110.bpid =  bcstc008.bpid  
 	 	 endif  
 	 	 var.whinr110.srnb =  determine.sales.order.sequence( 	 true, 	 	 |inv 	 | #  800 -  143063.n  
 	 	 	 	 	 	 	 	 	 tdinv700.orno,  
 	 	 	 	 	 	 	 	 	 tdinv700.pono,  
 	 	 	 	 	 	 	 	 	 tdinv700.trdt,  
 	 	 	 	 	 	 	 	 	 tdinv700.trtm, 	 	 | #  800 -  143063.n  
 	 	 	 	 	 	 	 	 	 tdinv700.sern, 	 	 | #  800 -  143063.n  
 	 	 	 	 	 	 	 	 	 "",              	                            	                            	              |#              800-              143063.n                            
 	 	 	 	 	 	 	 	 	 tdinv700.quan) 	 | #  800 -  143063.n  
 	 	 break  
 	 case tckoor.sma.order :  
 	 	 if not get.business.partner(tdinv700.rlcd, bcstc.orgn.cuno, o.mess) then  
 	 	 	 var.whinr110.bpid =  bcstc008.bpid  
 	 	 endif  
 	 	 break  
 	 case tckoor.wrh.order :  
 	 	 if tdinv700.kost <>  tckost.stc.correction then  
 	 	 	 if (tdinv700.quan <  0) then  
 	 	 	 	 var.whinr110.qstk =  abs (tdinv700.quan)  
 	 	 	 endif  
 	 	 else  
 	 	 	 var.whinr110.pono =  determine.new.pono(tdinv700.orno)  
 	 	 endif  
 	 	 break  
 	 case tckoor.act.rpl :  
 	 	 if tdinv700.kost =  tckost.stc.transfer then  
 	 	 	 if (tdinv700.quan <  0) then  
 	 	 	 	 var.whinr110.qstk =  abs (tdinv700.quan)  
 	 	 	 endif  
 	 	 endif  
 	 	 	 	 	 	 	 	 	 | #  800 -  142206.sn  
 	 	 var.whinr110.srnb =  determine.rpl.order.sequence( 	 tdinv700.orno,  
 	 	 	 	 	 	 	 	 	 tdinv700.pono,  
 	 	 	 	 	 	 	 	 	 tdinv700.kost,  
 	 	 	 	 	 	 	 	 	 tdinv700.cwar,  
 	 	 	 	 	 	 	 	 	 tdinv700.trdt)  
 	 	 	 	 	 	 	 	 	 | #  800 -  142206.en  
 	 	 break  
 	 case tckoor.pcs.wrh :  
 	 	 if tdinv700.kost =  tckost.stc.transfer then  
 	 	 	 if (tdinv700.quan <  0) then  
 	 	 	 	 var.whinr110.qstk =  abs (tdinv700.quan)  
 	 	 	 endif  
 	 	 endif  
 	 	 	 	 	 	 	 	 | #  200 -  101937.sn  
 	 	 var.whinr110.pono =  10  
 	 	 var.whinr110.srnb =  1  
 	 	 	 	 	 	 	 	 | #  200 -  101937.en  
 	 	 break  
 	 endcase  
 	 if tdinv700.prst <>  empty then  
 	 	 var.whinr110.prnt =  tdinv700.prst  
 	 else  
 	 	 var.whinr110.prnt =  tcyesno.no  
 	 endif  
 	 var.whinr110.koor =  convert.tckoor(tdinv700.koor, tdinv700.orno)  
 	 if var.whinr110.koor =  51 then | cycle count  
 	 	 var.whinr110.orno =  get.new.cycle.count.order.number(  
 	 	 	 	 	 	 tdinv700.orno, tdinv700.cwar)  
 	 else  
 	 	 var.whinr110.orno =  convert.number(  
 	 	 	 	 	 convert.tckoor.to.bcckon(tdinv700.koor), tdinv700.orno)  
 	 endif  
 	 var.whinr110.kost =  convert.tckost(tdinv700.kost, tdinv700.quan)  
 	 itid =  itid +  1  
 	 var.whinr110.itid =  edit$(itid,"999999999")  
 	 var.whinr110.itse =  1  
 	 	 	 	 	 	 | #  800 -  142486.sn  
 	 | *  calculate quantity after transaction because it is not reliable in Baan4  
 	 if var.whinr110.kost =  1 or 	 	 |tckost.stc.correction  
 	 var.whinr110.kost =  3 then 	 	 |tckost.receipt  
 	 	 var.whinr110.qhnd =  var.whinr110.qhnd +  var.whinr110.qstk  
 	 endif  
 	 if var.whinr110.kost =  5 then 	 	 |tckost.issue  
 	 	 var.whinr110.qhnd =  var.whinr110.qhnd -  var.whinr110.qstk  
 	 endif  
 	 	 	 	 	 	 | #  800 -  142486.en  
 	 dump 1  
 	 if receipt.counter =  dummy.array.nr -  1 then  
 	 	 receipt.counter =  receipt.counter +  1  
 	 	 hold.koor =  var.whinr110.koor  
 	 	 hold.kost =  var.whinr110.kost  
 	 	 hold.orno =  var.whinr110.orno  
 	 	 hold.trdt =  var.whinr110.trdt  
 	 	 hold.seqn =  var.whinr110.seqn  
 	 	 hold.qstk =  var.whinr110.qstk  
 	 	 hold.bpid =  var.whinr110.bpid  
 	 	 itid =  itid +  1  
 	 	 var.whinr110.itid =  edit$(itid,"999999999")  
 	 	 var.whinr110.itse =  1  
 	 	 var.whinr110.koor =  52 	 | *  adjustment order  
 	 	 var.whinr110.kost =  1 	 | *  stock correction  
 	 	 var.whinr110.orno =  "MIGRATION"                                                                                                                
 	 	 var.whinr110.trdt =  arr.whina112.trdt(1,dummy.array.nr)  
 	 	 var.whinr110.seqn =  999 	 | *  take care  
 	 	 var.whinr110.qstk =  dummy.receipt.qty  
 	 	 var.whinr110.bpid =  empty()  
 	 	 	 	 	 	 | #  800 -  142486.sn  
 	 	 var.whinr110.qhnd =  var.whinr110.qhnd +  var.whinr110.qstk  
 	 	 	 	 	 	 | #  800 -  142486.en  
 	 	 dump 1  
 	 	 to.be.received =  to.be.received -  dummy.receipt.qty  
 	 	 if to.be.received >=  onhand.inventory then  
 	 	 	 | *  totally consumed  
 	 	 	 var.whina112.qskt =  0.0  
 	 	 else  
 	 	 	 if var.whina112.qskt >  0 then  
 	 	 	 	 | *  not consumed  
 	 	 	 	 var.whina112.qskt =  dummy.receipt.qty  
 	 	 	 else  
 	 	 	 	 | *  partially consumed  
 	 	 	 	 var.whina112.qskt =  onhand.inventory -  to.be.received  
 	 	 	 endif  
 	 	 endif  
 	 	 var.whina112.qstk =  dummy.receipt.qty  
 	 	 dump 3  
 	 	 get.standard.cost.price(tdinv700.item, dummy.receipt.qty,  
 	 	 	 	 	 tdinv700.trdt, true, false)  
 	 	 var.whinr110.koor =  hold.koor  
 	 	 var.whinr110.kost =  hold.kost  
 	 	 var.whinr110.orno =  hold.orno  
 	 	 var.whinr110.trdt =  hold.trdt  
 	 	 var.whinr110.seqn =  hold.seqn  
 	 	 var.whinr110.qstk =  hold.qstk  
 	 	 var.whinr110.bpid =  hold.bpid  
 	 endif  
 	 if (tdinv700.kost =  tckost.stc.correction and tdinv700.quan >  0) or  
 	 ((tdinv700.kost =  tckost.pur.receipt or  
 	 tdinv700.kost =  tckost.prd.receipt or  
 	 tdinv700.kost =  tckost.rpl.receipt) and tdinv700.quan >  0) or  
 	 ((tdinv700.kost =  tckost.sls.delivery or  
 	 tdinv700.kost =  tckost.prd.mat.issue or  
 	 tdinv700.kost =  tckost.rpl.delivery) and tdinv700.quan <  0) or  
 	 (tdinv700.kost =  tckost.stc.transfer and tdinv700.quan >  0) then  
 	 	 var.whina112.qstk =  abs(tdinv700.quan)  
 	 	 receipt.counter =  receipt.counter +  1  
 	 	 to.be.received =  to.be.received -  abs(tdinv700.quan)  
 	 	 if to.be.received >=  onhand.inventory then  
 	 	 	 | *  totally consumed  
 	 	 	 var.whina112.qskt =  0.0  
 	 	 else  
 	 	 	 if var.whina112.qskt >  0 then  
 	 	 	 	 | *  not consumed  
 	 	 	 	 var.whina112.qskt =  abs(tdinv700.quan)  
 	 	 	 else  
 	 	 	 	 | *  partially consumed  
 	 	 	 	 var.whina112.qskt =  onhand.inventory -  to.be.received  
 	 	 	 endif  
 	 	 endif  
 	 	 dump 3  
 	 	 get.standard.cost.price(tdinv700.item, abs(tdinv700.quan),  
 	 	 	 	 	 tdinv700.trdt, true, false)  
 	 else  
 	 	 remain.quan =  abs(tdinv700.quan)  
 	 	 if arr.whina112.qskt(i) =  0 then  
 	 	 	 if tdinv000.nega =  tcyesno.yes then  
 	 	 	 	 dump 11  
 	 	 	 	 hold.negative =  hold.negative +  abs(tdinv700.quan)  
 	 	 	 	 get.standard.cost.price(tdinv700.item, abs(tdinv700.quan),  
 	 	 	 	 	 	 	 tdinv700.trdt, false, true)  
 	 	 	 endif  
 	 	 	 | *  corrupt data: more issued then received  
 	 	 	 continue  
 	 	 endif  
 	 	 repeat  
 	 	 	 if remain.quan <=  arr.whina112.qskt(i) then  
 	 	 	 	 var.whina114.trdt =  arr.whina112.trdt(1,i)  
 	 	 	 	 var.whina114.seqn =  arr.whina112.seqn(i)  
 	 	 	 	 var.whina114.sern =  prev.sern +  1  
 	 	 	 	 var.whina114.qstk =  remain.quan  
 	 	 	 	 arr.whina112.qskt(i) =  arr.whina112.qskt(i) -  remain.quan  
 	 	 	 	 remain.quan =  0  
 	 	 	 	 prev.sern =  prev.sern +  1  
 	 	 	 else  
 	 	 	 	 var.whina114.trdt =  arr.whina112.trdt(1,i)  
 	 	 	 	 var.whina114.seqn =  arr.whina112.seqn(i)  
 	 	 	 	 var.whina114.sern =  prev.sern +  1  
 	 	 	 	 var.whina114.qstk =  arr.whina112.qskt(i)  
 	 	 	 	 remain.quan =  remain.quan -  arr.whina112.qskt(i)  
 	 	 	 	 arr.whina112.qskt(i) =  0  
 	 	 	 endif  
 	 	 	 dump 4  
 	 	 	 get.standard.cost.price(tdinv700.item, var.whina114.qstk,  
 	 	 	 	 	 	 tdinv700.trdt, false, false)  
 	 	 	 if arr.whina112.qskt(i) =  0 then  
 	 	 	 	 prev.sern =  0  
 	 	 	 	 i =  i +  1  
 	 	 	 endif  
 	 	 	 if remain.quan >  0 and arr.whina112.qskt(i) =  0 then  
 	 	 	 	 if tdinv000.nega =  tcyesno.yes then  
 	 	 	 	 	 dump 11  
 	 	 	 	 	 hold.negative =  hold.negative +   
 	 	 	 	 	 	 	 remain.quan  
 	 	 	 	 	 get.standard.cost.price(  
 	 	 	 	 	 	 tdinv700.item,  
 	 	 	 	 	 	 remain.quan,  
 	 	 	 	 	 	 tdinv700.trdt, false, true)  
 	 	 	 	 endif  
 	 	 	 	 | *  corrupt data: more issued then received  
 	 	 	 	 break  
 	 	 	 endif  
 	 	 until remain.quan =  0  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:wh
:TCMOD:inr
:TFLNO:110
:SCPAC:td
:SCMOD:inv
:SFLNO:700
:ICOD:F
:QURY:START

	 if hold.negative >  0 then  
 	 	 var.whwmd255.coqu =  hold.negative  
 	 	 dump 13  
 	 	 hold.negative =  0.0  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:wh
:TCMOD:inr
:TFLNO:110
:SCPAC:td
:SCMOD:inv
:SFLNO:700
:ICOD:S
:QURY:START

select 	 tdinv700.*  , tcmcs003.typw
from 	 tdinv700, tcmcs003
where 	 tcmcs003._index1 =  {tdinv700.cwar}  
 and 	 tcmcs003.typw <>  tctypw.transito  
 and 	 tdinv700.item >  ""                                                                                                                                                                                    
 and 	 tdinv700.cntr =  ""
order by tdinv700._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:wh
:TCMOD:inr
:TFLNO:110
:SCPAC:td
:SCMOD:inv
:SFLNO:700
:ICOD:X
:QURY:START

  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:wh
:TCMOD:inr
:TFLNO:110
:SCPAC:ti
:SCMOD:pcs
:SFLNO:700
:ICOD:D
:QURY:START

| 	 var.whinr110.trdt =  utc(tipcs700.trdt, tipcs700.trtm) | #  800 -  142000.o  
 | 	 var.whinr110.seqn =  tipcs700.sern +  1 	 	 | #  800 -  142000.o  
 	 var.whinr110.trdt =  utc(tipcs700.trdt, 0) 	 	 	 | #  800 -  142000.sn  
 	 if check1.trdt <>  tipcs700.trdt then  
 	 	 check1.trdt =  tipcs700.trdt  
 	 	 var.whinr110.seqn =  1  
 	 else  
 	 	 var.whinr110.seqn =  var.whinr110.seqn +  1  
 	 endif  
 	 	 	 	 	 	 	 	 	 | #  800 -  142000.en  
 	 var.whinr110.cprj =  get.project(tipcs700.cprj)  
 	 if hold.cprj <>  tipcs700.cprj or  
 	 hold.item <>  tipcs700.item then  
 	 	 var.whinr110.seqn =  1 	 	 	 	 	 | #  800 -  142000.n  
 	 	 var.whinr110.qhnd =  0.0 	 	 	 | #  800 -  142486.n  
 	 	 hold.cprj =  tipcs700.cprj  
 	 	 hold.item =  tipcs700.item  
 	 	 select 	 tipcs021.stoc  
 	 	 from 	 tipcs021  
 	 	 where 	 tipcs021._index1 =  {:hold.cprj, :hold.item}  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 endselect  
 	 	 var.whina112.qskt =  0.0  
 	 	 to.be.received =  0.0  
 	 	 issued =  0.0  
 	 	 i =  0  
 	 	 dummy.receipt.qty =  0.0  
 	 	 dummy.array.nr =  0  
 	 	 receipt.counter =  0  
 	 	 set.mem(arr.whina112.trdt, "")                                                                                                                                                                                                                                                                                        
 	 	 set.mem(arr.whina112.seqn, 0)  
 	 	 set.mem(arr.whina112.qskt, 0.0)  
 	 	 select 	 tipcs700._index1,  
 	 	 	 tipcs700.quan:curr.quan,  
 	 	 	 tipcs700.kost:curr.kost  
 	 	 from 	 tipcs700  
 	 	 where 	 tipcs700._index1 =  {:hold.cprj, :hold.item}  
 	 	 order by tipcs700._index1  
 	 	 selectdo  
 	 	 	 	 	 	 	 	 	 	 	 | #  800 -  142000.sn  
 	 	 	 if check2.item <>  tipcs700.item or  
 	 	 	 check2.trdt <>  tipcs700.trdt then  
 	 	 	 	 check2.item =  tipcs700.item  
 	 	 	 	 check2.trdt =  tipcs700.trdt  
 	 	 	 	 check.seqn =  1  
 	 	 	 else  
 	 	 	 	 check.seqn =  check.seqn +  1  
 	 	 	 endif  
 	 	 	 	 	 	 	 	 	 	 	 | #  800 -  142000.en  
 	 	 	 if (curr.kost =  tckost.stc.correction and curr.quan >  0) or  
 	 	 	 ((curr.kost =  tckost.pur.receipt or  
 	 	 	 curr.kost =  tckost.prd.receipt or  
 	 	 	 curr.kost =  tckost.rpl.receipt) and curr.quan >  0) or  
 	 	 	 ((curr.kost =  tckost.sls.delivery or  
 	 	 	 curr.kost =  tckost.prd.mat.issue or  
 	 	 	 curr.kost =  tckost.rpl.delivery) and curr.quan <  0) or  
 	 	 	 (curr.kost =  tckost.stc.transfer and curr.quan >  0) then  
 	 	 	 	 to.be.received =  to.be.received +  abs(curr.quan)  
 	 	 	 	 i =  i +  1  
 	 	 	 	 if i >  array.len then  
 	 	 	 	 	 array.len =  array.len +  100  
 	 	 	 	 	 alloc.mem(arr.whina112.trdt, 22, array.len)  
 	 	 	 	 	 alloc.mem(arr.whina112.seqn, array.len)  
 	 	 	 	 	 alloc.mem(arr.whina112.qskt, array.len)  
 	 	 	 	 endif  
 | 	 	 	 	 arr.whina112.trdt(1,i) =  utc(tipcs700.trdt, tipcs700.trtm) | #  800 -  142000.o  
 	 	 	 	 arr.whina112.trdt(1,i) =  utc(tipcs700.trdt, 0) 	 	 | #  800 -  142000.n  
 | 	 	 	 	 arr.whina112.seqn(i) =  tipcs700.sern +  1 	 	 	 | #  800 -  142000.o  
 	 	 	 	 arr.whina112.seqn(i) =  check.seqn 	 	 	 	 | #  800 -  142000.n  
 	 	 	 	 arr.whina112.qskt(i) =  abs(curr.quan)  
 	 	 	 else  
 	 	 	 	 issued =  issued +  abs(curr.quan)  
 	 	 	 endif  
 	 	 selecteos  
 	 	 	 onhand.inventory =  max(to.be.received -  issued, tipcs021.stoc)  
 	 	 	 if onhand.inventory >  to.be.received -  issued then  
 	 	 	 	 | *  create dummy receipt  
 	 	 	 	 dummy.receipt.qty =  onhand.inventory -  to.be.received +  issued  
 	 	 	 	 to.be.received =  to.be.received +  dummy.receipt.qty  
 	 	 	 	 i =  i +  1  
 	 	 	 	 if i >  array.len then  
 	 	 	 	 	 array.len =  array.len +  100  
 	 	 	 	 	 alloc.mem(arr.whina112.trdt, 22, array.len)  
 	 	 	 	 	 alloc.mem(arr.whina112.seqn, array.len)  
 	 	 	 	 	 alloc.mem(arr.whina112.qskt, array.len)  
 	 	 	 	 endif  
 | 	 	 	 	 arr.whina112.trdt(1,i) =  utc(tipcs700.trdt, tipcs700.trtm) | #  800 -  142000.o  
 	 	 	 	 arr.whina112.trdt(1,i) =  utc(tipcs700.trdt, 0) 	 	 | #  800 -  142000.n  
 	 	 	 	 arr.whina112.seqn(i) =  999 	 | *  take care  
 	 	 	 	 arr.whina112.qskt(i) =  dummy.receipt.qty  
 	 	 	 	 dummy.array.nr =  i  
 	 	 	 endif  
 	 	 endselect  
 	 	 i =  1  
 	 	 prev.sern =  0  
 	 endif  
 	  
 	 var.whinr110.qstk =  tipcs700.quan  
 	 var.whinr110.bpid =  empty()  
 	 var.whinr110.srnb =  0  
 	 on case tipcs700.koor  
 	 	 case tckoor.act.pur :  
 	 	 	 if not get.business.partner(tipcs700.rlcd, bcstc.orgn.suno, o.mess) then  
 	 	 	 	 var.whinr110.bpid =  bcstc008.bpid  
 	 	 	 endif  
 	 	 	 break  
 	 	 case tckoor.act.sls :  
 	 	 	 if not get.business.partner(tipcs700.rlcd, bcstc.orgn.cuno, o.mess) then  
 	 	 	 	 var.whinr110.bpid =  bcstc008.bpid  
 	 	 	 endif  
 	 	 	 var.whinr110.srnb =  determine.sales.order.sequence( 	 false, 	 |pcs 	 | #  800 -  143063.n  
 	 	 	 	 	 	 	 	 	 	 tipcs700.orno,  
 	 	 	 	 	 	 	 	 	 	 tipcs700.pono,  
 	 	 	 	 	 	 	 	 	 	 tipcs700.trdt,  
 	 	 	 	 	 	 	 	 	 	 tipcs700.trtm, 	 | #  800 -  143063.n  
 	 	 	 	 	 	 	 	 	 	 tipcs700.sern, 	 | #  800 -  143063.n  
 	 	 	 	 	 	 	 	 	 	 tipcs700.cprj, 	 | #  800 -  143063.n  
 	 	 	 	 	 	 	 	 	 	 tipcs700.quan) 	 | #  800 -  143063.n  
 	 	 	 break  
 	 	 case tckoor.sma.order :  
 	 	 	 if not get.business.partner(tipcs700.rlcd, bcstc.orgn.cuno, o.mess) then  
 	 	 	 	 var.whinr110.bpid =  bcstc008.bpid  
 	 	 	 endif  
 	 	 	 break  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101937.sn  
 	 	 case tckoor.pcs.wrh:  
 	 	 	 tipcs700.pono =  10  
 	 	 	 var.whinr110.srnb =  1  
 	 	 	 break  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101937.en  
 	 endcase  
 	 if tipcs700.prst <>  empty then  
 	 	 var.whinr110.prnt =  tipcs700.prst  
 	 else  
 	 	 var.whinr110.prnt =  tcyesno.no  
 	 endif  
 	 var.whinr110.qstk =  tipcs700.quan  
 	 if tipcs700.kost =  tckost.stc.transfer then  
 	 	 if (tipcs700.quan <  0) then  
 	 	 	 var.whinr110.qstk =  abs (tipcs700.quan)  
 	 	 endif  
 	 endif  
 	 var.whinr110.koor =  convert.tckoor(tipcs700.koor, tipcs700.orno)  
 	 var.whinr110.kost =  convert.tckost(tipcs700.kost, tipcs700.quan)  
 	 if var.whinr110.koor =  51 then | cycle count  
 	 	 var.whinr110.orno =  get.new.cycle.count.order.number(  
 	 	 	 	 	 tipcs700.orno, tipcs021.cwar)  
 	 else  
 	 	 var.whinr110.orno =  convert.number(  
 	 	 	 	 	 convert.tckoor.to.bcckon(tipcs700.koor), tipcs700.orno)  
 	 endif  
 	 itid =  itid +  1  
 	 var.whinr110.itid =  edit$(itid,"999999999")  
 	 var.whinr110.itse =  1  
 	 	 	 	 	 	 | #  800 -  142486.sn  
 	 | *  calculate quantity after transaction because it is not reliable in Baan4  
 	 if var.whinr110.kost =  1 or 	 	 |tckost.stc.correction  
 	 var.whinr110.kost =  3 then 	 	 |tckost.receipt  
 	 	 var.whinr110.qhnd =  var.whinr110.qhnd +  var.whinr110.qstk  
 	 endif  
 	 if var.whinr110.kost =  5 then 	 	 |tckost.issue  
 	 	 var.whinr110.qhnd =  var.whinr110.qhnd -  var.whinr110.qstk  
 	 endif  
 	 	 	 	 	 	 | #  800 -  142486.en  
 	 dump 2  
 	 if receipt.counter =  dummy.array.nr -  1 then  
 	 	 receipt.counter =  receipt.counter +  1  
 	 	 hold.koor =  var.whinr110.koor  
 	 	 hold.kost =  var.whinr110.kost  
 	 	 hold.orno =  var.whinr110.orno  
 	 	 hold.trdt =  var.whinr110.trdt  
 	 	 hold.seqn =  var.whinr110.seqn  
 	 	 hold.qstk =  var.whinr110.qstk  
 	 	 itid =  itid +  1  
 	 	 var.whinr110.itid =  edit$(itid,"999999999")  
 	 	 var.whinr110.itse =  1  
 	 	 var.whinr110.koor =  52 	 | *  adjustment  
 	 	 var.whinr110.kost =  1 	 | *  stock correction  
 	 	 var.whinr110.trdt =  arr.whina112.trdt(1,dummy.array.nr)  
 	 	 var.whinr110.orno =  "MIGRATION"                                                                                                                                                                      
 	 	 var.whinr110.seqn =  999 	 | *  take care  
 	 	 var.whinr110.qstk =  dummy.receipt.qty  
 	 	 	 	 	 	 | #  800 -  142486.sn  
 	 	 var.whinr110.qhnd =  var.whinr110.qhnd +  var.whinr110.qstk  
 	 	 	 	 	 	 | #  800 -  142486.en  
 	 	 dump 2  
 	 	 to.be.received =  to.be.received -  dummy.receipt.qty  
 	 	 if to.be.received >=  onhand.inventory then  
 	 	 	 | *  totally consumed  
 	 	 	 var.whina112.qskt =  0.0  
 	 	 else  
 	 	 	 if var.whina112.qskt >  0 then  
 	 	 	 	 | *  not consumed  
 	 	 	 	 var.whina112.qskt =  dummy.receipt.qty  
 	 	 	 else  
 	 	 	 	 | *  partially consumed  
 	 	 	 	 var.whina112.qskt =  onhand.inventory -  to.be.received  
 	 	 	 endif  
 	 	 endif  
 	 	 var.whina112.qstk =  dummy.receipt.qty  
 	 	 dump 5  
 	 	 get.customized.cost.price(tipcs700.cprj, tipcs700.item,  
 	 	 	 	 	 	 dummy.receipt.qty, true)  
 	 	 var.whinr110.koor =  hold.koor  
 	 	 var.whinr110.kost =  hold.kost  
 	 	 var.whinr110.orno =  hold.orno  
 	 	 var.whinr110.trdt =  hold.trdt  
 	 	 var.whinr110.seqn =  hold.seqn  
 	 	 var.whinr110.qstk =  hold.qstk  
 	 endif  
 	 if (tipcs700.kost =  tckost.stc.correction and tipcs700.quan >  0) or  
 	 ((tipcs700.kost =  tckost.pur.receipt or  
 	 tipcs700.kost =  tckost.prd.receipt or  
 	 tipcs700.kost =  tckost.rpl.receipt) and tipcs700.quan >  0) or  
 	 ((tipcs700.kost =  tckost.sls.delivery or  
 	 tipcs700.kost =  tckost.prd.mat.issue or  
 	 tipcs700.kost =  tckost.rpl.delivery) and tipcs700.quan <  0) or  
 	 (tipcs700.kost =  tckost.stc.transfer and tipcs700.quan >  0) then  
 	 	 var.whina112.qstk =  abs(tipcs700.quan)  
 	 	 receipt.counter =  receipt.counter +  1  
 	 	 to.be.received =  to.be.received -  abs(tipcs700.quan)  
 	 	 if to.be.received >=  onhand.inventory then  
 	 	 	 | *  totally consumed  
 	 	 	 var.whina112.qskt =  0.0  
 	 	 else  
 	 	 	 if var.whina112.qskt >  0 then  
 	 	 	 	 | *  not consumed  
 	 	 	 	 var.whina112.qskt =  abs(tipcs700.quan)  
 	 	 	 else  
 	 	 	 	 | *  partially consumed  
 	 	 	 	 var.whina112.qskt =  onhand.inventory -  to.be.received  
 	 	 	 endif  
 	 	 endif  
 	 	 dump 5  
 	 	 get.customized.cost.price(tipcs700.cprj, tipcs700.item,  
 	 	 	 	 	 	 abs(tipcs700.quan), true)  
 	 else  
 	 	 remain.quan =  abs(tipcs700.quan)  
 	 	 if arr.whina112.qskt(i) =  0 then  
 	 	 	 | *  corrupt data: more issued then received  
 	 	 	 continue  
 	 	 endif  
 	 	 repeat  
 	 	 	 if remain.quan <=  arr.whina112.qskt(i) then  
 	 	 	 	 var.whina114.trdt =  arr.whina112.trdt(1,i)  
 	 	 	 	 var.whina114.seqn =  arr.whina112.seqn(i)  
 	 	 	 	 var.whina114.sern =  prev.sern +  1  
 	 	 	 	 var.whina114.qstk =  remain.quan  
 	 	 	 	 arr.whina112.qskt(i) =  arr.whina112.qskt(i) -  remain.quan  
 	 	 	 	 remain.quan =  0  
 	 	 	 	 prev.sern =  prev.sern +  1  
 	 	 	 else  
 	 	 	 	 var.whina114.trdt =  arr.whina112.trdt(1,i)  
 	 	 	 	 var.whina114.seqn =  arr.whina112.seqn(i)  
 	 	 	 	 var.whina114.sern =  prev.sern +  1  
 	 	 	 	 var.whina114.qstk =  arr.whina112.qskt(i)  
 	 	 	 	 remain.quan =  remain.quan -  arr.whina112.qskt(i)  
 	 	 	 	 arr.whina112.qskt(i) =  0  
 	 	 	 endif  
 	 	 	 dump 6  
 	 	 	 get.customized.cost.price(tipcs700.cprj, tipcs700.item,  
 	 	 	 	 	 	 	 var.whina114.qstk, false)  
 	 	 	 if arr.whina112.qskt(i) =  0 then  
 	 	 	 	 prev.sern =  0  
 	 	 	 	 i =  i +  1  
 	 	 	 endif  
 	 	 	 if remain.quan >  0 and arr.whina112.qskt(i) =  0 then  
 	 	 	 	 | *  corrupt data: more issued then received  
 	 	 	 	 break  
 	 	 	 endif  
 	 	 until remain.quan =  0  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:wh
:TCMOD:inr
:TFLNO:110
:SCPAC:ti
:SCMOD:pcs
:SFLNO:700
:ICOD:S
:QURY:START

select 	 tipcs700.*  , tipcs021.cwar
from 	 tipcs700, tipcs021
where 	 tipcs021._index1 =  {tipcs700.cprj, tipcs700.item}  
 and 	 tipcs700.cprj >  ""                                                                                                                                                                                                                                                                                                                
 and 	 tipcs700.item >  ""
order by tipcs700._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:wh
:TCMOD:inr
:TFLNO:110
:SCPAC:ti
:SCMOD:pcs
:SFLNO:700
:ICOD:X
:QURY:START

  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:wh
:TCMOD:ltc
:TFLNO:100
:SCPAC:td
:SCMOD:ltc
:SFLNO:001
:ICOD:D
:QURY:START

	 if isspace(tdltc001.cprj) then  
 	 	 project.code =  ""                                                                                                                                                                                                                                                                                                          
 	 else  
 	 	 project.code =  get.ti.project( tdltc001.cprj)  
 	 endif  
 	 var.mwhltc100.item =  segment.item.code(  
 	 	 	 	 	 tdltc001.item,  
 	 	 	 	 	 project.code)  
 	 if tdltc001.olot =  tdltc.olot.purch then  
 	 	 kind.of.number =  bcckon.act.pur  
 	 else  
 	 	 kind.of.number =  bcckon.act.sfc  
 	 endif  
 	 var.mwhltc100.orno =  convert.number(  
 	 	 	 	 kind.of.number,  
 	 	 	 	 tdltc001.orno)  
 	 if lot.controlled.item( tdltc001.cprj,  
 	 	 	 	 tdltc001.item) then  
 	 	 | *  Fill dump 1 (Lot)  
 	 	 if tdltc001.olot =  tdltc.olot.purch and  
 	 	 get.business.partner( 	 tdltc001.suno,  
 	 	 	 	 	 bcstc.orgn.suno,  
 	 	 	 	 	 errmess) =  0 then  
 	 	 	 var.whltc100.bfbp =  bcstc008.bpid  
 	 	 else  
 	 	 	 var.whltc100.bfbp =  empty() 	  
 	 	 endif  
 	 	 if not isspace(tdltc001.revi) and  
 	 	 item.revision.is.valid( 	 tdltc001.item,  
 	 	 	 	 	 tdltc001.revi) then  
 	 	 	 var.whltc100.revi =  tdltc001.revi  
 	 	 else  
 	 	 	 var.whltc100.revi =  empty()  
 	 	 endif  
 	 	 | *  Lot date =  Date of first receipt,  
 	 	 | *  if empty then current date  
 	 	 lot.date =  tdltc001.ardt  
 	 	 if lot.date =  0 then  
 	 	 	 lot.date =  date.num()  
 	 	 endif  
 	 	 var.whltc100.ldat =  utc(lot.date, 0)  
 	 	 Dump 1 	 	 | *  Lots  
 	 	 if lot.price.item( 	 tdltc001.cprj,  
 	 	 	 	 	 tdltc001.item) then  
 	 	 	 | *  Fill Dump 2 (Lot Price)  
 	 	 	 material.component.price(1) =  0  
 	 	 	 material.component.price(2) =  0  
 	 	 	 material.component.price(3) =  0  
 	 	 	 operation.component.price(1) =  0  
 	 	 	 operation.component.price(2) =  0  
 	 	 	 operation.component.price(3) =  0  
 	 	 	 surcharge.component.price(1) =  0  
 	 	 	 surcharge.component.price(2) =  0  
 	 	 	 surcharge.component.price(3) =  0  
 | 	 	 	 select tdltc004.cpcp, 	 	 | #  CNT.so  
 | 	 	 	 	 tdltc004.amnt 	 	 | #  CNT.eo  
 	 	 	 select tdltc004.*  	 	 	 | #  CNT.n  
 	 	 	 from 	 tdltc004  
 	 	 	 where 	 tdltc004._index1 =  { 	 :tdltc001.item,  
 	 	 	 	 	 	 	 :tdltc001.cntr,  
 	 	 	 	 	 	 	 :tdltc001.clot}  
 	 	 	 selectdo  
 	 	 	 	 analyze.cost.component( tdltc001.item,  
 	 	 	 	 	 	 	 tdltc001.cprj,  
 	 	 	 	 	 	 	 tdltc004.cpcp,  
 	 	 	 	 	 	 	 detail.cost.component,  
 	 	 	 	 	 	 	 material.component,  
 	 	 	 	 	 	 	 operation.component,  
 	 	 	 	 	 	 	 surcharge.component,  
 	 	 	 	 	 	 	 result)  
 	 	 	 	 on case result  
 	 	 	 	 case 0:  
 	 	 	 	 	 | *  Cost Component in chart  
 	 	 	 	 	 | *  Dump record  
 	 	 	 	 	 var.whltc101.cpcp =  detail.cost.component  
 	 	 	 	 	 if is.masterdata.conversion() then  
 	 	 	 	 	 	 var.whltc101.pric(1) =  0.0 	  
 	 	 	 	 	 	 var.whltc101.pric(2) =  0.0 	  
 	 	 	 	 	 	 var.whltc101.pric(3) =  0.0 	  
 	 	 	 	 	 else  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  CNT.so  
 | 	 	 	 	 	 	 var.whltc101.pric(1) =  fill.mc.field.double(tdltc004.amnt, 1)  
 | 	 	 	 	 	 	 var.whltc101.pric(2) =  fill.mc.field.double(tdltc004.amnt, 2)  
 | 	 	 	 	 	 	 var.whltc101.pric(3) =  fill.mc.field.double(tdltc004.amnt, 3)  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  CNT.eo  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  CNT.sn  
 	 	 	 	 	 	 for i =  1 to g.mc.depth  
 	 	 	 	 	 	 	 var.whltc101.pric(i) =   
 	 	 	 	 	 	 	 	 get.amount.per.cost.component( "tdltc004", i)                    
 	 	 	 	 	 	 endfor  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  CNT.en  
 	 	 	 	 	 endif  
 	 	 	 	 	 dump.cost.details() 	 | *  Lot Price 	  
 	 	 	 	 	 break  
 	 	 	 	 case 1:  
 	 	 	 	 	 | *  Merge to aggregated material cost component  
 	 	 	 	 	 if not is.masterdata.conversion() then  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  CNT.so  
 | 	 	 	 	 	 	 material.component.price(1) =  material.component.price(1) +   
 | 	 	 	 	 	 	 	 fill.mc.field.double(tdltc004.amnt, 1)  
 | 	 	 	 	 	 	 material.component.price(2) =  material.component.price(2) +   
 | 	 	 	 	 	 	 	 fill.mc.field.double(tdltc004.amnt, 2)  
 | 	 	 	 	 	 	 material.component.price(3) =  material.component.price(3) +   
 | 	 	 	 	 	 	 	 fill.mc.field.double(tdltc004.amnt, 3)  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  CNT.eo  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  CNT.sn  
 	 	 	 	 	 	 for i =  1 to g.mc.depth  
 	 	 	 	 	 	 	 material.component.price(i) =  material.component.price(i) +   
 	 	 	 	 	 	 	 	 get.amount.per.cost.component( "tdltc004", i)                      
 	 	 	 	 	 	 endfor  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  CNT.en  
 	 	 	 	 	 endif  
 	 	 	 	 	 break  
 	 	 	 	 case 2:  
 	 	 	 	 	 | *  Merge to aggregated opration cost component  
 	 	 	 	 	 if not is.masterdata.conversion() then  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  CNT.so  
 | 	 	 	 	 	 	 operation.component.price(1) =  operation.component.price(1) +   
 | 	 	 	 	 	 	 	 fill.mc.field.double(tdltc004.amnt, 1)  
 | 	 	 	 	 	 	 operation.component.price(2) =  operation.component.price(2) +   
 | 	 	 	 	 	 	 	 fill.mc.field.double(tdltc004.amnt, 2)  
 | 	 	 	 	 	 	 operation.component.price(3) =  operation.component.price(3) +   
 | 	 	 	 	 	 	 	 fill.mc.field.double(tdltc004.amnt, 3)  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  CNT.eo  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  CNT.sn  
 	 	 	 	 	 	 for i =  1 to g.mc.depth  
 	 	 	 	 	 	 	 operation.component.price(i) =  operation.component.price(i) +   
 	 	 	 	 	 	 	 	 get.amount.per.cost.component( "tdltc004", i)                      
 	 	 	 	 	 	 endfor  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  CNT.en  
 	 	 	 	 	 endif  
 	 	 	 	 	 break  
 	 	 	 	 case 3:  
 	 	 	 	 	 | *  Merge to aggregated surcharge cost component  
 	 	 	 	 	 if not is.masterdata.conversion() then 	  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  CNT.so  
 | 	 	 	 	 	 	 surcharge.component.price(1) =  surcharge.component.price(1) +   
 | 	 	 	 	 	 	 	 fill.mc.field.double(tdltc004.amnt, 1)  
 | 	 	 	 	 	 	 surcharge.component.price(2) =  surcharge.component.price(2) +   
 | 	 	 	 	 	 	 	 fill.mc.field.double(tdltc004.amnt, 2)  
 | 	 	 	 	 	 	 surcharge.component.price(3) =  surcharge.component.price(3) +   
 | 	 	 	 	 	 	 	 fill.mc.field.double(tdltc004.amnt, 3)  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  CNT.eo  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  CNT.sn  
 	 	 	 	 	 	 for i =  1 to g.mc.depth  
 	 	 	 	 	 	 	 surcharge.component.price(i) =  surcharge.component.price(i) +   
 	 	 	 	 	 	 	 	 get.amount.per.cost.component( "tdltc004", i)                      
 	 	 	 	 	 	 endfor  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  CNT.en  
 	 	 	 	 	 endif  
 	 	 	 	 	 break  
 	 	 	 	 endcase  
 	 	 	 endselect  
 	 	  
 	 	 	 var.whltc101.cpcp =  material.component  
 	 	 	 if not is.masterdata.conversion() then  
 	 	 	 	 var.whltc101.pric(1) =  material.component.price(1)  
 	 	 	 	 var.whltc101.pric(2) =  material.component.price(2)  
 	 	 	 	 var.whltc101.pric(3) =  material.component.price(3)  
 	 	 	 else  
 	 	 	 	 var.whltc101.pric(1) =  0  
 	 	 	 	 var.whltc101.pric(2) =  0  
 	 	 	 	 var.whltc101.pric(3) =  0  
 	 	 	 endif  
 	 	 	 dump.cost.details() 	 | *  Lot Price 	  
 	 	 	 var.whltc101.cpcp =  operation.component  
 	 	 	 if not is.masterdata.conversion() then  
 	 	 	 	 var.whltc101.pric(1) =  operation.component.price(1)  
 	 	 	 	 var.whltc101.pric(2) =  operation.component.price(2)  
 	 	 	 	 var.whltc101.pric(3) =  operation.component.price(3)  
 	 	 	 else  
 	 	 	 	 var.whltc101.pric(1) =  0  
 	 	 	 	 var.whltc101.pric(2) =  0  
 	 	 	 	 var.whltc101.pric(3) =  0  
 	 	 	 endif  
 	 	 	 dump.cost.details() 	 | *  Lot Price 	  
 	 	 	 var.whltc101.cpcp =  surcharge.component  
 	 	 	 if not is.masterdata.conversion() then  
 	 	 	 	 var.whltc101.pric(1) =  surcharge.component.price(1)  
 	 	 	 	 var.whltc101.pric(2) =  surcharge.component.price(2)  
 	 	 	 	 var.whltc101.pric(3) =  surcharge.component.price(3)  
 	 	 	 else  
 	 	 	 	 var.whltc101.pric(1) =  0  
 	 	 	 	 var.whltc101.pric(2) =  0  
 	 	 	 	 var.whltc101.pric(3) =  0  
 	 	 	 endif  
 	 	 	 dump.cost.details() 	 | *  Lot Price 	  
 	 	 endif  
 	 	 | *  Fill Dump 3 (Lot Inventory by Item and Warehouse)  
 	 	 hold.cwar =  ""                                                                                                                                                                                                                                                                                                          
 	 	 var.whltc105.qhnd =  0.0  
 	 	 var.whltc105.qblk =  0.0  
 	 	 var.whltc105.qord =  0.0  
 	 	 var.whltc105.qall =  0.0  
 	 	 var.whltc105.qlal =  0.0  
 	 	 var.whltc105.ball =  tcyesno.no  
 	 	 var.whltc105.binb =  tcyesno.no  
 	 	 var.whltc105.bout =  tcyesno.no  
 	 	 var.whltc105.btri =  tcyesno.no  
 	 	 var.whltc105.btrr =  tcyesno.no  
 	 	 select tdilc101.*  , tcmcs003.cwar  
 	 	 from 	 tdilc101, tcmcs003  
 	 	 where 	 tdilc101._index3 =  { 	 :tdltc001.cprj,  
 	 	 	 	 	 	 :tdltc001.item,  
 	 	 	 	 	 	 :tdltc001.cntr,  
 	 	 	 	 	 	 :tdltc001.clot}  
 	 	 and 	 tcmcs003.cwar =  tdilc101.cwar  
 	 	 and 	 tcmcs003.typw <>  tctypw.transito  
 	 	 order by tdilc101.cprj,tdilc101.item,tdilc101.cntr,  
 	 	 	 tdilc101.clot,tdilc101.cwar  
 	 	 selectdo  
 	 	 	 var.whltc105.cwar =  tdilc101.cwar  
 	 	 	 if hold.cwar <>  "" and                                                                                                                                                                                                                                                                                                          
 	 	 	 tdilc101.cwar <>  hold.cwar then  
 	 	 	 	 var.whltc105.cwar =  hold.cwar  
 	 	 	 	 if tdilc101.date =  0 then  
 	 	 	 	 	 var.whltc105.trdt =  tdltc001.ardt  
 	 	 	 	 else  
 	 	 	 	 	 var.whltc105.trdt =  tdilc101.date  
 	 	 	 	 endif  
 	 	 	 	 | *  Subtract location allocated quantity from allocated  
 	 	 	 	 | *  and on order  
 	 	 	 	 determine.location.allocated.quantity(  
 	 	 	 	 	 	 var.whltc105.cwar,  
 	 	 	 	 	 	 tdltc001.cprj,  
 	 	 	 	 	 	 tdltc001.item,  
 	 	 	 	 	 	 tdltc001.clot,  
 	 	 	 	 	 	 location.allocated.quantity)  
 	 	 	 	 var.whltc105.qall =  var.whltc105.qall -   
 	 	 	 	 	 	 location.allocated.quantity  
 	 	 	 	 var.whltc105.qord =  var.whltc105.qord -   
 	 	 	 	 	 	 location.allocated.quantity  
 	 	 	 	 var.whltc105.qlal =  location.allocated.quantity  
 	 	 	 	 Dump 3 	 | *  Lot Inventory  
 	 	 	 	 var.whltc105.qhnd =  0.0  
 	 	 	 	 var.whltc105.qblk =  0.0  
 	 	 	 	 var.whltc105.qord =  0.0  
 	 	 	 	 var.whltc105.qall =  0.0  
 	 	 	 	 var.whltc105.qlal =  0.0  
 	 	 	 endif  
 	 	 	 | *  Cumulate quantities by warehouse  
 	 	 	 if not is.masterdata.conversion() then  
 	 	 	 	 var.whltc105.qhnd =  var.whltc105.qhnd +   
 	 	 	 	 	 	 	 tdilc101.stks  
 	 	 	 	 determine.blocked.quantity( 	  
 	 	 	 	 	 	 tdilc101.cwar,  
 	 	 	 	 	 	 tdilc101.loca,  
 	 	 	 	 	 	 "",       |*                                                                                  Project                                                                                                                                                                                                                                                                                                                                              
 	 	 	 	 	 	 tdilc101.item,  
 	 	 	 	 	 	 tdilc101.clot,  
 	 	 	 	 	 	 tdilc101.date,  
 	 	 	 	 	 	 tdilc101.stun,  
 	 	 	 	 	 	 tdilc101.strb,  
 	 	 	 	 	 	 tdilc101.stra,  
 	 	 	 	 	 	 process.blocked,  
 	 	 	 	 	 	 manual.blocked)  
 	 	 	 	 var.whltc105.qblk =  var.whltc105.qblk +   
 	 	 	 	 	 	 	 process.blocked +  manual.blocked  
 	 	 	 	 var.whltc105.qall =  var.whltc105.qall +   
 	 	 	 	 	 	 	 tdilc101.stka  
 	 	 	 	 var.whltc105.qord =  var.whltc105.qord +   
 	 	 	 	 	 	 	 tdilc101.stko  
 	 	 	 	 var.whltc105.ball =  tdltc001.blst  
 	 	 	 	 var.whltc105.binb =  tdltc001.inbl  
 	 	 	 	 var.whltc105.bout =  tdltc001.outb  
 	 	 	 	 var.whltc105.btri =  tdltc001.trsb  
 	 	 	 	 var.whltc105.btrr =  tcyesno.no  
 	 	 	 endif  
 	 	 	 hold.cwar =  tdilc101.cwar  
 	 	 selecteos  
 	 	 	 var.whltc105.cwar =  hold.cwar  
 	 	 	 var.whltc105.trdt =  tdilc101.date  
 	 	 	 Dump 3 	 	 | *  Lot Inventory  
 	 	 endselect  
 	 endif  
 	 if serialized.item( 	 tdltc001.cprj,  
 	 	 	 	 tdltc001.item) then  
 	 	 | *  Fill Dump 4 (Serials)  
 	 	 if tdltc001.olot =  tdltc.olot.purch and  
 	 	 get.business.partner( tdltc001.suno,  
 	 	 	 	 	 bcstc.orgn.suno,  
 	 	 	 	 	 errmess) =  0 then  
 	 	 	 var.whltc500.bpid =  bcstc008.bpid  
 	 	 else  
 	 	 	 var.whltc500.bpid =  empty()  
 	 	 endif  
 	 	 if not isspace(tdltc001.revi) and  
 	 	 item.revision.is.valid( 	 tdltc001.item,  
 	 	 	 	 	 tdltc001.revi) then  
 	 	 	 var.whltc500.revi =  tdltc001.revi  
 	 	 else  
 	 	 	 var.whltc500.revi =  empty()  
 	 	 endif  
 	 	 | *  Inventory date  
 	 	 if fifo.lifo.item( 	 tdltc001.cprj,  
 	 	 	 	 	 tdltc001.item) then  
 	 	 	 if tdltc001.ardt <>  0 then  
 	 	 	 	 inventory.date =  tdltc001.ardt  
 	 	 	 else  
 	 	 	 	 inventory.date =  date.num()  
 	 	 	 endif  
 	 	 else  
 	 	 	 inventory.date =  0  
 	 	 endif  
 	 	 var.whltc500.idat =  utc(inventory.date, 0)  
 	 	 select tdilc101.*  , tcmcs003.cwar  
 	 	 from 	 tdilc101, tcmcs003  
 	 	 where 	 tdilc101._index3 =  { 	 :tdltc001.cprj,  
 	 	 	 	 	 	 :tdltc001.item,  
 	 	 	 	 	 	 :tdltc001.cntr,  
 	 	 	 	 	 	 :tdltc001.clot}  
 	 	 and 	 tcmcs003.cwar =  tdilc101.cwar  
 	 	 and 	 tcmcs003.typw <>  tctypw.transito  
 	 	 selectdo  
 	 	 	 if tdilc101.stro >  0.0 then  
 	 	 	 	 | *  Check whether OnHand is on other location  
 	 	 	 	 if serial.on.other.location() then  
 	 	 	 	 	 continue  
 	 	 	 	 endif  
 	 	 	 endif  
 	 	 	 if is.masterdata.conversion() then  
 	 	 	 	 var.whltc500.qhnd =  0.0  
 	 	 	 	 var.whltc500.qblk =  0.0  
 	 	 	 	 var.whltc500.qall =  0.0  
 	 	 	 	 var.whltc500.qord =  0.0  
 	 	 	 	 var.whltc500.qlal =  0.0  
 	 	 	 	 var.whltc500.ball =  tcyesno.no 	 | *  target  
 	 	 	 	 var.whltc500.bout =  tcyesno.no 	 | *  target  
 	 	 	 	 var.whltc500.btri =  tcyesno.no 	 | *  target  
 	 	 	 else  
 	 	 	 	 var.whltc500.qhnd =  tdilc101.stks  
 	 	 	 	 var.whltc500.qblk =  tdilc101.stkb  
 	 	 	 	 var.whltc500.qall =  tdilc101.stka  
 	 	 	 	 var.whltc500.qord =  tdilc101.stko  
 	 	 	 	 var.whltc500.qlal =  tdilc101.stka  
 	 	 	 	 var.whltc500.ball =  tdilc101.blst  
 	 	 	 	 var.whltc500.bout =  tdilc101.outb  
 	 	 	 	 var.whltc500.btri =  tdilc101.trfb  
 	 	 	 endif  
 	 	 	 Dump 4 	 	 | *  Serials  
 	 	 selectempty  
 	 	 	 if is.masterdata.conversion() then  
 	 	 	 	 var.whltc500.qhnd =  0.0  
 	 	 	 	 var.whltc500.qblk =  0.0  
 	 	 	 	 var.whltc500.qall =  0.0  
 	 	 	 	 var.whltc500.qord =  0.0  
 	 	 	 	 var.whltc500.qlal =  0.0  
 	 	 	 	 var.whltc500.ball =  tcyesno.no 	 | *  target  
 	 	 	 	 var.whltc500.bout =  tcyesno.no 	 | *  target  
 	 	 	 	 var.whltc500.btri =  tcyesno.no 	 | *  target  
 	 	 	 else  
 	 	 	 	 var.whltc500.qhnd =  tdltc001.stoc  
 	 	 	 	 var.whltc500.qblk =  tdltc001.bloc  
 	 	 	 	 var.whltc500.qall =  tdltc001.allo  
 	 	 	 	 var.whltc500.qord =  tdltc001.ordr  
 	 	 	 	 var.whltc500.qlal =  tdltc001.allo  
 	 	 	 	 var.whltc500.ball =  tcyesno.no 	 | *  target  
 	 	 	 	 var.whltc500.bout =  tcyesno.no 	 | *  target  
 	 	 	 	 var.whltc500.btri =  tcyesno.no 	 | *  target  
 	 	 	 endif  
 	 	 	 Dump 4 	 	 | *  Serials  
 	 	 endselect  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:wh
:TCMOD:ltc
:TFLNO:100
:SCPAC:td
:SCMOD:ltc
:SFLNO:001
:ICOD:S
:QURY:START

select 	 tdltc001.*
from 	 tdltc001
where 	 tdltc001.cntr =  ""
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:wh
:TCMOD:ltc
:TFLNO:100
:SCPAC:td
:SCMOD:ltc
:SFLNO:001
:ICOD:X
:QURY:START

  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:wh
:TCMOD:wmd
:TFLNO:215
:SCPAC:td
:SCMOD:inv
:SFLNO:001
:ICOD:D
:QURY:START

	 read.parameters()  
 	 g.mc.depth =  get.mc.depth()  
 	 set.period.variables()  
 	 migrate.distribution.item.data.by.warehouse()  
 	 migrate.project.item.data.by.warehouse()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:wh
:TCMOD:wmd
:TFLNO:215
:SCPAC:td
:SCMOD:inv
:SFLNO:001
:ICOD:S
:QURY:START

select 	 tdinv000.perl
from 	 tdinv000
as set with 1  rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:19
:VERS:B40U
:RELE:c4
:CUST:cont
:TCPAC:wh
:TCMOD:wmd
:TFLNO:215
:SCPAC:td
:SCMOD:inv
:SFLNO:001
:ICOD:X
:QURY:START

  
:QURY:END
:TEXT:

:TEXT:END
