QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:100
:SCPAC:tc
:SCMOD:mcs
:SFLNO:042
:ICOD:D
:QURY:START
if tcmcs042.reto =  tcyesno.no then  
 | 	 	 var.sott =  tcmcs042.ttyp 	 	 |binda.o  
 	 	 var.cisli100.sott =  read.tfgld011.iseq(tcmcs042.ttyp) 	 |binda.n  
 	 	 if var.cisli100.sott =  empty.string(1;3) then  
 	 	 	 var.cisli100.sosr =  0  
 	 	 else  
 	 	 	 var.cisli100.sosr =  tcmcs042.seri  
 	 	 endif  
 | 	 	 var.sosr =  tcmcs042.seri  
 	 else 	  
 | 	 	 var.cntt =  tcmcs042.ttyp 	 	 |binda.so  
 | 	 	 var.cnsr =  tcmcs042.seri 	 	 |binda.eo  
 	 	 var.cisli100.cntt =  read.tfgld011.iseq(tcmcs042.ttyp) 	 |binda.n  
 	 	 if var.cisli100.cntt =  empty.string(1;3) then  
 	 	 	 var.cisli100.cnsr =  0  
 	 	 else  
 	 	 	 var.cisli100.cnsr =  tcmcs042.seri  
 	 	 endif  
 	 endif  
 | 	 if var.sott <>  "" and var.cntt <>                                 "" then                                                                                                                                                            
 	 if var.cisli100.sott <>  "" and var.cisli100.cntt <>                                 "" then                                                                                                                                                            
 	 	 break  
 	 endif  
 	 call.tfgld011()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:100
:SCPAC:tc
:SCMOD:mcs
:SFLNO:042
:ICOD:E
:QURY:START
call.tfgld011()  
 	 select tfgld011.*   
 	 from tfgld011  
 	 where tfgld011.catg =  tfgld.catg.sales.inv  
 	 or tfgld011.catg =  tfgld.catg.sales.cred  
 	 selectdo  
 	 	 if tfgld011.catg =  tfgld.catg.sales.inv then  
 | 	 	 	 var.sott =  tfgld011.ttyp  
 | 	 	 	 var.sosr =  tfgld011.dsrn  
 	 	 	 var.cisli100.sott =  read.tfgld011.iseq(tfgld011.ttyp) 	 |binda.n  
 	 	 	 if var.cisli100.sott =  empty.string(1;3) then  
 	 	 	 	 var.cisli100.sosr =  0  
 	 	 	 else  
 	 	 	 	 var.cisli100.sosr =  tfgld011.dsrn  
 	 	 	 endif  
 	 	 	  
 	 	 else  
 | 	 	 	 var.cntt =  tfgld011.ttyp  
 | 	 	 	 var.cnsr =  tfgld011.dsrn  
 	 	 	 var.cisli100.cntt =  read.tfgld011.iseq(tfgld011.ttyp) 	 |binda.n  
 	 	 	 if var.cisli100.cntt =  empty.string(1;3) then  
 	 	 	 	 var.cisli100.cnsr =  0  
 	 	 	 else  
 	 	 	 	 var.cisli100.cnsr =  tfgld011.dsrn  
 	 	 	 endif  
 	 	 	  
 	 	 endif  
 	 	  
 | 	 	 if var.sott <>  "" and var.cntt <>                                "" then          |binda.0                                                          
 	 if var.cisli100.sott <>  "" and var.cisli100.cntt <>                                 "" then                                                                                                                                                            
 	 	 	 break  
 	 	 endif  
 	 endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:100
:SCPAC:tc
:SCMOD:mcs
:SFLNO:042
:ICOD:S
:QURY:START
select 	 tcmcs042.*
from tcmcs042
where tcmcs042.modc =  tcmodc.sls  
 and tcmcs042.coun =  tcyesno.no  
 and tcmcs042.sund =  tcyesno.no  
 and tcmcs042.subc =  tcyesno.no
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:100
:SCPAC:tc
:SCMOD:mcs
:SFLNO:042
:ICOD:X
:QURY:START
var.cisli100.indt =  utc(0,0)  
 var.cisli100.dsca =  form.text$("bcstc00035") | *  Actual Set  
 dump 11  
 var.cisli100.indt =  utc(date.num(),time.num())  
 var.cisli100.dsca =  form.text$("bcstc00036") | *  Converted from Baan IVc4  
 dump 11
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:td
:SCMOD:cms
:SFLNO:050
:ICOD:D
:QURY:START
rebate.invoice =  1  
 | store.index.fields.rebates () 	 	 	 	 	 	 	 |binda25 -  06.o  
 	 initialize.variables ()  
 	 initialize.cisli206.variables () 	 	 	  
 	 if (prev.tran1 <>  tdcms050.crtt or prev.invn1 <>  tdcms050.crin) then 	 | #  ravi_array.sn  
 	 	 prev.tran1 =  tdcms050.crtt  
 	 	 prev.invn1 =  tdcms050.crin  
 	 	 prev.ncmp1 =  tdsls050.comp 	  
 	 	 allocate.memories(tdcms201.ccty) 	 	  
 	 endif 	 	 	 	 	 	 	 	 	 | #  ravi_array.en 	  
 	 	 	 	  
 	 if tdcms000.lnrp =  tdcms.lnrp.order then  
 	 	 if not read.sales.order.history () then  
 	 	 	 continue  
 	 	 endif  
 	 else  
 	 	 if not read.sales.order.line.history () then  
 	 	 	 continue  
 	 	 endif  
 	 endif  
 	 	 	 	 	 	 	 	 	 |binda24 -  07.so  
 | 	 order.count =  order.count +  1  
 | 	 alloc.mem (rebates.array,6,order.count)  
 | 	 if rebates.array (1, order.count) =  0 then  
 | 	 	 rebates.array (1, order.count) =  tdcms050.orno  
 | 	 endif  
 	  
 | 	 header.dumped =  false  
 | 	 for counter1 =  1 to order.count -  1  
 | 	 	 if tdcms050.orno =  rebates.array (1, counter1) then  
 | 	 	 	 header.dumped =  true  
 | 	 	 	 break  
 | 	 	 endif  
 | 	 endfor  
 	 	 	 	 	 	 	 	 	 |binda24 -  07.eo  
 	 	 	 	 	 	 	 	 	 |binda24 -  07.sn  
 	 	 header.dumped =  false  
 	 	 if order.count >  0 and tdcms050.orno =  rebates.array(order.count) then  
 	 	 	 | record is found  
 	 	 	 header.dumped =  true  
 	 	 else  
 	 	 	 |WR PERF search record  
 	 	 	 if order.count >  0 then  
 	 	 	 	 ret =  0  
 	 	 	 	 if tdcms050.orno >  rebates.array(order.count) or |new value larger than last value in array  
 	 	 	 	 tdcms050.orno <  rebates.array(1) then |new value smaller than first value in array  
 	 	 	 	 	 | not found  
 	 	 	 	 else  
 	 	 	 	 	 | do a binary search  
 	 	 	 	 	  
 	 	 	 	 	 ret =  qss.search(QSS.SRC.IS.SORTED +  QSS.EQUAL,  
 	 	 	 	 	 tdcms050.orno,rebates.array,sort_def,order.count)  
 	 	 	 	 	  
 	 	 	 	 endif  
 	 	 	 endif  
 	 	  
 	 	 	 |WR PERF insert record  
 	 	 	 if ret >  0 then  
 	 	 	 	 | record is found, do not insert again  
 	 	 	 	 header.dumped =  true  
 	 	 	 else  
 	 	 	 	 order.count =  order.count +  1  
 	  
 	 	 	 	 if order.count >  array.length then 	 	 |WR PERF allocate memory per 1000 records  
 	 	 	 	 	  
 	 	 	 	 	 array.length =  array.length +  1000  
 	 	 	 	 	 alloc.mem (rebates.array,array.length)  
 	 	 	 	 	  
 	 	 	 	 endif  
 	 	 	 	 |insert orno  
 	 	 	 	 rebates.array(order.count) =  tdcms050.orno  
 	 	 	  
 	 	 	 	 |sort array only if last inserted record is smaller than the previous  
 	 	 	 	 if order.count >  1 and rebates.array(order.count) <  rebates.array(order.count -  1) then  
 	 	 	 	 	  
 	 	 	 	 	 qss.sort(rebates.array,sort_def,order.count)  
 	 	 	 	 	  
 	 	 	 	 endif  
 	 	  
 	 	 	 endif  
 	 	 endif  
 	 	 |WR PERF end  
 	 	 	 	 	 	 	 	 	 	 |binda24 -  07.en  
 	 if not convert.rebate.invoice.header.fields () then  
 	 	 continue  
 	 endif  
 	 if header.dumped =  false then  
 	 	  
 	 	 dump.cisli290 ()  
 	 endif  
 	  
 	 convert.rebate.invoice.line.fields ()  
 	 dump.cisli295 ()  
 	 cisli209.dumped =  false 	 	 	 |ravi_cisli209.n  
 | 	 if not isspace (new.txct) then 	 	 	 |ravi_july28th.so  
 | 	 	 read.tcmcs032 (new.txct,new.txid,tdcms050.invd)  
 | 	 	 read.tcmcs036 (new.txct, new.txid) 	  
 | 	 endif 	 	 	 	 	 	 |ravi_july28th.eo  
 | 	 if not isspace (tdcms010.cuno) then 	 	 	 	 | #  ravi_array.so  
 | 	 	 read.tcmcs142 (tdcms010.cuno, tcmcs036.ctau.l, tdcms050.invd)  
 | 	 endif 	 	 	 	 	 	 	 	 | #  ravi_array.eo  
 | 	 get.tax.code.details (new.txct, new.txid, tdcms050.cmdt) |ravi_july28th.o  
 	 get.financial.company.country (tdsls050.comp) 	  
 	 convert.cisli290.ofad () 	 	  
 	 var.cisli206.stcy =  bcstc004.ccty  
 | 	 for i =  1 to 3 	 | *  MCR 	 	 	 	 	 | #  ravi_array.so  
 | 	 	 update.fields.bcsci002.cisli206 (tdcms050.comp, tdcms201.crtt,  
 | 	 	 tdcms201.crin, new.txct, new.txid,  
 | 	 	 var.cisli295.txai, var.cisli295.amti,  
 	 	 | *  MCR -  s  
 	 	 | tdcms201.rate,  
 	 	 | tdcms201.ratf,  
 | 	 	 fill.mc.field.double(tdcms201.rate,i),  
 | 	 	 fill.mc.field.long(tdcms201.ratf,i),  
 	 	 | *  MCR -  e  
 | 	 	 tdcms201.ccur,  
 | 	 	 var.fin.comp.country,var.cisli206.stcy,  
 | 	 	 var.fin.comp.country,var.cisli206.stcy, var.cisli206.ceno, var.cisli206.rcod)  
 | 	 endfor | *  MCR 	 	 	 	 	 	 | #  ravi_array.eo  
 | 	 get.tax.percentage (new.txct, new.txid, var.compnr, 	 |ravi_july28th.so  
 | 	 	 	 	 	 tdcms050.invd, var.singular.tax, var.cisli209.pvat)  
 	 	 	 	 	 	 |ravi_july28th.eo  
 | 	 for i =  1 to 3 | *  MCR 	 	 	 	 	 	 | #  ravi_cisli209.so 	  
 | 	 	 update.fields.bcsci002.cisli209 (var.cisli295.txai,  
 | 	 	 	 	 tdcms201.ccur,  
 | 	 	 	 	 tdcms050.invd,  
 | 	 	 	 	 var.cisli.rtyp,  
 	 	 	 	 | *  MCR -  s  
 	 	 	 	 |tdcms201.rate, 	 	  
 	 	 	 	 |tdcms201.ratf, 	  
 | 	 	 	 	 fill.mc.field.double(tdcms201.rate,i),  
 | 	 	 	 	 fill.mc.field.long(tdcms201.ratf,i),  
 	 	 	 	 | *  MCR -  e 	 	 	  
 | 	 	 	 	 var.cisli209.pvat,  
 | 	 	 	 	 tcmcs036.ctau.l,  
 | 	 	 	 	 tdcms201.crtt,  
 | 	 	 	 	 tdcms201.crin,  
 | 	 	 	 	 1,  
 | 	 	 	 	 tdcms050.comp,  
 | 	 	 	 	 tcmcs142.reas,  
 | 	 	 	 	 tcmcs142.exno,  
 | 	 	 	 	 var.cisli295.amti)  
 | 	 	 endfor | *  MCR 	 	 	 	 	 | #  ravi_cisli209.eo  
 	 	 	 	 	 	 	 |ravi_cisli209.sn  
 	 	 	 	 	 	 	  
 	 	 	 	 | *  MCR -  s  
 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 tmp.mc.tdcms201.rate(i) =  fill.mc.field.double(tdcms201.rate,i,0.000001)  
 	 	 	 	 	 tmp.mc.tdcms201.ratf(i) =  fill.mc.field.long(tdcms201.ratf,i,1) 	 	  
 	 	 	 	 endfor 	  
 	 	 	 	 | *  MCR -  e  
 	 	 	 	 	 	 	 |ravi_july28th.so  
 | 	 	 	 	 update.row.in.cache.cisli209( 	 	 	  
 | 	 	 	 	 	 tdcms050.comp,  
 | 	 	 	 	 	 tdcms201.crtt,  
 | 	 	 	 	 	 tdcms201.crin,  
 | 	 	 	 	 	 tcmcs036.ctau.l,  
 | 	 	 	 	 	 var.cisli206.ceno,  
 | 	 	 	 	 	 var.cisli209.pvat,  
 | 	 	 	 	 	 var.cisli295.txai,  
 | 	 	 	 	 	 var.cisli295.amti,  
 | 	 	 	 	 	 var.cisli206.rcod,  
 | 	 	 	 	 	 tdcms201.ccur,  
 | 	 	 	 	 	 tdcms050.invd,  
 | 	 	 	 	 	 var.cisli.rtyp,  
 | 	 	 	 	 	 |tdcms201.rate, | MCR -  o 	  
 | 	 	 	 	 	 |tdcms201.ratf) |MCR -  o 	  
 | 	 	 	 	 	 tmp.mc.tdcms201.rate, | MCR -  n  
 | 	 	 	 	 	 tmp.mc.tdcms201.ratf) | MCR -  n  
 	 	 	 	 	 	 	 |ravi_july28th.eo 	 	 	 	 	  
 	 	 	 	 	 	 	 |ravi_cisli209.en  
 	 if (prev.tran <>  tdcms050.crtt or prev.invn <>  tdcms050.crin) then  
 	 	 prev.tran =  tdcms050.crtt  
 	 	 prev.invn =  tdcms050.crin  
 	 	 no.of.records =  0  
 	 	 var.cisli205.txai =  0  
 	 	 var.cisli205.stai =  0  
 	 	 var.cisli205.csai =  0  
 	 	 var.net.amti =  0  
 	  
 	 	 select tdcms050.*  , tdcms010.*  , tdcms201.*   
 	 	 from 	 tdcms050, tdcms010, tdcms201  
 	 	 where 	 tdcms050.type =  tdcms.type.rebate  
 	 	 and 	 tdcms010._index1 =  {tdcms050.reln}  
 	 	 and 	 tdcms050._index5 =  {:prev.tran, :prev.invn}  
 	 	 and 	 (tdcms050.cmst =  tdcms.cmst.closed or 	  
 	 	 	 tdcms050.cmst =  tdcms.cmst.ready)  
 	 	 and 	 tdcms201._index1 =  {:prev.tran, :prev.invn}  
 	 	 order by tdcms050._index5  
 	 	 selectdo  
 	 	 	 convert.cisli295.txai ()  
 	 	 	  
 	 	 	 | *  MCR .s  
 	 	 	 |var.net.amti =  var.net.amti +  ( -  tdcms050.cmam) 	  
 	 	 	 for i =  1 to 3  
 	 	 	 	 var.net.amti =  var.net.amti +  ( -  fill.mc.field.double(tdcms050.cmam,i,0.000001)) 	  
 	 	 	 endfor  
 	 	 	 | *  MCR .e  
 	 	 	  
 	 	 	 var.cisli205.txai =  var.cisli205.txai +  var.cisli295.txai  
 	 	 	 if not isspace (new.txct) then 	 	 	 	  
 	 	 	 	 read.tcmcs036 (new.txct, new.txid)  
 	 	 	 endif 	 	 	 	 	 	  
 	 	 	 if tcmcs036.tvat =  tctvat.shifted then  
 	 	 	 var.cisli205.stai =  var.cisli205.stai +  var.cisli295.txai  
 	 	 	 if var.cisli205.stai <>  0.0 then  
 | *  MCR -  new changes .s 	 	 	  
 | 	 	 	 	 for i =  1 to 3 | *  MCR  
 | 	 	 	 	 	 calculate.amount.in.other.currency (var.cisli205.stai,  
 | 	 	 	 	 	 	 | *  MCR -  s  
 | 	 	 	 	 	 	 |tdcms201.rate,  
 | 	 	 	 	 	 	 |tdcms201.ratf,  
 | 	 	 	 	 	 	 tmp.mc.tdcms201.rate(i), | MCR -  n  
 | 	 	 	 	 	 	 tmp.mc.tdcms201.ratf(i), | MCR -  n  
 | 	 	 	 	 	 	 | *  MCR -  e 	 	 	  
 | 	 	 	 	 	 	 tdcms201.ccur,  
 | 	 	 	 	 	 	 |var.cisli205.stah,  
 | 	 	 	 	 	 	 var.cisli205.stah(i), | *  MCR  
 | 	 	 	 	 	 	 err.mess)  
 | 	 	 	 	 endfor | *  MCR  
 	 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 	 calculate.amount.in.home.currency.variables(var.cisli205.stai, 	 	 	  
 	 	 	 	 	 tdcms201.ccur, 	 	 	 	 	  
 	 	 	 	 	 tmp.mc.tdcms201.rate(i),  
 	 	 	 	 	 tmp.mc.tdcms201.ratf(i),  
 	 	 	 	 	 i,  
 	 	 	 	 	 var.cisli205.stah(i), 	 	 	 	 	 	 	  
 	 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 	 endfor 	 	 	 	 	 	  
 | *  MCR -  new changes .e  
 	 	 	 else  
 	 	 	 	 | *  MCR -  s  
 	 	 	 	 |var.cisli205.stah =  0.0  
 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 var.cisli205.stah(i) =  0.0  
 	 	 	 	 endfor  
 	 	 	 	 | *  MCR -  e 	  
 	 	 	 endif  
 	 	 	 endif  
 	 	 	 | *  MCR -  s  
 	 	 	 |var.cisli205.csai =  var.cisli205.csai +  ( -  tdcms050.cmam)  
 	 	 	 for i =  1 to 3  
 	 	 	 	 var.cisli205.csai =  var.cisli205.csai +  ( -  fill.mc.field.double(tdcms050.cmam,i,0.000001)) 	  
 	 	 	 endfor 	  
 	 	 	 | *  MCR -  e  
 	 	 	 no.of.records =  no.of.records +  1  
 	 	 	 	 	 	 	 	 | #  ravi_array.sn  
 	 	 	 convert.cisli295.txai()  
 	 	 	 	 	 	 	 	 | #  210859.so  
 | 	 	 	 	 get.tax.by.country.code( tdcms201.ccty, |ravi_july28th.sn  
 | 	 	 	 	 	 tdcms201.cvat,  
 | 	 	 	 	 	 new.txct,  
 | 	 	 	 	 	 new.txid,  
 | 	 	 	 	 	 err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 	 	 	 	 	 | #  210859.sn  
 	 	 	 	 get.tax.by.country.code.and.financial.company(  
 	 	 	 	 	 tdcms201.ccty,  
 	 	 	 	 	 tdcms201.cvat,  
 	 	 	 	 	 var.compnr,  
 	 	 	 	 	 new.txct,  
 	 	 	 	 	 new.txid,  
 	 	 	 	 	 err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.en  
 	 	 	 	 if not isspace (new.txct) then 	 	 	 	  
 	 	 	 	 	 read.tcmcs032 (new.txct,new.txid,tdcms050.invd)  
 	 	 	 	 	 read.tcmcs036 (new.txct, new.txid) 	  
 	 	 	 	 endif 	 	 	 	 	 	  
 	 	 	 	 get.tax.percentage (new.txct, new.txid, var.compnr, 	  
 	 	 	 	 	 	 tdcms050.invd, var.singular.tax, var.cisli209.pvat)  
 	 	 	 	 get.tax.code.details (new.txct, new.txid, tdcms050.cmdt)  
 	 	 	 	 	 	 	 	 	 |ravi_july28th.en  
 | 	 	 	 update.tax.amounts.array(new.txid, 	 | #  207750.so  
 | 	 	 	 	 	 var.cisli295.txai, var.cisli295.amti) 	  
 	 	 	 	 	 	 	 	 | #  207750.eo  
 	 	 	 	 	 	 	 	 | #  ravi_array.en  
 	 	 	 	 	 	 	 |ravi_july28th.sn  
 	 	 	 if update.tax.amounts.array(new.txid, 	 | #  207750.sn  
 	 	 	 	 	 var.cisli295.txai, var.cisli295.amti) then  
 	 	 	 	 	 	 	 	 | #  207750.en  
 	 	 	 	 update.row.in.cache.cisli209( 	 	 	  
 	 	 	 	 	 tdcms050.comp,  
 	 	 	 	 	 tdcms201.crtt,  
 	 	 	 	 	 tdcms201.crin,  
 	 	 	 	 	 tcmcs036.ctau.l,  
 	 	 	 	 	 var.cisli206.ceno,  
 	 	 	 	 	 var.cisli209.pvat,  
 	 	 	 	 	 var.cisli295.txai,  
 	 	 	 	 	 var.cisli295.amti,  
 	 	 	 	 	 var.cisli206.rcod,  
 	 	 	 	 	 tdcms201.ccur,  
 	 	 	 	 	 tdcms050.invd,  
 	 	 	 	 	 var.cisli.rtyp,  
 	 	 	 	 	 |tdcms201.rate, | MCR -  o 	  
 	 	 	 	 	 |tdcms201.ratf) |MCR -  o 	  
 	 	 	 	 	 tmp.mc.tdcms201.rate, | MCR -  n  
 	 	 	 	 	 tmp.mc.tdcms201.ratf) | MCR -  n  
 	 	 	 	 	 	 |ravi_july28th.en  
 	 	 	 	 	 cisli209.dumped =  true 	 | #  207750.sn  
 	 	 	 else  
 	 	 	 	 	 cisli209.dumped =  false  
 	 	 	 endif 	 	 	 	 	 | #  207750.en 	 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 	 	 	  
 	 	 endselect  
 	 	 	 	 	 	 	 | #  ravi_array.sn  
 	 	 dump.fields.cisli206.from.array( 	 	  
 	 	 	 	 tdcms050.comp,  
 	 	 	 	 tdcms201.crtt,  
 	 	 	 	 tdcms201.crin,  
 	 	 	 	 new.txct,  
 	 	 	 	 |tdcms201.rate, | MCR -  o 	  
 	 	 	 	 |tdcms201.ratf) |MCR -  o 	  
 	 	 	 	 tmp.mc.tdcms201.rate, | MCR -  n  
 	 	 	 	 tmp.mc.tdcms201.ratf, | MCR -  n  
 	 	 	 	 tdcms201.ccur,  
 	 	 	 	 var.fin.comp.country,  
 	 	 	 	 var.cisli206.stcy,  
 	 	 	 	 var.fin.comp.country,  
 	 	 	 	 var.cisli206.itcy,  
 	 	 	 	 var.cisli206.ceno,  
 	 	 	 	 var.cisli206.rcod)  
 	 	 	 	 	 	 	 | #  ravi_array.en  
 	 	 	 	 	 	 	 | #  ravi_cisli209.sn  
 	 	 dump.records.from.cache.cisli209() 	 	  
 	 	 	 	 	 	 	 | #  ravi_cisli209.sn  
 | 	 	 restore.pointer.tdcms050 () 	 	 	 	 |binda25 -  06.o  
 	 	 if tdcms050.cmst =  tdcms.cmst.closed then  
 	 	 	 var.cisli205.stat =  6  
 	 	 	 var.cisli205.brid =  1  
 	 	 else  
 	 	 	 if tdcms050.cmst =  tdcms.cmst.ready then  
 	 	 	 	 var.cisli205.stat =  5  
 	 	 	 	 var.cisli205.brid =  2  
 	 	 	 endif 	 	  
 	 	 endif  
 	 	 get.crnd (tdcms201.ccur)  
 	 	 fill.lps.cisli205.rebates ()  
 	 	  
 	 	 itccom0016.calculate.discount.dates (tdcms201.crdt ,  
 	 	 	 	 tdcms010.cpay, var.cisli205.d1dt, var.cisli205.d2dt,  
 	 	 	 	 var.cisli205.d3dt)  
 	 	 itfcmg0007.calculate.discount (tdcms010.cpay, var.net.amti +  var.cisli205.txai, var.cisli205.txai,  
 	 	 	 	 	 	 tdcms201.ccur, tcmcs002.crnd,  
 	 	 	 	 	 	 var.cisli205.d1ai, var.cisli205.d2ai,  
 	 	 	 	 	 	 var.cisli205.d3ai) 	 	  
 	 	 if var.cisli205.d1ai <>  0.0 then  
 | *  MCR -  new changes .s 	 	  
 | 	 	 	 for i =  1 to 3 | *  MCR  
 | 	 	 	 	 calculate.amount.in.other.currency (var.cisli205.d1ai,  
 | 	 	 	 	 	 	 | *  MCR -  s  
 | 	 	 	 	 	 	 |tdcms201.rate,  
 | 	 	 	 	 	 	 |tdcms201.ratf,  
 | 	 	 	 	 	 	 tmp.mc.tdcms201.rate(i), | MCR -  n  
 | 	 	 	 	 	 	 tmp.mc.tdcms201.ratf(i), | MCR -  n  
 | 	 	 	 	 	 	 | *  MCR -  e  
 | 	 	 	 	 	 	 tdcms201.ccur,  
 | 	 	 	 	 	 	 |var.cisli205.d1ah,  
 | 	 	 	 	 	 	 var.cisli205.d1ah(i), | *  MCR  
 | 	 	 	 	 	 	 err.mess)  
 | 	 	 	 endfor | *  MCR  
 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 calculate.amount.in.home.currency.variables(var.cisli205.d1ai, 	 	 	  
 	 	 	 	 tdcms201.ccur, 	 	 	 	 	  
 	 	 	 	 tmp.mc.tdcms201.rate(i),  
 	 	 	 	 tmp.mc.tdcms201.ratf(i),  
 	 	 	 	 i,  
 	 	 	 	 var.cisli205.d1ah(i), 	 	 	 	 	 	 	  
 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 endfor 	 	 	 	 	 	  
 | *  MCR -  new changes .e  
 	 	 else  
 	 	 	 | *  MCR -  s  
 	 	 	 |var.cisli205.d1ah =  0.0  
 	 	 	 for i =  1 to 3  
 	 	 	 	 var.cisli205.d1ah(i) =  0.0  
 	 	 	 endfor  
 	 	 	 | *  MCR -  e  
 	 	 endif  
 	 	 if var.cisli205.d2ai <>  0.0 then  
 | *  MCR -  new changes .s 	 	  
 | 	 	 	 for i =  1 to 3 | *  MCR  
 | 	 	 	 	 calculate.amount.in.other.currency (var.cisli205.d2ai,  
 | 	 	 	 	 	 	 | *  MCR -  s  
 | 	 	 	 	 	 	 |tdcms201.rate,  
 | 	 	 	 	 	 	 |tdcms201.ratf,  
 | 	 	 	 	 	 	 tmp.mc.tdcms201.rate(i), | MCR -  n  
 | 	 	 	 	 	 	 tmp.mc.tdcms201.ratf(i), | MCR -  n  
 | 	 	 	 	 	 	 | *  MCR -  e  
 | 	 	 	 	 	 	 tdcms201.ccur,  
 | 	 	 	 	 	 	 |var.cisli205.d2ah,  
 | 	 	 	 	 	 	 var.cisli205.d2ah(i), | *  MCR  
 | 	 	 	 	 	 	 err.mess)  
 | 	 	 	 endfor | *  MCR  
 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 calculate.amount.in.home.currency.variables(var.cisli205.d2ai, 	 	 	  
 	 	 	 	 tdcms201.ccur, 	 	 	 	 	  
 	 	 	 	 tmp.mc.tdcms201.rate(i),  
 	 	 	 	 tmp.mc.tdcms201.ratf(i),  
 	 	 	 	 i,  
 	 	 	 	 var.cisli205.d2ah(i), 	 	 	 	 	 	 	  
 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 endfor 	 	 	 	 	 	  
 | *  MCR -  new changes .e 	 	 	  
 	 	 else  
 	 	 	 | *  MCR -  s  
 	 	 	 |var.cisli205.d2ah =  0.0  
 	 	 	 for i =  1 to 3  
 	 	 	 	 var.cisli205.d2ah(i) =  0.0  
 	 	 	 endfor  
 	 	 	 | *  MCR -  e 	  
 	 	 endif  
 	 	 if var.cisli205.d3ai <>  0.0 then  
 | *  MCR -  new changes .s 	 	  
 | 	 	 	 for i =  1 to 3 | *  MCR  
 | 	 	 	 	 calculate.amount.in.other.currency (var.cisli205.d3ai,  
 | 	 	 	 	 	 	 | *  MCR -  s  
 | 	 	 	 	 	 	 |tdcms201.rate,  
 | 	 	 	 	 	 	 |tdcms201.ratf,  
 | 	 	 	 	 	 	 tmp.mc.tdcms201.rate(i), | MCR -  n  
 | 	 	 	 	 	 	 tmp.mc.tdcms201.ratf(i), | MCR -  n  
 | 	 	 	 	 	 	 | *  MCR -  e  
 | 	 	 	 	 	 	 tdcms201.ccur,  
 | 	 	 	 	 	 	 |var.cisli205.d3ah,  
 | 	 	 	 	 	 	 var.cisli205.d3ah(i),  
 | 	 	 	 	 	 	 err.mess)  
 | 	 	 	 endfor | *  MCR  
 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 calculate.amount.in.home.currency.variables(var.cisli205.d3ai, 	 	 	  
 	 	 	 	 tdcms201.ccur, 	 	 	 	 	  
 	 	 	 	 tmp.mc.tdcms201.rate(i),  
 	 	 	 	 tmp.mc.tdcms201.ratf(i),  
 	 	 	 	 i,  
 	 	 	 	 var.cisli205.d3ah(i), 	 	 	 	 	 	 	  
 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 endfor 	 	 	 	 	 	  
 | *  MCR -  new changes .e 	 	 	  
 	 	 else  
 	 	 	 | *  MCR -  s  
 	 	 	 |var.cisli205.d3ah =  0.0  
 	 	 	 for i =  1 to 3  
 	 	 	 	 var.cisli205.d3ah(i) =  0.0  
 	 	 	 endfor  
 	 	 	 | *  MCR -  e  
 	 	 endif  
 	 	 var.cisli205.amti =  var.net.amti +  var.cisli205.txai +  var.cisli205.scai  
 	 	 if var.cisli205.amti <>  0.0 then  
 | *  MCR -  new changes .s 	 	  
 | 	 	 	 for i =  1 to 3 | *  MCR  
 | 	 	 	 calculate.amount.in.other.currency (var.cisli205.amti,  
 | 	 	 	 	 	 	 | *  MCR -  s  
 | 	 	 	 	 	 	 |tdcms201.rate,  
 | 	 	 	 	 	 	 |tdcms201.ratf,  
 | 	 	 	 	 	 	 tmp.mc.tdcms201.rate(i), | MCR -  n  
 | 	 	 	 	 	 	 tmp.mc.tdcms201.ratf(i), | MCR -  n  
 | 	 	 	 	 	 	 | *  MCR -  e  
 | 	 	 	 	 	 	 tdcms201.ccur,  
 | 	 	 	 	 	 	 |var.cisli205.amth,  
 | 	 	 	 	 	 	 var.cisli205.amth(i), | *  MCR  
 | 	 	 	 	 	 	 err.mess)  
 | 	 	 	 endfor | *  MCR  
 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 calculate.amount.in.home.currency.variables(var.cisli205.amti, 	 	 	  
 	 	 	 	 tdcms201.ccur, 	 	 	 	 	  
 	 	 	 	 tmp.mc.tdcms201.rate(i),  
 	 	 	 	 tmp.mc.tdcms201.ratf(i),  
 	 	 	 	 i,  
 	 	 	 	 var.cisli205.amth(i), 	 	 	 	 	 	 	  
 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 endfor 	 	 	 	 	 	  
 | *  MCR -  new changes .e 	 	 	  
 	 	 else  
 	 	 	 | *  MCR -  s  
 	 	 	 |var.cisli205.amth =  0.0  
 	 	 	 for i =  1 to 3  
 	 	 	 	 var.cisli205.amth(i) =  0.0  
 	 	 	 endfor  
 	 	 	 | *  MCR -  e  
 	 	 endif  
 	  
 	 	 	  
 	 	 	 fill.cisli205.fields (tdcms050.comp,tdcms201.crtt, tdcms201.crin,  
 	 	 	 var.cisli205.brid,var.cisli205.stat,  
 	 	 	 var.cisli290.ofbp, var.cisli290.ofad, var.cisli290.cofc,  
 	 	 	 tdsls050.ccrs, tdcms010.cpay, new.txct,6,0,0,0,0,0,0, tdcms201.ccur,  
 	 	 	 tdcms201.crdt,var.cisli205.amti,  
 	 	 	 var.cisli205.amth, 	 	 	  
 	 	 	 var.cisli205.txai,  
 	 	 	 var.cisli205.txah, 	 	 	  
 	 	 	 var.cisli205.stai,  
 	 	 	 var.cisli205.stah, 	 	 	  
 	 	 	 |tdcms201.rate,  
 	 	 	 tmp.mc.tdcms201.rate, | *  MCR  
 	 	 	 |tdcms201.ratf,  
 	 	 	 tmp.mc.tdcms201.ratf, | *  MCR  
 	 	 	 var.cisli205.scdt,  
 	 	 	 var.cisli205.scai,  
 	 	 	 var.cisli205.scah, 	 	 	  
 	 	 	 0.0, var.cisli205.csai,0.0, var.cisli205.d1ai,  
 	 	 	 var.cisli205.d1ah, 	 	 	  
 	 	 	 var.cisli205.d1dt, var.cisli205.d2ai,  
 	 	 	 var.cisli205.d2ah, 	 	 	  
 	 	 	 var.cisli205.d2dt, var.cisli205.d3ai,  
 	 	 	 var.cisli205.d3ah, 	 	 	  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.so  
 | 	 	 	 var.cisli205.d3dt, var.cisli290.paym, no.of.records,0.0,var.cisli205.amti -  var.cisli205.txai)  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.eo  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.sn  
 	 	 	  
 | 	 	 	 var.cisli205.d3dt, var.cisli290.paym, no.of.records,0.0,var.cisli205.amti -  var.cisli205.txai,target(cisli.doct.credit)) | #  jyosh.o  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en  
 	 	 	 var.cisli205.d3dt, var.cisli290.paym, no.of.records,0.0,var.cisli205.amti -  var.cisli205.txai,target(cisli.doct.credit),"") | #  jyosh.n 	 	 	 	 	 	 	 	 	 	 	  
 	 	 	  
 	 	 	 dump.cisli205 ()  
 	 	 	 reset.variables.cisli205 ()  
 	 	  
 	 endif  
 	 cisli209.dumped =  true 	 	 	 |ravi_cisli209.n  
 	 if (total.records >=  20000 and 	 	 	 |haddock.err.sn  
 	 	 tppin190.accessed and 	  
 	 	 cisli209.dumped ) then  
 	 	 	 reinitialize.cache()  
 	 endif 	 	 	 	 	 	 |haddock.err.en  
 	 free.memories() 	 	 	 	 |ravi_array.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:td
:SCMOD:cms
:SFLNO:050
:ICOD:S
:QURY:START
select 	 tdcms050.*  ,tdcms010.*  ,tdcms201.*
from tdcms050, tdcms010, tdcms201
where tdcms050.type =  tdcms.type.rebate  
 and 	 tdcms050.crin <>  0  
 and 	 tdcms050.crtt <>  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
 and 	 (tdcms050.cmst =  tdcms.cmst.closed or 	  
 	 tdcms050.cmst =  tdcms.cmst.ready)  
 and 	 tdcms010._index1 =  {tdcms050.reln}  
 and 	 tdcms201._index1 =  {tdcms050.crtt, tdcms050.crin}
order by tdcms050._index5
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:td
:SCMOD:cms
:SFLNO:050
:ICOD:X
:QURY:START
rebate.invoice =  0  
 temp.scai =  0  
 order.count =  0  
 free.mem ( rebates.array )  
 reset.variables.cisli205 ()  
 prev.tran =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
 prev.invn =  0  
 | dump.cisli206 () 	 	 	 | #  ravi_array.so  
 | delete.bcsci002.records.cisli206 ()  
 | dump.cisli209 ()  
 | delete.bcsci002.records.cisli209 () 	 | #  ravi_array.eo
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:td
:SCMOD:sls
:SFLNO:045
:ICOD:D
:QURY:START
initialize.variables ()  
 | 	 store.index.fields.sales.orders () 	 	 	 	 |binda25 -  06.o  
 	 initialize.cisli206.variables ()  
 	 	 	 	 	 	 	 	 	 |binda24 -  07.so  
 | 	 order.count =  order.count +  1  
 | 	 alloc.mem (slsorder.array,6,order.count)  
 | 	 if slsorder.array (1, order.count) =  0 then  
 | 	 	 slsorder.array (1, order.count) =  tdsls045.orno  
 | 	 endif  
 	  
 | 	 header.dumped =  false  
 | 	 for counter1 =  1 to order.count -  1  
 | 	 	 if tdsls045.orno =  slsorder.array (1, counter1) then  
 | 	 	 	 header.dumped =  true  
 | 	 	 	 break  
 | 	 	 endif  
 | 	 endfor  
 	 	 	 	 	 	 	 	 	 |binda2407.eo  
 	 	 	 	 	 	 	 	 	 	 |binda24 -  07.sn  
 	 	 header.dumped =  false  
 	 	 if order.count >  0 and tdsls045.orno =  slsorder.array(order.count) then  
 	 	 	 | record is found  
 	 	 	 header.dumped =  true  
 	 	 else  
 	 	 	 |WR PERF search record  
 	 	 	 if order.count >  0 then  
 	 	 	 	 ret =  0  
 	 	 	 	 if tdsls045.orno >  slsorder.array(order.count) or |new value larger than last value in array  
 	 	 	 	 tdsls045.orno <  slsorder.array(1) then |new value smaller than first value in array  
 	 	 	 	 	 | not found  
 	 	 	 	 else  
 	 	 	 	 	 | do a binary search  
 	 	 	 	 	  
 	 	 	 	 	 ret =  qss.search(QSS.SRC.IS.SORTED +  QSS.EQUAL,  
 	 	 	 	 	 tdsls045.orno,slsorder.array,sort_def,order.count)  
 	 	 	 	 	  
 	 	 	 	 endif  
 	 	 	 endif  
 	 	  
 	 	 	 |WR PERF insert record  
 	 	 	 if ret >  0 then  
 	 	 	 	 | record is found, do not insert again  
 	 	 	 	 header.dumped =  true  
 	 	 	 else  
 	 	 	 	 order.count =  order.count +  1  
 	  
 	 	 	 	 if order.count >  array.length then 	 	 |WR PERF allocate memory per 1000 records  
 	 	 	 	 	  
 	 	 	 	 	 array.length =  array.length +  1000  
 	 	 	 	 	 alloc.mem (slsorder.array,array.length)  
 	 	 	 	 	  
 	 	 	 	 endif  
 	 	 	 	 |insert orno  
 	 	 	 	 slsorder.array(order.count) =  tdsls045.orno  
 	 	 	  
 	 	 	 	 |sort array only if last inserted record is smaller than the previous  
 	 	 	 	 if order.count >  1 and slsorder.array(order.count) <  slsorder.array(order.count -  1) then  
 	 	 	 	 	  
 	 	 	 	 	 qss.sort(slsorder.array,sort_def,order.count)  
 	 	 	 	 	  
 	 	 	 	 endif  
 	 	  
 	 	 	 endif  
 	 	 endif  
 	 	 |WR PERF end  
 	 	 	 	 	 	 	 	 	 	 |binda24 -  07.en  
 	 read.sales.order.header.data ()  
 	 get.customer.data ()  
 	 var.cisli205.bpid =  convert.business.partner ()  
 	 var.cisli205.cadr =  convert.address ()  
 	 	 	 	 	 	 	 | #  200284.sn  
 	 if not valid.installments.present () then  
 	 log.error(sprintf$("Record Skipped:Sales-order %s/%d/%d not migrated because installment line missing in tdsls048",tdsls045.orno,tdsls045.pono,tdsls045.srnb))  
 	 continue  
 	 endif  
 	 	 	 	 	 	 	 | #  200284.en  
 	  
 	 if header.dumped =  false then  
 	 	  
 	 	 dump.cisli240 () 	  
 	 endif  
 	 var.cisli245.chtp =  convert.cisli245.chtp ()  
 	 | *  MCR -  s  
 	 for i =  1 to 3  
 	 	 tmp.mc.tdsls045.rats(i) =  fill.mc.field.double(tdsls045.rats,i,0.000001)  
 	 	 tmp.mc.tdsls045.ratf(i) =  fill.mc.field.long(tdsls045.ratf,i,1)  
 	 	 tmp.mc.tdsls040.rats(i) =  fill.mc.field.double(tdsls040.rats,i,0.000001)  
 	 	 tmp.mc.tdsls040.ratf(i) =  fill.mc.field.long(tdsls040.ratf,i,1) 	  
 	 endfor  
 	 | *  MCR -  e  
 	  
 	 if tdsls045.amnt <>  0.0 then  
 | *  MCR -  new changes .s 	  
 | 	 	 for i =  1 to 3 | *  MCR .n  
 | 	 	 	 calculate.amount.in.other.currency (tdsls045.amnt,  
 | 	 	 	 	 |tdsls045.rats, tdsls045.ratf, | *  MCR .o  
 | 	 	 	 	 tmp.mc.tdsls045.rats(i), | *  MCR .n  
 | 	 	 	 	 tmp.mc.tdsls045.ratf(i), | *  MCR .n  
 | 	 	 	 	 tdsls040.ccur,  
 | 	 	 	 	 |var.cisli245.amth, | *  MCR .o  
 | 	 	 	 	 var.cisli245.amth(i), | *  MCR .n  
 | 	 	 	 	 err.mess) 	  
 | 	 	 endfor 	 | *  MCR .n 	 	  
 	 	 for i =  1 to 3 	 	 	 	 	 	  
 | 	 	 	 calculate.amount.in.home.currency.variables(tdsls045.amnt, 	 	 	 | #  200 -  101916.o 	 	  
 	 	 	 calculate.amount.in.home.currency.variables(tdsls045.amnt +  tdsls045.ldam, 	 | #  200 -  101916.n  
 	 	 	 tdsls040.ccur, 	 	 	 	 	  
 	 	 	 tmp.mc.tdsls045.rats(i),  
 	 	 	 tmp.mc.tdsls045.ratf(i),  
 	 	 	 i,  
 	 	 	 var.cisli245.amth(i), 	 	 	 	 	 	 	  
 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 endfor 	 	 	 	 	 	  
 | *  MCR -  new changes .e 	  
 	 else  
 	 	 | *  MCR .s  
 	 	 |var.cisli245.amth =  0.0  
 	 	 for i =  1 to 3  
 	 	 	 var.cisli245.amth(i) =  0.0  
 	 	 endfor  
 	 	 | *  MCR .e  
 	 endif 	  
 	 calculate.tax.amounts () 	 	 	 	 	 	 	  
 	 if (prev.tran1 <>  tdsls045.ttyp or 	 	 	 | #  ravi_array.sn  
 	 	 	 prev.invn1 <>  tdsls045.invn) then 	  
 	 	 prev.tran1 =  tdsls045.ttyp  
 	 	 prev.invn1 =  tdsls045.invn  
 	 	 prev.ncmp1 =  var.compnr 	  
 	 	 allocate.memories(new.txct) 	 	  
 	 endif 	 	 	 	 	 	 	 | #  ravi_array.en  
 	 	 	 	 	 	 	 	 | #  800 -  141306.so 	 	 	  
 | 	 if not dump.cisli245 () then  
 | 	 	 continue  
 | 	 endif  
 	 	 	 	 	 	 	 	 | #  800 -  141306.eo  
 	  
 	 dump.cisli245() 	 	 	 	 	 	 | #  800 -  141306.n  
 	 cisli209.dumped =  false 	 	 |ravi_cisli209.n 	 	 	 	 	 	 	 	  
 	 get.financial.company.country (tdsls040.comp)  
 	 temp.addr =  convert.cisli245.stoa ()  
 	 var.cisli206.stcy =  bcstc004.ccty  
 	 temp.addr =  convert.address ()  
 	 var.cisli206.itcy =  bcstc004.ccty  
 	 temp.addr =  convert.cisli245.sfra () 	 	 	  
 	 warehouse.country =  bcstc004.ccty  
 | 	 update.fields.bcsci002.cisli206 (var.compnr, tdsls045.ttyp , 	 	 | #  ravi_array.so  
 | 	 	 tdsls045.invn, new.txct, new.txid,  
 | 	 	 var.cisli245.txai, var.cisli245.amti,  
 | 	 	 tdsls045.rats, tdsls045.ratf, tdsls040.ccur,  
 | 	 	 warehouse.country, var.cisli206.stcy,  
 | 	 	 var.fin.comp.country, var.cisli206.itcy,"", "")                                |#                                                                                                                                                                                                                                                                                                                                         ravi_array.eo                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
 | 	 if not isspace (new.txct) then 	 	 |ravi_july28th.so  
 | 	 	 read.tcmcs032 (new.txct, new.txid,tdsls045.invd)  
 | 	 	 read.tcmcs036 (new.txct, new.txid) 	  
 | 	 endif 	 	 	 	 	  
 | 	 get.tax.code.details (new.txct, new.txid, tdsls045.invd) |ravi_july28th.eo  
 | 	 if not isspace (tdsls041.cuno) then 	 	 	 	 	 | #  ravi_array.so  
 | 	 	 read.tcmcs142 (tdsls041.cuno, tcmcs036.ctau.l, tdsls045.invd)  
 | 	 endif 	 	 	 	 	 	 	 	 	 | #  ravi_array.eo  
 | 	 get.tax.percentage (new.txct, new.txid, var.compnr, 	 |ravi_july28th.so  
 | 	 	 	 	 	 tdsls045.invd, var.singular.tax, var.cisli209.pvat)  
 	 	 	 	 	 	 	 	 |ravi_july28th.so  
 | 	 update.fields.bcsci002.cisli209 (var.cisli245.txai, 	 	 	 	 | #  ravi_cisli209.so  
 | 	 	 	 tdsls040.ccur,  
 | 	 	 	 tdsls045.invd,  
 | 	 	 	 var.cisli.rtyp,  
 | 	 	 	 tdsls045.rats, 	 	  
 | 	 	 	 tdsls045.ratf, 	  
 | 	 	 	 var.cisli209.pvat,  
 | 	 	 	 tcmcs036.ctau.l,  
 | 	 	 	 tdsls045.ttyp,  
 | 	 	 	 tdsls045.invn,  
 | 	 	 	 1,  
 | 	 	 	 tdsls040.comp,  
 | 	 	 	 tcmcs142.reas,  
 | 	 	 	 tcmcs142.exno,  
 | 	 	 	 var.cisli245.amti) 	 	 	 	 	 | #  ravi_cisli209.eo  
 	 	 	 	 	 	 	 |ravi_cisli209.sn  
 	 	 	 	 	 	 |ravi_july28th.so  
 | 	 	 	 	 update.row.in.cache.cisli209( 	  
 | 	 	 	 	 	 tdsls040.comp,  
 | 	 	 	 	 	 tdsls045.ttyp,  
 | 	 	 	 	 	 tdsls045.invn,  
 | 	 	 	 	 	 tcmcs036.ctau.l,  
 | 	 	 	 	 	 var.cisli206.ceno,  
 | 	 	 	 	 	 var.cisli209.pvat,  
 | 	 	 	 	 	 var.cisli245.txai,  
 | 	 	 	 	 	 var.cisli245.amti,  
 | 	 	 	 	 	 var.cisli206.rcod,  
 | 	 	 	 	 	 tdsls040.ccur,  
 | 	 	 	 	 	 tdsls045.invd,  
 | 	 	 	 	 	 var.cisli.rtyp,  
 | 	 	 	 	 	 |tdsls045.rats, | *  MCR .o 	  
 | 	 	 	 	 	 |tdsls045.ratf) | *  MCR .o 	  
 | 	 	 	 	 	 tmp.mc.tdsls045.rats, | *  MCR .n  
 | 	 	 	 	 	 tmp.mc.tdsls045.ratf) | *  MCR .n  
 	 	 	 	 	 	 	 |ravi_july28th.eo  
 	 	 	 	 	 	 	 |ravi_cisli209.en  
 	 	  
 	 if not installment.or.proforma.invoice () then  
 	 	 dump.cisli246 ()  
 	 endif  
 	 if (hold.ttyp <>  tdsls045.ttyp or hold.invn <>  tdsls045.invn) then  
 	 	 hold.ttyp =  tdsls045.ttyp  
 	 	 hold.invn =  tdsls045.invn  
 	 	 no.of.records =  0  
 	  
 	 	 	 	 	 	 	 | #  800 -  141306.sn  
 	 	 var.cisli205.txai =  0  
 	 	 var.cisli205.stai =  0  
 	 	 var.cisli205.csai =  0  
 	 	 var.net.amti =  0  
 	 	 	 	 	 	 	 | #  800 -  141306.en  
 	 	 select 	 tdsls045.*  , tdsls041.*  ,  
 	 	 tiitm001.kitm, tiitm001.itmt  
 	 	 from tdsls045, tdsls041, tiitm001  
 	 	 where tdsls045.invn =  :hold.invn  
 	 	 and 	 tdsls045.ttyp =  :hold.ttyp  
 	 	 and 	 tdsls045.cmba refers to tdsls041  
 	 	 and 	 tdsls045.item refers to tiitm001  
 	 	 order by tdsls045._index5  
 	 	  
 	 	 selectdo  
 	 	 	 	 	 	 	 	 	 | #  800 -  141306.sn  
 	 	 	 calculate.tax.amounts()  
 	 	 	 | *  MCR .s 	 	 	 	 	  
 	 	 	 | var.net.amti =  var.net.amti +  ( -  tdcms050.cmam)  
 	 	 	 	 	 	 	 	 | #  200 -  102419.so 	  
 | 	 	 	 for i =  1 to 3  
 | 	 	 	 	 var.net.amti =  var.net.amti +  ( -  fill.mc.field.double(tdcms050.cmam,i,0.00001)) 	 | #  200 -  101244.o  
 | 	 	 	 	 var.net.amti =  var.net.amti +  ( -  fill.mc.field.double(tdsls045.amnt,i,0.00001)) 	 | #  200 -  101244.n  
 | 	 	 	 endfor  
 	 	 	 	 	 	 	 	 | #  200 -  102419.eo  
 	 	 	 	 	 	 	 	 | #  200 -  102419.sn  
 	 	 	 var.net.amti =  var.net.amti +  tdsls045.amnt  
 	 	 	 	 	 	 	 	 | #  200 -  102419.en  
 	 	 	 | *  MCR .e  
 	 	 	 var.cisli205.txai =  var.cisli205.txai +  var.cisli245.txai  
 	 	 	 if not isspace (new.txct) then 	 	 	 	  
 	 	 	 	 read.tcmcs036 (new.txct, new.txid)  
 	 	 	 endif 	 	 	 	 	 	  
 	 	 	 if tcmcs036.tvat =  tctvat.shifted then  
 	 	 	 var.cisli205.stai =  var.cisli205.stai +  var.cisli245.txai  
 	 	 	 if var.cisli205.stai <>  0.0 then  
 | *  MCR -  new changes .s 	 	 	  
 | 	 	 	 	 for i =  1 to 3 | *  MCR .n  
 | 	 	 	 	 	 calculate.amount.in.other.currency (var.cisli205.stai,  
 | 	 	 	 	 	 |tdsls045.rats,tdsls045.ratf,  
 | 	 	 	 	 	 tmp.mc.tdsls045.rats(i), | *  MCR .n  
 | 	 	 	 	 	 tmp.mc.tdsls045.ratf(i), | *  MCR .n  
 | 	 	 	 	 	 tdsls040.ccur,  
 | 	 	 	 	 	 |var.cisli205.stah,  
 | 	 	 	 	 	 var.cisli205.stah(i), | *  MCR  
 | 	 	 	 	 	 err.mess)  
 | 	 	 	 	 endfor | *  MCR .n  
 	 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 	 calculate.amount.in.home.currency.variables(var.cisli205.stai, 	 	 	  
 	 	 	 	 	 tdsls040.ccur, 	 	 	 	 	  
 	 	 	 	 	 tmp.mc.tdsls045.rats(i),  
 	 	 	 	 	 tmp.mc.tdsls045.ratf(i),  
 	 	 	 	 	 i,  
 	 	 	 	 	 var.cisli205.stah(i), 	 	 	 	 	 	 	  
 	 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 	 endfor 	 	  
 | *  MCR -  new changes .e 	 	 	 	  
 	 	 	 else  
 	 	 	 	 | *  MCR .s  
 	 	 	 	 |var.cisli205.stah =  0.0  
 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 var.cisli205.stah(i) =  0.0  
 	 	 	 	 endfor  
 	 	 	 	 | *  MCR .e  
 	 	 	 	  
 	 	 	 endif  
 	 	 	 endif  
 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 	 | #  800 -  141306.en  
 	 	 	 no.of.records =  no.of.records +  1  
 	  
 	 	 	 on case convert.cisli245.chtp ()  
 	 	 	 case 1 :  
 	 	 	 	 var.cisli205.gdai =  var.cisli205.gdai +  tdsls045.amnt  
 	 	 	 	 break  
 	 	 	 case 2 :  
 	 	 	 	 var.cisli205.csai =  var.cisli205.csai +  tdsls045.amnt  
 	 	 	 	 break  
 	 	 	 case 3 :  
 	 	 	 	 var.cisli205.rmai =  var.cisli205.rmai +  tdsls045.amnt  
 	 	 	 	 break  
 	 	 	 default :  
 	 	 	 	 var.cisli205.rmai =  var.cisli205.rmai +  tdsls045.amnt  
 	 	 	 	 break  
 	 	 	 endcase  
 	 	 	 var.cisli205.dcai =  var.cisli205.dcai +  tdsls045.odam +  tdsls045.ldam  
 	 	 	 	 	 	 	 	 	 | #  ravi_array.sn  
 	 	 	 calculate.tax.amounts() 	  
 	 	 	 	 	 	 	 	 	 | #  207750.so  
 | 	 	 	 update.tax.amounts.array(new.txid, 	  
 | 	 	 	 	 	 var.cisli245.txai, var.cisli245.amti) 	  
 	 	 	 	 	 	 	 	 	 | #  ravi_array.en  
 	 	 	 	 	 	 	 	 	 | #  207750.eo  
 	 	 	 	 	 	 	 	 |ravi_july28th.sn  
 	 	 	 	 if not isspace (new.txct) then 	 	  
 	 	 	 	 	 read.tcmcs032 (new.txct, new.txid,tdsls045.invd)  
 	 	 	 	 	 read.tcmcs036 (new.txct, new.txid) 	  
 	 	 	 	 endif 	  
 	 	 	 	 get.tax.code.details (new.txct, new.txid, tdsls045.invd)  
 	 	 	 	 get.tax.percentage (new.txct, new.txid, var.compnr, 	  
 	 	 	 	 	 	 tdsls045.invd, var.singular.tax, var.cisli209.pvat)  
 	 	 	 	 	 	 	 	 | #  207750.sn  
 	 	 	 if update.tax.amounts.array(new.txid, 	  
 	 	 	 	 	 var.cisli245.txai, var.cisli245.amti) then  
 	 	 	 	 	 	 	 	 | #  207750.en  
 	 	 	 	 	  
 	 	 	 	 update.row.in.cache.cisli209( 	  
 	 	 	 	 	 tdsls040.comp,  
 	 	 	 	 	 tdsls045.ttyp,  
 	 	 	 	 	 tdsls045.invn,  
 	 	 	 	 	 tcmcs036.ctau.l,  
 	 	 	 	 	 var.cisli206.ceno,  
 	 	 	 	 	 var.cisli209.pvat,  
 	 	 	 	 	 var.cisli245.txai,  
 	 	 	 	 	 var.cisli245.amti,  
 	 	 	 	 	 var.cisli206.rcod,  
 	 	 	 	 	 tdsls040.ccur,  
 	 	 	 	 	 tdsls045.invd,  
 	 	 	 	 	 var.cisli.rtyp,  
 	 	 	 	 	 |tdsls045.rats, | *  MCR .o 	  
 	 	 	 	 	 |tdsls045.ratf) | *  MCR .o 	  
 	 	 	 	 	 tmp.mc.tdsls045.rats, | *  MCR .n  
 	 	 	 	 	 tmp.mc.tdsls045.ratf) | *  MCR .n  
 	 	 	 	 	 	 	 	 |ravi_july28th.en  
 	 	 	 	 	 cisli209.dumped =  true 	 | #  207750.sn  
 	 	 	 else  
 	 	 	 	 	 cisli209.dumped =  false  
 	 	 	 endif 	 	 	 	 	 | #  207750.en  
 	 	 	 	 	 	 	 	 	  
 	 	 endselect  
 	 	 	 	 	 	 	 | #  ravi_array.sn  
 	 	 	 dump.fields.cisli206.from.array( 	  
 	 	 	 	 	 tdsls040.comp,  
 	 	 	 	 	 tdsls045.ttyp,  
 	 	 	 	 	 tdsls045.invn,  
 	 	 	 	 	 new.txct,  
 	 	 	 	 	 |tdsls045.rats, 	  
 	 	 	 	 	 |tdsls045.ratf,  
 	 	 	 	 	 tmp.mc.tdsls045.rats, | *  MCR .n  
 	 	 	 	 	 tmp.mc.tdsls045.ratf, | *  MCR .n  
 	 	 	 	 	 tdsls040.ccur,  
 	 	 	 	 	 var.fin.comp.country,  
 	 	 	 	 	 var.cisli206.stcy,  
 	 	 	 	 	 var.fin.comp.country,  
 	 	 	 	 	 var.cisli206.itcy, var.cisli206.ceno,  
 	 	 	 	 	 var.cisli206.rcod)  
 	 	 	 	 	 	 	 	 | #  ravi_array.en  
 	 	 	 	 	 	 	 | #  ravi_cisli209.sn  
 	 	 	 dump.records.from.cache.cisli209() 	 	  
 	 	 	 	 	 	 	 | #  ravi_cisli209.sn  
 | 	 	 restore.pointer.tdsls045 () 	 	 	 	 	 |binda25 -  06.o  
 	 	 	 	 	 	 	 	 	 	 | #  800 -  141306.sn  
 	 	 if var.stat =  6 then  
 	 	 	 var.cisli205.stat =  6  
 	 	 	 var.cisli205.brid =  1  
 	 	 else  
 	 	 	 var.cisli205.stat =  5  
 	 	 	 var.cisli205.brid =  2  
 	 	 	  
 	 	 endif  
 	 	 get.crnd (tdsls040.ccur)  
 	 	 fill.lps.cisli205.salesorders ()  
 	 	  
 	 	 itccom0016.calculate.discount.dates (tdsls045.invd ,  
 	 	 	 	 tdsls040.cpay, var.cisli205.d1dt, var.cisli205.d2dt,  
 	 	 	 	 var.cisli205.d3dt)  
 	 	 itfcmg0007.calculate.discount (tdsls040.cpay, var.net.amti +  var.cisli205.txai, var.cisli205.txai,  
 	 	 	 	 	 	 tdsls040.ccur, tcmcs002.crnd,  
 	 	 	 	 	 	 var.cisli205.d1ai, var.cisli205.d2ai,  
 	 	 	 	 	 	 var.cisli205.d3ai) 	 	  
 	 	 if var.cisli205.d1ai <>  0.0 then  
 | *  MCR -  new changes .s 	 	  
 | 	 	 	 for i =  1 to 3 | *  MCR .n  
 | 	 	 	 	 calculate.amount.in.other.currency (var.cisli205.d1ai,  
 | 	 	 	 	 	 	 |tdsls045.rats,tdsls045.ratf,  
 | 	 	 	 	 	 	 tmp.mc.tdsls045.rats(i), | *  MCR .n  
 | 	 	 	 	 	 	 tmp.mc.tdsls045.ratf(i), | *  MCR .n  
 | 	 	 	 	 	 	 tdsls040.ccur,  
 | 	 	 	 	 	 	 |var.cisli205.d1ah,  
 | 	 	 	 	 	 	 var.cisli205.d1ah(i), | *  MCR  
 | 	 	 	 	 	 	 err.mess)  
 | 	 	 	 endfor | *  MCR .n  
 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 	 calculate.amount.in.home.currency.variables(var.cisli205.d1ai, 	 	 	  
 	 	 	 	 	 tdsls040.ccur, 	 	 	 	 	  
 	 	 	 	 	 tmp.mc.tdsls045.rats(i),  
 	 	 	 	 	 tmp.mc.tdsls045.ratf(i),  
 	 	 	 	 	 i,  
 	 	 	 	 	 var.cisli205.d1ah(i), 	 	 	 	 	 	 	  
 	 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 endfor 	 	  
 | *  MCR -  new changes .e 	 	 	 	 	  
 	 	 else  
 	 	 	 | *  MCR .s  
 	 	 	 |var.cisli205.d1ah =  0.0  
 	 	 	 for i =  1 to 3  
 	 	 	 	 var.cisli205.d1ah(i) =  0.0  
 	 	 	 endfor  
 	 	 	 | *  MCR .e  
 	 	 endif  
 	 	 if var.cisli205.d2ai <>  0.0 then  
 | *  MCR -  new changes .s 	 	  
 | 	 	 	 for i =  1 to 3 | *  MCR .n  
 | 	 	 	 	 calculate.amount.in.other.currency (var.cisli205.d2ai,  
 | 	 	 	 	 	 	 |tdsls045.rats,tdsls045.ratf,  
 | 	 	 	 	 	 	 tmp.mc.tdsls045.rats(i), | *  MCR .n  
 | 	 	 	 	 	 	 tmp.mc.tdsls045.ratf(i), | *  MCR .n  
 | 	 	 	 	 	 	 tdsls040.ccur,  
 | 	 	 	 	 	 	 |var.cisli205.d2ah,  
 | 	 	 	 	 	 	 var.cisli205.d2ah(i), | *  MCR  
 | 	 	 	 	 	 	 err.mess)  
 | 	 	 	 endfor | *  MCR 	 	 	  
 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 calculate.amount.in.home.currency.variables(var.cisli205.d2ai, 	 	 	  
 	 	 	 	 tdsls040.ccur, 	 	 	 	 	  
 	 	 	 	 tmp.mc.tdsls045.rats(i),  
 	 	 	 	 tmp.mc.tdsls045.ratf(i),  
 	 	 	 	 i,  
 	 	 	 	 var.cisli205.d2ah(i), 	 	 	 	 	 	 	  
 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 endfor 	 	  
 | *  MCR -  new changes .e 	 	 	 	  
 	 	 else  
 	 	 	 | *  MCR .s  
 	 	 	 |var.cisli205.d2ah =  0.0  
 	 	 	 for i =  1 to 3  
 	 	 	 	 var.cisli205.d2ah(i) =  0.0  
 	 	 	 endfor  
 	 	 	 | *  MCR .e  
 	 	 endif  
 	 	 if var.cisli205.d3ai <>  0.0 then  
 | *  MCR -  new changes .s 	 	  
 | 	 	 	 for i =  1 to 3 | *  MCR .n  
 | 	 	 	 	 calculate.amount.in.other.currency (var.cisli205.d3ai,  
 | 	 	 	 	 	 	 |tdsls045.rats,tdsls045.ratf,  
 | 	 	 	 	 	 	 tmp.mc.tdsls045.rats(i), | *  MCR .n  
 | 	 	 	 	 	 	 tmp.mc.tdsls045.ratf(i), | *  MCR .n  
 | 	 	 	 	 	 	 tdsls040.ccur,  
 | 	 	 	 	 	 	 |var.cisli205.d3ah,  
 | 	 	 	 	 	 	 var.cisli205.d3ah(i), | *  MCR  
 | 	 	 	 	 	 	 err.mess)  
 | 	 	 	 endfor | *  MCR .n 	  
 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 calculate.amount.in.home.currency.variables(var.cisli205.d3ai, 	 	 	  
 	 	 	 	 tdsls040.ccur, 	 	 	 	 	  
 	 	 	 	 tmp.mc.tdsls045.rats(i),  
 	 	 	 	 tmp.mc.tdsls045.ratf(i),  
 	 	 	 	 i,  
 	 	 	 	 var.cisli205.d3ah(i), 	 	 	 	 	 	 	  
 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 endfor 	 	  
 | *  MCR -  new changes .e 	 	 	 	 	 	  
 	 	 else  
 	 	 	 | *  MCR .s  
 	 	 	 |var.cisli205.d3ah =  0.0  
 	 	 	 for i =  1 to 3  
 	 	 	 	 var.cisli205.d3ah(i) =  0.0  
 	 	 	 endfor  
 	 	 	 | *  MCR .e  
 	 	 endif  
 	 	 var.cisli205.amti =  var.net.amti +  var.cisli205.txai +  var.cisli205.scai  
 	 	 if var.cisli205.amti <>  0.0 then  
 | *  MCR -  new changes .s 	 	  
 | 	 	 	 for i =  1 to 3 | *  MCR .n  
 | 	 	 	 	 calculate.amount.in.other.currency (var.cisli205.amti,  
 | 	 	 	 	 	 	 |tdsls045.rats,tdsls045.ratf,  
 | 	 	 	 	 	 	 tmp.mc.tdsls045.rats(i), | *  MCR .n  
 | 	 	 	 	 	 	 tmp.mc.tdsls045.ratf(i), | *  MCR .n  
 | 	 	 	 	 	 	 tdsls040.ccur,  
 | 	 	 	 	 	 	 |var.cisli205.amth,  
 | 	 	 	 	 	 	 var.cisli205.amth(i), | *  MCR  
 | 	 	 	 	 	 	 err.mess)  
 | 	 	 	 endfor | *  MCR 	  
 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 calculate.amount.in.home.currency.variables(var.cisli205.amti, 	 	 	  
 	 	 	 	 tdsls040.ccur, 	 	 	 	 	  
 	 	 	 	 tmp.mc.tdsls045.rats(i),  
 	 	 	 	 tmp.mc.tdsls045.ratf(i),  
 	 	 	 	 i,  
 	 	 	 	 var.cisli205.amth(i), 	 	 	 	 	 	 	  
 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 endfor 	 	  
 | *  MCR -  new changes .e 	 	 	  
 	 	 else  
 	 	 	 | *  MCR .s  
 	 	 	 |var.cisli205.amth =  0.0  
 	 	 	 for i =  1 to 3  
 	 	 	 	 var.cisli205.amth(i) =  0.0  
 	 	 	 endfor  
 	 	 	 | *  MCR .e  
 	 	 endif 	 	 	 	 	 	 	 	  
 	 	  
 	 	 if var.stat =  6 then 	  
 	 	 	 	 	 	 	 	 	 	 | #  800 -  141306.en 	 	 	 	 	 	  
 	 	 select tfacr200.*   
 	 	 from tfacr200  
 	 	 where tfacr200._index1 =  {:hold.ttyp, :hold.invn, 0}  
 | 	 	 and tfacr200.trec =  tfacr.trec.invoice 	 	 	 | #  200 -  101927.o  
 	 	  
 	 	 	 	 	 	 	 	 	 | #  200 -  101927.sn  
 	 	 and (tfacr200.trec =  tfacr.trec.invoice or 	  
 	 	 tfacr200.trec =  tfacr.trec.credit) 	 	 	 	  
 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.sn  
 	 	 	 if tfacr200.trec =  tfacr.trec.invoice then  
 	 	 	 	 var.tfacr200.trec =  target(cisli.doct.invoice)  
 	 	 	 else  
 	 	 	 	 var.tfacr200.trec =  target(cisli.doct.credit)  
 	 	 	 	 	 	 	 	 | #  148886.so  
 | 	 	 	 	 if var.cisli205.gdai >  0 then  
 | 	 	 	 	 	 var.cisli205.gdai = -  var.cisli205.gdai  
 | 	 	 	 	 endif  
 | 	 	 	 	 if var.cisli205.csai >  0 then  
 | 	 	 	 	 	 var.cisli205.csai = -  var.cisli205.csai  
 | 	 	 	 	 endif  
 | 	 	 	 	 if var.cisli205.rmai >  0 then  
 | 	 	 	 	 	 var.cisli205.rmai = -  var.cisli205.rmai  
 | 	 	 	 	 endif  
 | 	 	 	 	 if var.cisli205.dcai >  0 then  
 | 	 	 	 	 	 var.cisli205.dcai = -  var.cisli205.dcai  
 | 	 	 	 	 endif  
 	 	 	 	 	 	 	 	 | #  148886.eo  
 	 	 	 endif 	  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en  
 	 	 	 	 	 	 	 	 	 	 | *  MCR -  sn 	  
 	 	 	 for i =  1 to 3 	  
 	 	 	 	 tmp.mc.tfacr200.amth(i) =  fill.mc.field.double(tfacr200.amth,i)  
 	 	 	 	 tmp.mc.tfacr200.vath(i) =  fill.mc.field.double(tfacr200.vath,i)  
 	 	 	 	 tmp.mc.tfacr200.svah(i) =  fill.mc.field.double(tfacr200.svah,i)  
 	 	 	 	 tmp.mc.tfacr200.rate(i) =  fill.mc.field.double(tfacr200.rate,i)  
 	 	 	 	 tmp.mc.tfacr200.ratf(i) =  fill.mc.field.long(tfacr200.ratf,i)  
 	 	 	 	 tmp.mc.tfacr200.laph(i) =  fill.mc.field.double(tfacr200.laph,i)  
 	 	 	 	 tmp.mc.tfacr200.dc1h(i) =  fill.mc.field.double(tfacr200.dc1h,i)  
 	 	 	 	 tmp.mc.tfacr200.dc2h(i) =  fill.mc.field.double(tfacr200.dc2h,i)  
 	 	 	 	 tmp.mc.tfacr200.dc3h(i) =  fill.mc.field.double(tfacr200.dc3h,i)  
 	 	 	 endfor  
 	 	 	 | *  MCR -  en  
 	 	 	  
 	 	 	 fill.cisli205.fields (tdsls040.comp,tfacr200.ttyp, tfacr200.ninv,1,6,  
 	 	 	 var.cisli205.bpid, var.cisli205.cadr, convert.cisli245.cofc () ,  
 	 	 	 tfacr200.ccrs, tfacr200.cpay, new.txct,  
 	 	 	 |convert.cisli240.fcrt() , | *  MCR  
 	 	 	 convert.cisli240.fcrt(tdsls040.fcrt), | *  MCR  
 	 	 	 0,0,0,no.of.records,0,0, tdsls040.ccur,tfacr200.docd,  
 	 	 	 tfacr200.amti,  
 	 	 	 |tfacr200.amth,  
 	 	 	 tmp.mc.tfacr200.amth, | *  MCR  
 	 	 	 tfacr200.vati,  
 	 	 	 |tfacr200.vath,  
 	 	 	 tmp.mc.tfacr200.vath, | *  MCR  
 	 	 	 tfacr200.svam,  
 	 	 	 |tfacr200.svah,  
 	 	 	 |tfacr200.rate,  
 	 	 	 |tfacr200.ratf,  
 	 	 	 tmp.mc.tfacr200.svah, | *  MCR  
 	 	 	 tmp.mc.tfacr200.rate, | *  MCR  
 	 	 	 tmp.mc.tfacr200.ratf, | *  MCR  
 	 	 	 tfacr200.lpdt, tfacr200.lapa,  
 	 	 	 |tfacr200.laph,  
 	 	 	 tmp.mc.tfacr200.laph, | *  MCR  
 	 	 	 var.cisli205.gdai,var.cisli205.csai,  
 	 	 	 var.cisli205.rmai, tfacr200.dc1i,  
 	 	 	 |tfacr200.dc1h,  
 	 	 	 tmp.mc.tfacr200.dc1h, | *  MCR  
 	 	 	 tfacr200.did1, tfacr200.dc2i,  
 	 	 	 |tfacr200.dc2h,  
 	 	 	 tmp.mc.tfacr200.dc2h, | *  MCR  
 	 	 	 tfacr200.did2,tfacr200.dc3i,  
 	 	 	 |tfacr200.dc3h,  
 	 	 	 tmp.mc.tfacr200.dc3h, | *  MCR  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.so  
 | 	 	 	 tfacr200.did3, tfacr200.paym, 0,var.cisli205.dcai,tfacr200.amti -  tfacr200.vati)  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.eo  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.sn  
 | 	 	 	 tfacr200.did3, tfacr200.paym, 0,var.cisli205.dcai,tfacr200.amti -  tfacr200.vati,var.tfacr200.trec) | #  jyosh.o  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en  
 	 	 	 tfacr200.did3, tfacr200.paym, 0,var.cisli205.dcai,tfacr200.amti -  tfacr200.vati,var.tfacr200.trec, new.bpct) | #  jyosh.n 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	  
 	 	 	 dump.cisli205 ()  
 	 	 	 reset.variables.cisli205 ()  
 	 	 endselect  
 	 	 	 	 	 	 	 	 	 	 | #  800 -  141306.sn 	 	 	 	 	 	 	  
 	 	 else 	  
 	 	 	 select tcmcs039.stno:step.no 	 	 | #  210712.sn  
 	 	 	 from 	 tcmcs039  
 	 	 	 where 	 tcmcs039._index1 =  {"tdsls4223m000"}  
 	 	 	 and 	 tcmcs039.modc =  tcmodc.sls  
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 	 process =  tdsls045.pmsk(step.no;1)  
 	 	 	 	 if process =  "e" then                                                                      
 	 	 	 	 	 var.stat =  6  
 	 	 	 	 else  
 	 	 	 	 	 var.stat =  5  
 	 	 	 	 endif  
 	 	 	 selectempty 	 	 	 	 	  
 	 	 	 	 var.stat =  5 	 	 	 	 	  
 	 	 	 endselect 	 	 	 	 	  
 	 	 	 if var.stat =  6 then  
 	 	 	 	 var.cisli205.brid =  1  
 	 	 	 else  
 	 	 	 	 var.cisli205.brid =  2  
 	 	 	 endif 	 	 	 	 | #  210712.en  
 | 	 	 	 fill.cisli205.fields (tdsls040.comp,tdsls045.ttyp, tdsls045.invn,var.cisli205.brid,5, | #  210712.o  
 	 	 	 fill.cisli205.fields (tdsls040.comp,tdsls045.ttyp, tdsls045.invn,var.cisli205.brid,var.stat, | #  210712.n  
 	 	 	 convert.business.partner(), convert.address(), convert.cisli245.cofc (),  
 	 	 	 tdsls040.ccrs, tdsls040.cpay, new.txct,  
 	 	 	 |convert.cisli240.fcrt (), | *  MCR.o  
 	 	 	 convert.cisli240.fcrt(tdsls040.fcrt), | *  MCR.n  
 	 	 	 0,0,0,no.of.records,0,0, tdsls040.ccur,tdsls045.invd,  
 	 	 	 var.cisli205.amti,  
 	 	 	 var.cisli205.amth, var.cisli205.txai, var.cisli205.txah,  
 	 	 	 var.cisli205.stai, var.cisli205.stah,  
 	 	 	 | tdsls045.rats, tdsls045.ratf,  
 	 	 	 tmp.mc.tdsls045.rats, | *  MCR .n  
 	 	 	 tmp.mc.tdsls045.ratf, | *  MCR .n  
 	 	 	 var.cisli205.scdt,  
 	 	 	 var.cisli205.scai, var.cisli205.scah,0.0, var.cisli205.csai,  
 	 	 	 0.0, var.cisli205.d1ai, var.cisli205.d1ah, var.cisli205.d1dt, var.cisli205.d2ai, var.cisli205.d2ah,  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.so  
 | 	 	 	 var.cisli205.d2dt, var.cisli205.d3ai, var.cisli205.d3ah, var.cisli205.d3dt, var.cisli240.paym,0,var.cisli205.dcai,var.cisli205.amti -  var.cisli205.txai)  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.eo  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.sn  
 | 	 	 	 var.cisli205.d2dt, var.cisli205.d3ai, var.cisli205.d3ah, var.cisli205.d3dt, var.cisli240.paym,0,var.cisli205.dcai,var.cisli205.amti -  var.cisli205.txai,target(cisli.doct.invoice)) |jyosh.o  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en  
 	 	 	 var.cisli205.d2dt, var.cisli205.d3ai, var.cisli205.d3ah, var.cisli205.d3dt, var.cisli240.paym,0,var.cisli205.dcai,var.cisli205.amti -  var.cisli205.txai,target(cisli.doct.invoice), new.bpct) |jyosh.n 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	  
 	 	 	 dump.cisli205 ()  
 	 	 	 reset.variables.cisli205 ()  
 	 	 endif 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 	 	 | #  800 -  141306.en 	 	  
 	 endif  
 	 cisli209.dumped =  true 	 	 	 |ravi_cisli209.n  
 	 if (total.records >=  20000 and 	 	 |haddock.err.sn  
 	 	 tppin190.accessed and 	  
 	 	 cisli209.dumped ) then  
 	 	 	 reinitialize.cache()  
 	 endif 	 	 	 	 	 |haddock.err.en  
 	 free.memories() 	 	 	 	 |ravi_array.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:td
:SCMOD:sls
:SFLNO:045
:ICOD:S
:QURY:START
select 	 tdsls045.*  , tdsls041.*  , 	 tiitm001.dsca, tiitm001.cuni, tiitm001.kitm, 	 tiitm001.itmt, tiitm001.txts, tiitm001.copr
from tdsls045, tdsls041, tiitm001
where tdsls045.invn <>  0  
 and 	 tdsls045.ttyp <>  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
 and 	 tdsls045.cmba refers to tdsls041  
 and 	 tdsls045.item refers to tiitm001
order by tdsls045._index5
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:td
:SCMOD:sls
:SFLNO:045
:ICOD:X
:QURY:START
order.count =  0  
 free.mem ( slsorder.array )  
 reset.variables.cisli205 ()  
 hold.ttyp =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
 hold.invn =  0  
 g.hold.orno =  0  
 |dump.cisli206 () 	 	 	 	 | #  ravi_array.so  
 |delete.bcsci002.records.cisli206 ()  
 |dump.cisli209 ()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:tf
:SCMOD:acr
:SFLNO:400
:ICOD:D
:QURY:START
initialize.variables ()  
 	 initialize.cisli206.variables ()  
 	 allocate.memories(tfacr400.ccty) 	 	 | #  ravi_array.n 	 	 	  
 	 var.cisli220.msid =  var.cisli220.msid +  1  
 	 fill.fcrt.and.business.partner.cisli220 ()  
 	 if etol (tfacr400.vatc) =  0 then 	 	 	 	  
 	 	 var.cisli220.vatc =  tcyesno.no  
 	 else  
 	 	 var.cisli220.vatc =  get.tax.flag.via.bp (  
 	 	 	 tfacr400.cuno,  
 	 	 	 bcstc.orgn.cuno,  
 	 	 	 err.mess)  
 	 endif  
 	 fill.postal.address.cisli220 ()  
 	 fill.sales.representative.cisli220 ()  
 	 fill.cisli220.stoa ()  
 	 	 	 	 	 	 | #  SL -  146520.sn  
 	 if tfacr400.inst =  tfacr.inst.cancelled then  
 	 	 var.cisli220.date =  utc(date.num(),time.num())  
 	 else  
 	 	 var.cisli220.date =  utc(tfacr400.invd,0)  
 	 endif 	 	 	 	 	  
 	 	 	 	 	 	 | #  SL -  146520.en  
 	 dump.cisli220 ()  
 	 no.of.records =  0  
 	 cisli209.dumped =  false 	 	 |ravi_cisli209.n  
 	 select 	 tfacr401.*   
 	 from 	 tfacr401  
 	 where tfacr401._index1 =  {:tfacr400.ttyp, :tfacr400.ninv}  
 	 order by tfacr401._index1 	 	 	  
 	 selectdo  
 	 	 	 	 	 	 	 	 | #  210859.so  
 | 	 	 get.tax.by.country.code (  
 | 	 	 	 	 	 tfacr401.vatc,  
 | 	 	 	 	 	 tfacr401.cvat,  
 | 	 	 	 	 	 new.txct,  
 | 	 	 	 	 	 new.txid,  
 | 	 	 	 	 	 err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 	 	 	 	 	 | #  210859.sn  
 	 	 get.tax.by.country.code.and.financial.company(  
 	 	 	 	 	 tfacr401.vatc,  
 	 	 	 	 	 tfacr401.cvat,  
 	 	 	 	 	 var.compnr,  
 	 	 	 	 	 new.txct,  
 	 	 	 	 	 new.txid,  
 	 	 	 	 	 err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.en  
 	 	 no.of.records =  no.of.records +  1  
 	 	  
 	 	 | *  MCR -  sn  
 	 	 for i =  1 to 3  
 	 	 	 tmp.mc.tfacr400.rate(i) =  fill.mc.field.double(tfacr400.rate,i)  
 	 	 	 tmp.mc.tfacr400.ratf(i) =  fill.mc.field.long( tfacr400.ratf,i)  
 	 	 endfor  
 	 	 | *  MCR -  en  
 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 calculate.amount.in.home.currency.variables(tfacr401.amnt, 	 	 	  
 	 	 	 tfacr400.ccur, 	 	 	 	 	  
 	 	 	 tmp.mc.tfacr400.rate(i),  
 	 	 	 tmp.mc.tfacr400.ratf(i),  
 	 	 	 i,  
 	 	 	 var.cisli225.amth(i), 	 	 	 	 	 	 	  
 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 endfor 	 	 	 	 	 	  
 | *  MCR -  new changes .e 	 	 	 	  
 	 	 fill.status.cisli225 ()  
 	 	 fill.tax.amount.cisli225 ()  
 	 	 if isspace (tfacr400.ccrs) then  
 	 	 	 var.cisli225.lpai =  0.0 	 	 	  
 	 	 	 | *  MCR -  s  
 	 	 	 |var.cisli225.lpah =  0.0  
 	 	 	 for i =  1 to 3  
 	 	 	 	 var.cisli225.lpah(i) =  0.0  
 	 	 	 endfor  
 	 	 	 | *  MCR -  e  
 	 	 else  
 	 	 	 fill.lps.cisli225 ()  
 	 	 endif  
 	 	 var.cisli205.scai =  var.cisli205.scai +  var.cisli225.lpai  
 	 	 var.net.amti =  var.net.amti +  nett.amnt  
 	 	 	 	  
 	 	 dump.cisli225 ()  
 	 	 	  
 	 	 if tfacr400.inst <>  tfacr.inst.cancelled then 	 	 | #  SL -  146520.n 	 	  
 	 	 	 	 	  
 	 	 get.financial.company.country (var.compnr)  
 	 	 	 	 	 	 	 	 | #  207750.so  
 | 	 	 update.tax.amounts.array(new.txid, 	 	 	 	 | #  ravi_array.sn  
 | 	 	 	 	 amnt.cvat, nett.amnt) 	  
 	 	 	 	 	 	 	 	 	 	 | #  ravi_array.en  
 	 	 	 	 	 	 	 	 | #  207750.eo  
 	 	 	 	 	 	 	 	 | #  207750.sn  
 	 	 if update.tax.amounts.array(new.txid, 	 	 	 	 | #  ravi_array.sn  
 	 	 	 	 amnt.cvat, nett.amnt) then  
 	 	 	 	 	 	 	 	 | #  207750.en  
 	 	 if not isspace (new.txct) then 	 	 	  
 	 	 	 read.tcmcs032 (new.txct, new.txid,tfacr400.invd)  
 	 	 	 read.tcmcs036 (new.txct, new.txid) 	  
 	 	 endif 	 	 	 	 	 	  
 	 	 get.tax.percentage (new.txct, new.txid, var.compnr, 	  
 	 	 	 tfacr400.invd, var.singular.tax, var.cisli209.pvat)  
 	 	 	 	 	 	 	 |ravi_cisli209.sn  
 	 	 	 	 	 	  
 	 	 	  
 	 	 	 update.row.in.cache.cisli209( 	 	 	 	  
 	 	 	 	 var.compnr,  
 	 	 	 	 tfacr400.ttyp,  
 	 	 	 	 tfacr400.ninv,  
 	 	 	 	 tcmcs036.ctau.l,  
 	 	 	 	 var.cisli206.ceno,  
 	 	 	 	 var.cisli209.pvat,  
 	 	 	 	 amnt.cvat,  
 	 	 	 	 nett.amnt,  
 	 	 	 	 var.cisli206.rcod,  
 	 	 	 	 tfacr400.ccur,  
 	 	 	 	 tfacr400.invd,  
 	 	 	 	 var.cisli.rtyp,  
 	 	 	 	 | tfacr400.rate, 	 | *  MCR .o  
 	 	 	 	 |tfacr400.ratf) 	 | *  MCR .o  
 	 	 	 	 tmp.mc.tfacr400.rate, | *  MCR .n  
 	 	 	 	 tmp.mc.tfacr400.ratf) 	 | *  MCR .n 	 	 	 	 	 	 	 	  
 	 	 	 	 	 |ravi_cisli209.en  
 	 	 	 	 cisli209.dumped =  true 	 	 | #  207750.sn  
 	 	 else  
 	 	 	 	 cisli209.dumped =  false  
 	 	 endif 	 	 	 	 	 	 | #  207750.en  
 	 	 endif 	 	 	 	 	 | #  SL -  146520.n  
 	 	 select tfacr402.*   
 	 	 from tfacr402  
 	 	 where tfacr402._index1 =  {:tfacr401.ttyp, :tfacr401.ninv, :tfacr401.lino}  
 	 	 selectdo  
 	 	 	 if etol (tfacr402.clcm) =  0 then  
 	 	 	 	 var.cisli226.clcm =  1  
 	 	 	 else  
 	 	 	 	 var.cisli226.clcm =  etol (tfacr402.clcm)  
 	 	 	 endif  
 	 	 	 dump.cisli226 ()  
 	 	 endselect 	 	 	 	  
 	 endselect 	 	  
 	 if tfacr400.inst <>  tfacr.inst.cancelled then 	 	 | #  SL -  146520.n 	 	  
 	 	 	 	 	 	 	 | #  ravi_array.sn  
 	 	 dump.fields.cisli206.from.array( 	  
 	 	 	 	 var.compnr, tfacr400.ttyp,  
 	 	 	 	 tfacr400.ninv, tfacr400.ccty,  
 	 	 	 	 |tfacr400.rate, tfacr400.ratf, | *  MCR .o  
 	 	 	 	 tmp.mc.tfacr400.rate, | *  MCR .n  
 	 	 	 	 tmp.mc.tfacr400.ratf, 	 | *  MCR .n  
 	 	 	 	 tfacr400.ccur, var.fin.comp.country,  
 	 	 	 	 var.cisli206.stcy, var.fin.comp.country,  
 	 	 	 	 var.cisli206.itcy, "" , "")                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
 	 	 	 	 	 	 	 | #  ravi_array.en  
 	 	 	 	 	 	 	 | #  ravi_cisli209.sn  
 	 	 dump.records.from.cache.cisli209() 	 	  
 	 	 cisli209.dumped =  true  
 	 	 	 	 	 	 	 | #  ravi_cisli209.sn  
 	 	 if (total.records >=  20000 and 	 	 |haddock.err.sn  
 	 	 	 tppin190.accessed and 	  
 	 	 	 cisli209.dumped ) then  
 	 	 	 	 reinitialize.cache()  
 	 	 endif 	 	 	 	 	 |haddock.err.en 	  
 	  
 	  
 	  
 	 if tfacr400.inst =  tfacr.inst.posted then  
 	 	 var.cisli205.stat =  6  
 	 	 var.cisli205.brid =  1  
 	 else  
 	 	 var.cisli205.stat =  5  
 	 	 var.cisli205.brid =  2  
 	  
 	 endif  
 	  
 	 | *  MCR -  sn  
 	 	 for i =  1 to 3  
 	 	 	 tmp.mc.tfacr400.rate(i) =  fill.mc.field.double(tfacr400.rate,i,0.000001)  
 	 	 	 tmp.mc.tfacr400.ratf(i) =  fill.mc.field.long( tfacr400.ratf,i,1)  
 	 	 endfor  
 	 | *  MCR -  en  
 	  
 	 get.crnd (tfacr400.ccur)  
 	 if shift.vata <>  0.0 then  
 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 calculate.amount.in.home.currency.variables(shift.vata, 	 	 	  
 	 	 	 tfacr400.ccur, 	 	 	 	 	  
 	 	 	 tmp.mc.tfacr400.rate(i),  
 	 	 	 tmp.mc.tfacr400.ratf(i),  
 	 	 	 i,  
 	 	 	 var.cisli205.stah(i), 	 	 	 	 	 	 	  
 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 endfor 	 	 	 	 	 	  
 | *  MCR -  new changes .e 	  
 	 else  
 	 	 | *  MCR -  s  
 	 	 |var.cisli205.stah =  0.0  
 	 	 for i =  1 to 3  
 	 	 	 var.cisli205.stah(i) =  0.0  
 	 	 endfor  
 	 	 | *  MCR -  e  
 	 endif  
 	 if total.vata <>  0.0 then  
 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 calculate.amount.in.home.currency.variables(total.vata, 	 	 	  
 	 	 	 tfacr400.ccur, 	 	 	 	 	  
 	 	 	 tmp.mc.tfacr400.rate(i),  
 	 	 	 tmp.mc.tfacr400.ratf(i),  
 	 	 	 i,  
 	 	 	 total.vath(i), 	 	 	 	 	 	 	  
 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 endfor 	 	 	 	 	 	  
 | *  MCR -  new changes .e  
 	 else  
 	 	 | *  MCR -  s  
 	 	 |total.vath =  0.0  
 	 	 for i =  1 to 3  
 	 	 	 total.vath(i) =  0.0  
 	 	 endfor  
 	 	 | *  MCR -  e  
 	 endif  
 	 if var.net.amti <>  0.0 then  
 	 	  
 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 calculate.amount.in.home.currency.variables(var.net.amti, 	 	 	  
 	 	 	 tfacr400.ccur, 	 	 	 	 	  
 	 	 	 tmp.mc.tfacr400.rate(i),  
 	 	 	 tmp.mc.tfacr400.ratf(i),  
 	 	 	 i,  
 	 	 	 var.net.amth(i), 	 	 	 	 	 	 	  
 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 endfor 	 	 	 	 	 	  
 | *  MCR -  new changes .e 	 	  
 	 else  
 	 	 | *  MCR -  s  
 	 	 |var.net.amth =  0.0  
 	 	 for i =  1 to 3  
 	 	 	 var.net.amth(i) =  0.0  
 	 	 endfor  
 	 	 | *  MCR -  e  
 	 endif  
 	 if var.cisli205.scai <>  0.0 then  
 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 calculate.amount.in.home.currency.variables(var.cisli205.scai, 	 	 	  
 	 	 	 tfacr400.ccur, 	 	 	 	 	  
 	 	 	 tmp.mc.tfacr400.rate(i),  
 	 	 	 tmp.mc.tfacr400.ratf(i),  
 	 	 	 i,  
 	 	 	 var.cisli205.scah(i), 	 	 	 	 	 	 	  
 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 endfor 	 	 	 	 	 	  
 | *  MCR -  new changes .e 	 	  
 	 else  
 	 	 | *  MCR -  s  
 	 	 |var.cisli205.scah =  0.0  
 	 	 for i =  1 to 3  
 	 	 	 var.cisli205.scah(i) =  0.0  
 	 	 endfor  
 	 	 | *  MCR -  e  
 	 endif  
 	 itccom0016.calculate.discount.dates (tfacr400.invd,  
 	 	 	 tfacr400.cpay, var.cisli205.d1dt, var.cisli205.d2dt,  
 	 	 	 var.cisli205.d3dt)  
 	 itfcmg0007.calculate.discount (tfacr400.cpay, var.net.amti +  total.vata, total.vata,  
 	 	 	 	 	 tfacr400.ccur, tcmcs002.crnd,  
 	 	 	 	 	 var.cisli205.d1ai, var.cisli205.d2ai,  
 	 	 	 	 	 var.cisli205.d3ai) 	 	  
 	 if var.cisli205.d1ai <>  0.0 then  
 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 calculate.amount.in.home.currency.variables(var.cisli205.d1ai, 	 	 	  
 	 	 	 tfacr400.ccur, 	 	 	 	 	  
 	 	 	 tmp.mc.tfacr400.rate(i),  
 	 	 	 tmp.mc.tfacr400.ratf(i),  
 	 	 	 i,  
 	 	 	 var.cisli205.d1ah(i), 	 	 	 	 	 	 	  
 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 endfor 	 	 	 	 	 	  
 | *  MCR -  new changes .e  
 	 else  
 	 	 | *  MCR -  s  
 	 	 |var.cisli205.d1ah =  0.0  
 	 	 for i =  1 to 3  
 	 	 	 var.cisli205.d1ah(i) =  0.0  
 	 	 endfor  
 	 	 | *  MCR -  e  
 	 endif  
 	 if var.cisli205.d2ai <>  0.0 then  
 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 calculate.amount.in.home.currency.variables(var.cisli205.d2ai, 	 	 	  
 	 	 	 tfacr400.ccur, 	 	 	 	 	  
 	 	 	 tmp.mc.tfacr400.rate(i),  
 	 	 	 tmp.mc.tfacr400.ratf(i),  
 	 	 	 i,  
 	 	 	 var.cisli205.d2ah(i), 	 	 	 	 	 	 	  
 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 endfor 	 	 	 	 	 	  
 | *  MCR -  new changes .e  
 	 else  
 	 	 | *  MCR -  s  
 	 	 |var.cisli205.d2ah =  0.0  
 	 	 for i =  1 to 3  
 	 	 	 var.cisli205.d2ah(i) =  0.0  
 	 	 endfor  
 	 	 | *  MCR -  e  
 	 endif  
 	 if var.cisli205.d3ai <>  0.0 then  
 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 calculate.amount.in.home.currency.variables(var.cisli205.d3ai, 	 	 	  
 	 	 	 tfacr400.ccur, 	 	 	 	 	  
 	 	 	 tmp.mc.tfacr400.rate(i),  
 	 	 	 tmp.mc.tfacr400.ratf(i),  
 	 	 	 i,  
 	 	 	 var.cisli205.d3ah(i), 	 	 	 	 	 	 	  
 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 endfor 	 	 	 	 	 	 	  
 	 	  
 | *  MCR -  new changes .e  
 	 else  
 	 	 | *  MCR -  s  
 	 	 |var.cisli205.d3ah =  0.0  
 	 	 for i =  1 to 3  
 	 	 	 var.cisli205.d3ah(i) =  0.0  
 	 	 endfor  
 	 	 | *  MCR -  e  
 	 endif  
 	 	 	 	 	 |bin.sn  
 	 if tfacr400.inst =  tfacr.inst.posted then  
 	 	 select tfacr200.*   
 	 	 from tfacr200  
 	 	 where tfacr200._index1 =  {:tfacr400.ttyp, :tfacr400.ninv, 0}  
 | 	 	 and tfacr200.trec =  tfacr.trec.invoice 	 	 	 	 | #  200 -  101927.o  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.sn  
 	 	 and (tfacr200.trec =  tfacr.trec.invoice or 	  
 	 	 tfacr200.trec =  tfacr.trec.credit) 	 	 	 	  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	  
 	 	 	 | *  MCR -  sn 	  
 	 	 	 for i =  1 to 3 	  
 	 	 	 	 tmp.mc.tfacr200.amth(i) =  fill.mc.field.double(tfacr200.amth,i)  
 	 	 	 	 tmp.mc.tfacr200.vath(i) =  fill.mc.field.double(tfacr200.vath,i)  
 	 	 	 	 tmp.mc.tfacr200.svah(i) =  fill.mc.field.double(tfacr200.svah,i)  
 	 	 	 	 tmp.mc.tfacr200.rate(i) =  fill.mc.field.double(tfacr200.rate,i)  
 	 	 	 	 tmp.mc.tfacr200.ratf(i) =  fill.mc.field.long(tfacr200.ratf,i)  
 	 	 	 	 tmp.mc.tfacr200.laph(i) =  fill.mc.field.double(tfacr200.laph,i)  
 	 	 	 	 tmp.mc.tfacr200.dc1h(i) =  fill.mc.field.double(tfacr200.dc1h,i)  
 	 	 	 	 tmp.mc.tfacr200.dc2h(i) =  fill.mc.field.double(tfacr200.dc2h,i)  
 	 	 	 	 tmp.mc.tfacr200.dc3h(i) =  fill.mc.field.double(tfacr200.dc3h,i)  
 	 	 	 	 	 	 	 	 	 	  
 	 	 	 endfor  
 	 	 	 | *  MCR -  en  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.sn  
 	 	 	 l.cisli205.csai =  var.net.amti  
 	 	 	 if tfacr200.trec =  tfacr.trec.invoice then  
 	 	 	 	 var.tfacr200.trec =  target(cisli.doct.invoice)  
 	 	 	 else  
 	 	 	 	 var.tfacr200.trec =  target(cisli.doct.credit)  
 	 	 	 	 	 	 	 	 | #  148886.so  
 | 	 	 	 	 if var.net.amti >  0 then  
 | 	 	 	 	 	 l.cisli205.csai = -  var.net.amti  
 | 	 	 	 	  
 | 	 	 	 	 endif  
 	 	 	 	 	 	 	 	 | #  148886.eo  
 	 	 	 endif  
 	 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en 	  
 	 	 	  
 	 	 	 fill.cisli205.fields (var.compnr,tfacr200.ttyp, tfacr200.ninv,var.cisli205.brid,  
 	 	 	 var.cisli205.stat,var.cisli220.bpid, var.cisli220.itoa, var.fin.cofc,  
 	 	 	 tfacr200.ccrs, tfacr200.cpay, new.txct,var.cisli220.fcrt,0,  
 	 	 	 no.of.records,0,0,0,0, tfacr400.ccur,tfacr200.docd,  
 	 	 	 tfacr200.amti, 	 	 	 	 	  
 	 	 	 |tfacr200.amth, 	 	 | *  MCR .o 	  
 	 	 	 tmp.mc.tfacr200.amth, | *  MCR .n  
 	 	 	 tfacr200.vati, 	 	 	 	  
 	 	 	  
 	 	 	 |tfacr200.vath 	 	 | *  MCR .o  
 	 	 	 tmp.mc.tfacr200.vath, | *  MCR .n  
 	 	 	 tfacr200.svam, 	 	 	 	  
 	 	 	  
 	 	 	 |tfacr200.svah, 	 | *  MCR .o  
 	 	 	 tmp.mc.tfacr200.svah, 	 | *  MCR.n  
 	 	 	 |tfacr200.rate, 	 | *  MCR .o  
 	 	 	 tmp.mc.tfacr200.rate, 	 | *  MCR .n  
 	 	 	 |tfacr200.ratf, 	 | *  MCR .o 	 	  
 	 	 	 tmp.mc.tfacr200.ratf, 	 | *  MCR .n 	 	 	  
 	 	 	 tfacr200.lpdt,  
 | 	 	 	 tfacr200.lapa, 	 	 	 	 	 | #  200 -  101927.o  
 	 	 	 tfacr200.lapi, 	 	 	 	 	 | #  200 -  101927.n  
 	 	 	 |tfacr200.laph, 	 | *  MCR .o  
 	 	 	 tmp.mc.tfacr200.laph, | *  MCR .n  
 	 	 	 0.0,  
 | 	 	 	 var.net.amti, 	 	 	 	 	 | #  200 -  101927.o 	  
 	 	 	 l.cisli205.csai, 	 	 	 	 	 | #  200 -  101927.n  
 	 	 	 0.0, tfacr200.dc1i,  
 	 	 	 |tfacr200.dc1h,  
 	 	 	 tmp.mc.tfacr200.dc1h, | *  MCR  
 	 	 	 tfacr200.did1, tfacr200.dc2i,  
 	 	 	 |tfacr200.dc2h,  
 	 	 	 tmp.mc.tfacr200.dc2h, | *  MCR  
 	 	 	 tfacr200.did2,tfacr200.dc3i,  
 	 	 	 |tfacr200.dc3h,  
 	 	 	 tmp.mc.tfacr200.dc3h, | *  MCR  
 | 	 	 	 tfacr200.did3, tfacr200.paym, 0,0.0,tfacr200.amti -  tfacr200.vati) | #  200 -  101927.o  
 | 	 	 	 tfacr200.did3, tfacr200.paym, 0,0.0,tfacr200.amti -  tfacr200.vati,var.tfacr200.trec) | #  200 -  101927.n | #  jyosh.o  
 	 	 	 tfacr200.did3, tfacr200.paym, 0,0.0,tfacr200.amti -  tfacr200.vati,var.tfacr200.trec, new.bpct) | #  jyosh.n 	 	 	  
 	 	 	 dump.cisli205 ()  
 	 	 	 reset.variables.cisli205 ()  
 	 	 endselect  
 	 else  
 	 	 	 	 	 	 	 	 	 	 |bin.en  
 	 	  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.sn  
 	 	 	 if tfacr200.trec =  tfacr.trec.invoice then  
 	 	 	 	 var.tfacr200.trec =  target(cisli.doct.invoice)  
 	 	 	 else  
 	 	 	 	 var.tfacr200.trec =  target(cisli.doct.credit) 	  
 	 	 	 endif  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en 	  
 	  
 	 	 | *  MCR -  s  
 	 	 for i =  1 to 3 	  
 	 	 	 tmp.mc.cisli205.amth(i) =  (var.net.amth(i) +  total.vath(i) +  var.cisli205.scah(i)) 	 	 	  
 	 	 endfor 	  
 	 	 | *  MCR -  e  
 	 	  
 	 	 fill.cisli205.fields (var.compnr,tfacr400.ttyp, tfacr400.ninv,var.cisli205.brid,var.cisli205.stat,  
 	 	 var.cisli220.bpid, var.cisli220.itoa, var.fin.cofc,  
 	 	 tfacr400.ccrs, tfacr400.cpay, new.txct,var.cisli220.fcrt,0,no.of.records,0,0,0,0, tfacr400.ccur,tfacr400.invd,  
 	 	 (var.net.amti +  total.vata +  var.cisli205.scai) ,  
 	 	 |(var.net.amth +  total.vath +  var.cisli205.scah) , | *  MCR .o  
 	 	 tmp.mc.cisli205.amth, | *  MCR .n  
 	 	 total.vata,  
 	 	 total.vath, 	 	  
 	 	 shift.vata, 	 	  
 	 	 var.cisli205.stah, 	 	  
 	 	 |tfacr400.rate, | *  MCR.o  
 	 	 tmp.mc.tfacr400.rate, | *  MCR.n  
 	 	 |tfacr400.ratf, | *  MCR.o 	 	  
 	 	 tmp.mc.tfacr400.ratf, 	 | *  MCR.n 	  
 	 	 var.cisli205.scdt, var.cisli205.scai,  
 	 	 var.cisli205.scah, 	 	  
 	 	 0.0,  
 	 	 var.net.amti,0.0, var.cisli205.d1ai,  
 	 	 var.cisli205.d1ah, 	 	  
 	 	 var.cisli205.d1dt, var.cisli205.d2ai,  
 	 	 var.cisli205.d2ah, 	 	  
 	 	 var.cisli205.d2dt,var.cisli205.d3ai,  
 	 	 var.cisli205.d3ah, 	 	  
 | 	 	 var.cisli205.d3dt, tfacr400.paym, 0,0.0,var.net.amti +  var.cisli205.scai) 	 	 | #  200 -  101927.o  
 | 	 	 var.cisli205.d3dt, tfacr400.paym, 0,0.0,var.net.amti +  var.cisli205.scai,var.tfacr200.trec) | #  200 -  101927.n | #  jyosh.o  
 	 	 var.cisli205.d3dt, tfacr400.paym, 0,0.0,var.net.amti +  var.cisli205.scai,var.tfacr200.trec, new.bpct) | #  200 -  101927.n | #  jyosh.n 	 	  
 	 	 dump.cisli205 ()  
 	 	 reset.variables.cisli205 ()  
 	 endif 	 	 	 	 	 	 	 	 |bin.n  
 	 endif 	 	 	 	 	 	 | #  SL -  146520.n 	  
 	 free.memories() 	 	 	 	 |ravi_array.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:tf
:SCMOD:acr
:SFLNO:400
:ICOD:S
:QURY:START
select 	 tfacr400.*
from tfacr400
where tfacr400.inst <>  tfacr.inst.open
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:tf
:SCMOD:acr
:SFLNO:400
:ICOD:X
:QURY:START
reset.variables.cisli205 ()  
 | End select is for tfacr400  
 | dump.cisli206 () 	 	 	 	 | #  ravi_array.so  
 |delete.bcsci002.records.cisli206 ()  
 |dump.cisli209 ()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:tf
:SCMOD:acr
:SFLNO:510
:ICOD:D
:QURY:START
	 	 order.count =  order.count +  1  
 	 	 alloc.mem (intorder.array,length.of.str,order.count)  
 	 	 if isspace(intorder.array (1, order.count)) then  
 	 	 	 intorder.array (1, order.count) =  concat$("|",shiftr$(shiftl$(tfacr510.ttyp)),tfacr510.ninv)  
 	 	 endif  
 	 	  
 	 	 header.dumped =  false  
 	 	 for counter1 =  1 to order.count -  1  
 	 	 	 temp.order =  concat$("|",shiftr$(shiftl$(tfacr510.ttyp)),tfacr510.ninv)  
 	 	 	 intorder1 =  strip$(intorder.array (1, counter1))  
 | 	 	 	 if intorder1 =  temp.order then 	 | #  200 -  101240.o  
 	 	 	 	 	 	 	 	 | #  200 -  101240.sn  
 	 	 	 if intorder1 =  temp.order and  
 	 	 	 tfacr510.iist =  tfacr.iist.selected then 	  
 	 	 	 	 	 	 	 	 | #  200 -  101240.en  
 	 	 	 	 header.dumped =  true  
 	 	 	 	 break  
 	 	 	 endif  
 	 	 endfor  
 	 	 if header.dumped =  true then  
 	 	 	 continue  
 	 	 endif 	  
 	 	 if first.time then  
 	 	 	 interest.invoice =  1  
 	 	 	 read.tfacr501 ()  
 	 	 	 first.time =  false  
 	 	 endif  
 	 	 	 	 	 	 	 	 | #  200 -  101240.sn  
 	 	 hold.ityp1 =  hold.ityp  
 	 	 hold.idoc1 =  hold.idoc  
 	 	 	 	 	 	 	 	 | #  200 -  101240.en  
 	 	 if tfacr510.iist <>  tfacr.iist.selected then  
 	 	 if ((tfacr510.ityp <>  hold.ityp) or (tfacr510.idoc <>  hold.idoc)) then 	  
 	 	 	 initialize.cisli206.variables () 	 |ravi_array.sn  
 	 	 	 cisli209.dumped =  false 	 	 |ravi_array.en  
 	 	 	 no.of.records =  0 	 	  
 	 	 	 hold.ityp =  tfacr510.ityp 	 	 	 	  
 	 	 	 hold.idoc =  tfacr510.idoc  
 	 	 	 var.sum.tfacr510.icam =  0  
 	 	 	 var.sum.tfacr510.amnt =  0  
 	 	 endif  
 	 	 else  
 	 	 	 no.of.records =  0  
 	 	 	 var.sum.tfacr510.icam =  0  
 	 	 	 var.sum.tfacr510.amnt =  0  
 	 	 endif  
 	 	 	 	 	 	 	 	 | #  200 -  101240.sn  
 flag.check =  false  
 	 	 	 	 	 	 	 	  
 if (tfacr510.ttyp =  prev.ttyp) and (tfacr510.ninv =  prev.ninv) then  
 	 if tfacr510.iist =  tfacr.iist.selected then  
 	 	 	 continue  
 	 else 	 	 	 	 	 	 	  
 	 	 if hold.ityp1 =  tfacr510.ityp and  
 	 	 hold.idoc1 =  tfacr510.idoc then  
 	 	 	 continue  
 	 else 	  
 	 	 	 flag.check =  true  
 	 	 endif  
 	 endif  
 else  
 	 flag.check =  true  
 endif  
 	 if flag.check =  true then 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 | #  200 -  101240.en  
 | 	 	 if ((tfacr510.ttyp <>  prev.ttyp) or (tfacr510.ninv <>  prev.ninv)) then | #  200 -  101240.o  
 	 	 	  
 	 	 	 reset.variables.1 ()  
 	 	 	 	  
 	 	 	 prev.ttyp =  tfacr510.ttyp 	 	 	 	  
 	 	 	 prev.ninv =  tfacr510.ninv 	 	 	 	  
 	 	 	 prev.line =  tfacr510.line  
 	 	 	 prev.tdoc =  tfacr510.tdoc 	 	 	 	  
 	 	 	 prev.docn =  tfacr510.docn 	 	 	 	  
 	 	 	 prev.lino =  tfacr510.lino  
 	 	 	 prev.ityp =  tfacr510.ityp  
 	 	 	 prev.cuno =  tfacr510.cuno  
 	 	 	 prev.idoc =  tfacr510.idoc  
 	 	 	 count.records.same.invoice () 	  
 	 	 	 var.cisli210.ctyn =  get.tax.flag.via.bp (  
 	 	 	 	 tfacr510.cuno,  
 	 	 	 	 bcstc.orgn.cuno,  
 	 	 	 	 err.mess)  
 	 	 	 read.customers.table ()  
 	 	 	 	 	 	 	 	 	 |binda.so 	 	 	 	  
 	 | 	 	 if tfacr510.iist =  tfacr.iist.printed or  
 	 | 	 	 tfacr510.iist =  tfacr.iist.posted then  
 	 	 	 	 	 	 	 	 	 |binda.eo  
 	 	 	 	 	  
 	 	 	 	 select tfacr200.*   
 	 	 	 	 from tfacr200  
 	 	 	 	 where tfacr200._index1 =  {:prev.ttyp, :prev.ninv, :prev.line,"",0,0}  
 	 	 	 	 as set with 1 rows  
 	 	 	 	 selectdo  
 	 	 	 	 	 var.cisli210.oidd =  utc (tfacr200.dued,0)  
 | 	 	 	 	 	 get.tax.by.country.code ( 	 	 	 | #  jyosh.so  
 | 	 	 	 	 	 	 	 	 tfacr200.vatc,  
 | 	 	 	 	 	 	 	 	 temp.txid,  
 | 	 	 	 	 	 	 	 	 var.cisli210.txct,  
 | 	 	 	 	 	 	 	 	 var.cisli210.txid,  
 | 	 	 	 	 	 	 	 	 err.mess) 	 	 | #  jyosh.eo  
 	 	 	 	 	 	 	 	 | #  210859.so  
 | 	 	 	 	 	 var.cisli210.txct =  get.country.of.financial.company(var.compnr) | #  jyosh.sn  
 | 	 	 	 	 	 var.cisli210.txid =  temp.txid 	 	 	  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 	 	 	 	 	 | #  210859.so  
 	 	 	 	 	 	 	 	 | #  210859.sn  
 | 	 	 	 	 	 get.tax.by.country.code ( 	 	 	  
 | 	 	 	 	 	 	 	 	 tfacr200.vatc,  
 | 	 	 	 	 	 	 	 	 temp.txid,  
 | 	 	 	 	 	 	 	 	 var.cisli210.txct,  
 | 	 	 	 	 	 	 	 	 var.cisli210.txid,  
 | 	 	 	 	 	 	 	 	 err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.en  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 	 	 	 	 	 | #  210859.sn  
 	 	 	 	 get.tax.by.country.code.and.financial.company(  
 	 	 	 	 	 	 	 	 tfacr200.vatc,  
 	 	 	 	 	 	 	 	 temp.txid,  
 	 	 	 	 	 	 	 	 var.compnr,  
 	 	 	 	 	 	 	 	 var.cisli210.txct,  
 	 	 	 	 	 	 	 	 var.cisli210.txid,  
 	 	 	 	 	 	 	 	 err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.en  
 	 	 	 	 	 new.bpct =  tfacr200.vatc 	 | #  jyosh.en 	 	 	 	 	 	 	 	  
 	 	 	 	 	 if not isspace (var.cisli210.txct) then 	 	  
 	 	 	 	 	 	 read.tcmcs036 (var.cisli210.txct,var.cisli210.txid) 	 	 	  
 	 	 	 	 	 endif 	 	 	 	 	 	  
 	 	 	 	 	  
 	 	 	 	 	 if vat.code.found =  false then 	  
 	 	 	 	 	 	 var.cisli210.txid =  empty.string (1;9)  
 	 	 	 	 	 endif  
 	 	 	 	 	 var.cisli210.paym =  tfacr200.paym  
 	 	 	 	 	 var.cisli210.cpay =  tfacr200.cpay  
 	 	 	 	 	 var.cisli210.ccrs =  tfacr200.ccrs  
 	 	 	 	 	 var.cisli210.itoa =  get.invoice.to.address (tfacr200.adrs)  
 	 	 	 	 	 | *  MCR -  s  
 	 	 	 	 	 |var.cisli205.rate =  tfacr200.rate  
 	 	 	 	 	 |var.cisli205.ratf =  tfacr200.ratf 	  
 	 	 	 	 	 for i =  1 to 3 	 	 	 	 	  
 	 	 	 	 	 	 var.cisli205.rate(i) =  fill.mc.field.double(tfacr200.rate,i,0.000001)  
 	 	 	 	 	 	 var.cisli205.ratf(i) =  fill.mc.field.long(tfacr200.ratf,i,1) 	  
 	 	 	 	 	 endfor 	  
 	 	 	 	 	 | *  MCR -  e  
 	 	 	 	 	 var.cisli205.ccur =  tfacr200.ccur  
 	 	 	 	 	 if tfacr200.crep <>  0 then 	 	 | #  200.101008.n  
 	 	 	 	 	 	 var.cisli210.crep =  str$ (tfacr200.crep)  
 	 	 	 	 	 else 	 	 	 	 	 | #  200.101008.sn  
 	 	 	 	 	 	 var.cisli210.crep =  empty.string(1;6)  
 	 	 	 	 	 endif 	 	 	 	 	 | #  200.101008.en  
 	 	 	 	 endselect  
 	 	 	 	 allocate.memories(var.cisli210.txct) | #  ravi_array.n  
 	 	 	 	 if tfacr510.iist =  tfacr.iist.printed then  
 	 	 	 	 	 var.tfacr200.docd =  date.num ()  
 	 	 	 	 else  
 	 	 	 	 	 if tfacr510.iist =  tfacr.iist.posted 	 then 	 	 	 |binda.n  
 	 	 	 	 	 	 var.tfacr200.docd =  get.invoice.date.of.interest.invoice ()  
 	 	 	 	 	 	 restore.pointer.tfacr200 ()  
 	 	 	 	 	 endif 	 	 	 	 	 	 	 |binda.n  
 	 	 	 	 endif  
 	 | 	 	 endif 	 	 	 	 	 	 |binda.o  
 	 	 	 	  
 	 	 	  
 	 	  
 	 	 if not get.business.partner (tfacr510.cuno,bcstc.orgn.cuno,var.str.err.mess) then  
 	 	 	 var.tfacr510.itbp =  bcstc008.bpid  
 	 	 else 	  
 	 	 	 var.tfacr510.itbp =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
 	 	 endif  
 	 	 if not isspace (var.cisli210.txct) then 	 	  
 	 	 	 read.tcmcs032 (var.cisli210.txct, var.cisli210.txid,var.tfacr200.docd)  
 	 	 	 read.tcmcs036 (var.cisli210.txct, var.cisli210.txid) 	 	 	  
 	 	 endif 	 	 	 	 	 	  
 	 | 	 if not isspace (var.tfacr510.itbp) then 	 	 	 | #  ravi_array.so 	 	  
 	 | 	 	 read.tcmcs142 (var.tfacr510.itbp, tcmcs036.ctau.l, var.tfacr200.docd) 	  
 	 | 	 endif 	 	 	 	 	 	 	 | #  ravi_array.eo  
 	 	  
 	 	 store.schedule.data ()  
 	 	 if sch.present =  false then  
 	 	 	 	 	 	 	 	 | #  200 -  101240.sn 	 	 	 	  
 	 	 	 if tfacr510.iist =  tfacr.iist.printed or  
 	 	 	 tfacr510.iist =  tfacr.iist.posted then  
 	 	 	 	 	 	 	 	 | #  200 -  101240.en 	 	  
 	 	 	 	 select tfacr510.*   
 	 	 	 	 from tfacr510  
 	 	 	 	 where tfacr510._index1 =  {:prev.ttyp,  
 	 	 	 	 	 	 	 :prev.ninv,  
 	 	 	 	 	 	 	 :prev.line}  
 	 	 	 	 	 	 	 	 | #  200 -  101240.sn  
 	 	 	 	 and tfacr510.ityp =  :prev.ityp  
 	 	 	 	 and tfacr510.idoc =  :prev.idoc  
 	 	 	 	 	 	 	 	 | #  200 -  101240.en  
 	 	 	 	 selectdo  
 	 	 	 	 	 test.count =  test.count +  1  
 	 | 	 	 	 	 initialize.cisli206.variables () 	 |ravi_array.o  
 	 	 	 	 	 select tfacr200.*   
 	 	 	 	 	 from tfacr200  
 	 	 	 	 	 where tfacr200._index1 =  {:tfacr510.ttyp,  
 	 	 	 	 	 	 	 	 :tfacr510.ninv,  
 	 	 	 	 	 	 	 	 :tfacr510.line,  
 	 	 	 	 	 	 	 	 :tfacr510.tdoc,  
 	 	 	 	 	 	 	 	 :tfacr510.docn,  
 	 	 	 	 	 	 	 	 :tfacr510.lino}  
 	 	 	 	 	 as set with 1 rows 	 	 	  
 	 	 	 	 	 selectdo  
 	 	 	 	 	 	  
 	 	 	 	 	 	 | *  MCR .sn  
 	 	 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 	 	 tmp.mc.tfacr200.rate(i) =  fill.mc.field.double(tfacr200.rate,i)  
 	 	 	 	 	 	 	 tmp.mc.tfacr200.ratf(i) =  fill.mc.field.long(tfacr200.ratf,i)  
 	 	 	 	 	 	 endfor  
 	 	 	 	 	 	 | *  MCR .en  
 	 	 	 	 	 	  
 	 	 	 	 	 	 var.tfacr510.cldt =  utc (tfacr200.docd,0,2) 	  
 | 	 	 	 	 	 	 var.tfacr510.icam = -  tfacr200.amnt 	 | #  200 -  101240.o  
 	 	 	 	 	 	 var.tfacr510.icam = -  tfacr200.amti 	 | #  200 -  101240.n  
 	 	 	 	 	 	 get.interest.percentage ()  
 	 	 	 	 	 	 get.rounding.code ()  
 	 	 	 	 	 	 var.tfacr510.amnt =  (var.tfacr510.icam *  tfacr510.days /  var.tfacr501.intsel) *  (var.tfacr510.iprc /  100)  
 	 	 	 	 	 	 if var.tfacr510.amnt <>  0.0 then  
 	 | *  MCR -  new changes .s 	 	 	 	 	  
 	 | 	 	 	 	 	 | *  MCR -  s  
 	 | 	 	 	 	 	 	 for i =  1 to 3 	  
 	 | 	 	 	 	 	 | *  MCR -  e 	  
 	 | 	 	 	 	 	 	 calculate.amount.in.other.currency (var.tfacr510.amnt,  
 	 | 	 	 	 	 	 	 	 | *  MCR -  s 	  
 	 | 	 	 	 	 	 	 	 |tfacr200.rate,  
 	 | 	 	 	 	 	 	 	 |tfacr200.ratf,  
 	 | 	 	 	 	 	 	 	 tmp.mc.tfacr200.rate(i),  
 	 | 	 	 	 	 	 	 	 tmp.mc.tfacr200.ratf(i),  
 	 | 	 	 	 	 	 	 	 | *  MCR -  e 	  
 	 | 	 	 	 	 	 	 	 tfacr510.ccur,  
 	 | 	 	 	 	 	 	 	 | *  MCR -  s 	 	  
 	 | 	 	 	 	 	 	 	 |var.tfacr510.amth,  
 	 | 	 	 	 	 	 	 	 var.tfacr510.amth(i),  
 	 | 	 	 	 	 	 	 	 | *  MCR -  e  
 	 | 	 	 	 	 	 	 	 err.mess)  
 	 | 	 	 	 	 	 	 | *  MCR -  s  
 	 | 	 	 	 	 	 	 endfor  
 	 | 	 	 	 	 	 	 | *  MCR -  e  
 	 	 	 	 	 	  
 	 	 	 	 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 calculate.amount.in.home.currency.variables (var.tfacr510.amnt, 	 	 	  
 	 	 	 	 	 	 	 	 tfacr510.ccur, 	 	 	 	 	  
 	 	 	 	 	 	 	 	 tmp.mc.tfacr200.rate(i),  
 	 	 	 	 	 	 	 	 tmp.mc.tfacr200.ratf(i),  
 	 	 	 	 	 	 	 	 i,  
 	 	 	 	 	 	 	 	 var.tfacr510.amth(i), 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 err.mess) 	 	  
 	 	 	 	 	 	 	 endfor 	 	 	 	 	 	  
 	 | *  MCR -  new changes .e 	 	 	 	 	 	  
 	 	 	 	 	 	 else  
 	 	 	 	 	 	 	 | *  MCR -  s 	 	 	 	 	  
 	 	 	 	 	 	 	 |var.tfacr510.amth =  0.0  
 	 	 	 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 	 	 	 var.tfacr510.amth(i) =  0.0  
 	 	 	 	 	 	 	 endfor  
 	 	 	 	 	 	 	 | *  MCR -  e  
 	 	 	 	 	 	 endif  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101240.so  
 	 | 	 	 	 	 	 if tfacr510.iist =  tfacr.iist.selected then  
 	 | 	 	 	 	 	 	 var.sum.tfacr510.icam =  var.sum.tfacr510.icam +  var.tfacr510.icam  
 	 | 	 	 	 	 	 	 var.sum.tfacr510.amnt =  var.sum.tfacr510.amnt +  var.tfacr510.amnt  
 	 | 	 	 	 	 	 endif 	  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101240.eo  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101240.so 	 	 	 	 	  
 	 | 	 	 	 	 	 if tfacr510.iist =  tfacr.iist.selected then 	 	  
 	 | 	 	 	 	 	 	 dump.tfacr510.lines ()  
 	 | 	 	 	 	 	 	 	 	 	 	 	 	  
 	 | 	 	 	 	 	 else 	 	 	 	  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101240.eo 	 	  
 	 	 	 	 	 	 	 calc.tax.amount.interest.invoice ()  
 	 	 	 	 	 	 	 var.count =  var.count +  1  
 	 	 	 	 	 	 	 no.of.records =  no.of.records +  1  
 	 	 	 	 	 	 	 var.net.amti =  var.net.amti +  var.tfacr510.amnt  
 	 	 	 	 	 	 	 |MCR -  s  
 	 	 	 	 	 	 	 |var.net.amth =  var.net.amth +  var.tfacr510.amth  
 	 	 	 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 	 	 	 var.net.amth(i) =  var.net.amth(i) +  var.tfacr510.amth(i)  
 	 	 	 	 	 	 	 endfor  
 	 	 	 	 	 	 	 |MCR -  e  
 	 	 	 	 	 	 	 var.tax.amti =  var.tax.amti +  var.cisli210.txai  
 	 	 	 	 	 	 	 |MCR -  s  
 	 	 	 	 	 	 	 |var.tax.amth =  var.tax.amth +  var.cisli210.txah  
 	 	 	 	 	 	 	 for i =  1 to 3 	  
 	 	 	 	 	 	 	 	 var.tax.amth(i) =  var.tax.amth(i) +  var.cisli210.txah(i)  
 	 	 	 	 	 	 	 endfor 	  
 	 	 	 	 	 	 	 |MCR -  e 	 	 	 	 	  
 	 	 	 	 	 	 	 if tcmcs036.tvat =  tctvat.shifted then  
 	 	 	 	 	 	 	 var.shift.amti =  var.shift.amti +  var.cisli210.txai  
 	 	 	 	 	 	 	 |MCR -  s 	  
 	 	 	 	 	 	 	 |var.shift.amth =  var.shift.amth +  var.cisli210.txah  
 	 	 	 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 	 	 	 var.shift.amth(i) =  var.shift.amth(i) +  var.cisli210.txah(i)  
 	 	 	 	 	 	 	 endfor  
 	 	 	 	 	 	 	 |MCR -  e  
 	 	 	 	 	 	 	 endif  
 	 	 	 	 	 	 	 dump.cisli210.without.schedule ()  
 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 get.financial.company.country (var.compnr)  
 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 get.tax.percentage (var.cisli210.txct, var.cisli210.txid, var.compnr, 	  
 	 	 	 	 	 	 	 	 	 var.tfacr200.docd, var.singular.tax, var.cisli209.pvat)  
 	 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 |MCR -  s 	 	 	 	 | #  ravi_array.so 	  
 	 | 	 	 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 	 	 |MCR -  e  
 	 | 	 	 	 	 	 	 	 update.fields.bcsci002.cisli206 (var.compnr, tfacr510.ityp,  
 	 | 	 	 	 	 	 	 	 tfacr510.idoc, var.cisli210.txct, var.cisli210.txid,  
 	 | 	 	 	 	 	 	 	 var.cisli210.txai, var.tfacr510.amnt,  
 	 	 	 	 	 	 	 	 |MCR -  s  
 	 	 	 	 	 	 	 	 |tfacr200.rate,  
 	 | 	 	 	 	 	 	 	 |tfacr200.ratf,  
 	 | 	 	 	 	 	 	 	 fill.mc.field.double(tfacr200.rate,i),  
 	 | 	 	 	 	 	 	 	 fill.mc.field.long(tfacr200.ratf,i),  
 	 	 	 	 	 	 	 	 |MCR -  e 	 	 	 	 	 	 	 	 	 	 	  
 	 | 	 	 	 	 	 	 	 tfacr510.ccur,  
 	 | 	 	 	 	 	 	 	 var.fin.comp.country, var.cisli206.itcy,  
 	 | 	 	 	 	 	 	 	 var.fin.comp.country,var.cisli206.itcy,"", "")                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
 	 	 	 	 	 	 	 |MCR -  s 	 	  
 	 | 	 	 	 	 	 	 endfor  
 	 	 	 	 	 	 	 |MCR -  e  
 	 	 	 	 	 	 	 	 	 	 	 	 | #  ravi_array.eo  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  207750.so  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  ravi_array.sn  
 | 	 	 	 	 	 	 	 	 update.tax.amounts.array(var.cisli210.txid, 	  
 | 	 	 	 	 	 	 	 	 	 	 var.cisli210.txai, var.tfacr510.amnt) 	  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  ravi_array.en  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  207750.eo  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  207750.sn  
 	 	 	 	 	 	 	 	 if update.tax.amounts.array(var.cisli210.txid, 	  
 	 	 	 	 	 	 	 	 	 	 var.cisli210.txai, var.tfacr510.amnt) then  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  207750.en  
 	 	 	 	 	 	 	 | *  MCR -  s 	 	 	 	 	 | #  ravi_cisli209.so  
 	 | 	 	 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 	 	 | *  MCR -  e 	 	 	 	 	 	 	 	 	 	 	 	  
 	 | 	 	 	 	 	 	 	 update.fields.bcsci002.cisli209 (var.cisli210.txai, tfacr510.ccur,  
 	 | 	 	 	 	 	 	 	 var.tfacr200.docd,var.cisli.rtyp,  
 	 	 	 	 	 	 	 	 | *  MCR -  s  
 	 	 	 	 	 	 	 	 |tfacr200.rate,  
 	 | 	 	 	 	 	 	 	 |tfacr200.ratf,  
 	 | 	 	 	 	 	 	 	 fill.mc.field.double(tfacr200.rate,i),  
 	 | 	 	 	 	 	 	 	 fill.mc.field.long(tfacr200.ratf,i),  
 	 	 	 	 	 	 	 	 | *  MCR -  e 	  
 	 | 	 	 	 	 	 	 	 var.cisli209.pvat, tcmcs036.ctau.l,tfacr510.ityp,  
 	 | 	 	 	 	 	 	 	 tfacr510.idoc, 1,var.compnr, tcmcs142.reas,tcmcs142.exno,  
 	 | 	 	 	 	 	 	 	 var.tfacr510.amnt)  
 	 	 	 	 	 	 	 |MCR -  s  
 	 | 	 	 	 	 	 	 endfor  
 	 	 	 	 	 	 	 |MCR -  e 	 	 	 	 	 | #  ravi_cisli209.eo  
 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 	 	 |ravi_cisli209.sn  
 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 update.row.in.cache.cisli209( 	 	 	 	  
 	 	 	 	 	 	 	 	 	 var.compnr,  
 	 	 	 	 	 	 	 	 	 tfacr510.ityp,  
 	 	 	 	 	 	 	 	 	 tfacr510.idoc,  
 	 	 	 	 	 	 	 	 	 tcmcs036.ctau.l,  
 	 	 	 	 	 	 	 	 	 var.cisli206.ceno,  
 	 	 	 	 	 	 	 	 	 var.cisli209.pvat,  
 	 	 	 	 	 	 	 	 	 var.cisli210.txai,  
 	 	 	 	 	 	 	 	 	 var.tfacr510.amnt,  
 	 	 	 	 	 	 	 	 	 var.cisli206.rcod,  
 	 	 	 	 	 	 	 	 	 tfacr510.ccur,  
 	 	 	 	 	 	 	 	 	 var.tfacr200.docd,  
 	 	 	 	 	 	 	 	 	 var.cisli.rtyp,  
 	 	 	 	 	 	 	 	 	 | *  MCR .s  
 	 	 	 	 	 	 	 	 	 |tfacr200.rate, 	  
 	 	 	 	 	 	 	 	 	 |tfacr200.ratf) 	  
 	 	 	 	 	 	 	 	 	 tmp.mc.tfacr200.rate,  
 	 	 	 	 	 	 	 	 	 tmp.mc.tfacr200.ratf)  
 	 	 	 	 	 	 	 	 	 | *  MCR .e  
 	 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 	 	 	 |ravi_cisli209.en  
 	 	 	 	 	 	 	 	 	 cisli209.dumped =  true 	 	 | #  207750.sn  
 	 	 	 	 	 	 	 else  
 	 	 	 	 	 	 	 	 	 cisli209.dumped =  false  
 	 	 	 	 	 	 	 endif 	 	 	 	 	 	 | #  207750.en  
 	 | 	 	 	 	 	 endif 	 	 	 	 | #  200 -  101240.o  
 	 	 	 	 	 endselect  
 	 	 	 	 endselect  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101240.sn  
 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	  
 	 	 	 else  
 	 	 	 	  
 	 	 	 	 select tfacr510.*   
 	 	 	 	 from tfacr510  
 	 	 	 	 where tfacr510._index1 =  {:prev.ttyp,  
 	 	 	 	 	 	 	 :prev.ninv,  
 	 	 	 	 	 	 	 :prev.line}  
 	 	 	 	 selectdo  
 	 	 	 	  
 	 	 	 	 	 select tfacr200.*   
 	 	 	 	 	 from tfacr200  
 	 	 	 	 	 where tfacr200._index1 =  {:tfacr510.ttyp,  
 	 	 	 	 	 	 	 	 :tfacr510.ninv,  
 	 	 	 	 	 	 	 	 :tfacr510.line,  
 	 	 	 	 	 	 	 	 :tfacr510.tdoc,  
 	 	 	 	 	 	 	 	 :tfacr510.docn,  
 	 	 	 	 	 	 	 	 :tfacr510.lino}  
 	 	 	 	 	 as set with 1 rows 	 	 	  
 	 	 	 	 	 selectdo  
 	 	 	  
 	 	 	 	 	 | *  MCR .sn  
 	 	 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 	 	 tmp.mc.tfacr200.rate(i) =  fill.mc.field.double(tfacr200.rate,i)  
 	 	 	 	 	 	 	 tmp.mc.tfacr200.ratf(i) =  fill.mc.field.long(tfacr200.ratf,i)  
 	 	 	 	 	 	 endfor  
 	 	 	 	 	 | *  MCR .en  
 	 	 	  
 	 	 	 	 	 var.tfacr510.cldt =  utc (tfacr200.docd,0,2) 	  
 | 	 	 	 	 	 var.tfacr510.icam = -  tfacr200.amnt 	 | #  200 -  101240.o  
 	 	 	 	 	 var.tfacr510.icam = -  tfacr200.amti 	 | #  200 -  101240.n  
 	 	 	 	 	 get.interest.percentage ()  
 	 	 	 	 	 get.rounding.code ()  
 	 	 	 	 	 var.tfacr510.amnt =  (var.tfacr510.icam *  tfacr510.days /  var.tfacr501.intsel) *  (var.tfacr510.iprc /  100)  
 	 	 	 	 if var.tfacr510.amnt <>  0.0 then  
 	 	 	 	 	 	 | *  MCR -  new changes .s 	 	 	 	 	  
 	 | 	 	 	 	 	 | *  MCR -  s  
 	 | 	 	 	 	 	 	 for i =  1 to 3 	  
 	 | 	 	 	 	 	 | *  MCR -  e 	  
 	 | 	 	 	 	 	 	 calculate.amount.in.other.currency (var.tfacr510.amnt,  
 	 | 	 	 	 	 	 	 	 | *  MCR -  s 	  
 	 | 	 	 	 	 	 	 	 |tfacr200.rate,  
 	 | 	 	 	 	 	 	 	 |tfacr200.ratf,  
 	 | 	 	 	 	 	 	 	 tmp.mc.tfacr200.rate(i),  
 	 | 	 	 	 	 	 	 	 tmp.mc.tfacr200.ratf(i),  
 	 | 	 	 	 	 	 	 	 | *  MCR -  e 	  
 	 | 	 	 	 	 	 	 	 tfacr510.ccur,  
 	 | 	 	 	 	 	 	 	 | *  MCR -  s 	 	  
 	 | 	 	 	 	 	 	 	 |var.tfacr510.amth,  
 	 | 	 	 	 	 	 	 	 var.tfacr510.amth(i),  
 	 | 	 	 	 	 	 	 	 | *  MCR -  e  
 	 | 	 	 	 	 	 	 	 err.mess)  
 	 | 	 	 	 	 	 	 | *  MCR -  s  
 	 | 	 	 	 	 	 	 endfor  
 	 | 	 	 	 	 	 	 | *  MCR -  e  
 	 	 	 	 	  
 	 	 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 	 	 calculate.amount.in.home.currency.variables (var.tfacr510.amnt, 	 	 	  
 	 	 	 	 	 	 tfacr510.ccur, 	 	 	 	 	  
 	 	 	 	 	 	 tmp.mc.tfacr200.rate(i),  
 	 	 	 	 	 	 tmp.mc.tfacr200.ratf(i),  
 	 	 	 	 	 	 i,  
 	 	 	 	 	 	 var.tfacr510.amth(i), 	 	 	 	 	 	 	  
 	 	 	 	 	 	 err.mess) 	 	  
 	 	 	 	 	 endfor 	 	 	 	 	 	  
 	 	 	 	 	 | *  MCR -  new changes .e 	 	 	 	 	 	  
 	 	 	 	 else  
 	 	 	 	 	 | *  MCR -  s 	 	 	 	 	  
 	 	 	 	 	 |var.tfacr510.amth =  0.0  
 	 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 	 var.tfacr510.amth(i) =  0.0  
 	 	 	 	 	 endfor  
 	 	 	 	 	 | *  MCR -  e  
 	 	 	 	 endif  
 	 	 	 	 	 var.sum.tfacr510.icam =  var.sum.tfacr510.icam +  var.tfacr510.icam  
 	 	 	 	 	 var.sum.tfacr510.amnt =  var.sum.tfacr510.amnt +  var.tfacr510.amnt  
 	 	 	 	 	 dump.tfacr510.lines ()  
 	 	 	 	 	 endselect  
 	 	 	 	 endselect  
 	 	 	 endif  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101240.en  
 	 	 	 	  
 	 	 	 	 if tfacr510.iist =  tfacr.iist.selected then  
 	 	 	 	 	 restore.pointer.tfacr200 ()  
 	 	 	 	 	 if var.sum.tfacr510.amnt <>  0.0 then  
 	 | *  MCR new changes .s 	 	 	 	  
 	 | 	 	 	 	 	 |MCR -  s  
 	 | 	 	 	 	 	 for i =  1 to 3  
 	 | 	 	 	 	 	 |MCR -  e  
 	 | 	 	 	 	 	 	 calculate.amount.in.other.currency (var.sum.tfacr510.amnt,  
 	 | 	 	 	 	 	 	 |MCR -  s  
 	 | 	 	 	 	 	 	 |tfacr200.rate,  
 	 | 	 	 	 	 	 	 |tfacr200.ratf,  
 	 | 	 	 	 	 	 	 fill.mc.field.double(tfacr200.rate,i),  
 	 | 	 	 	 	 	 	 fill.mc.field.long(tfacr200.ratf,i),  
 	 | 	 	 	 	 	 	 |MCR -  e  
 	 | 	 	 	 	 	 	 tfacr510.ccur,  
 	 | 	 	 	 	 	 	 |MCR -  s  
 	 | 	 	 	 	 	 	 |var.sum.tfacr510.amth,  
 	 | 	 	 	 	 	 	 var.sum.tfacr510.amth(i),  
 	 | 	 	 	 	 	 	 |MCR -  e  
 	 | 	 	 	 	 	 	 err.mess)  
 	 | 	 	 	 	 	 |MCR -  s  
 	 | 	 	 	 	 	 endfor  
 	 | 	 	 	 	 	 |MCR -  e  
 	 	 	 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 	 	 	 calculate.amount.in.home.currency.variables (var.sum.tfacr510.amnt, 	 	 	  
 	 	 	 	 	 	 	 tfacr510.ccur, 	 	 	 	 	  
 	 	 	 	 	 	 	 tmp.mc.tfacr200.rate(i),  
 	 	 	 	 	 	 	 tmp.mc.tfacr200.ratf(i),  
 	 	 	 	 	 	 	 i,  
 	 	 	 	 	 	 	 var.sum.tfacr510.amth(i), 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 	 	 	 endfor  
 	 | *  MCR new changes .e 	 	 	 	 	  
 	 	 	 	 	 else  
 	 	 	 	 	 	 | *  MCR -  s  
 	 	 	 	 	 	 | var.sum.tfacr510.amth =  0.0  
 	 	 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 	 	 var.sum.tfacr510.amth(i) =  0.0  
 	 	 	 	 	 	 endfor  
 	 	 	 	 	 	 | *  MCR -  e  
 	 	 	 	 	 endif  
 	 	 	 	 	 dump.header.record.tfacr510 ()  
 	 	 	 	 endif  
 	 	 else  
 	 	 	  
 	 	 	 sch.amnt.left =  sch.amnt (1) 	  
 	 	 	 sum.rec.amnt.paid =  0 	  
 	 	 	 tot.rec.amnt =  0  
 	 	 	 select tfacr200.*   
 	 	 	 from tfacr200  
 	 	 	 where tfacr200._index1 =  {:prev.ttyp,  
 	 	 	 	 	 	 :prev.ninv,  
 	 	 	 	 	 	 :prev.line}  
 	 	 	 and tfacr200.tdoc <>  ""                                                                                                                                                                                                                                                                                                                                                                                                                                   	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
 	 	 	 selectdo  
 	 	 	 	 tot.rec.amnt = -  (tfacr200.amti +   
 	 	 	 	 	 	 	 tfacr200.lapi +   
 	 	 	 	 	 	 	 tfacr200.dc1i +   
 	 	 	 	 	 	 	 tfacr200.padi)  
 	 	 	 	 	 	 	  
 	 	 	 	 select tfacr510.*   
 	 	 	 	 from tfacr510  
 	 	 	 	 where tfacr510._index1 =  {:tfacr200.ttyp,  
 	 	 	 	 	 	 	 :tfacr200.ninv,  
 	 	 	 	 	 	 	 :tfacr200.line,  
 	 	 	 	 	 	 	 :tfacr200.tdoc,  
 	 	 	 	 	 	 	 :tfacr200.docn,  
 	 	 	 	 	 	 	 :tfacr200.lino}  
 	 	 	 	 as set with 1 rows  
 	 	 	 	 selectdo 	 	 	 	 	 	 	 	 	  
 	 	 	 	 	  
 	 	 	 	 	 | *  These variables are used in the function no.schedule.amount.left()  
 	 	 	 	 	 | *  schedule.amount.left()  
 	 	 	 	 	 | *  MCR .sn  
 	 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 	 tmp.mc.tfacr200.rate(i) =  fill.mc.field.double(tfacr200.rate,i)  
 	 	 	 	 	 	 tmp.mc.tfacr200.ratf(i) =  fill.mc.field.long(tfacr200.ratf,i)  
 	 	 	 	 	 endfor 	 	 	 	  
 	 	 	 	 	 | *  MCR .en  
 	 	 	 	 	  
 	 	 	 	 	 test.count =  test.count +  1  
 	 	 	 	 	 check.rec =  0  
 	 	 	 	 	 check.for.records.based.on.schedule.date ()  
 	 	 	 	 	 for i =  1 to check.rec  
 	 	 	 	 	 	  
 	 	 	 	 	 	  
 	 	 	 	 	 	 if sum.rec.amnt.paid <>  0 then  
 	 	 	 	 	 	 	 sch.amnt.left =  sch.amnt.left -  sum.rec.amnt.paid  
 	 	 	 	 	 	 	 sum.rec.amnt.paid =  0 	  
 	 	 	 	 	 	 endif 	  
 	 	 	 	 	 	 if sch.amnt.left =  0 then  
 	 	 	 	 	 	 	 if no.schedule.amount.left () then  
 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 continue  
 	 	 	 	 	 	 	 else  
 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 break  
 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 endif  
 	 	 	 	 	 	  
 	 	 	 	 	 	 else  
 	 	 	 	 	 	 	 if schedule.amount.left () then  
 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 continue  
 	 	 	 	 	 	 	 else  
 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 break  
 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 endif 	 	 	 	 	  
 	 	 	 	 	 	 endif 	 	 	 	 	  
 	 	 	 	 	 endfor  
 	 	 	 	 selectempty 	 	 	 	 	 	 	 	 	 	 	 	  
 	 	 	 	 	 sum.rec.amnt.paid =  sum.rec.amnt.paid +  tot.rec.amnt  
 	 	 	 	 endselect  
 	 	 	 	  
 	 	 	 endselect  
 	 	 	 	 	 	  
 	 	 	  
 	 	 	 if tfacr510.iist =  tfacr.iist.selected then  
 	 	 	 	 if var.sum.tfacr510.amnt <>  0.0 then  
 	 | *  MCR . new changes .s 	 	 	  
 	 | 	 	 	 	 | *  MCR -  s  
 	 | 	 	 	 	 for i =  1 to 3  
 	 | 	 	 	 	 | *  MCR -  e  
 	 | 	 	 	 	 	 calculate.amount.in.other.currency (var.sum.tfacr510.amnt,  
 	 | 	 	 	 	 	 | *  MCR -  s  
 	 | 	 	 	 	 	 |tfacr200.rate,  
 	 | 	 	 	 	 	 |tfacr200.ratf,  
 	 | 	 	 	 	 	 fill.mc.field.double(tfacr200.rate,i),  
 	 | 	 	 	 	 	 fill.mc.field.long(tfacr200.ratf,i),  
 	 | 	 	 	 	 	 | *  MCR -  e  
 	 | 	 	 	 	 	 tfacr510.ccur,  
 	 | 	 	 	 	 	 | *  MCR -  s  
 	 | 	 	 	 	 	 |var.sum.tfacr510.amth,  
 	 | 	 	 	 	 	 var.sum.tfacr510.amth(i),  
 	 | 	 	 	 	 	 | *  MCR -  e  
 	 | 	 	 	 	 	 err.mess)  
 	 | 	 	 	 	 | *  MCR -  s  
 	 | 	 	 	 	 endfor  
 	 | 	 	 	 	 | *  MCR -  e  
 	 	 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 	 	 calculate.amount.in.home.currency.variables (var.sum.tfacr510.amnt, 	 	 	  
 	 	 	 	 	 	 tfacr510.ccur, 	 	 	 	 	  
 	 	 	 	 	 	 fill.mc.field.double(tfacr200.rate,i),  
 	 	 	 	 	 	 fill.mc.field.long(tfacr200.ratf,i),  
 	 	 	 	 	 	 i,  
 	 	 	 	 	 	 var.sum.tfacr510.amth(i), 	 	 	 	 	 	 	  
 	 	 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 	 	 endfor  
 	 | *  MCR . new changes .e 	 	 	 	  
 	 	 	 	 else  
 	 	 	 	 	 | *  MCR -  s  
 	 	 	 	 	 |var.sum.tfacr510.amth =  0.0  
 	 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 	 var.sum.tfacr510.amth(i) =  0.0  
 	 	 	 	 	 endfor  
 	 	 	 	 	 | *  MCR -  e  
 	 	 	 	 endif  
 	 	 	 	 dump.header.record.tfacr510 ()  
 	 	 	 endif 	  
 	 	 endif 	  
 	 	 restore.pointer.tfacr510 ()  
 	 	 if tfacr510.iist <>  tfacr.iist.selected then  
 	 	 	 check.for.records.with.different.invoice ()  
 	 	 	 if count.records =  cnt then  
 	 	 	 	 	 	 	 	  
 	 	 	 if tfacr510.iist =  tfacr.iist.posted then  
 	 	 	 	 var.cisli205.stat =  6  
 	 	 	 	 var.cisli205.brid =  1  
 	 	 	 else  
 	 	 	 	 var.cisli205.stat =  5  
 	 	 	 	 var.cisli205.brid =  2  
 	 	 	 endif  
 	 	 	 get.crnd (var.cisli205.ccur)  
 	 	 	 fill.lps.cisli205.interest ()  
 	 	 	 	 	 	 	 	 | #  200 -  102112.so 	  
 | 	 	 	 tax.on.lps =  calc.tax.amount (var.cisli210.txct, tfacr501.cvat,  
 	 	 	 	 	 	 	 	 | #  200 -  102112.eo  
 	 	 	 	 	 	 	 	 | #  200 -  102112.sn  
 	 	 	 tax.on.lps =  calculate.interest.tax.amount (var.cisli210.txct, tfacr501.cvat,  
 	 	 	 	 	 	 	 	 | #  200 -  102112.en 	 	 	 	 	 	 	 	  
 	 	 	 	 var.cisli205.scai, var.cisli205.ccur, date.num () ,  
 	 	 	 	 | *  MCR -  s  
 	 	 	 	 |var.cisli205.rate,  
 	 	 	 	 |var.cisli205.ratf,  
 	 	 	 	 var.cisli205.rate(1),  
 	 	 	 	 var.cisli205.ratf(1),  
 	 	 	 	 | *  MCR -  e  
 | 	 	 	 	 get.compnr () , tfacr510.cuno) | #  200 -  102112.o  
 	 	 	 	 get.compnr () , tfacr510.cuno,crnd.orno) | #  200 -  102112.n  
 	 	 	 total.tax =  old.tax.amti +  tax.on.lps  
 	 	 	 if total.tax <>  0.0 then  
 	 | *  MCR .new changes.s 	 	  
 	 | 	 	 	 | *  MCR -  s  
 	 | 	 	 	 for i =  1 to 3  
 	 | 	 	 	 | *  MCR -  e  
 	 | 	 	 	 	 calculate.amount.in.other.currency (total.tax,  
 	 | 	 	 	 	 	 	 	 | *  MCR -  s 	  
 	 | 	 	 	 	 	 	 	 |var.cisli205.rate,  
 	 | 	 	 	 	 	 	 	 |var.cisli205.ratf,  
 	 | 	 	 	 	 	 	 	 var.cisli205.rate(i),  
 	 | 	 	 	 	 	 	 	 var.cisli205.ratf(i),  
 	 | 	 	 	 	 	 	 	 | *  MCR -  e 	 	  
 	 | 	 	 	 	 	 	 	 var.cisli205.ccur,  
 	 | 	 	 	 	 	 	 	 | *  MCR -  s  
 	 | 	 	 	 	 	 	 	 |total.taxh,  
 	 | 	 	 	 	 	 	 	 total.taxh(i),  
 	 | 	 	 	 	 	 	 	 | *  MCR -  e  
 	 | 	 	 	 	 	 	 	 err.mess) 	  
 	 | 	 	 	 	 | *  MCR -  s  
 	 | 	 	 	 	 endfor  
 	 | 	 	 	 	 | *  MCR -  e  
 	 	 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 	 	 calculate.amount.in.home.currency.variables (total.tax, 	 	 	  
 	 	 	 	 	 	 var.cisli205.ccur, 	 	 	 	 	  
 	 	 	 	 	 	 var.cisli205.rate(i),  
 	 	 	 	 	 	 var.cisli205.ratf(i),  
 	 	 	 	 	 	 i,  
 	 	 	 	 	 	 total.taxh(i), 	 	 	 	 	 	 	  
 	 	 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 	 	 endfor  
 	 | *  MCR .new changes.e 	 	 	 	  
 	 	 	 else  
 	 	 	 	 | *  MCR -  s  
 	 	 	 	 |total.taxh =  0.0  
 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 total.taxh(i) =  0.0  
 	 	 	 	 endfor  
 	 	 	 	 | *  MCR -  e  
 	 	 	 endif 	 	  
 	 	 	 if var.cisli205.scai <>  0.0 then  
 	 | *  MCR .new changes.s 	 	 	  
 	 | 	 	 	 |MCR -  s  
 	 | 	 	 	 for i =  1 to 3  
 	 | 	 	 	 |MCR -  e  
 	 | 	 	 	 	 calculate.amount.in.other.currency (var.cisli205.scai,  
 	 | 	 	 	 	 	 |MCR -  s  
 	 | 	 	 	 	 	 |tfacr200.rate,  
 	 | 	 	 	 	 	 |tfacr200.ratf,  
 	 | 	 	 	 	 	 fill.mc.field.double(tfacr200.rate,i),  
 	 | 	 	 	 	 	 fill.mc.field.long(tfacr200.ratf,i),  
 	 | 	 	 	 	 	 |MCR -  e  
 	 | 	 	 	 	 	 var.cisli205.ccur,  
 	 | 	 	 	 	 	 |MCR -  s 	  
 	 | 	 	 	 	 	 |var.cisli205.scah,  
 	 | 	 	 	 	 	 var.cisli205.scah(i),  
 	 | 	 	 	 	 	 |MCR -  e  
 	 | 	 	 	 	 err.mess) 	 	  
 	 | 	 	 	 |MCR -  s  
 	 | 	 	 	 endfor  
 	 | 	 	 	 |MCR -  e  
 	 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 	 calculate.amount.in.home.currency.variables (var.cisli205.scai, 	 	 	  
 	 	 	 	 	 var.cisli205.ccur, 	 	 	 	 	  
 	 	 	 	 	 fill.mc.field.double(tfacr200.rate,i),  
 	 	 	 	 	 fill.mc.field.long(tfacr200.ratf,i),  
 	 	 	 	 	 i,  
 	 	 	 	 	 var.cisli205.scah(i), 	 	 	 	 	 	 	  
 	 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 	 endfor  
 	 | *  MCR .new changes.e 	 	 	  
 	 	 	 else  
 	 	 	 	 |MCR -  s  
 	 	 	 	 |var.cisli205.scah =  0.0  
 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 var.cisli205.scah(i) =  0.0  
 	 	 	 	 endfor 	 	  
 	 	 	 	 |MCR -  e 	  
 	 	 	 endif  
 	 	 	 itccom0016.calculate.discount.dates (date.num () ,  
 	 	 	 	 	 var.cisli210.cpay, var.cisli205.d1dt, var.cisli205.d2dt,  
 	 	 	 	 	 var.cisli205.d3dt)  
 	 	 	 itfcmg0007.calculate.discount (var.cisli210.cpay, old.net.amti +  old.tax.amti, old.tax.amti,  
 	 	 	 	 	 	 	 var.cisli205.ccur, tcmcs002.crnd,  
 	 	 	 	 	 	 	 var.cisli205.d1ai, var.cisli205.d2ai,  
 	 	 	 	 	 	 	 var.cisli205.d3ai) 	 	  
 	 	 	 if var.cisli205.d1ai <>  0.0 then  
 	 | *  MCR .new changes.s 	 	 	 	  
 	 | 	 	 	 | *  MCR -  s  
 	 | 	 	 	 for i =  1 to 3  
 	 | 	 	 	 | *  MCR -  e  
 	 | 	 	 	 	 calculate.amount.in.other.currency (var.cisli205.d1ai,  
 	 | 	 	 	 	 	 	 	 | *  MCR -  s  
 	 | 	 	 	 	 	 	 	 |var.cisli205.rate,  
 	 | 	 	 	 	 	 	 	 |var.cisli205.ratf,  
 	 | 	 	 	 	 	 	 	 var.cisli205.rate(i),  
 	 | 	 	 	 	 	 	 	 var.cisli205.ratf(i),  
 	 | 	 	 	 	 	 	 	 | *  MCR -  e  
 	 | 	 	 	 	 	 	 	 var.cisli205.ccur,  
 	 | 	 	 	 	 	 	 	 | *  MCR -  s  
 	 | 	 	 	 	 	 	 	 |var.cisli205.d1ah,  
 	 | 	 	 	 	 	 	 	 var.cisli205.d1ah(i),  
 	 | 	 	 	 	 	 	 	 | *  MCR -  e  
 	 | 	 	 	 	 	 	 	 err.mess)  
 	 | 	 	 	 	 | *  MCR -  s  
 	 | 	 	 	 	 endfor  
 	 | 	 	 	 	 | *  MCR -  e  
 	 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 	 calculate.amount.in.home.currency.variables (var.cisli205.d1ai, 	 	 	  
 	 	 	 	 	 var.cisli205.ccur, 	 	 	 	 	  
 	 	 	 	 	 var.cisli205.rate(i),  
 	 	 	 	 	 var.cisli205.ratf(i),  
 	 	 	 	 	 i,  
 	 	 	 	 	 var.cisli205.d1ah(i),  
 	 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 	 endfor  
 	 | *  MCR .new changes.e 	 	  
 	 	 	 else  
 	 	 	 	 | *  MCR -  s  
 	 	 	 	 |var.cisli205.d1ah =  0.0  
 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 var.cisli205.d1ah(i) =  0.0  
 	 	 	 	 endfor  
 	 	 	 	 | *  MCR -  e  
 	 	 	 endif  
 	 	 	 if var.cisli205.d2ai <>  0.0 then  
 	 | *  MCR .new changes.n 	 	  
 	 | 	 	 	 | *  MCR -  s  
 	 | 	 	 	 for i =  1 to 3  
 	 | 	 	 	 | *  MCR -  e  
 	 | 	 	 	 	 calculate.amount.in.other.currency (var.cisli205.d2ai,  
 	 | 	 	 	 	 	 	 | *  MCR -  s  
 	 | 	 	 	 	 	 	 |var.cisli205.rate,  
 	 | 	 	 	 	 	 	 |var.cisli205.ratf,  
 	 | 	 	 	 	 	 	 var.cisli205.rate(i),  
 	 | 	 	 	 	 	 	 var.cisli205.ratf(i),  
 	 | 	 	 	 	 	 	 | *  MCR -  e  
 	 | 	 	 	 	 	 	 var.cisli205.ccur,  
 	 | 	 	 	 	 	 	 | *  MCR -  s  
 	 | 	 	 	 	 	 	 |var.cisli205.d2ah,  
 	 | 	 	 	 	 	 	 var.cisli205.d2ah(i),  
 	 | 	 	 	 	 	 	 | *  MCR -  e 	 	 	 	 	 	 	  
 	 | 	 	 	 	 	 	 err.mess)  
 	 | 	 	 	 	 | *  MCR -  s  
 	 | 	 	 	 	 endfor  
 	 | 	 	 	 	 | *  MCR -  e  
 	 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 	 calculate.amount.in.home.currency.variables (var.cisli205.d2ai, 	 	 	  
 	 	 	 	 	 var.cisli205.ccur, 	 	 	 	 	  
 	 	 	 	 	 var.cisli205.rate(i),  
 	 	 	 	 	 var.cisli205.ratf(i),  
 	 	 	 	 	 i,  
 	 	 	 	 	 var.cisli205.d2ah(i),  
 	 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 	 endfor  
 	 | *  MCR .new changes.e 	 	  
 	 	 	 else  
 	 	 	 	 | *  MCR -  s  
 	 	 	 	 |var.cisli205.d2ah =  0.0  
 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 var.cisli205.d2ah(i) =  0.0  
 	 	 	 	 endfor  
 	 	 	 	 | *  MCR -  s  
 	 	 	 endif  
 	 	 	 if var.cisli205.d3ai <>  0.0 then  
 	 | *  MCR .new changes.n 	 	 	  
 	 | 	 	 	 | *  MCR -  s  
 	 | 	 	 	 for i =  1 to 3  
 	 | 	 	 	 | *  MCR -  e  
 	 | 	 	 	 	 calculate.amount.in.other.currency (var.cisli205.d3ai,  
 	 | 	 	 	 	 	 	 | *  MCR -  s  
 	 | 	 	 	 	 	 	 |var.cisli205.rate,  
 	 | 	 	 	 	 	 	 |var.cisli205.ratf,  
 	 | 	 	 	 	 	 	 var.cisli205.rate(i),  
 	 | 	 	 	 	 	 	 var.cisli205.ratf(i),  
 	 | 	 	 	 	 	 	 | *  MCR -  e  
 	 | 	 	 	 	 	 	 var.cisli205.ccur,  
 	 | 	 	 	 	 	 	 | *  MCR -  s 	 	  
 	 | 	 	 	 	 	 	 |var.cisli205.d3ah,  
 	 | 	 	 	 	 	 	 var.cisli205.d3ah(i),  
 	 | 	 	 	 	 	 	 | *  MCR -  e  
 	 | 	 	 	 	 	 	 err.mess)  
 	 | 	 	 	 	 | *  MCR -  s  
 	 | 	 	 	 	 endfor  
 	 | 	 	 	 	 | *  MCR -  e  
 	 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 	 calculate.amount.in.home.currency.variables (var.cisli205.d3ai, 	 	 	  
 	 	 	 	 	 var.cisli205.ccur, 	 	 	 	 	  
 	 	 	 	 	 var.cisli205.rate(i),  
 	 	 	 	 	 var.cisli205.ratf(i),  
 	 	 	 	 	 i,  
 	 	 	 	 	 var.cisli205.d3ah(i),  
 	 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 	 endfor  
 	 | *  MCR .new changes.e 	 	  
 	 	 	 else  
 	 	 	 	 | *  MCR -  s  
 	 	 	 	 |var.cisli205.d3ah =  0.0  
 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 var.cisli205.d3ah(i) =  0.0  
 	 	 	 	 endfor  
 	 	 	 	 | *  MCR -  e  
 	 	 	 endif 	  
 	 	 	  
 	 	 	 | *  MCR -  sn  
 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 tmp.mc.cisli205.amth(i) =  (old.net.amth(i) +  total.taxh(i) +  var.cisli205.scah(i))  
 	 	 	 	 endfor 	  
 	 	 	 | *  MCR -  en  
 	 	 	  
 	 	 	 	 fill.cisli205.fields (var.compnr,tfacr510.ityp, tfacr510.idoc,var.cisli205.brid,var.cisli205.stat,  
 	 	 	 	 var.tfacr510.itbp, var.cisli210.itoa, var.fin.cofc,  
 	 	 	 	 var.cisli210.ccrs, var.cisli210.cpay, var.cisli210.txct,6,no.of.records,0,0,0,0,0, var.cisli205.ccur,var.tfacr200.docd ,  
 	 	 	 	 (old.net.amti +  total.tax +  var.cisli205.scai) ,  
 	 	 	 	 |(old.net.amth +  total.taxh +  var.cisli205.scah) , | *  MCR .o  
 	 	 	 	 tmp.mc.cisli205.amth, | *  MCR .n  
 	 	 	 	 total.tax,  
 	 	 	 	 total.taxh, 	 	 	  
 	 	 	 	 old.shift.amti,  
 	 	 	 	 old.shift.amth, 	 	 	  
 	 	 	 	 var.cisli205.rate,  
 	 	 	 	 var.cisli205.ratf, 	 	 	  
 	 	 	 	 var.cisli205.scdt, var.cisli205.scai,  
 	 	 	 	 var.cisli205.scah, 	 	 	  
 	 	 	 	 0.0,  
 	 	 	 	 0.0,old.net.amti, var.cisli205.d1ai,  
 	 	 	 	 var.cisli205.d1ah, 	 	 	  
 	 	 	 	 	 var.cisli205.d1dt, var.cisli205.d2ai,  
 	 	 	 	 var.cisli205.d2ah, 	 	 	  
 	 	 	 	 var.cisli205.d2dt,var.cisli205.d3ai,  
 	 	 	 	 var.cisli205.d3ah, 	 	 	  
 	 	 	 	 var.cisli205.d3dt, var.cisli210.paym, 0,0.0,  
 | 	 	 	 	 old.net.amti +  var.cisli205.scai) 	 	 | #  200 -  101927.o  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.sn  
 | 	 	 	 	 old.net.amti +  var.cisli205.scai, target(cisli.doct.invoice)) | #  jyosh.o  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en  
 	 	 	 	 old.net.amti +  var.cisli205.scai, target(cisli.doct.invoice), new.bpct) | #  jyosh.n 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	  
 	 	 	 dump.cisli205 ()  
 	 	 	 reset.variables ()  
 | 	 	 	 reset.variables.cisli205 () 	 	 | #  207750.o  
 	 	 	 	 	 	 	 	 | #  ravi_array.sn  
 	 	 	 	 dump.fields.cisli206.from.array( 	  
 	 	 	 	 	 var.compnr, tfacr510.ityp,  
 	 	 	 	 	 tfacr510.idoc, var.cisli210.txct,  
 	 	 	 	 	 var.cisli205.rate, var.cisli205.ratf,  
 	 	 	 	 	 var.cisli205.ccur, var.fin.comp.country,  
 	 	 	 	 	 var.cisli206.stcy, var.fin.comp.country,  
 	 	 	 	 	 var.cisli206.itcy,"", "")                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
 	 	 	 	 	 	 	 	 | #  ravi_array.en  
 	 	 	 	 	 	 	 	 | #  207750.so  
 	 	 	 	 	 	 	 	 | #  ravi_cisli209.sn  
 | 	 	 	 	 dump.records.from.cache.cisli209() 	 	  
 | 	 	 	 	 cisli209.dumped =  true 	 	  
 	 	 	 	 	 	 	 	 | #  ravi_cisli209.en  
 	 	 	 	 	 	 	 	 | #  207750.eo  
 	 	 	 	 if cisli209.dumped =  true then | #  207750.sn  
 	 	 	 	 	 dump.records.from.cache.cisli209()  
 	 	 	 	 endif 	 	 	 	 	  
 	 	 	 	 reset.variables.cisli205 () 	 	 | #  207750.en  
 	 	 	 	 	 if (total.records >=  20000 and |haddock.err.sn  
 	 	 	 	 	 	 tppin190.accessed and 	  
 	 	 	 	 	 	 cisli209.dumped ) then  
 	 	 	 	 	 	 	 reinitialize.cache()  
 	 	 	 	 	 endif 	 	 	 	 |haddock.err.en  
 	 	 endif  
 	 	 endif 	  
 | 	 	 endif 	 	 	 	 | #  200 -  101240.o  
 	 	 	 	 	 	 	  
 	 endif 	 	 	 	 	 	 | #  200 -  101240.n  
 	  
 	 	 	 	 	 	 	  
 	 	 free.memories() 	 	 	 	 |ravi_array.n  
 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:tf
:SCMOD:acr
:SFLNO:510
:ICOD:S
:QURY:START
select tfacr510.*
from tfacr510
order by tfacr510._index3
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:tf
:SCMOD:acr
:SFLNO:510
:ICOD:X
:QURY:START
	 reset.variables.cisli205 ()  
 	 interest.invoice =  0  
 	 first.time =  true 	  
 	 prev.ttyp =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
 	 prev.ninv =  0  
 	 hold.ityp =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
 	 hold.idoc =  0  
 	 | dump.cisli206 () 	 	 	 	 | #  ravi_array_so  
 	 | delete.bcsci002.records.cisli206 ()  
 	 | dump.cisli209 ()  
 	 | delete.bcsci002.records.cisli209 () 	 	 | #  ravi_array.eo
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:tp
:SCMOD:pin
:SFLNO:100
:ICOD:D
:QURY:START
insert.records.bcstp001 (tppin120.cprj,tppin120.cuno,tppin120.stin,tppin120.ninv)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:tp
:SCMOD:pin
:SFLNO:100
:ICOD:S
:QURY:START
select 	 tppin120.*  , tppin100.cprj
from tppin120, tppin100
where tppin120.stin =  tppdm.stin.final and  
 	 tppin100._index1 =  {tppin120.stin,tppin120.ninv} and  
 	 tppin100.cfpo =  tppdm.yeno.yes and  
 	 tppin100.post =  tppdm.yeno.yes
order by tppin120.cprj,tppin120.cuno
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:tp
:SCMOD:pin
:SFLNO:100
:ICOD:X
:QURY:START
select 	 tppin130.*  , tppin100.cprj  
 from 	 tppin130, tppin100  
 where 	 tppin130.stin =  tppdm.stin.final and  
 	 tppin100._index1 =  {tppin130.stin,tppin130.ninv} and  
 	 tppin100.cfpo =  tppdm.yeno.yes and  
 	 tppin100.post =  tppdm.yeno.yes  
 order by tppin130.cprj,tppin130.cuno  
 selectdo  
 	 insert.records.bcstp001 ( tppin130.cprj,tppin130.cuno,tppin130.stin,tppin130.ninv )  
 endselect  
 select 	 tppin140.*  , tppin100.cprj  
 from 	 tppin140, tppin100  
 where 	 tppin140.stin =  tppdm.stin.final and  
 	 tppin100._index1 =  {tppin140.stin,tppin140.ninv} and  
 	 tppin100.cfpo =  tppdm.yeno.yes and  
 	 tppin100.post =  tppdm.yeno.yes  
 order by tppin140.cprj,tppin140.cuno  
 selectdo  
 	 insert.records.bcstp001 ( tppin140.cprj,tppin140.cuno,tppin140.stin,tppin140.ninv )  
 endselect  
 select 	 tppin150.*  , tppin100.cprj  
 from 	 tppin150, tppin100  
 where 	 tppin150.stin =  tppdm.stin.final and  
 	 tppin100._index1 =  {tppin150.stin,tppin150.ninv} and  
 	 tppin100.cfpo =  tppdm.yeno.yes and  
 	 tppin100.post =  tppdm.yeno.yes  
 order by tppin150.cprj,tppin150.cuno  
 selectdo  
 	 insert.records.bcstp001 ( tppin150.cprj,tppin150.cuno,tppin150.stin,tppin150.ninv )  
 endselect  
 select 	 tppin160.*  , tppin100.cprj  
 from 	 tppin160, tppin100  
 where 	 tppin160.stin =  tppdm.stin.final and  
 	 tppin100._index1 =  {tppin160.stin,tppin160.ninv} and  
 	 tppin100.cfpo =  tppdm.yeno.yes and  
 	 tppin100.post =  tppdm.yeno.yes  
 order by tppin160.cprj,tppin160.cuno  
 selectdo  
 	 insert.records.bcstp001 ( tppin160.cprj,tppin160.cuno,tppin160.stin,tppin160.ninv )  
 endselect  
 select 	 tppin170.*  , tppin100.cprj  
 from 	 tppin170, tppin100  
 where 	 tppin170.stin =  tppdm.stin.final and  
 	 tppin100._index1 =  {tppin170.stin,tppin170.ninv} and  
 	 tppin100.cfpo =  tppdm.yeno.yes and  
 	 tppin100.post =  tppdm.yeno.yes  
 order by tppin170.cprj,tppin170.cuno  
 selectdo  
 	 insert.records.bcstp001 ( tppin170.cprj,tppin170.cuno,tppin170.stin,tppin170.ninv )  
 endselect  
 select 	 tppin180.*  , tppin100.cprj  
 from 	 tppin180, tppin100  
 where 	 tppin180.stin =  tppdm.stin.final and  
 	 tppin100._index1 =  {tppin180.stin,tppin180.ninv} and  
 	 tppin100.cfpo =  tppdm.yeno.yes and  
 	 tppin100.post =  tppdm.yeno.yes  
 order by tppin180.cprj,tppin180.cuno  
 selectdo  
 	 insert.records.bcstp001 ( tppin180.cprj,tppin180.cuno,tppin180.stin,tppin180.ninv )  
 endselect  
 select 	 tppin190.*  , tppin100.cprj  
 from 	 tppin190, tppin100  
 where 	 tppin190.stin =  tppdm.stin.final and  
 	 tppin100._index1 =  {tppin190.stin,tppin190.ninv} and  
 	 tppin100.cfpo =  tppdm.yeno.yes and  
 	 tppin100.post =  tppdm.yeno.yes  
 order by tppin190.cprj,tppin190.cuno  
 selectdo  
 	 insert.records.bcstp001 ( tppin190.cprj,tppin190.cuno,tppin190.stin,tppin190.ninv )  
 endselect  
 hold.invn =  0  
 | Dumping into table cisli230,cisli235,cisli236  
 select 	 tppin100.*  , tppdm600.pcba, bcstp001.*   
 from tppin100, tppdm600, bcstp001  
 where tppin100.stin =  tppdm.stin.final and  
 	 tppin100.cfpo =  tppdm.yeno.yes and  
 	 tppin100.post =  tppdm.yeno.yes and  
 	 tppin100._index1 =  {bcstp001.stin,bcstp001.ninv} and  
 	 tppdm600._index1 =  {bcstp001.cprj}  
 order by tppin100.cprj,tppin100.cuno,bcstp001.ninv  
 selectdo  
 	 famn =  round.amnt.itpdround (( tppin100.amoi -  tppin100.amdi -  tppin100.amdl +  tppin100.csqz ) ,tppin100.ccur,TP_PDM_AALC )  
 	 if famn <  0 then  
 	 	 invoice.transaction.type =  tpprc000.ttsc  
 	 else  
 	 	 invoice.transaction.type =  tpprc000.ttys  
 	 endif  
 	 record.found =  true  
 	 select tfacr200.*   
 	 from tfacr200  
 	 where tfacr200._index1 =  { :invoice.transaction.type, :tppin100.ninv, 0}  
 	 and tfacr200.trec =  tfacr.trec.invoice  
 	 as set with 1 rows  
 	 selectdo  
 	 selectempty  
 	 	 record.found =  false  
 	 endselect 	 	  
 	 if record.found =  false then  
 	 	 continue  
 	 endif  
 	 initialize.variables ()  
 	 get.business.partner ( bcstp001.cuno,bcstc.orgn.cuno,err.mess )  
 	 get.enterprise.unit ( tppin100.ocmp,ext.lng.comp,err.mess )  
 	 get.invoice.to.address.proj.customer ( tppin100.cuno )  
 	 var.cisli230.itoa =  var.tccom110.cadr  
 	 get.addresses ( "tccom000", edit$  (  ext.lng.comp,"999"  )  , err.mess  )                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
 	 var.cisli230.oaad =  bcstc004.cadr  
 	 var.cisli230.pcba =  tppdm600.pcba  
 	 get.financial.company.country ( tppin100.ocmp ) 	 	 	 | #  ravi.n  
 	  
 	 var.cisli230.paym =  tfacr200.paym  
 	 if not isspace ( tfacr200.crep ) then  
 	 	 var.cisli230.crep =  format.emno ( tfacr200.crep )  
 	 else  
 	 	 var.cisli230.crep =  " "  
 	 endif 	  
 dump.cisli230 ()  
 	 	  
 	 | *  Dump cisli235  
 	 dump.advance.payment.records ()  
 	 dump.installment.records ()  
 	 dump.cost.plus.records ()  
 	 dump.extension.records ()  
 	 dump.unit.rate.records ()  
 	  
 | 	 	 if hold.invn <>  bcstp001.ninv then 	 	 	 	 | #  ravi_array.so  
 	 	  
 | 	 	 	 hold.invn =  bcstp001.ninv  
 | 	 	 for i =  1 to 3 | *  MCR  
 | 	 	 	 fill.cisli205.fields ( tppin100.ocmp,tfacr200.ttyp, tfacr200.ninv,1,6,  
 | 	 	 	 bcstc008.bpid, bcstc004.cadr, bcstc018.sofd,  
 | 	 	 	 tfacr200.ccrs, tfacr200.cpay, new.txct,6,0,0,no.of.records,0,0,0, tfacr200.ccur,tfacr200.docd,  
 | 	 	 	 tfacr200.amti , tfacr200.amth, tfacr200.vati ,  
 	 	 	 |tfacr200.vath ,  
 | 	 	 	 fill.mc.field.double(tfacr200.vath,i) | *  MCR  
 | 	 	 	 tfacr200.svam ,  
 	 	 	 |tfacr200.svah ,  
 | 	 	 	 fill.mc.field.double(tfacr200.svah, i) | *  MCR  
 	 	 	 |tfacr200.rate,  
 	 	 	 |tfacr200.ratf,  
 | 	 	 	 fill.mc.field.double(tfacr200.rate,i), | *  MCR  
 | 	 	 	 fill.mc.field.long(tfacr200.ratf,i), | *  MCR  
 | 	 	 	 tfacr200.lpdt, tfacr200.lapa ,  
 	 	 	 |tfacr200.laph ,  
 | 	 	 	 fill.mc.field.double(tfacr200.laph,i), | *  MCR  
 | 	 	 	 0.0, 0.0,var.cisli205.rmai, tfacr200.dc1i ,  
 	 	 	 |tfacr200.dc1h ,  
 | 	 	 	 fill.mc.field.double(tfacr200.dc1h,i), | *  MCR  
 | 	 	 	 tfacr200.did1, tfacr200.dc2i ,  
 	 	 	 |tfacr200.dc2h ,  
 | 	 	 	 fill.mc.field.double(tfacr200.dc2h,i), | *  MCR  
 | 	 	 	 tfacr200.did2,tfacr200.dc3i ,  
 	 	 	 |tfacr200.dc3h ,  
 | 	 	 	 fill.mc.field.double(tfacr200.dc3h,i), | *  MCR  
 | 	 	 	 tfacr200.did3, tfacr200.paym, 0,  
 | 	 	 	 var.cisli205.dcai,tfacr200.amti -  tfacr200.vati,  
 	 	 	 | *  MCR  
 | 	 	 	 i )  
 | 	 	 endfor | *  MCR  
 | 	 	 dump.cisli205 ()  
 | 	 	 reset.variables.cisli205 ()  
 | 	 	 endif 	 	 	 	 	 	 | #  ravi_array.eo  
 	  
 endselect  
 dump.records.for.cisli206.cisli209.projects() 	 	 	 | #  ravi_array.n  
 | reset.variables.cisli205 () 	 	 	 	 	 | #  ravi_array.so  
 | dump.cisli206 ()  
 | delete.bcsci002.records.cisli206 ()  
 | dump.cisli209 ()  
 | delete.bcsci002.records.cisli209 ()  
 | hold.invn =  0 	 	 	 	 	 	 | #  ravi_array.eo  
 select 	 bcstp001.*   
 from 	 bcstp001 for update  
 selectdo  
 	 db.delete ( tbcstp001,db.retry )  
 	 commit.transaction ()  
 endselect  
 order.count =  0
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:ts
:SCMOD:sma
:SFLNO:220
:ICOD:D
:QURY:START
|initialize.variables () 	 	 	 | #  200285.o  
 	 fill.cutoff.date ()  
 | store.index.fields.service.contracts () 	 	 	 	 	 |binda25 -  06.o  
 	 initialize.variables ()  
 	 initialize.cisli206.variables ()  
 	 if (prev.tran1 <>  tssma611.ttyp or prev.invn1 <>  tssma611.invn) then 	 | #  ravi_array.sn  
 	 	 prev.tran1 =  tssma611.ttyp  
 	 	 prev.invn1 =  tssma611.invn  
 	 	 prev.ncmp1 =  tssma611.ncmp 	  
 	 	 allocate.memories(tssma611.ccty) 	 	  
 	 endif 	 	 	 	 	 	 	 | #  ravi_array.en  
 	 	 	 	 	 	 	 	 |binda24 -  07.so  
 | 	 order.count =  order.count +  1  
 | 	 alloc.mem (servcont.array,10,order.count)  
 | 	 if servcont.array (1, order.count) =  empty.string (1;10) then  
 | 	 	 servcont.array (1, order.count) =  tssma221.ccon  
 | 	 endif  
 	  
 | 	 header.dumped =  false  
 | 	 for counter1 =  1 to order.count -  1  
 | 	 	 if tssma221.ccon =  servcont.array (1, counter1) then  
 | 	 	 	 header.dumped =  true  
 | 	 	 	 break  
 | 	 	 endif  
 | 	 endfor  
 	 	 	 	 	 	 	 	 |binda24 -  07.eo  
 	 	 	 	 	 	 	 	 |binda24 -  07.sn  
 	 	 header.dumped =  false  
 | 	 	 if order.count >  0 and tssma221.ccon =  servcont.array(order.count) then 	 | #  200 -  101734.o  
 	 	 	 	 	 	 	 	 | #  200285.so  
 | 	 	 if order.count >  0 and tssma221.ccon =  strip$(servcont.array(order.count)) then | #  200 -  101734.n  
 	 	 	 	 	 	 	 	 | #  200285.eo  
 	 	 	 	 	 	 	 	 | #  200285.sn  
 	 	 if order.count >  0 and tssma221.ccon =  strip$(servcont.array(1,order.count;10)) then 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 | #  200285.en  
 	 	 	 | record is found  
 	 	 	 header.dumped =  true  
 	 	 else  
 	 	 	 |WR PERF search record  
 	 	 	 if order.count >  0 then  
 	 	 	 	 ret =  0  
 	 	 	 	 	 	 	 	 | #  200285.so  
 | 	 	 	 	 if tssma221.ccon >  servcont.array(order.count) or |new value larger than last value in array  
 | 	 	 	 	 tssma221.ccon <  servcont.array(1) then |new value smaller than first value in array  
 	 	 	 	 	 	 	 	 | #  200285.eo  
 	 	 	 	 	 	 	 	 | #  200285.sn 	 	  
 	 	 	 	 if tssma221.ccon >  servcont.array(1, order.count;10) or |new value larger than last value in array  
 	 	 	 	 tssma221.ccon <  servcont.array(1, 1;10) then 	 |new value smaller than first value in array  
 	 	 	 	 	 	 	 	 | #  200285.en  
 	 	 	 	 	 	 	 	  
 	 	 	 	 	 | not found  
 	 	 	 	 else  
 	 	 	 	 	 | do a binary search  
 	 	 	 	 	  
 	 	 	 	 	 ret =  qss.search(QSS.SRC.IS.SORTED +  QSS.EQUAL,  
 	 	 	 	 	 tssma221.ccon,servcont.array,sort_def,order.count)  
 	 	 	 	 	  
 	 	 	 	 endif  
 	 	 	 endif  
 	 	  
 	 	 	 |WR PERF insert record  
 	 	 	 if ret >  0 then  
 	 	 	 	 | record is found, do not insert again  
 	 	 	 	 header.dumped =  true  
 	 	 	 else  
 	 	 	 	 order.count =  order.count +  1  
 	  
 	 	 	 	 if order.count >  array.length then 	 	 |WR PERF allocate memory per 1000 records  
 	 	 	 	 	  
 	 	 	 	 	 array.length =  array.length +  1000  
 	 	 	 	 	 	 	 	 | #  200285.so  
 | 	 	 	 	 	 alloc.mem (servcont.array,array.length)  
 	 	 	 	 	 	 	 	 | #  200285.eo  
 	 	 	 	 	 	 	 	 | #  200285.sn 	 	 	  
 	 	 	 	 	 alloc.mem (servcont.array,13 ,array.length) 	 	 	  
 	 	 	 	 	 	 	 	 | #  200285.en  
 	 	 	 	 	  
 	 	 	 	 endif  
 	 	 	 	 |insert orno  
 	 	 	 	 	 	 	 	 | #  200285.so  
 | 	 	 	 	 servcont.array(order.count) =  tssma221.ccon  
 	 	 	 	 	 	 	 	 | #  200285.eo  
 	 	 	 	 	 	 	 	 | #  200285.sn  
 	 	 	 	 servcont.array(1, order.count;10) =  tssma221.ccon  
 	 	 	 	 servcont.array(11, order.count) =  "000"                                                                                                                                                                                                                                                                                   
 	 	 	 	 	 	 	 	 | #  200285.en 	 	 	 	 	 	  
 	 	 	  
 	 	 	 	 |sort array only if last inserted record is smaller than the previous  
 	 	 	 	 	 	 	 	 | #  200285.so  
 | 	 	 	 	 if order.count >  1 and servcont.array(order.count) <  servcont.array(order.count -  1) then  
 	 	 	 	 	 	 	 	 | #  200285.eo  
 	 	 	 	 	 	 	 	 | #  200285.sn  
 	 	 	 	 if order.count >  1 and servcont.array(1, order.count;10) <  servcont.array(1, order.count -  1;10) then 	 	 	 	  
 	 	 	 	 	 	 	 	 | #  200285.en 	  
 	 	 	 	 	 qss.sort(servcont.array,sort_def,order.count)  
 	 	 	 	 	  
 	 	 	 	 endif  
 	 	  
 	 	 	 endif  
 	 	 endif  
 	 	 |WR PERF end  
 	 	 	 	 	 	 	 	 |binda24 -  07.en  
 	 fill.contract ()  
 	 var.cisli260.cofc =  get.department ()  
 	 fill.business.partner ()  
 	 fill.addresses () 	 	  
 	 fill.customer.related.fields ()  
 	 if header.dumped =  false then  
 	 	 hold.ccon =  tssma220.ccon  
 	 	  
 	 	 dump.cisli260 ()  
 	 endif  
 	 fill.addresses ()  
 	 	 	 	 	 	 	 | #  200285.so  
 | 	 if strip$ (shiftl$ (var.str.prev.ccon)) =  strip$ (shiftl$ (var.cisli260.csco)) then  
 | 	 	 var.cisli265.seqn =  var.cisli265.seqn +  10  
 | 	 else  
 | 	 	 var.cisli265.seqn =  10  
 | 	 endif  
 | 	 var.str.prev.ccon =  var.cisli260.csco  
 	 	 	 	 	 	 	 | #  200285.eo  
 	 	 	 	 	 	 	 | #  200285.sn 	  
 	 ret =  qss.search(QSS.SRC.IS.SORTED +  QSS.EQUAL,tssma221.ccon, 	 	  
 	 	 servcont.array,sort_def,order.count) 	 	 	 	 	  
 	 	 var.cisli265.seqn =  lval(servcont.array(11, ret;3)) +  10 	 	 	  
 	 	 servcont.array(11, ret) =  edit$(var.cisli265.seqn, "999")                                                                                                                                          	                                                                                                                                                                                                                                                                                    	                                                                                                                                                                                                                                                                                    	                                                                                                                                                                                                                                                                                                                                                                                                                              
 	 	 	 	 	 	 	 | #  200285.en  
 	 fill.cisli265.fields ()  
 	 dump.cisli265 ()  
 	 cisli209.dumped =  false 	 	 	 	 	 | ravi_cisli209.n 	 	 	 	 	 	  
 	 get.financial.company.country (tssma611.ncmp)  
 | 	 for i =  1 to 3 | *  MCR 	 	 	 	 	 	 | #  ravi_array.so  
 | 	 	 update.fields.bcsci002.cisli206 (tssma611.ncmp, tssma611.ttyp, tssma611.invn,  
 | 	 	 new.txct, new.txid,  
 | 	 	 var.cisli265.txai, var.cisli265.amti,  
 	 	 | *  MCR -  s  
 	 	 |tssma611.rats,  
 	 	 |tssma611.ratf,  
 | 	 	 fill.mc.field.double(tssma611.rats,i),  
 | 	 	 fill.mc.field.long(tssma611.ratf,i),  
 	 	 | *  MCR -  e  
 | 	 	 tssma611.ccur,  
 | 	 	 var.fin.comp.country, var.cisli206.stcy,  
 | 	 	 var.fin.comp.country,var.cisli206.itcy,"", "")                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
 | 	 endfor | *  MCR 	 	 	 	 	 	 | #  ravi_array.eo  
 | 	 if not isspace (new.txct) then 	 	 	 	 |ravi_july28th.so  
 | 	 	 read.tcmcs032 (new.txct, new.txid,tssma611.invd)  
 | 	 	 read.tcmcs036 (new.txct, new.txid) 	  
 | 	 endif 	 	 	 	 	 	 	 |ravi_july28th.eo  
 | 	 if not isspace (tssma611.cuno) then 	 	 	 	 | #  ravi_array.so  
 | 	 	 read.tcmcs142 (tssma611.cuno, tcmcs036.ctau.l, tssma611.invd)  
 | 	 endif 	 	 	 	 	 	 	 	 | #  ravi_array.eo  
 | 	 get.tax.percentage (new.txct, new.txid, var.compnr, 	 |ravi_july28th.so  
 | 	 	 	 	 	 tssma611.invd, var.singular.tax, var.cisli209.pvat)  
 	 	 	 	 	 	 	 	 |ravi_july28th.eo  
 | 	 for i =  1 to 3 | *  MCR 	 	 	 	 	 	 | #  ravi_cisli209.so  
 | 	 	 update.fields.bcsci002.cisli209 (  
 | 	 	 	 var.cisli265.txai,  
 | 	 	 	 tssma611.ccur,  
 | 	 	 	 tssma611.invd,  
 | 	 	 	 var.cisli.rtyp,  
 	 	 	 | *  MCR -  s  
 	 	 	 |tssma611.rats,  
 	 	 	 |tssma611.ratf,  
 | 	 	 	 fill.mc.field.double(tssma611.rats,i),  
 | 	 	 	 fill.mc.field.long(tssma611.ratf,i),  
 	 	 	 | *  MCR -  e  
 | 	 	 	 var.cisli209.pvat,  
 | 	 	 	 tcmcs036.ctau.l,  
 | 	 	 	 tssma611.ttyp,  
 | 	 	 	 tssma611.invn,  
 | 	 	 	 1,  
 | 	 	 	 tssma611.ncmp, 	  
 | 	 	 	 tcmcs142.reas,  
 | 	 	 	 tcmcs142.exno,  
 | 	 	 	 var.cisli265.amti) 	 	 	 	 | #  ravi_cisli209.eo  
 	 	 	 	 	 	 	 |ravi_cisli209.sn  
 	 	 	 	 	 	 	  
 	 	 	 	 | *  MCR -  sn  
 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 tmp.mc.tssma611.rats(i) =  fill.mc.field.double(tssma611.rats,i,0.000001)  
 	 	 	 	 	 tmp.mc.tssma611.ratf(i) =  fill.mc.field.long(tssma611.ratf,i,1)  
 	 	 	 	 endfor 	  
 	 	 	 	 | *  MCR -  en 	 	  
 	 	 	 	  
 | 	 	 	 	 update.row.in.cache.cisli209( 	 |ravi_july28th.so  
 | 	 	 	 	 	 tssma611.ncmp,  
 | 	 	 	 	 	 tssma611.ttyp,  
 | 	 	 	 	 	 tssma611.invn,  
 | 	 	 	 	 	 tcmcs036.ctau.l,  
 | 	 	 	 	 	 var.cisli206.ceno,  
 | 	 	 	 	 	 var.cisli209.pvat,  
 | 	 	 	 	 	 var.cisli265.txai,  
 | 	 	 	 	 	 var.cisli265.amti,  
 | 	 	 	 	 	 var.cisli206.rcod,  
 | 	 	 	 	 	 tssma611.ccur,  
 | 	 	 	 	 	 tssma611.invd,  
 | 	 	 	 	 	 var.cisli.rtyp,  
 | 	 	 	 	 	 |tssma611.rats, | *  MCR .o 	  
 | 	 	 	 	 	 |tssma611.ratf) | *  MCR .o 	  
 | 	 	 	 	 	 tmp.mc.tssma611.rats, | *  MCR .n  
 | 	 	 	 	 	 tmp.mc.tssma611.ratf) | *  MCR .n  
 	 	 	 	 	 	 |ravi_july28th.eo  
 	 	 	 	 	  
 	 	 	 	 	 	 	 |ravi_cisli209.en  
 	 if (prev.tran <>  tssma611.ttyp or prev.invn <>  tssma611.invn) then  
 	 	 prev.tran =  tssma611.ttyp  
 	 	 prev.invn =  tssma611.invn  
 	 	 prev.ncmp =  tssma611.ncmp 	  
 	 	 no.of.records =  0  
 	  
 	 	 var.cisli205.dcai =  0  
 	 	 var.cisli205.rmai =  0  
 	 	 select 	 tssma220.*  , tssma221.*   
 	 	 from tssma220, tssma221  
 	 	 where 	 tssma221._index4 =  {:prev.invn, :prev.tran, :prev.ncmp}  
 	 	 and 	 tssma221.ccon refers to tssma220  
 	 	 order by tssma221._index4  
 	 	 selectdo  
 	 	 	 no.of.records =  no.of.records +  1  
 	  
 	 	 	 var.cisli205.dcai =  var.cisli205.dcai +  tssma221.ldam  
 	 	 	 var.cisli205.rmai =  var.cisli205.rmai +  tssma221.nprc  
 	 	 	 	 	 	 	 	 | #  ravi_array.sn  
 	 	 	 var.cisli265.amti =  calc.tax.base.amount (tssma220.cpay, tssma221.nprc, 0.0,  
 	 	 	 	 	 	 	 	 	 tssma220.ccrs, tssma611.ccur)  
 	 	 	 if tssma220.cvat <>  "" then                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
 	 	 	 	 if tssma221.txam.l <>  0 then  
 	 	 	 	 	 var.cisli265.txai =  tssma221.txam.l  
 	 	 	 	 else  
 	 	 	 	 	 var.cisli265.txai =  calc.tax.amount.logistics(tssma611.ccty, tssma220.cvat,  
 	 	 	 	 	 	 tssma611.ccur,  
 	 	 	 	 	 	 |tssma611.rats,tssma611.ratf, | *  MCR .o  
 	 	 	 	 	 	 tmp.mc.tssma611.rats(1), | *  MCR .n  
 	 	 	 	 	 	 tmp.mc.tssma611.ratf(1), | *  MCR .n  
 	 	 	 	 	 	 var.cisli265.amti,  
 	 	 	 	 	 	 tssma220.cuno,tssma221.invd)  
 	 	 	 	 endif  
 	 	 	 else  
 	 	 	 	 var.cisli265.txai =  0.0  
 	 	 	 endif  
 | 	 	 	 	 get.tax.by.country.code( 	 |ravi_july28th.sn |Jyosh.so  
 | 	 	 	 	 	 tssma611.ccty,  
 | 	 	 	 	 	 tssma220.cvat,  
 | 	 	 	 	 	 new.txct,  
 | 	 	 	 	 	 new.txid,  
 | 	 	 	 	 	 err.mess) 	 	 	 	 	 |Jyosh.eo  
 	 	 	 	 	 	 	 	 | #  210859.so  
 	 	 	 	 	 	 	 	 | #  210859.sn  
 | 	 	 	 	 get.tax.by.country.code( 	  
 | 	 	 	 	 	 tssma611.ccty,  
 | 	 	 	 	 	 tssma220.cvat,  
 | 	 	 	 	 	 new.txct,  
 | 	 	 	 	 	 new.txid,  
 | 	 	 	 	 	 err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.en  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 	 	 	 	 	 | #  210859.sn  
 	 	 	 	 get.tax.by.country.code.and.financial.company(  
 	 	 	 	 	 tssma611.ccty,  
 	 	 	 	 	 tssma220.cvat,  
 	 	 	 	 	 var.compnr,  
 	 	 	 	 	 new.txct,  
 	 	 	 	 	 new.txid,  
 	 	 	 	 	 err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.en  
 	 	 	 	 	 	 	 	 | #  210859.so  
 | 	 	 	 new.txct =  get.country.of.financial.company(tssma611.ncmp) |Jyosh.sn  
 | 	 	 	 new.txid =  tssma220.cvat  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 new.bpct =  tssma611.ccty 	 	 	 	 |Jyosh.en  
 	 	 	 	 if not isspace (new.txct) then 	 	  
 	 	 	 	 	 read.tcmcs032 (new.txct, new.txid,tssma611.invd)  
 	 	 	 	 	 read.tcmcs036 (new.txct, new.txid) 	  
 	 	 	 	 endif 	 	 	 	 	 	  
 	 	 	 	 get.tax.percentage (new.txct, new.txid, var.compnr, 	  
 	 	 	 	 	 	 	 	 tssma611.invd, var.singular.tax, var.cisli209.pvat)  
 	 	 	 	 	 	 	 	 |ravi_july28th.en  
 | 	 	 	 update.tax.amounts.array( tssma220.cvat, | #  207750.so  
 | 	 	 	 	 	 var.cisli265.txai, var.cisli265.amti) 	  
 	 	 	 	 	 	 	 	 | #  ravi_array.en  
 	 	 	 	 	 	 	 	 | #  207750.eo  
 	 	 	 	 	 	 	 	 | #  207750.sn  
 	 	 	 if update.tax.amounts.array( tssma220.cvat,  
 	 	 	 	 	 var.cisli265.txai, var.cisli265.amti) then  
 	 	 	 	 	 	 	 	 | #  207750.en 	  
 	 	 	 	 	 	 	 	 |ravi_july28th.sn  
 	 	 	 	 	 update.row.in.cache.cisli209( 	 	 	  
 	 	 	 	 	 	 tssma611.ncmp,  
 	 	 	 	 	 	 tssma611.ttyp,  
 	 	 	 	 	 	 tssma611.invn,  
 	 	 	 	 	 	 tcmcs036.ctau.l,  
 	 	 	 	 	 	 var.cisli206.ceno,  
 	 	 	 	 	 	 var.cisli209.pvat,  
 	 	 	 	 	 	 var.cisli265.txai,  
 	 	 	 	 	 	 var.cisli265.amti,  
 	 	 	 	 	 	 var.cisli206.rcod,  
 	 	 	 	 	 	 tssma611.ccur,  
 	 	 	 	 	 	 tssma611.invd,  
 	 	 	 	 	 	 var.cisli.rtyp,  
 	 	 	 	 	 	 |tssma611.rats, | *  MCR .o 	  
 	 	 	 	 	 	 |tssma611.ratf) | *  MCR .o 	  
 	 	 	 	 	 	 tmp.mc.tssma611.rats, | *  MCR .n  
 	 	 	 	 	 	 tmp.mc.tssma611.ratf) | *  MCR .n  
 	 	 	 	 	 	 	 	 |ravi_july28th.en  
 	 	 	 	 	 	 cisli209.dumped =  true 	 | #  207750.sn  
 	 	 	 else  
 	 	 	 	 	 	 cisli209.dumped =  false  
 	 	 	 endif 	 	 	 	 	 	 | #  207750.en  
 	 	 endselect  
 	 	 	 	 	 	 	 | #  ravi_array.sn 	 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	  
 	 	 dump.fields.cisli206.from.array( 	 	  
 	 	 	 	 tssma611.ncmp, tssma611.ttyp,  
 	 	 	 	 tssma611.invn, tssma611.ccty,  
 	 	 	 	 |tssma611.rats, tssma611.ratf, | *  MCR .o  
 	 	 	 	 tmp.mc.tssma611.rats, | *  MCR .n  
 	 	 	 	 tmp.mc.tssma611.ratf, | *  MCR .n  
 	 	 	 	 tssma611.ccur, var.fin.comp.country,  
 	 	 	 	 var.cisli206.stcy, var.fin.comp.country,  
 	 	 	 	 var.cisli206.itcy, "", "")                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
 	 	 	 	 	 	 	 | #  ravi_array.en  
 	 	 	 	 	 	 	 | #  ravi_cisli209.sn  
 	 	 dump.records.from.cache.cisli209() 	 	  
 	 	 	 	 	 	 	 | #  ravi_cisli209.sn  
 | 	 	 restore.pointer.tssma221 () 	 	 	 	 	 |binda25 -  06.o  
 	 	 var.net.amti =  0  
 	 	 select tssma612.*   
 	 	 from tssma612  
 	 	 where tssma612._index1 =  {:prev.invn, :prev.tran, :tssma611.ncmp}  
 	 	 selectdo  
 | 	 	 	 get.tax.by.country.code ( 	 	 | #  Jyosh.so  
 | 	 	 	 	 tssma611.ccty,  
 | 	 	 	 	 tssma612.cvat,  
 | 	 	 	 	 new.txct,  
 | 	 	 	 	 new.txid,  
 | 	 	 	 	 err.mess) 	 	 	 | #  Jyosh.eo  
 	 	 	 	 	 	 	 	 | #  210859.so  
 	 	 	 	 	 	 	 	 | #  210859.sn  
 | 	 	 	 get.tax.by.country.code ( 	 	 | #  Jyosh.so  
 | 	 	 	 	 tssma611.ccty,  
 | 	 	 	 	 tssma612.cvat,  
 | 	 	 	 	 new.txct,  
 | 	 	 	 	 new.txid,  
 | 	 	 	 	 err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.en  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 	 	 	 	 	 | #  210859.sn  
 	 	 	 get.tax.by.country.code.and.financial.company(  
 	 	 	 	 tssma611.ccty,  
 	 	 	 	 tssma612.cvat,  
 	 	 	 	 var.compnr,  
 	 	 	 	 new.txct,  
 	 	 	 	 new.txid,  
 	 	 	 	 err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.en  
 	 	 	 	 	 	 	 	 | #  210859.so  
 | 	 	 new.txct =  get.country.of.financial.company(tssma611.ncmp) | Jyosh.sn  
 | 	 	 new.txid =  tssma612.cvat  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 new.bpct =  tssma611.ccty 	 	 |Jyosh.en  
 	 	 	 if not isspace (new.txct) then 	 	 	 	  
 	 	 	 	 read.tcmcs036 (new.txct, new.txid)  
 	 	 	 endif 	 	 	 	 	 	  
 	 	 	 var.net.amti =  var.net.amti +  tssma612.amev  
 	 	 	 var.cisli205.txai =  var.cisli205.txai +  tssma612.tvam +  tssma612.vcam  
 	 	 	 if tcmcs036.tvat =  tctvat.shifted then  
 	 	 	 var.cisli205.stai =  var.cisli205.stai +  tssma612.tvam +  tssma612.vcam  
 	 	 	 if var.cisli205.stai <>  0.0 then  
 | *  MCR -  new changes .s 	 	 	  
 | 	 	 	 	 for i =  1 to 3 | *  MCR  
 | 	 	 	 	 	 calculate.amount.in.other.currency (var.cisli205.stai,  
 | 	 	 	 	 	 	 	 | *  MCR -  s  
 | 	 	 	 	 	 	 	 |tssma611.rats,  
 | 	 	 	 	 	 	 	 |tssma611.ratf,  
 | 	 	 	 	 	 	 	 tmp.mc.tssma611.rats(i), | *  MCR .n  
 | 	 	 	 	 	 	 	 tmp.mc.tssma611.ratf(i), | *  MCR .n  
 | 	 	 	 	 	 	 	 | *  MCR -  e  
 | 	 	 	 	 	 	 	 tssma611.ccur,  
 | 	 	 	 	 	 	 	 |var.cisli205.stah,  
 | 	 	 	 	 	 	 	 var.cisli205.stah(i), | *  MCR  
 | 	 	 	 	 	 	 	 err.mess)  
 | 	 	 	 	 endfor | *  MCR  
 	 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 	 calculate.amount.in.home.currency.variables(var.cisli205.stai, 	 	 	  
 	 	 	 	 	 tssma611.ccur, 	 	 	 	 	  
 	 	 	 	 	 tmp.mc.tssma611.rats(i),  
 	 	 	 	 	 tmp.mc.tssma611.ratf(i),  
 	 	 	 	 	 i,  
 	 	 	 	 	 var.cisli205.stah(i), 	 	 	 	 	 	 	  
 	 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 	 endfor 	 	 	 	 	 	  
 | *  MCR -  new changes .e  
 	 	 	 else  
 	 	 	 	 | *  MCR -  s  
 	 	 	 	 |var.cisli205.stah =  0.0  
 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 var.cisli205.stah(i) =  0.0  
 	 	 	 	 endfor  
 	 	 	 	 | *  MCR -  e  
 	 	 	 endif  
 	 	 	 endif  
 	 	 	 var.cisli205.scai =  var.cisli205.scai +  tssma612.csam  
 	 	 endselect  
 	 	 if var.cisli205.scai <>  0.0 then  
 | *  MCR -  new changes .s 	 	  
 | 	 	 	 for i =  1 to 3 | *  MCR  
 | 	 	 	 	 calculate.amount.in.other.currency (var.cisli205.scai,  
 | 	 	 	 	 	 | *  MCR -  s  
 | 	 	 	 	 	 |tssma611.rats,  
 | 	 	 	 	 	 |tssma611.ratf,  
 | 	 	 	 	 	 tmp.mc.tssma611.rats(i), | *  MCR .n  
 | 	 	 	 	 	 tmp.mc.tssma611.ratf(i), | *  MCR .n  
 | 	 	 	 	 	 | *  MCR -  e  
 | 	 	 	 	 	 tssma611.ccur,  
 | 	 	 	 	 	 |var.cisli205.scah,  
 | 	 	 	 	 	 var.cisli205.scah(i), | *  MCR  
 | 	 	 	 	 	 err.mess)  
 | 	 	 	 endfor 	 |MCR  
 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 	 calculate.amount.in.home.currency.variables(var.cisli205.scai, 	 	 	  
 	 	 	 	 	 tssma611.ccur, 	 	 	 	 	  
 	 	 	 	 	 tmp.mc.tssma611.rats(i),  
 	 	 	 	 	 tmp.mc.tssma611.ratf(i),  
 	 	 	 	 	 i,  
 	 	 	 	 	 var.cisli205.scah(i), 	 	 	 	 	 	 	  
 	 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 endfor 	 	 	 	 	 	  
 | *  MCR -  new changes .e  
 	 	 else  
 	 	 	 | *  MCR -  s  
 	 	 	 |var.cisli205.scah =  0.0  
 	 	 	 for i =  1 to 3  
 	 	 	 	 var.cisli205.scah(i) =  0.0 	  
 	 	 	 endfor  
 	 	 	 | *  MCR -  e  
 	 	 endif  
 	 	 |binda.so  
 | 	 	 if tssma611.ista =  tssma.ista.posted.finance or 	 	  
 | 	 	 tssma611.ista =  tssma.ista.posted.project then 	  
 | 	 	 	 var.cisli205.stat =  6  
 | 	 	 	 var.cisli205.brid =  1  
 | 	 	 else  
 | 	 	 	 if tssma611.ista =  tssma.ista.checked then  
 | 	 	 	 var.cisli205.stat =  5  
 | 	 	 	 var.cisli205.brid =  2  
 | 	 	 	 endif  
 | 	 	 endif  
 	 	 	 	 	 	 	 	 	 |binda.eo 	 	 	 	 	  
 	 	 	 	 	 	 	 	 	 |bin.so  
 | 	 	 get.crnd (tssma611.ccur)  
 | 	 	 if var.cisli205.txai <>  0.0 then  
 | 	 	 	 calculate.amount.in.other.currency (var.cisli205.txai, tssma611.rats,tssma611.ratf,  
 | 	 	 	 	 	 	 tssma611.ccur, var.cisli205.txah, err.mess)  
 | 	 	 else  
 | 	 	 	 var.cisli205.txah =  0.0  
 | 	 	 endif  
 	 	 | *  LPS is already available from tssma612, the function below is used to get the LPS date, i.e var.cisli205.scdt  
 | 	 	 itfcmg0007.calculate.surcharge (tssma611.ccrs, var.net.amti +  var.cisli205.scai, tssma611.invd, tssma611.ccur, tcmcs002.crnd,  
 | 	 	 temp.scai, var.cisli205.scdt)  
 	 	  
 | 	 	 itccom0016.calculate.discount.dates (tssma611.invd ,  
 | 	 	 	 	 tssma611.cpay, var.cisli205.d1dt, var.cisli205.d2dt,  
 | 	 	 	 	 var.cisli205.d3dt)  
 | 	 	 itfcmg0007.calculate.discount (tssma611.cpay, var.net.amti +  var.cisli205.txai, var.cisli205.txai,  
 | 	 	 	 	 	 	 tssma611.ccur, tcmcs002.crnd,  
 | 	 	 	 	 	 	 var.cisli205.d1ai, var.cisli205.d2ai,  
 | 	 	 	 	 	 	 var.cisli205.d3ai) 	 	  
 | 	 	 if var.cisli205.d1ai <>  0.0 then  
 | 	 	 	 calculate.amount.in.other.currency (var.cisli205.d1ai, tssma611.rats,tssma611.ratf,  
 | 	 	 	 	 	 	 tssma611.ccur, var.cisli205.d1ah, err.mess)  
 | 	 	 else  
 | 	 	 	 var.cisli205.d1ah =  0.0  
 | 	 	 endif  
 | 	 	 if var.cisli205.d2ai <>  0.0 then  
 | 	 	 	 calculate.amount.in.other.currency (var.cisli205.d2ai, tssma611.rats,tssma611.ratf,  
 | 	 	 	 	 	 	 tssma611.ccur, var.cisli205.d2ah, err.mess)  
 | 	 	 else  
 | 	 	 	 var.cisli205.d2ah =  0.0  
 | 	 	 endif  
 | 	 	 if var.cisli205.d3ai <>  0.0 then  
 | 	 	 	 calculate.amount.in.other.currency (var.cisli205.d3ai, tssma611.rats,tssma611.ratf,  
 | 	 	 	 	 	 	 tssma611.ccur, var.cisli205.d3ah, err.mess)  
 | 	 	 else  
 | 	 	 	 var.cisli205.d3ah =  0.0  
 | 	 	 endif  
 | 	 	 var.cisli205.amti =  var.net.amti +  var.cisli205.txai +  var.cisli205.scai  
 | 	 	 if var.cisli205.amti <>  0.0 then  
 | 	 	 	 calculate.amount.in.other.currency (var.cisli205.amti, tssma611.rats,tssma611.ratf,  
 | 	 	 	 	 	 	 tssma611.ccur, var.cisli205.amth, err.mess)  
 | 	 	 else  
 | 	 	 	 var.cisli205.amth =  0.0  
 | 	 	 endif  
 	 	 	 	 	 	 	 	 	 	 	 	  
 	 	 select tfacr200.*   
 	 	 from tfacr200  
 	 	 where tfacr200._index1 =  {:prev.tran, :prev.invn, 0}  
 | 	 	 and tfacr200.trec =  tfacr.trec.invoice 	 	 	 | #  200 -  101927.o  
 	 	 	 	 	 	 	 	 	 | #  200 -  101927.sn  
 	 	 and (tfacr200.trec =  tfacr.trec.invoice or 	  
 	 	 tfacr200.trec =  tfacr.trec.credit) 	 	 	 	  
 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.sn  
 	 	 	 if tfacr200.trec =  tfacr.trec.invoice then  
 	 	 	 	 var.tfacr200.trec =  target(cisli.doct.invoice)  
 	 	 	 else  
 	 	 	 	 var.tfacr200.trec =  target(cisli.doct.credit)  
 	 	 	 	 	 	 	 	 	 | #  148886.so  
 | 	 	 	 	 if var.cisli205.rmai >  0 then  
 | 	 	 	 	 	 var.cisli205.rmai = -  var.cisli205.rmai  
 | 	 	 	 	 endif  
 | 	 	 	 	 if var.cisli205.dcai >  0 then  
 | 	 	 	 	 	 var.cisli205.dcai = -  var.cisli205.dcai  
 | 	 	 	 	 endif  
 	 	 	 	 	 	 	 	 	 | #  148886.eo  
 	 	 	 endif  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en  
 	 	 	 | *  MCR -  sn 	  
 	 	 	 for i =  1 to 3 	  
 	 	 	 	 tmp.mc.tfacr200.amth(i) =  fill.mc.field.double(tfacr200.amth,i)  
 	 	 	 	 tmp.mc.tfacr200.vath(i) =  fill.mc.field.double(tfacr200.vath,i)  
 	 	 	 	 tmp.mc.tfacr200.svah(i) =  fill.mc.field.double(tfacr200.svah,i)  
 	 	 	 	 tmp.mc.tfacr200.rate(i) =  fill.mc.field.double(tfacr200.rate,i)  
 	 	 	 	 tmp.mc.tfacr200.ratf(i) =  fill.mc.field.long(tfacr200.ratf,i)  
 	 	 	 	 tmp.mc.tfacr200.laph(i) =  fill.mc.field.double(tfacr200.laph,i)  
 	 	 	 	 tmp.mc.tfacr200.dc1h(i) =  fill.mc.field.double(tfacr200.dc1h,i)  
 	 	 	 	 tmp.mc.tfacr200.dc2h(i) =  fill.mc.field.double(tfacr200.dc2h,i)  
 	 	 	 	 tmp.mc.tfacr200.dc3h(i) =  fill.mc.field.double(tfacr200.dc3h,i)  
 	 	 	 endfor  
 	 	 	 | *  MCR -  en  
 	 	 	 	 	  
 	 	 	 fill.cisli205.fields (tssma611.ncmp,tfacr200.ttyp, tfacr200.ninv,1,6,  
 	 	 	 var.cisli260.bpid, var.cisli260.itad, var.cisli260.cofc,  
 	 	 	 tfacr200.ccrs, tfacr200.cpay, new.txct,6,0,0,0,0,0,no.of.records, tssma611.ccur,tfacr200.docd,  
 	 	 	 tfacr200.amti,  
 	 	 	 |tfacr200.amth,  
 	 	 	 tmp.mc.tfacr200.amth, | *  MCR  
 	 	 	 tfacr200.vati,  
 	 	 	 | tfacr200.vath,  
 	 	 	 tmp.mc.tfacr200.vath, | *  MCR  
 	 	 	 tfacr200.svam,  
 	 	 	 |tfacr200.svah,  
 	 	 	 tmp.mc.tfacr200.svah, | *  MCR  
 	 	 	 |tfacr200.rate, 	  
 	 	 	 tmp.mc.tfacr200.rate, | *  MCR  
 	 	 	 | tfacr200.ratf,  
 	 	 	 tmp.mc.tfacr200.ratf, | *  MCR  
 	 	 	 tfacr200.lpdt, tfacr200.lapa,  
 	 	 	 |tfacr200.laph,  
 	 	 	 tmp.mc.tfacr200.laph, | *  MCR  
 	 	 	 0.0,0.0,var.cisli205.rmai, tfacr200.dc1i,  
 	 	 	 |tfacr200.dc1h,  
 	 	 	 tmp.mc.tfacr200.dc1h, | *  MCR  
 	 	 	 tfacr200.did1, tfacr200.dc2i,  
 	 	 	 |tfacr200.dc2h,  
 	 	 	 tmp.mc.tfacr200.dc2h, | *  MCR 	 	  
 	 	 	 tfacr200.did2,tfacr200.dc3i,  
 	 	 	 |tfacr200.dc3h,  
 	 	 	 tmp.mc.tfacr200.dc3h, | *  MCR  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.so  
 | 	 	 	 tfacr200.did3, tfacr200.paym, 0,var.cisli205.dcai,tfacr200.amti -  tfacr200.vati)  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.eo  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.sn 	  
 | 	 	 	 tfacr200.did3, tfacr200.paym, 0,var.cisli205.dcai,tfacr200.amti -  tfacr200.vati,var.tfacr200.trec) |Jyosh.o  
 	 	 	 tfacr200.did3, tfacr200.paym, 0,var.cisli205.dcai,tfacr200.amti -  tfacr200.vati,var.tfacr200.trec, new.bpct) |Jyosh.n 	 	 	  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en  
 	 	 	  
 	 	 	 dump.cisli205 ()  
 	 	 	 reset.variables.cisli205 ()  
 	 	 endselect  
 | 	 	 fill.cisli205.fields (tssma611.ncmp,tssma611.ttyp, tssma611.invn,var.cisli205.brid,var.cisli205.stat, |binda.o  
 	 	 	 	 	 	 	 	 	 	 	 	 |bin.so  
 | 	 	 fill.cisli205.fields (tssma611.ncmp,tssma611.ttyp, tssma611.invn,1,6,  
 | 	 	 var.cisli260.bpid, var.cisli260.itad, var.cisli260.cofc,  
 | 	 	 tssma611.ccrs, tssma611.cpay, new.txct,6,0,0,0,0,0,no.of.records,tssma611.ccur,tssma611.invd,  
 | 	 	 var.cisli205.amti, var.cisli205.amth, var.cisli205.txai, var.cisli205.txah, var.cisli205.stai, var.cisli205.stah,  
 | 	 	 tssma611.rats,tssma611.ratf, var.cisli205.scdt, var.cisli205.scai, var.cisli205.scah,0.0,  
 | 	 	 0.0,var.cisli205.rmai, var.cisli205.d1ai, var.cisli205.d1ah, var.cisli205.d1dt, var.cisli205.d2ai, var.cisli205.d2ah, var.cisli205.d2dt,var.cisli205.d3ai,  
 | 	 	 var.cisli205.d3ah, var.cisli205.d3dt,"", 0,var.cisli205.dcai,var.cisli205.amti -  var.cisli205.txai)  
 | 	 	 dump.cisli205 ()  
 | 	 	 reset.variables.cisli205 () 	 	 	  
 	 	 	 	 	 	 	 	 	 	  
 	 endif  
 	 cisli209.dumped =  true 	 	 	 |ravi_cisli209.n  
 	 if (total.records >=  20000 and 	 	 |haddock.err.sn  
 	 	 tppin190.accessed and 	  
 	 	 cisli209.dumped ) then  
 	 	 	 reinitialize.cache()  
 	 endif 	 	 	 	 	 |haddock.err.en  
 	 free.memories() 	 	 	 	 |ravi_array.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:ts
:SCMOD:sma
:SFLNO:220
:ICOD:S
:QURY:START
select 	 tssma611.*  , tssma220.*  , tssma221.*
from tssma611, tssma220, tssma221
where tssma611.titr =  tssma.titr.contract  
 and tssma611.ista >  tssma.ista.checked 	 	 	  
 and 	 tssma221._index4 =  {tssma611.invn, tssma611.ttyp,  
 	 	 	 tssma611.ncmp}  
 and 	 tssma221.ccon refers to tssma220
order by tssma221._index4
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:ts
:SCMOD:sma
:SFLNO:220
:ICOD:X
:QURY:START
order.count =  0  
 free.mem ( servcont.array )  
 reset.variables.cisli205 ()  
 hold.ccon =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
 prev.tran =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
 prev.invn =  0  
 temp.scai =  0  
 | dump.cisli206 () 	 	 	 	 | #  ravi_array.so  
 | delete.bcsci002.records.cisli206 ()  
 | dump.cisli209 ()  
 | delete.bcsci002.records.cisli209 () 	 	 | #  ravi_array.eo
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:ts
:SCMOD:sma
:SFLNO:611
:ICOD:D
:QURY:START
|store.index.fields.service.orders () 	 	 	 	 	 |binda25 -  06.o  
 	 initialize.variables ()  
 	 initialize.cisli206.variables ()  
 	 if (prev.tran1 <>  tssma611.ttyp or prev.invn1 <>  tssma611.invn) then 	 | #  ravi_array.sn  
 	 	 prev.tran1 =  tssma611.ttyp  
 	 	 prev.invn1 =  tssma611.invn  
 	 	 prev.ncmp1 =  tssma611.ncmp 	  
 	 	 allocate.memories(tssma611.ccty) 	 	  
 	 endif 	 	 	 	 	 	 	 	 	 | #  ravi_array.en  
 	 	 	 	 	 	 	 |binda21 -  07.so  
 | 	 order.count =  order.count +  1  
 | 	 alloc.mem (servorder.array,6,order.count)  
 | 	 if servorder.array (1, order.count) =  0 then  
 | 	 	 servorder.array (1, order.count) =  tssma310.orno  
 | 	 endif  
 	  
 | 	 header.dumped =  false  
 | 	 for counter1 =  1 to order.count -  1  
 | 	 	 if tssma310.orno =  servorder.array (1, counter1) then  
 | 	 	 	 header.dumped =  true  
 | 	 	 	 break  
 | 	 	 endif  
 | 	 endfor  
 	 	 	 	 	 	 	 |binda21 -  07.eo  
 	 	 	 	 	 	 	 |binda21 -  07.sn  
 	 	 header.dumped =  false  
 	 	 if order.count >  0 and tssma310.orno =  servorder.array(order.count) then  
 	 	 	 | record is found  
 	 	 	 header.dumped =  true  
 	 	 else  
 	 	 	 |WR PERF search record  
 	 	 	 if order.count >  0 then  
 	 	 	 	 ret =  0  
 	 	 	 	 if tssma310.orno >  servorder.array(order.count) or |new value larger than last value in array  
 	 	 	 	 tssma310.orno <  servorder.array(1) then |new value smaller than first value in array  
 	 	 	 	 	 | not found  
 	 	 	 	 else  
 	 	 	 	 	 | do a binary search  
 	 	 	 	 	  
 	 	 	 	 	 ret =  qss.search(QSS.SRC.IS.SORTED +  QSS.EQUAL,  
 	 	 	 	 	 tssma310.orno,servorder.array,sort_def,order.count)  
 	 	 	 	 	  
 	 	 	 	 endif  
 	 	 	 endif  
 	 	  
 	 	 	 |WR PERF insert record  
 	 	 	 if ret >  0 then  
 	 	 	 	 | record is found, do not insert again  
 	 	 	 	 header.dumped =  true  
 	 	 	 else  
 	 	 	 	 order.count =  order.count +  1  
 	  
 	 	 	 	 if order.count >  array.length then 	 	 |WR PERF allocate memory per 1000 records  
 	 	 	 	 	  
 	 	 	 	 	 array.length =  array.length +  1000  
 	 	 	 	 	 alloc.mem (servorder.array,array.length)  
 	 	 	 	 	  
 	 	 	 	 endif  
 	 	 	 	 |insert orno  
 	 	 	 	 servorder.array(order.count) =  tssma310.orno  
 	 	 	  
 	 	 	 	 |sort array only if last inserted record is smaller than the previous  
 	 	 	 	 if order.count >  1 and servorder.array(order.count) <  servorder.array(order.count -  1) then  
 	 	 	 	 	  
 	 	 	 	 	 qss.sort(servorder.array,sort_def,order.count)  
 	 	 	 	 	  
 	 	 	 	 endif  
 	 	  
 	 	 	 endif  
 	 	 endif  
 	 	 |WR PERF end  
 	 	 	 	 	 	 	 	 |binda21 -  07.en  
 	 var.cisli250.cofc =  get.department.tssma611 ()  
 	 fill.cluster.tssma611 ()  
 	 fill.contract.tssma611 ()  
 	 fill.business.partners.tssma611 ()  
 	 fill.addresses.tssma611 () 	  
 	 fill.customer.related.fields.tssma611 ()  
 	 if header.dumped =  false then  
 	 	 hold.orno =  tssma301.orno  
 	 	 dump.cisli250 ()  
 	 endif  
 | 	 fill.addresses.tssma611 () 	 	 	 |binda21 -  07.o  
 	 fill.cisli255.fields ()  
 	 dump.cisli255 ()  
 	 cisli209.dumped =  false 	 	 	 	 	 	 |ravi_cisli209.n 	 	 	 	  
 	 get.financial.company.country (tssma611.ncmp)  
 	 if tssma310.tcst =  tssma.tcst.material then  
 	 	 read.warehouse.address (ext.lng.comp, tssma310.cwar)  
 	 	 var.cisli206.sfcy =  warehouse.country  
 	 else  
 	 	 var.cisli206.sfcy =  var.fin.comp.country  
 	 endif  
 | 	 	 if not isspace (new.txct) then 	 	 	 |ravi_july28th.so  
 | 	 	 	 read.tcmcs032 (new.txct, new.txid,tssma611.invd)  
 | 	 	 	 read.tcmcs036 (new.txct, new.txid) 	 	 	  
 | 	 	 endif 	 	 	 	 	 	  
 | 	 	 get.tax.percentage (new.txct, new.txid, var.compnr, 	  
 | 	 	 	 	 	 tssma611.invd, var.singular.tax, var.cisli209.pvat)  
 	 	 	 	 	 	 	 	 |ravi_july28th.eo  
 	 	 	 	 	 	 |ravi_cisli209.sn  
 	 	 	 	 	 	 	  
 	 	 	 	 	 	  
 	 	 	 	  
 	 	 	 | *  MCR .sn 	 	 	  
 	 	 	 for i =  1 to 3  
 	 	 	 	 tmp.mc.tssma611.rats(i) =  fill.mc.field.double(tssma611.rats,i)  
 	 	 	 	 tmp.mc.tssma611.ratf(i) =  fill.mc.field.long(tssma611.ratf,i)  
 	 	 	 endfor 	  
 	 	 	 | *  MCR .en  
 	 	 	 	  
 | 	 	 	 update.row.in.cache.cisli209( 	 	 	 |ravi_july28th.so  
 | 	 	 	 	 tssma611.ncmp,  
 | 	 	 	 	 tssma611.ttyp,  
 | 	 	 	 	 tssma611.invn,  
 | 	 	 	 	 tcmcs036.ctau.l,  
 | 	 	 	 	 var.cisli206.ceno,  
 | 	 	 	 	 var.cisli209.pvat,  
 | 	 	 	 	 var.cisli255.txai,  
 | 	 	 	 	 var.cisli255.amti,  
 | 	 	 	 	 var.cisli206.rcod,  
 | 	 	 	 	 tssma611.ccur,  
 | 	 	 	 	 tssma611.invd,  
 | 	 	 	 	 var.cisli.rtyp,  
 | 	 	 	 	 |tssma611.rats, 	 | *  MCR .o  
 | 	 	 	 	 |tssma611.ratf) 	 | *  MCR .o  
 | 	 	 	 	 tmp.mc.tssma611.rats, 	 | *  MCR .n  
 | 	 	 	 	 tmp.mc.tssma611.ratf) 	 | *  MCR .n |ravi_july28th.eo  
 	 	 	 	  
 	 	 	 	  
 	 	 	 	 	 	 |ravi_cisli209.en  
 	 if (prev.tran <>  tssma611.ttyp or prev.invn <>  tssma611.invn) then  
 	 	 prev.tran =  tssma611.ttyp  
 	 	 prev.invn =  tssma611.invn  
 	 	 prev.ncmp =  tssma611.ncmp 	  
 	 	 no.of.records =  0  
 	 	 var.cisli205.gdai =  0  
 	 	 var.cisli205.dcai =  0  
 	 	 var.cisli205.csai =  0  
 	  
 	 	 select 	 tssma301.*  ,tssma310.*   
 	 	 from tssma301,tssma310  
 	 	 where 	 tssma310._index3 =  {:prev.invn, :prev.tran, :prev.ncmp}  
 	 	 and 	 tssma310.orno refers to tssma301  
 	 	 order by tssma310._index3 	  
 	 	 selectdo  
 	 	 	 no.of.records =  no.of.records +  1  
 	  
 	 	 	 var.cisli205.dcai =  var.cisli205.dcai +  tssma310.ldam  
 	 	 	 if get.invoice.type () =  10 then  
 	 	 	 	 var.cisli205.gdai =  var.cisli205.gdai +  tssma310.amta  
 	 	 	 else  
 	 	 	 	 var.cisli205.csai =  var.cisli205.csai +  tssma310.amta  
 	 	 	 endif  
 	 	 	 var.cisli255.amti =  calc.tax.base.amount (tssma301.cpay, tssma310.amta, 0.0,  
 	 	 	 	 	 tssma301.ccrs, tssma301.ccur)  
 	 	 	 if tssma310.cvat <>  "" then                                                                                                                                                                                                                                                                                                                                                                 	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                	                                                                                                                                                                                                                                                                                                                                                                |ravi_array.sn                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
 	 	 	 	 if tssma310.txam.l <>  0 then  
 	 	 	 	 	 var.cisli255.txai =  tssma310.txam.l  
 	 	 	 	 else  
 	 	 	 	  
 	 	 	 	 	 var.cisli255.txai =  calc.tax.amount.logistics(tssma611.ccty,tssma310.cvat,tssma301.ccur,  
 	 	 	 	 	 	 |tssma301.rats,tssma301.ratf, | *  MCR .o  
 	 	 	 	 	 	 tmp.mc.tssma611.rats(1), 	 | *  MCR .n  
 	 	 	 	 	 	 tmp.mc.tssma611.ratf(1), 	 | *  MCR .n  
 	 	 	 	 	 	 var.cisli255.amti,tssma301.cuno,tssma310.invd)  
 	 	 	 	 endif  
 	 	 	 else  
 	 	 	 	 var.cisli255.txai =  0.0  
 	 	 	 endif  
 | 	 	 	 get.tax.by.country.code( 	 	 	 |ravi_july28th.sn |Jyosh.so  
 | 	 	 	 	 	 	 tssma310.ccty,  
 | 	 	 	 	 	 	 tssma310.cvat,  
 | 	 	 	 	 	 	 new.txct,  
 | 	 	 	 	 	 	 new.txid,  
 | 	 	 	 	 	 	 err.mess) 	 	 |ravi_july28th.en |Jyosh.eo  
 	 	 	 	 	 	 	 	 | #  210859.so  
 	 	 	 	 	 	 	 	 | #  210859.sn  
 | 	 	 	 get.tax.by.country.code( 	 	 	  
 | 	 	 	 	 	 	 tssma310.ccty,  
 | 	 	 	 	 	 	 tssma310.cvat,  
 | 	 	 	 	 	 	 new.txct,  
 | 	 	 	 	 	 	 new.txid,  
 | 	 	 	 	 	 	 err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.en  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 	 	 	 	 	 | #  210859.sn  
 	 	 	 get.tax.by.country.code.and.financial.company(  
 	 	 	 	 	 	 tssma310.ccty,  
 	 	 	 	 	 	 tssma310.cvat,  
 	 	 	 	 	 	 var.compnr,  
 	 	 	 	 	 	 new.txct,  
 	 	 	 	 	 	 new.txid,  
 	 	 	 	 	 	 err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.en  
 	 	 	 	 	 	 	 	 | #  210859.so  
 | 	 	 new.txct =  get.country.of.financial.company(tssma310.ncmp) |Jyosh.sn  
 | 	 	 new.txid =  tssma310.cvat  
 	 	 	 	 	 	 	 	 | #  210859.eo 	  
 	 	 new.bpct =  tssma310.ccty 	 	 	 	 |Jyosh.en  
 	 	 	 	 	 	 	 	 | #  207750.so 	 	 	 	 	 	  
 | 	 	 	 update.tax.amounts.array(tssma310.cvat, 	  
 | 	 	 	 	 	 var.cisli255.txai, var.cisli255.amti) 	  
 	 	 	 	 	 	 	 	 	 	 | #  ravi_array.en  
 	 	 	 	 	 	 	 	 | #  207750.eo  
 	 	 	 	 	 	 	 |ravi_july28th.sn  
 	 	 	 	 if not isspace (new.txct) then 	 	 	  
 	 	 	 	 	 read.tcmcs032 (new.txct, new.txid,tssma611.invd)  
 	 	 	 	 	 read.tcmcs036 (new.txct, new.txid) 	 	 	  
 	 	 	 	 endif 	 	 	 	 	 	  
 	 	 	 	 get.tax.percentage (new.txct, new.txid, var.compnr, 	  
 	 	 	 	 	 	 tssma611.invd, var.singular.tax, var.cisli209.pvat)  
 	 	 	 	 	 	 	 	 | #  207750.sn  
 	 	 	 if update.tax.amounts.array(tssma310.cvat, 	  
 	 	 	 	 	 var.cisli255.txai, var.cisli255.amti) then  
 	 	 	 	 	 	 	 	 | #  207750.en  
 	 	 	 	 update.row.in.cache.cisli209( 	 	 	  
 	 	 	 	 	 tssma611.ncmp,  
 	 	 	 	 	 tssma611.ttyp,  
 	 	 	 	 	 tssma611.invn,  
 	 	 	 	 	 tcmcs036.ctau.l,  
 	 	 	 	 	 var.cisli206.ceno,  
 	 	 	 	 	 var.cisli209.pvat,  
 	 	 	 	 	 var.cisli255.txai,  
 	 	 	 	 	 var.cisli255.amti,  
 	 	 	 	 	 var.cisli206.rcod,  
 	 	 	 	 	 tssma611.ccur,  
 	 	 	 	 	 tssma611.invd,  
 	 	 	 	 	 var.cisli.rtyp,  
 	 	 	 	 	 |tssma611.rats, 	 | *  MCR .o  
 	 	 	 	 	 |tssma611.ratf) 	 | *  MCR .o  
 	 	 	 	 	 tmp.mc.tssma611.rats, 	 | *  MCR .n  
 	 	 	 	 	 tmp.mc.tssma611.ratf) 	 | *  MCR .n  
 	 	 	 	 	 	 |ravi_july28th.en  
 	 	 	 	 	 cisli209.dumped =  true 	 | #  207750.sn  
 	 	 	 else  
 	 	 	 	 	 cisli209.dumped =  false  
 	 	 	 endif 	 	 	 	 	 | #  207750.en  
 	 	 endselect 	  
 	 	 	 	 	 	 	 | #  ravi_array.sn  
 	 	 dump.fields.cisli206.from.array( 	 	  
 	 	 	 	 tssma611.ncmp, tssma611.ttyp,  
 	 	 	 	 tssma611.invn, tssma611.ccty, 	 	 	 	  
 	 	 	 	 |tssma611.rats, 	 | *  MCR .o  
 	 	 	 	 |tssma611.ratf) 	 | *  MCR .o  
 	 	 	 	 tmp.mc.tssma611.rats, 	 | *  MCR .n  
 	 	 	 	 tmp.mc.tssma611.ratf, 	 | *  MCR .n  
 	 	 	 	 tssma611.ccur, var.fin.comp.country,  
 	 	 	 	 var.cisli206.stcy, var.fin.comp.country,  
 	 	 	 	 var.cisli206.itcy, "", "")                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
 	 	 	 	 	 	 | #  ravi_array.en  
 	 	 	 	 	 	 | #  ravi_cisli209.sn  
 	 	 dump.records.from.cache.cisli209() 	 	  
 	 	 	 	 	 	 | #  ravi_cisli209.sn  
 | 	 	 restore.pointer.tssma310 () 	 	 	 	 	 |binda25 -  06.o  
 	 	 var.net.amti =  0  
 	 	 select tssma612.*   
 	 	 from tssma612  
 	 	 where tssma612._index1 =  {:prev.invn, :prev.tran, :tssma611.ncmp}  
 	 	 selectdo  
 | 	 	 	 get.tax.by.country.code ( 	 	 	 	 |Jyosh.so  
 | 	 	 	 	 tssma301.ccty,  
 | 	 	 	 	 tssma612.cvat,  
 | 	 	 	 	 new.txct,  
 | 	 	 	 	 new.txid,  
 | 	 	 	 	 err.mess) 	 	 	 	 	 |Jyosh.eo  
 	 	 	 	 	 	 	 	 | #  210859.so  
 	 	 	 	 	 	 	 	 | #  210859.sn  
 | 	 	 	 get.tax.by.country.code ( 	 	 	 	  
 | 	 	 	 	 tssma301.ccty,  
 | 	 	 	 	 tssma612.cvat,  
 | 	 	 	 	 new.txct,  
 | 	 	 	 	 new.txid,  
 | 	 	 	 	 err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.en  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 	 	 	 	 	 | #  210859.sn  
 	 	 	 get.tax.by.country.code.and.financial.company(  
 	 	 	 	 tssma301.ccty,  
 	 	 	 	 tssma612.cvat,  
 	 	 	 	 var.compnr,  
 	 	 	 	 new.txct,  
 	 	 	 	 new.txid,  
 	 	 	 	 err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.en  
 	 	 	 	 	 	 	 	 | #  210859.so  
 | 	 	 new.txct =  get.country.of.financial.company(tssma301.ncmp) | Jyosh.sn  
 | 	 	 new.txid =  tssma612.cvat 	  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 new.bpct =  tssma301.ccty 	 	 	 	 |Jyosh.en  
 	 	  
 	 	 	 if not isspace (new.txct) then 	 	 	  
 	 	 	 	 read.tcmcs036 (new.txct, new.txid)  
 	 	 	 endif 	 	 	 	 	 	  
 	 	 	 var.net.amti =  var.net.amti +  tssma612.amev  
 	 	 	 var.cisli205.txai =  var.cisli205.txai +  tssma612.tvam +  tssma612.vcam  
 	 	 	 if tcmcs036.tvat =  tctvat.shifted then  
 	 	 	 var.cisli205.stai =  var.cisli205.stai +  tssma612.tvam +  tssma612.vcam  
 	 	 	  
 	 	 	 if var.cisli205.stai <>  0.0 then  
 | *  MCR -  new changes .s 	 	 	  
 | 	 	 	 	 for i =  1 to 3 | *  MCR  
 | 	 	 	 	 	 calculate.amount.in.other.currency (var.cisli205.stai,  
 | 	 	 	 	 	 	 | *  MCR -  s  
 | 	 	 	 	 	 	 |tssma301.rats,  
 | 	 	 	 	 	 	 |tssma301.ratf,  
 | 	 	 	 	 	 	 fill.mc.field.double(tssma301.rats,i),  
 | 	 	 	 	 	 	 fill.mc.field.long(tssma301.ratf,i),  
 | 	 	 	 	 	 	 | *  MCR -  e  
 | 	 	 	 	 	 	 tssma301.ccur,  
 | 	 	 	 	 	 	 |var.cisli205.stah,  
 | 	 	 	 	 	 	 var.cisli205.stah(i), | *  MCR 	 	 	  
 | 	 	 	 	 	 	 err.mess)  
 | 	 	 	 	 endfor | *  MCR  
 	 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 	 calculate.amount.in.home.currency.variables(var.cisli205.stai, 	 	 	  
 	 	 	 	 	 tssma301.ccur, 	 	 	 	 	  
 	 	 	 	 	 fill.mc.field.double(tssma301.rats,i),  
 	 	 	 	 	 fill.mc.field.long(tssma301.ratf,i),  
 	 	 	 	 	 i,  
 	 	 	 	 	 var.cisli205.stah(i), 	 	 	 	 	 	 	  
 	 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 	 endfor 	 	 	 	 	 	  
 | *  MCR -  new changes .e  
 	 	 	 else  
 	 	 	 	 | *  MCR -  s  
 	 	 	 	 |var.cisli205.stah =  0.0  
 	 	 	 	 for i =  1 to 3  
 	 	 	 	 	 var.cisli205.stah(i) =  0.0  
 	 	 	 	 endfor  
 	 	 	 	 | *  MCR -  e  
 	 	 	 endif  
 	 	 	 endif 	  
 	 	 	 var.cisli205.scai =  var.cisli205.scai +  tssma612.csam  
 	 	 endselect  
 	 	 if var.cisli205.scai <>  0.0 then  
 | *  MCR -  new changes .s 	 	  
 | 	 	 	 for i =  1 to 3 | *  MCR  
 | 	 	 	 	 calculate.amount.in.other.currency (var.cisli205.scai, 	  
 | 	 	 	 	 	 	 | *  MCR -  s  
 | 	 	 	 	 	 	 |tssma611.rats,  
 | 	 	 	 	 	 	 |tssma611.ratf,  
 | 	 	 	 	 	 	 tmp.mc.tssma611.rats(i), 	 | *  MCR .n  
 | 	 	 	 	 	 	 tmp.mc.tssma611.ratf(i), 	 | *  MCR .n  
 | 	 	 	 	 	 	 | *  MCR -  e  
 | 	 	 	 	 	 	 tssma611.ccur,  
 | 	 	 	 	 	 	 |var.cisli205.scah,  
 | 	 	 	 	 	 	 var.cisli205.scah(i), | *  MCR  
 | 	 	 	 	 	 	 err.mess)  
 | 	 	 	 endfor | 	 *  MCR  
 	 	 	 for i =  1 to 3 	 	 	 	 	 	  
 	 	 	 	 calculate.amount.in.home.currency.variables(var.cisli205.scai, 	 	 	  
 	 	 	 	 tssma611.ccur, 	 	 	 	 	  
 	 	 	 	 tmp.mc.tssma611.rats(i),  
 	 	 	 	 tmp.mc.tssma611.ratf(i),  
 	 	 	 	 i,  
 	 	 	 	 var.cisli205.scah(i), 	 	 	 	 	 	 	  
 	 	 	 	 err.mess) 	 	 	 	 	 	  
 	 	 	 endfor 	 	 	 	 	 	  
 | *  MCR -  new changes .e  
 	 	 	  
 	 	 else  
 	 	 	 | *  MCR -  s  
 	 	 	 |var.cisli205.scah =  0.0  
 	 	 	 for i =  1 to 3  
 	 	 	 	 var.cisli205.scah(i) =  0.0  
 	 	 	 endfor  
 	 	 	 | *  MCR -  e  
 	 	 endif  
 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	  
 	 	 select tfacr200.*   
 	 	 from tfacr200  
 	 	 where tfacr200._index1 =  {:prev.tran, :prev.invn, 0}  
 | 	 	 and tfacr200.trec =  tfacr.trec.invoice 	 	 	 	 | #  200 -  101927.o  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.sn  
 	 	 and (tfacr200.trec =  tfacr.trec.invoice or 	  
 	 	 tfacr200.trec =  tfacr.trec.credit) 	 	 	 	  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.sn  
 	 	 	 if tfacr200.trec =  tfacr.trec.invoice then  
 	 	 	 	 var.tfacr200.trec =  target(cisli.doct.invoice)  
 	 	 	 else  
 	 	 	 	 var.tfacr200.trec =  target(cisli.doct.credit)  
 	 	 	 	 	 	 	 	 	 | #  148886.so  
 | 	 	 	 	 if var.cisli205.gdai >  0 then  
 | 	 	 	 	 	 var.cisli205.gdai = -  var.cisli205.gdai  
 | 	 	 	 	 endif  
 | 	 	 	 	 if var.cisli205.csai >  0 then  
 | 	 	 	 	 	 var.cisli205.csai = -  var.cisli205.csai  
 | 	 	 	 	 endif  
 | 	 	 	 	 if var.cisli205.dcai >  0 then  
 | 	 	 	 	 	 var.cisli205.dcai = -  var.cisli205.dcai  
 | 	 	 	 	 endif  
 	 	 	 	 	 	 	 	 	 | #  148886.eo  
 	 	 	 endif  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en  
 	 	 	 | *  MCR .s 	 	  
 	 	 	 for i =  1 to 3  
 	 	 	 	 tmp.mc.tssma611.amth(i) =  fill.mc.field.double(tfacr200.amth,i)  
 	 	 	 	 tmp.mc.tssma611.vath(i) =  fill.mc.field.double(tfacr200.vath,i)  
 	 	 	 	 tmp.mc.tssma611.sath(i) =  fill.mc.field.double(tfacr200.svah,i)  
 	 	 	 	 tmp.mc.tssma611.rats(i) =  fill.mc.field.double(tfacr200.rate,i)  
 	 	 	 	 tmp.mc.tssma611.ratf(i) =  fill.mc.field.long(tfacr200.ratf,i)  
 	 	 	 	 tmp.mc.tssma611.laph(i) =  fill.mc.field.double(tfacr200.laph,i)  
 	 	 	 	 tmp.mc.tssma611.dc1h(i) =  fill.mc.field.double(tfacr200.dc1h,i)  
 	 	 	 	 tmp.mc.tssma611.dc2h(i) =  fill.mc.field.double(tfacr200.dc2h,i)  
 	 	 	 	 tmp.mc.tssma611.dc3h(i) =  fill.mc.field.double(tfacr200.dc3h,i)  
 	 	 	 	 	 	 	 	 | #  148886.so  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.sn  
 | 	 	 	 	 if tfacr200.trec =  tfacr.trec.credit and tfacr200.amnt >  0 then  
 | 	 	 	 	 	 tmp.mc.tssma611.amth(i) = -  tmp.mc.tssma611.amth(i)  
 | 	 	 	 	 	 tmp.mc.tssma611.vath(i) = -  tmp.mc.tssma611.vath(i)  
 | 	 	 	 	 	 tmp.mc.tssma611.sath(i) = -  tmp.mc.tssma611.sath(i)  
 | 	 	 	 	 	 tmp.mc.tssma611.laph(i) = -  tmp.mc.tssma611.laph(i)  
 | 	 	 	 	 	 tmp.mc.tssma611.dc1h(i) = -  tmp.mc.tssma611.dc1h(i)  
 | 	 	 	 	 	 tmp.mc.tssma611.dc2h(i) = -  tmp.mc.tssma611.dc2h(i)  
 | 	 	 	 	 	 tmp.mc.tssma611.dc3h(i) = -  tmp.mc.tssma611.dc3h(i)  
 | 	 	 	 	 endif  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en  
 	 	 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 | #  148886.eo 	 	  
 	 	 	 endfor 	  
 	 	 	 | *  MCR .e  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.sn  
 	  
 	 	 	 var.tfacr200.amti =  tfacr200.amti  
 	 	 	 var.tfacr200.vati =  tfacr200.vati  
 	 	 	 var.tfacr200.svam =  tfacr200.svam  
 	 	 	 var.tfacr200.lapi =  tfacr200.lapi 	  
 	 	 	 l.tbai =  tfacr200.amti -  tfacr200.vati  
 	 	 	 var.tfacr200.dc1i =  tfacr200.dc1i  
 	 	 	 var.tfacr200.dc2i =  tfacr200.dc2i  
 	 	 	 var.tfacr200.dc3i =  tfacr200.dc3i  
 	 	 	 	 	 	 	 	 | #  148886.so  
 | 	 	 	 if tfacr200.trec =  tfacr.trec.credit and tfacr200.amnt >  0 then  
 | 	 	 	 	 var.tfacr200.amti = -  tfacr200.amti  
 | 	 	 	 	 var.tfacr200.vati = -  tfacr200.vati  
 | 	 	 	 	 var.tfacr200.svam = -  tfacr200.svam  
 | 	 	 	 	 var.tfacr200.lapi = -  tfacr200.lapi  
 | 	 	 	 	 var.tfacr200.dc1i = -  tfacr200.dc1i  
 | 	 	 	 	 var.tfacr200.dc2i = -  tfacr200.dc2i  
 | 	 	 	 	 var.tfacr200.dc3i = -  tfacr200.dc3i  
 | 	 	 	 	 l.tbai = -  (tfacr200.amti -  tfacr200.vati)  
 | 	 	 	 endif  
 	 	 	 	 	 	 	 	 | #  148886.eo  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en  
 	 	 	 fill.cisli205.fields (tssma611.ncmp,tfacr200.ttyp, tfacr200.ninv,1,6,  
 	 	 	 var.cisli250.bpid, var.cisli250.itad, var.cisli250.cofc,  
 	 	 	 tfacr200.ccrs, tfacr200.cpay, new.txct,6,0,0,0,0,no.of.records,0,  
 	 	 	 tssma611.ccur,tfacr200.docd,  
 | 	 	 	 tfacr200.amti, 	 	 	 	 	 	 | #  200 -  101927.o  
 	 	 	 var.tfacr200.amti, 	 	 	 	 	 | #  200 -  101927.n  
 	 	 	 |tfacr200.amth,  
 	 	 	 tmp.mc.tssma611.amth, | *  MCR  
 | 	 	 	 tfacr200.vati, 	 	 	 	 	 	 | #  200 -  101927.o  
 	 	 	 var.tfacr200.vati, 	 	 	 	 	 | #  200 -  101927.n  
 	 	 	 |tfacr200.vath,  
 	 	 	 tmp.mc.tssma611.vath, | *  MCR  
 | 	 	 	 tfacr200.svam, 	 	 	 	 	 | #  200 -  101927.o 	 	  
 	 	 	 var.tfacr200.svam, 	 	 	 	 	 | #  200 -  101927.n  
 	 	 	 | *  MCR -  s  
 	 	 	 |tfacr200.svah,  
 	 	 	 |tfacr200.rate,  
 	 	 	 |tfacr200.ratf,  
 	 	 	 tmp.mc.tssma611.sath,  
 	 	 	 tmp.mc.tssma611.rats,  
 	 	 	 tmp.mc.tssma611.ratf,  
 	 	 	 | *  MCR -  e  
 	 	 	 tfacr200.lpdt,  
 | 	 	 	 tfacr200.lapa, 	 	 	 	 	 	 | #  200 -  101927.o  
 	 	 	 var.tfacr200.lapi, 	 	 	 	 	 | #  200 -  101927.n  
 	 	  
 	 	 	 |tfacr200.laph,  
 	 	 	 tmp.mc.tssma611.laph, | *  MCR  
 	 	 	 var.cisli205.gdai,var.cisli205.csai,  
 	 	 	 0.0,  
 	 	 	 |tfacr200.dc1i, 	 	 	 | #  200 -  101927.o  
 	 	 	 var.tfacr200.dc1i, 	 	 | #  200 -  101927.n  
 	 	 	 |tfacr200.dc1h,  
 	 	 	 tmp.mc.tssma611.dc1h, | *  MCR  
 	 	 	 tfacr200.did1,  
 	 	 	 |tfacr200.dc2i, 	 	 	 | #  200 -  101927.o  
 	 	 	 var.tfacr200.dc2i, 	 	 | #  200 -  101927.n  
 	 	 	 |tfacr200.dc2h,  
 	 	 	 tmp.mc.tssma611.dc2h, | *  MCR  
 	 	 	 tfacr200.did2,  
 	 	 	 |tfacr200.dc3i, 	 	 	 | #  200 -  101927.o  
 	 	 	 var.tfacr200.dc3i, 	 	 | #  200 -  101927.n  
 	 	 	 |tfacr200.dc3h,  
 	 	 	 tmp.mc.tssma611.dc3h, | *  MCR  
 	 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.so 	 	  
 | 	 	 	 tfacr200.did3, tfacr200.paym, 0,var.cisli205.dcai,tfacr200.amti -  tfacr200.vati)  
 	 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.eo  
 	 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.sn 	 	 	 	 	 	  
 	 	 	 tfacr200.did3, tfacr200.paym, 0,var.cisli205.dcai,  
 	 	 	 l.tbai,  
 | 	 	 	 var.tfacr200.trec) 	 	 	 	 	 	 	 |Jyosh.o  
 	 	 	 var.tfacr200.trec, new.bpct) 	 	 	 	 	 	 |Jyosh.n 	 	 	  
 	 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en 	  
 	 	  
 	 	 	 dump.cisli205 ()  
 	 	 	 reset.variables.cisli205 ()  
 	 	 endselect  
 	 	 	  
 	 	 	 	 	 	 	 	 	 |bin.so  
 | 	 	 fill.cisli205.fields (tssma611.ncmp,tssma611.ttyp, tssma611.invn,1,6, |binda.n  
 | 	 	 var.cisli250.bpid, var.cisli250.itad, var.cisli250.cofc,  
 | 	 	 tssma611.ccrs, tssma611.cpay, new.txct,6,0,0,0,0,no.of.records,0,tssma611.ccur,tssma611.invd,  
 | 	 	 var.cisli205.amti, var.cisli205.amth, var.cisli205.txai, var.cisli205.txah, var.cisli205.stai, var.cisli205.stah,  
 | 	 	 tssma611.rats,tssma611.ratf, var.cisli205.scdt, var.cisli205.scai, var.cisli205.scah,var.cisli205.gdai,  
 | 	 	 var.cisli205.csai,0.0, var.cisli205.d1ai, var.cisli205.d1ah, var.cisli205.d1dt, var.cisli205.d2ai, var.cisli205.d2ah, var.cisli205.d2dt,var.cisli205.d3ai,  
 | 	 	 var.cisli205.d3ah, var.cisli205.d3dt,"", 0,var.cisli205.dcai,var.cisli205.amti -  var.cisli205.txai)  
 | 	 	 dump.cisli205 ()  
 | 	 	 reset.variables.cisli205 ()  
 	 	 	 	 	 	 	 	 |bin.eo 	 	 	  
 	 endif  
 	 cisli209.dumped =  true 	 	 	 |ravi_cisli209.n  
 	 if (total.records >=  20000 and 	 	 |haddock.err.sn  
 	 	 	 tppin190.accessed and 	  
 	 	 	 cisli209.dumped ) then  
 	 	 	 	 reinitialize.cache()  
 	 endif 	 	 	 	 	 |haddock.err.en  
 	 free.memories() 	 	 	 	 |ravi_array.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:ts
:SCMOD:sma
:SFLNO:611
:ICOD:S
:QURY:START
select 	 tssma611.*  , tssma301.*  , tssma310.*  ,tiitm001.kitm 	 	 | #  200 -  101926.n  
 |from tssma611, tssma301, tssma310 	 	 	 	 	 | #  200 -  101926.o
from tssma611, tssma301, tssma310,tiitm001 	 	 	 	 | #  200 -  101926.n
where tssma611.titr =  tssma.titr.serviceorder  
 and tssma611.ista >  tssma.ista.checked 	 	 	  
 and 	 tssma310._index3 =  {tssma611.invn, tssma611.ttyp, tssma611.ncmp}  
 and 	 tssma310.orno refers to tssma301  
 and 	 tssma310.item refers to tiitm001 	 	 	 	 	 | #  200 -  101926.n
order by tssma310._index3
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ci
:TCMOD:sli
:TFLNO:205
:SCPAC:ts
:SCMOD:sma
:SFLNO:611
:ICOD:X
:QURY:START
temp.scai =  0  
 order.count =  0  
 free.mem ( servorder.array )  
 reset.variables.cisli205 ()  
 hold.orno =  0  
 prev.tran =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
 prev.invn =  0  
 | dump.cisli206 () 	 	 	 | #  ravi_array.so  
 | delete.bcsci002.records.cisli206 ()  
 | dump.cisli209 ()  
 | delete.bcsci002.records.cisli209 () 	 | #  ravi_array.eo
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:000
:SCPAC:cp
:SCMOD:rpd
:SFLNO:000
:ICOD:D
:QURY:START
	 get.scenario(get.compnr(), cprpd000.aplc, var.cprpd000.aplc, err.msg)  
 	 var.cprpd000.indt =  utc(0,0)  
 	 var.cprpd000.dsca =  form.text$("bcstc00035") 	 | *  Actual Set  
 	 Dump 1  
 	 var.cprpd000.indt =  utc(date.num(), time.num())  
 	 var.cprpd000.dsca =  form.text$("bcstc00036") 	 | *  Converted from BaanIVc4  
 	 Dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:000
:SCPAC:cp
:SCMOD:rpd
:SFLNO:000
:ICOD:S
:QURY:START
select cprpd000.*
from cprpd000  
 as set with 1 rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:000
:SCPAC:cp
:SCMOD:rpd
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:000
:SCPAC:ti
:SCMOD:mps
:SFLNO:000
:ICOD:D
:QURY:START
	 get.scenario(get.compnr(), timps000.apln, var.cprpd000.aplc, err.msg)  
 	 var.cprpd000.indt =  utc(0,0)  
 	 var.cprpd000.dsca =  form.text$("bcstc00035") 	 | *  Actual Set  
 	 Dump 2  
 	 var.cprpd000.indt =  utc(date.num(), time.num())  
 	 var.cprpd000.dsca =  form.text$("bcstc00036") 	 | *  Converted from BaanIVc4  
 	 Dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:000
:SCPAC:ti
:SCMOD:mps
:SFLNO:000
:ICOD:S
:QURY:START
select 	 timps000.*
from timps000  
 as set with 1 rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:000
:SCPAC:ti
:SCMOD:mps
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:000
:SCPAC:ti
:SCMOD:mrp
:SFLNO:000
:ICOD:D
:QURY:START
	 var.cprpd000.indt =  utc(0,0)  
 	 var.cprpd000.dsca =  form.text$("bcstc00035") 	 | *  Actual Set  
 	 Dump 3  
 	 var.cprpd000.indt =  utc(date.num(), time.num())  
 	 var.cprpd000.dsca =  form.text$("bcstc00036") 	 | *  Converted from BaanIVc4  
 	 Dump 3
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:000
:SCPAC:ti
:SCMOD:mrp
:SFLNO:000
:ICOD:S
:QURY:START
select timrp000.*
from timrp000  
 as set with 1 rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:000
:SCPAC:ti
:SCMOD:mrp
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:100
:SCPAC:bc
:SCMOD:scp
:SFLNO:003
:ICOD:D
:QURY:START
on case strip$(bcscp003.tabl)  
 	 case "timps200":                                                                                                                
 	 	 migrate.timps200(bcscp003.item)  
 	 	 break  
 	 case "cprpd100":                                                                                                                
 	 	 migrate.cprpd100(bcscp003.item)  
 	 	 break  
 	 case "tiitm001":                                                                                                                
 	 	 migrate.tiitm001(bcscp003.item)  
 	 	 break  
 	 case "tipcs021":                                                                                                                
 	 	 migrate.tipcs021(bcscp003.item, bcscp003.cprj)  
 	 	 break  
 | #  800 -  139660.sn  
 	 case "tipcs022":                                                                                                                
 	 	 migrate.tipcs022(bcscp003.item, bcscp003.cprj)  
 	 	 break  
 | #  800 -  139660.en  
 	 case "trdrp010":                                                                                                                
 	 	 migrate.trdrp010(bcscp003.item, bcscp003.clus, bcscp003.cwar)  
 	 	 break  
 	 endcase
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:100
:SCPAC:bc
:SCMOD:scp
:SFLNO:003
:ICOD:S
:QURY:START
select 	 bcscp003.*
from 	 bcscp003
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:100
:SCPAC:bc
:SCMOD:scp
:SFLNO:003
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:400
:SCPAC:bc
:SCMOD:scp
:SFLNO:000
:ICOD:D
:QURY:START
	 num.to.week(date.num(), var.week.dayno, dum, dum)  
 	 var.start.current.week =  date.num() -  var.week.dayno  
 	  
 	 dump 3
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:400
:SCPAC:bc
:SCMOD:scp
:SFLNO:000
:ICOD:S
:QURY:START
select 	 bcscp000.*
from 	 bcscp000  
 as set with 1 rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:400
:SCPAC:bc
:SCMOD:scp
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:400
:SCPAC:cp
:SCMOD:rpd
:SFLNO:400
:ICOD:D
:QURY:START
	 get.scenario(get.compnr(), cprpd400.plnc, var.cprpd400.plnc, err.mess)  
 	 if (cprpd400.plfd <=  date.num ()) then  
 	 	 var.plst =  cprpd.plst.closed  
 	 else  
 	 	 var.plst =  cprpd400.plst  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:400
:SCPAC:cp
:SCMOD:rpd
:SFLNO:400
:ICOD:S
:QURY:START
select 	 cprpd400.*
from cprpd400
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:400
:SCPAC:cp
:SCMOD:rpd
:SFLNO:400
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:400
:SCPAC:ti
:SCMOD:mps
:SFLNO:100
:ICOD:D
:QURY:START
	 get.scenario(get.compnr(), timps100.plnc, var.cprpd400.plnc, err.mess)  
 	 if (timps100.plfd <=  date.num ()) then  
 	 	 var.plst =  cprpd.plst.closed  
 	 else  
 	 	 if timps100.plst =  timps.plst.open then  
 	 	 	 var.plst =  cprpd.plst.open  
 	 	 else  
 	 	 	 var.plst =  cprpd.plst.closed  
 	 	 endif  
 	 endif  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:400
:SCPAC:ti
:SCMOD:mps
:SFLNO:100
:ICOD:S
:QURY:START
select 	 timps100.*  , timps100.bdfc, timps100.fdfc
from 	 timps100
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:400
:SCPAC:ti
:SCMOD:mps
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:600
:SCPAC:cp
:SCMOD:rpu
:SFLNO:100
:ICOD:D
:QURY:START


 
 	  if  	  cprpu100.plme =  cprpd.plme.cyclicplanning or  
 	   	  cprpu100.plme =  cprpd.plme.infinitplanning then  
 	   	  var.cprpd600.plme =  1  |  *  cprpd.plme.infinitplanning  
 
 	  else  
 	   	  var.cprpd600.plme =  3  |  *  cprpd.plme.workloadcontrol  
 
 	  endif  
 	  dump 1  
 
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:600
:SCPAC:cp
:SCMOD:rpu
:SFLNO:100
:ICOD:S
:QURY:START


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

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rpd
:TFLNO:600
:SCPAC:cp
:SCMOD:rpu
:SFLNO:100
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:bc
:SCMOD:scp
:SFLNO:004
:ICOD:D
:QURY:START
	 itm.cprj =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
 	 itm.clus =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
 	 skip.record =  false  
 	 if timps000.irpi =  tcyesno.no then  
 	 	 select 	 timps200.cplb:var.cprrp100.cplb  
 	 	 from 	 timps200  
 	 	 where 	 timps200._index1 =  {:bcscp004.plnc, :bcscp004.plvl, :bcscp004.plni, :bcscp004.cont}  
 	 	 as set with 1 rows  
 	 	 selectempty  
 	 	 	 | *  Should not happen  
 	 	 	 skip.record =  true  
 	 	 endselect  
 	 	 select 	 timps320.pdat:var.cprrp100.pfdt,  
 	 	 	 timps320.sprd:var.cprrp100.psdt,  
 	 	 	 timps320.pqan:var.cprrp100.oqan,  
 	 	 	 timps320.ssit:var.cprrp100.susi  
 	 	 from 	 timps320  
 	 	 where 	 timps320._index1 =  {:bcscp004.plnc, :bcscp004.plvl, :bcscp004.plni, :bcscp004.cont, :bcscp004.pdat, :bcscp004.sern}  
 	 	 as set with 1 rows  
 	 	 selectempty  
 	 	 	 | *  Should not happen  
 	 	 	 skip.record =  true  
 	 	 endselect  
 	 else  
 	 	 select 	 cprpd100.plid:var.cprrp100.cplb  
 	 	 from 	 cprpd100  
 	 	 where 	 cprpd100._index1 =  {:bcscp004.plnc, :bcscp004.plvl, :bcscp004.plni, :bcscp004.cont}  
 	 	 as set with 1 rows  
 	 	 selectempty  
 	 	 	 | *  Should not happen  
 	 	 	 skip.record =  true  
 	 	 endselect  
 	 	 select 	 cprmp150.pdat:var.cprrp100.pfdt,  
 	 	 	 cprmp150.sprd:var.cprrp100.psdt,  
 	 	 	 cprmp150.pqan:var.cprrp100.oqan,  
 	 	 	 cprmp150.ssit:var.cprrp100.susi  
 	 	 from 	 cprmp150  
 	 	 where 	 cprmp150._index1 =  {:bcscp004.plnc, :bcscp004.plvl, :bcscp004.plni, :bcscp004.cont, :bcscp004.pdat, :bcscp004.sern}  
 	 	 as set with 1 rows  
 	 	 selectempty  
 	 	 	 | *  Should not happen  
 	 	 	 skip.record =  true  
 	 	 endselect  
 	 endif  
 	 select 	 tiitm001.cwar:var.cprrp100.dwar  
 	 from 	 tiitm001  
 	 where 	 tiitm001._index1 =  {:bcscp004.plni}  
 	 as set with 1 rows  
 	 selectempty  
 	 	 | *  This can happen for Family Items  
 	 	 var.cprrp100.dwar =  bcscp000.cwar  
 	 endselect  
 	 select 	 tiitm001.cwar:var.cprrp100.suwa  
 	 from 	 tiitm001  
 	 where 	 tiitm001._index1 =  {:bcscp004.plni}  
 	 and 	 tiitm001._compnr =  :var.cprrp100.susi  
 	 as set with 1 rows  
 	 selectempty  
 	 	 | *  This can happen for Family Items. Select from other company !   
 	 	 select 	 bcscp000.cwar:var.cprrp100.suwa  
 	 	 from 	 bcscp000  
 	 	 where 	 bcscp000._compnr =  :var.cprrp100.susi  
 	 	 as set with 1 rows  
 	 	 selectempty  
 	 	 	 skip.record =  true  
 	 	 endselect  
 	 endselect  
 	 if skip.record then  
 	 	 | *  This should not happen  
 	 	 continue  
 	 endif  
 	 get.scenario(get.compnr(), bcscp004.plnc, var.cprrp100.plnc, err.mess)  
 	 if get.planned.order.and.order.type(  
 	 	 	 	 	 empty,  
 	 	 	 	 	 bcscp004.orno,  
 	 	 	 	 	 var.cprrp100.type,  
 	 	 	 	 	 var.cprrp100.orno,  
 	 	 	 	 	 err.mess) then  
 	 	 continue  
 	 endif  
 	 if get.plan.item(bcscp004.plni, itm.cprj, itm.clus, err.mess) then  
 	 | *  Skip the item when the code has not been found  
 	 	 continue  
 	 else  
 	 	 var.cprrp010.code =  bcscp003.code  
 	 endif  
 	 var.cprrp010.plnc =  var.cprrp100.plnc  
 	 var.cprrp010.resi =  var.curr.site  
 	 var.cprrp010.koor =  var.cprrp100.type  
 	 var.cprrp010.orno =  var.cprrp100.orno  
 	 var.cprrp010.pono =  0  
 	 var.cprrp010.kotr =  convert.tckotr(tckotr.receipt)  
 	 var.cprrp010.date =  bcscp004.pdat  
 	 var.cprrp010.time =  get.time(tckotr.receipt)  
 	 var.cprrp010.qana =  bcscp004.pqan  
 	 var.cprrp100.item =  cp.segment.item.code(bcscp004.plni, itm.cprj, itm.clus)  
 	 var.cprrp100.plmt =  get.plmt(empty, empty)  
 	 var.cprrp100.pstm =  get.time(tckotr.requirement)  
 	 var.cprrp100.pftm =  get.time(tckotr.receipt)  
 	 var.cprrp100.trdt =  date.num()  
 	 var.cprrp100.osta =  get.mps.osta(empty)  
 	 var.cprrp100.supl =  var.cprrp100.item  
 	 dump 1 	 | *  Planned Orders  
 	 dump 5 	 | *  Inventory Movements
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:bc
:SCMOD:scp
:SFLNO:004
:ICOD:S
:QURY:START
select 	 bcscp004.*
from 	 bcscp004
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:bc
:SCMOD:scp
:SFLNO:004
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:cp
:SCMOD:rmp
:SFLNO:140
:ICOD:D
:QURY:START
	 itm.cprj =  ""                                                                                                                                                                                                                                                                                                                                                            
 	 itm.clus =  ""                                                                                                                                                                                                                                                                                                                                                            
 	 get.scenario(var.curr.site, cprmp140.plnc, var.cprrp010.plnc, err.mess)  
 	 if get.interplant.receipt.number.multisite( 	  
 	 	 	 	 	 cprmp140.rsit,  
 	 	 	 	 	 cprmp140.rpln,  
 	 	 	 	 	 cprmp140.rplv,  
 	 	 	 	 	 cprmp140.plni,  
 	 	 	 	 	 cprmp140.cont,  
 	 	 	 	 	 cprmp140.rprd,  
 	 	 	 	 	 cprmp140.rser,  
 	 	 	 	 	 err.mess) then  
 	 	 continue  
 	 else  
 	 	 ipl.orno =  bcscp004.orno  
 	 endif  
 	 | *  Note: Order Type value 'empty' has been reserved for interplant demand /  receipt.  
 	 if get.planned.order.and.order.type(  
 	 	 	 	 	 empty,  
 	 	 	 	 	 ipl.orno,  
 	 	 	 	 	 var.cprrp010.koor,  
 	 	 	 	 	 var.cprrp010.orno,  
 	 	 	 	 	 err.mess) then  
 	 	 continue  
 	 endif  
 	 if get.plan.item(cprmp140.plni, itm.cprj, itm.clus, err.mess) then  
 	 | *  Skip the item when the code has not been found  
 	 	 continue  
 	 else  
 	 	 var.cprrp010.code =  bcscp003.code  
 	 endif  
 	 var.cprrp010.resi =  cprmp140.rsit  
 	 var.cprrp010.pono =  10  
 	 var.cprrp010.kotr =  convert.tckotr(tckotr.requirement)  
 	 var.cprrp010.date =  cprmp140.pddt  
 	 var.cprrp010.time =  get.time(tckotr.requirement) 	  
 	 var.cprrp010.qana =  cprmp140.pqan  
 	 dump 5 	 	 | *  Inventory Movements
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:cp
:SCMOD:rmp
:SFLNO:140
:ICOD:S
:QURY:START
select 	 cprmp140.*
from 	 cprmp140
where 	 cprmp140.cont =  ""
:QURY:END
:TEXT:
Planned Interplant Demand will be migrated to a Planned Inventory Movement, related to the Planned Interplant Receipt.
:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:cp
:SCMOD:rmp
:SFLNO:140
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:td
:SCMOD:inv
:SFLNO:150
:ICOD:D
:QURY:START
	 itm.cprj =  ""                                                                                                                                                                                                                                                        
 	 itm.clus =  ""                                                                                                                                                                                                                                                        
 	 var.cprrp010.plnc =  act.plnc  
 	 var.cprrp010.resi =  var.curr.site  
 	 if get.planned.order.and.order.type( 	  
 	 	 	 	 tdinv150.koor,  
 	 	 	 	 tdinv150.orno,  
 	 	 	 	 var.cprrp010.koor,  
 	 	 	 	 var.cprrp010.orno,  
 	 	 	 	 err.mess) then  
 	 	 continue  
 	 endif  
 	 if get.plan.item(tdinv150.item, itm.cprj, itm.clus, err.mess) then  
 	 | *  Skip the item when the code has not been found  
 	 	 continue  
 	 else  
 	 	 var.cprrp010.code =  bcscp003.code  
 	 endif  
 	 var.cprrp010.kotr =  convert.tckotr(tdinv150.kotr)  
 	 var.cprrp010.pono =  get.inv150.position.number(tdinv150.cprj, tdinv150.orno)  
 	 var.cprrp010.date =  tdinv150.date  
 	 var.cprrp010.time =  get.time( 	 tdinv150.kotr)  
 	 var.cprrp010.qana =  tdinv150.qana  
 	 dump 5 	 | *  Inventory Movements
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:td
:SCMOD:inv
:SFLNO:150
:ICOD:S
:QURY:START
select 	 tdinv150.*
from 	 tdinv150, tipcs020, tipcs510
where 	 tdinv150.koor =  tckoor.pcs.sfc  
 and 	 tdinv150.cprj refers to tipcs020  
 and 	 tipcs020.prtp <>  tcyesno.yes  
 and 	 tdinv150.item refers to tiitm001  
 and 	 (tiitm001.osys =  tcosys.mps or  
 	 tiitm001.osys =  tcosys.mrp )  
 and 	 {tdinv150.cprj, tdinv150.orno} refers to tipcs510  
 and 	 tipcs510.osta <>  tcorsa.actualized  
 and 	 tipcs510.osta <>  tcorsa.cancelled
order by tdinv150._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:td
:SCMOD:inv
:SFLNO:150
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:310
:ICOD:D
:QURY:START
	 itm.cprj =  ""                                                                                                                                                                                                                                                                                                                                                        
 	 itm.clus =  ""                                                                                                                                                                                                                                                                                                                                                        
 	 get.scenario(var.curr.site, timps310.plnc, var.cprrp010.plnc, err.mess)  
 	 if get.interplant.receipt.number.multisite( 	  
 	 	 	 	 	 timps310.rsit,  
 	 	 	 	 	 timps310.rpln,  
 	 	 	 	 	 timps310.rplv,  
 	 	 	 	 	 timps310.plni,  
 	 	 	 	 	 timps310.plct,  
 	 	 	 	 	 timps310.rprd,  
 	 	 	 	 	 timps310.rser,  
 	 	 	 	 	 err.mess) then  
 	 	 continue  
 	 else  
 	 	 ipl.orno =  bcscp004.orno  
 	 endif  
 	 | *  Note: Order Type value 'empty' has been reserved for interplant demand /  receipt.  
 	 if get.planned.order.and.order.type(  
 	 	 	 	 	 empty,  
 	 	 	 	 	 ipl.orno,  
 	 	 	 	 	 var.cprrp010.koor,  
 	 	 	 	 	 var.cprrp010.orno,  
 	 	 	 	 	 err.mess) then  
 	 	 continue  
 	 endif  
 	 if get.plan.item(timps310.plni, itm.cprj, itm.clus, err.mess) then  
 	 | *  Skip the item when the code has not been found  
 	 	 continue  
 	 else  
 	 	 var.cprrp010.code =  bcscp003.code  
 	 endif  
 	 var.cprrp010.resi =  timps310.rsit  
 	 var.cprrp010.pono =  10  
 	 var.cprrp010.kotr =  convert.tckotr(tckotr.requirement)  
 	 var.cprrp010.date =  timps310.pddt  
 	 var.cprrp010.time =  get.time(tckotr.requirement) 	  
 	 var.cprrp010.qana =  timps310.pqan  
 	 dump 5 	 	 | *  Inventory Movements
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:310
:ICOD:S
:QURY:START
select 	 timps310.*
from 	 timps310
where 	 timps310.plct =  ""
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:310
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:510
:ICOD:D
:QURY:START
	 itm.cprj =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
 	 itm.clus =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
 	 skip.record =  false  
 	 if get.plan.item(timps510.item, itm.cprj, itm.clus, err.mess) then  
 	 | *  Skip the item when the code has not been found  
 	 	 continue  
 	 else  
 	 	 var.cprrp010.code =  bcscp003.code  
 	 endif  
 	 if timps510.toio =  timps.toio.ipl.receipt then  
 	 	 if timps000.irpi =  tcyesno.no then  
 	 	 	 select 	 timps200.cplb:var.cprrp100.cplb  
 	 	 	 from 	 timps200  
 	 	 	 where 	 timps200._index3 =  {:timps000.apln, :timps510.item, :timps510.cont}  
 	 	 	 as set with 1 rows  
 	 	 	 selectempty  
 	 	 	 	 skip.record =  true  
 	 	 	 endselect  
 	 	 else  
 	 	 	 select cprpd100.plid:var.cprrp100.cplb  
 	 	 	 from 	 cprpd100  
 	 	 	 where 	 cprpd100._index2 =  {:cprpd000.aplc, :timps510.item, :timps510.cont}  
 	 	 	 as set with 1 rows  
 	 	 	 selectempty  
 	 	 	 	 skip.record =  true  
 	 	 	 endselect  
 	 	 endif  
 	 	 var.cprrp100.dwar =  timps510.cwar  
 	 	 if isspace(var.cprrp100.dwar) then  
 	 	 	 select 	 tiitm001.cwar:var.cprrp100.dwar  
 	 	 	 from 	 tiitm001  
 	 	 	 where 	 tiitm001._index1 =  {:timps510.item}  
 	 	 	 as set with 1 rows  
 	 	 	 selectempty  
 	 	 	 	 var.cprrp100.dwar =  bcscp000.cwar  
 	 	 	 endselect  
 	 	 endif  
 	 	 var.cprrp100.susi =  timps510.iprl  
 	 	 select tiitm001.cwar:var.cprrp100.suwa  
 	 	 from 	 tiitm001  
 	 	 where 	 tiitm001._index1 =  {:timps510.item}  
 	 	 and 	 tiitm001._compnr =  :var.cprrp100.susi  
 	 	 as set with 1 rows  
 	 	 selectempty  
 	 	 	 select bcscp000.cwar:var.cprrp100.suwa  
 	 	 	 from 	 bcscp000  
 	 	 	 where 	 bcscp000._compnr =  :var.cprrp100.susi  
 	 	 	 as set with 1 rows  
 	 	 	 selectempty  
 	 	 	 	 skip.record =  true  
 	 	 	 endselect  
 	 	 endselect  
 	 	 if skip.record then  
 	 	 	 | *  This should not happen  
 	 	 	 continue  
 	 	 endif  
 	 	 if get.planned.order.and.order.type(  
 	 	 	 	 	 	 tckoor.mps.ipl,  
 	 	 	 	 	 	 timps510.orno,  
 	 	 	 	 	 	 var.cprrp100.type,  
 	 	 	 	 	 	 var.cprrp100.orno,  
 	 	 	 	 	 	 err.mess) then  
 	 	 	 continue  
 	 	 endif  
 	 	 var.cprrp100.plnc =  act.plnc  
 	 	 var.cprrp010.plnc =  var.cprrp100.plnc  
 	 	 var.cprrp010.resi =  var.curr.site  
 	 	 var.cprrp010.koor =  var.cprrp100.type  
 	 	 var.cprrp010.orno =  var.cprrp100.orno  
 	 	 var.cprrp010.pono =  0  
 	 	 var.cprrp010.kotr =  convert.tckotr(tckotr.receipt)  
 	 	 var.cprrp010.date =  timps510.pddt  
 	 	 var.cprrp010.time =  get.time(tckotr.receipt)  
 	 	 var.cprrp010.qana =  timps510.oqan  
 	 	 var.cprrp100.item =  cp.segment.item.code(timps510.item, itm.cprj, itm.clus)  
 	 	 var.cprrp100.plmt =  get.plmt(timps510.cpla, empty)  
 	 	 var.cprrp100.psdt =  timps510.podt  
 	 	 var.cprrp100.pfdt =  timps510.pddt  
 	 	 var.cprrp100.trdt =  timps510.trdt  
 	 	 var.cprrp100.pstm =  get.time(tckotr.requirement)  
 	 	 var.cprrp100.pftm =  get.time(tckotr.receipt)  
 	 	 var.cprrp100.osta =  get.mps.osta(timps510.osta)  
 	 	 var.cprrp100.oqan =  timps510.oqan  
 	 	 var.cprrp100.supl =  var.cprrp100.item  
 	 	 dump 1 	 | *  Planned Orders  
 	 	 dump 5 	 | *  Inventory Movements  
 	 else  
 	 	 var.cprrp010.resi =  timps510.iprl  
 	 	 var.cprrp010.plnc =  act.plnc  
 	 	 if get.planned.order.and.order.type(  
 	 	 	 	 	 tckoor.mps.ipl,  
 	 	 	 	 	 timps510.iprf,  
 	 	 	 	 	 var.cprrp010.koor,  
 	 	 	 	 	 var.cprrp010.orno,  
 	 	 	 	 	 err.mess) then  
 	 	 	 continue  
 	 	 endif  
 	 	 var.cprrp010.pono =  10  
 	 	 var.cprrp010.kotr =  convert.tckotr(tckotr.requirement)  
 	 	 var.cprrp010.date =  timps510.pddt  
 	 	 var.cprrp010.time =  get.time(tckotr.requirement)  
 	 	 var.cprrp010.qana =  timps510.oqan  
 	 	 dump 5 	 | *  Inventory Movements  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:510
:ICOD:S
:QURY:START
select 	 timps510.*
from 	 timps510
where 	 timps510.cont =  ""
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:510
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:520
:ICOD:D
:QURY:START
	 itm.cprj =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                              
 	 itm.clus =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                              
 	 var.cprrp100.plnc =  act.plnc  
 	 if get.planned.order.and.order.type(  
 	 	 	 	 	 tckoor.mps.sfc,  
 	 	 	 	 	 timps520.orno,  
 	 	 	 	 	 var.cprrp100.type,  
 	 	 	 	 	 var.cprrp100.orno,  
 	 	 	 	 	 err.mess) then  
 	 	 continue  
 	 endif  
 	 if get.plan.item(timps520.item, itm.cprj, itm.clus, err.mess) then  
 	 | *  Skip the item when the code has not been found  
 	 	 continue  
 	 else  
 	 	 var.cprrp010.code =  bcscp003.code  
 	 endif  
 	 var.cprrp010.plnc =  var.cprrp100.plnc  
 	 var.cprrp010.resi =  var.curr.site  
 	 var.cprrp010.koor =  var.cprrp100.type  
 	 var.cprrp010.orno =  var.cprrp100.orno  
 	 var.cprrp010.pono =  0  
 	 var.cprrp010.kotr =  convert.tckotr(tckotr.receipt)  
 	 var.cprrp010.date =  timps520.pfdt  
 	 var.cprrp010.time =  get.time(tckotr.receipt)  
 	 var.cprrp010.qana =  timps520.oqan  
 	 var.cprrp100.item =  cp.segment.item.code(timps520.item, itm.cprj, itm.clus)  
 	 var.cprrp100.plmt =  get.plmt(timps520.cpla, empty)  
 	 var.cprrp100.psdt =  timps520.psdt  
 	 var.cprrp100.pfdt =  timps520.pfdt  
 	 var.cprrp100.trdt =  timps520.trdt  
 	 var.cprrp100.pstm =  get.time(tckotr.requirement)  
 	 var.cprrp100.pftm =  get.time(tckotr.receipt)  
 	 var.cprrp100.cplb =  timps520.cplb  
 	 var.cprrp100.osta =  get.mps.osta(timps520.osta)  
 	 var.cprrp100.dwar =  timps520.cwar  
 	 var.cprrp100.oqan =  timps520.oqan  
 	 var.cprrp100.opro =  timps520.opro  
 	 var.cprrp100.txta =  empty()  
 	 dump 2 	 | *  Planned Orders  
 	 dump 5 	 | *  Inventory Movements
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:520
:ICOD:S
:QURY:START
select 	 timps520.*
from 	 timps520
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:520
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:530
:ICOD:D
:QURY:START
	 itm.cprj =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                      
 	 itm.clus =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                      
 	 var.cprrp100.plnc =  act.plnc  
 	 if get.planned.order.and.order.type(  
 	 	 	 	 	 tckoor.mps.pur,  
 	 	 	 	 	 timps530.orno,  
 	 	 	 	 	 var.cprrp100.type,  
 	 	 	 	 	 var.cprrp100.orno,  
 	 	 	 	 	 err.mess) then  
 	 	 continue  
 	 endif  
 	 if get.plan.item(timps530.item, itm.cprj, itm.clus, err.mess) then  
 	 | *  Skip the item when the code has not been found  
 	 	 continue  
 	 else  
 	 	 var.cprrp010.code =  bcscp003.code  
 	 endif  
 	 var.cprrp010.plnc =  var.cprrp100.plnc  
 	 var.cprrp010.resi =  var.curr.site  
 	 var.cprrp010.koor =  var.cprrp100.type  
 	 var.cprrp010.orno =  var.cprrp100.orno  
 	 var.cprrp010.pono =  0  
 	 var.cprrp010.kotr =  convert.tckotr(tckotr.receipt)  
 	 var.cprrp010.date =  timps530.pddt  
 	 var.cprrp010.time =  get.time(tckotr.receipt)  
 	 var.cprrp010.qana =  timps530.oqan  
 	 var.cprrp100.item =  cp.segment.item.code(timps530.item, itm.cprj, itm.clus)  
 	 var.cprrp100.plmt =  get.plmt(timps530.cpla, empty)  
 	 var.cprrp100.psdt =  timps530.podt  
 	 var.cprrp100.pfdt =  timps530.pddt  
 	 var.cprrp100.trdt =  timps530.trdt  
 	 var.cprrp100.pstm =  get.time(tckotr.requirement)  
 	 var.cprrp100.pftm =  get.time(tckotr.receipt)  
 	 var.cprrp100.cplb =  timps530.cplb  
 	 var.cprrp100.osta =  get.mps.osta(timps530.osta)  
 	 var.cprrp100.dwar =  timps530.cwar  
 	 var.cprrp100.oqan =  timps530.oqan  
 	 var.cprrp100.suno =  get.business.partner.code(timps530.suno, bcstc.orgn.suno, err.mess)  
 	 var.cprrp100.txta =  empty()  
 	 dump 3 	 | *  Planned Orders  
 	 dump 5 	 | *  Inventory Movements
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:530
:ICOD:S
:QURY:START
select 	 timps530.*
from 	 timps530
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:530
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mrp
:SFLNO:010
:ICOD:D
:QURY:START
	 if base.order <>  timrp010.orno then  
 	 	 base.order =  timrp010.orno  
 	 	 base.position =  1  
 	 else  
 	 	 base.position =  base.position +  1  
 	 endif  
 	 skip.item =  false  
 	 itm.cprj =  ""                                                                                                                                                                                                                                                                                              
 	 itm.clus =  ""                                                                                                                                                                                                                                                                                              
 	 var.cprrp010.plnc =  act.plnc  
 	 if (timrp010.koor =  tckoor.mps.pmg or timrp010.koor =  tckoor.mrp.pmg) then  
 	 	 select tiitm001.item:dum.item  
 	 	 from 	 timrp022, tiitm001  
 	 	 where 	 timrp022._index1 =  {:timrp010.koor, :timrp010.orno}  
 	 	 and 	 timrp022.osta <>  tcorsa.actualized  
 	 	 and 	 timrp022.osta <>  tcorsa.cancelled  
 	 	 and 	 tiitm001._index1 =  {timrp022.item}  
 	 	 and 	 tiitm001.czed =  tcyesno.no  
 	 	 as set with 1 rows  
 	 	 selectempty  
 	 	 	 | *  The Parent is either containerized or invalid, and therefore the Parent Order  
 	 	 	 | *  will be skipped, so the Requirement has to be skipped too.  
 	 	 	 skip.item =  true  
 	 	 endselect  
 	 endif  
 	 if timrp010.koor =  tckoor.mrp.sfc then  
 	 	 select timrp020.item:dum.item  
 	 	 from 	 timrp020  
 	 	 where 	 timrp020._index1 =  {:timrp010.orno}  
 	 	 and 	 timrp020.osta <>  tcorsa.actualized  
 	 	 and 	 timrp020.osta <>  tcorsa.cancelled  
 	 	 as set with 1 rows  
 	 	 selectempty  
 	 	 	 | *  The Parent is invalid, and therefore the Parent Order  
 	 	 	 | *  will be skipped, so the Requirement has to be skipped too.  
 	 	 	 skip.item =  true  
 	 	 endselect  
 	 endif  
 	 if timrp010.koor =  tckoor.mrp.pur then  
 	 	 select timrp021.item:dum.item  
 	 	 from 	 timrp021  
 	 	 where 	 timrp021._index1 =  {:timrp010.orno}  
 	 	 and 	 timrp021.osta <>  tcorsa.actualized  
 	 	 and 	 timrp021.osta <>  tcorsa.cancelled  
 	 	 as set with 1 rows  
 	 	 selectempty  
 	 	 	 | *  The Parent is invalid, and therefore the Parent Order  
 	 	 	 | *  will be skipped, so the Requirement has to be skipped too.  
 	 	 	 skip.item =  true  
 	 	 endselect  
 	 endif  
 	 if skip.item then  
 	 	 continue  
 	 endif  
 	 	  
 	 if get.planned.order.and.order.type( 	  
 	 	 	 	 timrp010.koor,  
 	 	 	 	 timrp010.orno,  
 	 	 	 	 var.cprrp010.koor,  
 	 	 	 	 var.cprrp010.orno,  
 	 	 	 	 err.mess) then  
 	 	 continue  
 	 endif  
 	 if get.plan.item(timrp010.item, itm.cprj, itm.clus, err.mess) then  
 	 | *  Skip the item when the code has not been found  
 	 	 continue  
 	 else  
 	 	 var.cprrp010.code =  bcscp003.code  
 	 endif  
 	 var.cprrp010.resi =  var.curr.site  
 	 var.cprrp010.pono =  base.position  
 	 var.cprrp010.kotr =  convert.tckotr(timrp010.kotr)  
 	 var.cprrp010.date =  timrp010.date  
 	 var.cprrp010.time =  get.time(timrp010.kotr)  
 	 var.cprrp010.qana =  timrp010.qana  
 	 dump 5 	 | *  Inventory Movements
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mrp
:SFLNO:010
:ICOD:F
:QURY:START
	 base.order =  0
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mrp
:SFLNO:010
:ICOD:S
:QURY:START
select 	 timrp010.*
from 	 timrp010
where 	 timrp010.cntr =  ""                                                                                                                                                                                                                                                                                                                                                                                  
 and 	 timrp010.koor IN (tckoor.mps.sfc, tckoor.mps.pur, tckoor.mps.pmg,  
 	 	 	 tckoor.mrp.sfc, tckoor.mrp.pur, tckoor.mrp.pmg)  
 and 	 timrp010.kotr =  tckotr.requirement
order by timrp010._index2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mrp
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mrp
:SFLNO:020
:ICOD:D
:QURY:START
	 itm.cprj =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                  
 	 itm.clus =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                  
 	 var.cprrp100.plnc =  act.plnc  
 	 if get.planned.order.and.order.type(  
 	 	 	 	 	 tckoor.mrp.sfc,  
 	 	 	 	 	 timrp020.orno,  
 	 	 	 	 	 var.cprrp100.type,  
 	 	 	 	 	 var.cprrp100.orno,  
 	 	 	 	 	 err.mess) then  
 	 	 continue  
 	 endif  
 	 if get.plan.item(timrp020.item, itm.cprj, itm.clus, err.mess) then  
 	 | *  Skip the item when the code has not been found  
 	 	 continue  
 	 else  
 	 	 var.cprrp010.code =  bcscp003.code  
 	 endif  
 	 var.cprrp010.plnc =  var.cprrp100.plnc  
 	 var.cprrp010.resi =  var.curr.site  
 	 var.cprrp010.koor =  var.cprrp100.type  
 	 var.cprrp010.orno =  var.cprrp100.orno  
 	 var.cprrp010.pono =  0  
 	 var.cprrp010.kotr =  convert.tckotr(tckotr.receipt)  
 	 var.cprrp010.time =  get.time(tckotr.receipt)  
 	 var.cprrp010.qana =  timrp020.oqan  
 	 var.cprrp100.item =  cp.segment.item.code(timrp020.item, itm.cprj, itm.clus)  
 	 var.cprrp100.plmt =  get.plmt(timrp020.cpla, timrp020.plnm)  
 	 if timrp020.fsdt =  0 or timrp020.ffdt =  0 then  
 	 	 var.cprrp100.psdt =  timrp020.psdt  
 	 	 var.cprrp100.pfdt =  timrp020.pfdt  
 	 else  
 	 	 var.cprrp100.psdt =  timrp020.fsdt  
 	 	 var.cprrp100.pfdt =  timrp020.ffdt  
 	 endif  
 	 var.cprrp010.date =  var.cprrp100.pfdt  
 	 var.cprrp100.trdt =  timrp020.trdt  
 	 var.cprrp100.pstm =  get.time(tckotr.requirement)  
 	 var.cprrp100.pftm =  get.time(tckotr.receipt)  
 	 var.cprrp100.oqan =  timrp020.oqan  
 	 var.cprrp100.cplb =  timrp020.cplb  
 	 var.cprrp100.osta =  get.mrp.osta(timrp020.osta)  
 	 var.cprrp100.dwar =  timrp020.cwar  
 	 var.cprrp100.opro =  timrp020.opro  
 	 var.cprrp100.txta =  empty()  
 	 dump 2 	 | *  Planned Orders  
 	 dump 5 	 | *  Inventory Movements
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mrp
:SFLNO:020
:ICOD:S
:QURY:START
select 	 timrp020.*
from 	 timrp020
where 	 timrp020.osta <>  tcorsa.actualized  
 and 	 timrp020.osta <>  tcorsa.cancelled
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mrp
:SFLNO:020
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mrp
:SFLNO:021
:ICOD:D
:QURY:START
	 itm.cprj =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                          
 	 itm.clus =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                          
 	 var.cprrp100.plnc =  act.plnc  
 	 if get.planned.order.and.order.type(  
 	 	 	 	 	 tckoor.mrp.pur,  
 	 	 	 	 	 timrp021.orno,  
 	 	 	 	 	 var.cprrp100.type,  
 	 	 	 	 	 var.cprrp100.orno,  
 	 	 	 	 	 err.mess) then  
 	 	 continue  
 	 endif  
 	 if get.plan.item(timrp021.item, itm.cprj, itm.clus, err.mess) then  
 	 | *  Skip the item when the code has not been found  
 	 	 continue  
 	 else  
 	 	 var.cprrp010.code =  bcscp003.code  
 	 endif  
 	 var.cprrp010.plnc =  var.cprrp100.plnc  
 	 var.cprrp010.resi =  var.curr.site  
 	 var.cprrp010.koor =  var.cprrp100.type  
 	 var.cprrp010.orno =  var.cprrp100.orno  
 	 var.cprrp010.pono =  0  
 	 var.cprrp010.kotr =  convert.tckotr(tckotr.receipt)  
 	 var.cprrp010.time =  get.time(tckotr.receipt)  
 	 var.cprrp010.qana =  timrp021.oqan  
 	 var.cprrp100.item =  cp.segment.item.code(timrp021.item, itm.cprj, itm.clus)  
 	 var.cprrp100.plmt =  get.plmt(timrp021.cpla, empty)  
 	 if timrp021.fodt =  0 or timrp021.fddt =  0 then  
 	 	 var.cprrp100.psdt =  timrp021.podt  
 	 	 var.cprrp100.pfdt =  timrp021.pddt  
 	 else  
 	 	 var.cprrp100.psdt =  timrp021.fodt  
 	 	 var.cprrp100.pfdt =  timrp021.fddt  
 	 endif  
 	 var.cprrp010.date =  var.cprrp100.pfdt  
 	 var.cprrp100.trdt =  timrp021.trdt  
 	 var.cprrp100.pstm =  get.time(tckotr.requirement)  
 	 var.cprrp100.pftm =  get.time(tckotr.receipt)  
 	 var.cprrp100.cplb =  timrp021.cplb  
 	 var.cprrp100.osta =  get.mrp.osta(timrp021.osta)  
 	 var.cprrp100.dwar =  timrp021.cwar  
 	 var.cprrp100.oqan =  timrp021.oqan  
 	 var.cprrp100.suno =  get.business.partner.code(timrp021.suno, bcstc.orgn.suno, err.mess)  
 	 var.cprrp100.txta =  empty()  
 	 dump 3 	 | *  Planned Orders  
 	 dump 5 	 | *  Inventory Movements
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mrp
:SFLNO:021
:ICOD:S
:QURY:START
select 	 timrp021.*
from 	 timrp021
where 	 timrp021.osta <>  tcorsa.actualized  
 and 	 timrp021.osta <>  tcorsa.cancelled
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mrp
:SFLNO:021
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mrp
:SFLNO:022
:ICOD:D
:QURY:START
	 itm.cprj =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                
 	 itm.clus =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                
 	 var.cprrp100.plnc =  act.plnc  
 	 if get.planned.order.and.order.type(  
 	 	 	 	 	 timrp022.koor,  
 	 	 	 	 	 timrp022.orno,  
 	 	 	 	 	 var.cprrp100.type,  
 	 	 	 	 	 var.cprrp100.orno,  
 	 	 	 	 	 err.mess) then  
 	 	 continue  
 	 endif  
 	 if get.plan.item(timrp022.item, itm.cprj, itm.clus, err.mess) then  
 	 | *  Skip the item when the code has not been found  
 	 	 continue  
 	 else  
 	 	 var.cprrp010.code =  bcscp003.code  
 	 endif  
 	 var.cprrp010.plnc =  var.cprrp100.plnc  
 	 var.cprrp010.resi =  var.curr.site  
 	 var.cprrp010.koor =  var.cprrp100.type  
 	 var.cprrp010.orno =  var.cprrp100.orno  
 	 var.cprrp010.pono =  0  
 	 var.cprrp010.kotr =  convert.tckotr(tckotr.receipt)  
 	 var.cprrp010.time =  get.time(tckotr.receipt)  
 	 var.cprrp010.qana =  timrp022.oqan  
 	 var.cprrp100.item =  cp.segment.item.code(timrp022.item, itm.cprj, itm.clus)  
 	 var.cprrp100.plmt =  get.plmt(timrp022.cpla, empty)  
 	 if timrp022.fsdt =  0 or timrp022.ffdt =  0 then  
 	 	 var.cprrp100.psdt =  timrp022.psdt  
 	 	 var.cprrp100.pfdt =  timrp022.pfdt  
 	 else  
 	 	 var.cprrp100.psdt =  timrp022.fsdt  
 	 	 var.cprrp100.pfdt =  timrp022.ffdt  
 	 endif  
 	 var.cprrp010.date =  var.cprrp100.pfdt  
 	 var.cprrp100.trdt =  timrp022.trdt  
 	 var.cprrp100.pstm =  get.time(tckotr.requirement)  
 	 var.cprrp100.pftm =  get.time(tckotr.receipt)  
 	 var.cprrp100.cplb =  timrp022.cplb  
 	 var.cprrp100.osta =  get.mrp.osta(timrp022.osta)  
 	 var.cprrp100.dwar =  timrp022.cwar  
 	 var.cprrp100.oqan =  timrp022.oqan  
 	 var.cprrp100.opro =  timrp022.opro  
 	 var.cprrp100.txta =  empty()  
 	 dump 2 	 | *  Planned Orders  
 	 dump 5 	 | *  Inventory Movements
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mrp
:SFLNO:022
:ICOD:S
:QURY:START
select 	 timrp022.*
from 	 timrp022, tiitm001
where 	 timrp022.osta <>  tcorsa.actualized  
 and 	 timrp022.osta <>  tcorsa.cancelled  
 and 	 timrp022.item refers to tiitm001  
 and 	 tiitm001.czed =  tcyesno.no
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mrp
:SFLNO:022
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:pcs
:SFLNO:500
:ICOD:D
:QURY:START
	 if base.order <>  tipcs500.orno then  
 	 	 base.order =  tipcs500.orno  
 	 	 base.position =  1  
 	 else  
 	 	 base.position =  base.position +  1  
 	 endif  
 	 var.cprrp010.plnc =  act.plnc  
 	 var.cprrp010.resi =  var.curr.site  
 	 if get.planned.order.and.order.type( 	  
 	 	 	 	 tipcs500.koor,  
 	 	 	 	 tipcs500.orno,  
 	 	 	 	 var.cprrp010.koor,  
 	 	 	 	 var.cprrp010.orno,  
 	 	 	 	 err.mess) then  
 	 	 continue  
 	 endif  
 	 itm.cprj =  get.ti.project(tipcs500.cprj)  
 	 if not get.cluster(var.curr.site, itm.cwar, err.mess) then  
 	 	 itm.clus =  bcswh001.dicl  
 	 else  
 	 	 itm.clus =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
 	 endif  
 	 if get.plan.item(tipcs500.item, itm.cprj, itm.clus, err.mess) then  
 	 | *  Skip the item when the code has not been found  
 	 	 continue  
 	 else  
 	 	 var.cprrp010.code =  bcscp003.code  
 	 endif  
 	 var.cprrp010.kotr =  convert.tckotr(tipcs500.kotr)  
 	 var.cprrp010.pono =  base.position  
 	 var.cprrp010.date =  tipcs500.date  
 	 var.cprrp010.time =  get.time( 	 tipcs500.kotr)  
 	 var.cprrp010.qana =  tipcs500.qana  
 	 dump 5 	 | *  Inventory Movements
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:pcs
:SFLNO:500
:ICOD:F
:QURY:START
	 base.order =  0
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:pcs
:SFLNO:500
:ICOD:S
:QURY:START
select 	 tipcs500.*  , tipcs021.cwar:itm.cwar
from 	 tipcs500, tipcs020, tipcs021, tipcs510
where 	 tipcs500.koor =  tckoor.pcs.sfc  
 and 	 tipcs500.kotr =  tckotr.requirement  
 and 	 tipcs500.cprj refers to tipcs020  
 and 	 tipcs020.prtp <>  tcyesno.yes  
 and 	 tipcs021._index1 =  {tipcs500.cprj, tipcs500.item}  
 and 	 {tipcs500.cprj, tipcs500.orno} refers to tipcs510  
 and 	 tipcs510.osta <>  tcorsa.actualized  
 and 	 tipcs510.osta <>  tcorsa.cancelled
order by tipcs500._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:pcs
:SFLNO:500
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:pcs
:SFLNO:510
:ICOD:D
:QURY:START
	 itm.cprj =  get.ti.project(tipcs510.cprj)  
 	 if isspace(tipcs021.cwar) then  
 	 	 | *  This should not happen; just to make sure.  
 	 	 itm.clus =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
 	 else  
 	 	 if not get.cluster(var.curr.site, tipcs021.cwar, err.mess) then  
 	 	 	 itm.clus =  bcswh001.dicl  
 	 	 else  
 	 	 	 itm.clus =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
 	 	 endif  
 	 endif  
 	 var.cprrp100.plnc =  act.plnc  
 	 if get.planned.order.and.order.type(  
 	 	 	 	 	 tckoor.pcs.sfc,  
 	 	 	 	 	 tipcs510.orno,  
 	 	 	 	 	 var.cprrp100.type,  
 	 	 	 	 	 var.cprrp100.orno,  
 	 	 	 	 	 err.mess) then  
 	 	 continue  
 	 endif  
 	 if get.plan.item(tipcs510.item, itm.cprj, itm.clus, err.mess) then  
 	 | *  Skip the item when the code has not been found  
 	 	 continue  
 	 else  
 	 	 var.cprrp010.code =  bcscp003.code  
 	 endif  
 	 var.cprrp010.plnc =  var.cprrp100.plnc  
 	 var.cprrp010.resi =  var.curr.site  
 	 var.cprrp010.koor =  var.cprrp100.type  
 	 var.cprrp010.orno =  var.cprrp100.orno  
 	 var.cprrp010.pono =  0  
 	 var.cprrp010.kotr =  convert.tckotr(tckotr.receipt)  
 	 var.cprrp010.date =  tipcs510.pfdt  
 	 var.cprrp010.time =  get.time(tckotr.receipt)  
 	 var.cprrp010.qana =  tipcs510.oqan  
 	 var.cprrp100.item =  cp.segment.item.code(tipcs510.item, itm.cprj, itm.clus)  
 	 var.cprrp100.plmt =  get.plmt(tipcs510.cpla, empty)  
 	 var.cprrp100.psdt =  tipcs510.psdt  
 	 var.cprrp100.pfdt =  tipcs510.pfdt  
 	 var.cprrp100.trdt =  tipcs510.trdt  
 	 var.cprrp100.pstm =  get.time(tckotr.requirement)  
 	 var.cprrp100.pftm =  get.time(tckotr.receipt)  
 	 var.cprrp100.cplb =  tipcs510.cplb  
 	 var.cprrp100.osta =  get.mrp.osta(tipcs510.osta)  
 	 var.cprrp100.dwar =  tipcs021.cwar  
 	 var.cprrp100.oqan =  tipcs510.oqan  
 	 var.cprrp100.opro =  get.routing(tipcs510.cprj, tipcs510.item)  
 	 var.cprrp100.txta =  tipcs510.txta  
 	 dump 2 	 | *  Planned Orders  
 	 dump 5 	 | *  Inventory Movements
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:pcs
:SFLNO:510
:ICOD:S
:QURY:START
select 	 tipcs510.*  , tipcs021.cwar
from 	 tipcs510, tipcs021
where 	 tipcs510.osta <>  tcorsa.actualized  
 and 	 tipcs510.osta <>  tcorsa.cancelled  
 and 	 {tipcs510.cprj, tipcs510.item} refers to tipcs021
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:pcs
:SFLNO:510
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:pcs
:SFLNO:520
:ICOD:D
:QURY:START
	 itm.cprj =  get.ti.project(tipcs520.cprj)  
 	 if isspace(tipcs021.cwar) then  
 	 	 | *  This should not happen; just to make sure.  
 	 	 itm.clus =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
 	 else  
 	 	 if not get.cluster(var.curr.site, tipcs021.cwar, err.mess) then  
 	 	 	 itm.clus =  bcswh001.dicl  
 	 	 else  
 	 	 	 itm.clus =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
 	 	 endif  
 	 endif  
 	 var.cprrp100.plnc =  act.plnc  
 	 if get.planned.order.and.order.type(  
 	 	 	 	 	 tckoor.pcs.pur,  
 	 	 	 	 	 tipcs520.orno,  
 	 	 	 	 	 var.cprrp100.type,  
 	 	 	 	 	 var.cprrp100.orno,  
 	 	 	 	 	 err.mess) then  
 	 	 continue  
 	 endif  
 	 if get.plan.item(tipcs520.item, itm.cprj, itm.clus, err.mess) then  
 	 | *  Skip the item when the code has not been found  
 	 	 continue  
 	 else  
 	 	 var.cprrp010.code =  bcscp003.code  
 	 endif  
 	 var.cprrp010.plnc =  var.cprrp100.plnc  
 	 var.cprrp010.resi =  var.curr.site  
 	 var.cprrp010.koor =  var.cprrp100.type  
 	 var.cprrp010.orno =  var.cprrp100.orno  
 	 var.cprrp010.pono =  0  
 	 var.cprrp010.kotr =  convert.tckotr(tckotr.receipt)  
 	 var.cprrp010.date =  tipcs520.pddt  
 	 var.cprrp010.time =  get.time(tckotr.receipt)  
 	 var.cprrp010.qana =  tipcs520.oqan  
 	 var.cprrp100.item =  cp.segment.item.code(tipcs520.item, itm.cprj, itm.clus)  
 	 var.cprrp100.plmt =  get.plmt(tipcs520.cpla, empty)  
 	 var.cprrp100.psdt =  tipcs520.podt  
 	 var.cprrp100.pfdt =  tipcs520.pddt  
 	 var.cprrp100.trdt =  tipcs520.trdt  
 	 var.cprrp100.pstm =  get.time(tckotr.requirement)  
 	 var.cprrp100.pftm =  get.time(tckotr.receipt)  
 	 var.cprrp100.cplb =  tipcs520.cplb  
 	 var.cprrp100.osta =  get.mrp.osta(tipcs520.osta)  
 	 var.cprrp100.dwar =  tipcs021.cwar  
 	 var.cprrp100.oqan =  tipcs520.oqan  
 	 var.cprrp100.suno =  get.business.partner.code(tipcs520.suno, bcstc.orgn.suno, err.mess)  
 	 var.cprrp100.txta =  tipcs520.txta  
 	 dump 3 	 | *  Planned Orders  
 	 dump 5 	 | *  Inventory Movements
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:pcs
:SFLNO:520
:ICOD:S
:QURY:START
select 	 tipcs520.*  , tipcs021.cwar
from 	 tipcs520, tipcs021
where 	 tipcs520.osta <>  tcorsa.actualized  
 and 	 tipcs520.osta <>  tcorsa.cancelled  
 and 	 {tipcs520.cprj, tipcs520.item} refers to tipcs021
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:pcs
:SFLNO:520
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:tr
:SCMOD:drp
:SFLNO:015
:ICOD:D
:QURY:START
	 itm.cprj =  ""                                                                                                                                                                                                                                                                                  
 	 if get.planned.order.and.order.type( 	  
 	 	 	 	 trdrp015.koor,  
 	 	 	 	 trdrp015.orno,  
 	 	 	 	 var.cprrp010.koor,  
 	 	 	 	 var.cprrp010.orno,  
 	 	 	 	 err.mess) then  
 	 	 continue  
 	 endif  
 	 if not get.cluster(var.curr.site, trdrp015.cwar, err.mess) then  
 	 	 itm.clus =  bcswh001.dicl  
 	 else  
 	 	 itm.clus =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
 	 endif  
 	 | *  Skip DRP Orders that distribute within a Cluster  
 	 if not get.cluster(var.curr.site, trdrp015.dwar, err.mess) then  
 	 	 itm.rev.clus =  bcswh001.dicl  
 	 else  
 	 	 itm.rev.clus =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
 	 endif  
 	 if itm.clus =  itm.rev.clus then  
 	 	 continue  
 	 endif  
 	 if get.plan.item(trdrp015.item, itm.cprj, itm.clus, err.mess) then  
 	 | *  Skip the item when the code has not been found  
 	 	 continue  
 	 else  
 	 	 var.cprrp010.code =  bcscp003.code  
 	 endif  
 	 var.cprrp010.plnc =  act.plnc  
 	 var.cprrp010.resi =  var.curr.site  
 	 var.cprrp010.pono =  10  
 	 var.cprrp010.kotr =  convert.tckotr(trdrp015.kotr)  
 	 var.cprrp010.date =  trdrp015.date  
 	 var.cprrp010.time =  get.time( 	 trdrp015.kotr)  
 	 var.cprrp010.qana =  trdrp015.qana  
 	 dump 5 	 | *  Inventory Movements
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:tr
:SCMOD:drp
:SFLNO:015
:ICOD:S
:QURY:START
select 	 trdrp015.*
from 	 trdrp015, trdrp020, tiitm001
where 	 trdrp015.koor =  tckoor.drp.rpl  
 and 	 trdrp015.kotr =  tckotr.requirement  
 and 	 trdrp015.cntr =  ""                                                                                                                                                                                                                                                                                                                                                      
 and 	 trdrp015.item refers to tiitm001  
 and 	 (tiitm001.osys =  tcosys.mps or  
 	 tiitm001.osys =  tcosys.mrp )  
 and 	 trdrp015.orno refers to trdrp020  
 and 	 trdrp020.orsa <>  tcorsa.actualized  
 and 	 trdrp020.orsa <>  tcorsa.cancelled
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:tr
:SCMOD:drp
:SFLNO:015
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:tr
:SCMOD:drp
:SFLNO:020
:ICOD:D
:QURY:START
	 itm.cprj =  ""                                                                                                                                                                                                                                                                                                                                                                                                          
 	 if not get.cluster(var.curr.site, trdrp020.dwar, err.mess) then  
 	 	 itm.clus =  bcswh001.dicl  
 	 else  
 	 	 itm.clus =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
 	 endif  
 	 if not get.cluster(var.curr.site, trdrp020.rwar, err.mess) then  
 	 	 sup.clus =  bcswh001.dicl  
 	 else  
 	 	 sup.clus =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
 	 endif  
 	 if itm.clus =  sup.clus then  
 	 	 continue  
 	 endif  
 	 var.cprrp100.plnc =  act.plnc  
 	 if get.planned.order.and.order.type(  
 	 	 	 	 	 tckoor.drp.rpl,  
 	 	 	 	 	 trdrp020.orno,  
 	 	 	 	 	 var.cprrp100.type,  
 	 	 	 	 	 var.cprrp100.orno,  
 	 	 	 	 	 err.mess) then  
 	 	 continue  
 	 endif  
 	 if get.plan.item(trdrp020.item, itm.cprj, itm.clus, err.mess) then  
 	 | *  Skip the item when the code has not been found  
 	 	 continue  
 	 else  
 	 	 var.cprrp010.code =  bcscp003.code  
 	 endif  
 	 var.cprrp010.plnc =  var.cprrp100.plnc  
 	 var.cprrp010.resi =  var.curr.site  
 	 var.cprrp010.koor =  var.cprrp100.type  
 	 var.cprrp010.orno =  var.cprrp100.orno  
 	 var.cprrp010.pono =  0  
 	 var.cprrp010.kotr =  convert.tckotr(tckotr.receipt)  
 	 var.cprrp010.date =  trdrp020.prdt  
 	 var.cprrp010.time =  get.time(tckotr.receipt)  
 	 var.cprrp010.qana =  trdrp020.oqua  
 	 var.cprrp100.item =  cp.segment.item.code(trdrp020.item, itm.cprj, itm.clus)  
 	 var.cprrp100.plmt =  get.plmt(empty, empty)  
 	 var.cprrp100.psdt =  trdrp020.podt  
 	 var.cprrp100.pfdt =  trdrp020.prdt  
 	 var.cprrp100.trdt =  date.num()  
 	 var.cprrp100.pstm =  get.time(tckotr.requirement)  
 	 var.cprrp100.pftm =  get.time(tckotr.receipt)  
 	 var.cprrp100.cplb =  tiitm001.cplb  
 	 var.cprrp100.osta =  get.mrp.osta(trdrp020.orsa)  
 	 var.cprrp100.dwar =  trdrp020.dwar  
 	 var.cprrp100.supl =  cp.segment.item.code(trdrp020.item, itm.cprj, sup.clus)  
 	 var.cprrp100.susi =  var.curr.site  
 	 var.cprrp100.suwa =  trdrp020.rwar  
 	 var.cprrp100.oqan =  trdrp020.oqua  
 	 dump 1 	 | *  Planned Orders  
 	 dump 5 	 | *  Inventory Movements
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:tr
:SCMOD:drp
:SFLNO:020
:ICOD:S
:QURY:START
select 	 trdrp020.*  , tiitm001.cplb
from 	 trdrp020, tiitm001
where 	 trdrp020.cntr =  ""                                                                                                                                                                                                                                                                                                                                                                                                          
 and 	 trdrp020.orsa <>  tcorsa.actualized  
 and 	 trdrp020.orsa <>  tcorsa.cancelled  
 and 	 trdrp020.item refers to tiitm001  
 and 	 (tiitm001.osys =  tcosys.mps or tiitm001.osys =  tcosys.mrp)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:tr
:SCMOD:drp
:SFLNO:020
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:200
:SCPAC:ti
:SCMOD:crp
:SFLNO:001
:ICOD:D
:QURY:START
	 skip.item =  false  
 	 if (ticrp001.koor =  tckoor.mps.pmg or ticrp001.koor =  tckoor.mrp.pmg) then  
 	 	 select tiitm001.item:dum.item  
 	 	 from 	 timrp022, tiitm001  
 	 	 where 	 timrp022._index1 =  {:ticrp001.koor, :ticrp001.orno}  
 	 	 and 	 tiitm001._index1 =  {timrp022.item}  
 	 	 and 	 tiitm001.czed =  tcyesno.yes  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 | *  The Parent is containerized, and therefore the Parent Order  
 	 	 	 | *  will be skipped, so the Capacity has to be skipped too.  
 	 	 	 skip.item =  true  
 	 	 endselect  
 	 endif  
 	 if skip.item then  
 	 	 continue  
 	 endif  
 	 if fill.var.fields(  
 	 	 	 "",                                                            
 	 	 	 ticrp001.koor,  
 	 	 	 ticrp001.orno,  
 	 	 	 ticrp001.opno,  
 	 	 	 ticrp001.cwoc,  
 	 	 	 tirou001.ccap,  
 	 	 	 tirou001.dcru,  
 	 	 	 tirou001.nosh,  
 	 	 	 ticrp001.stdt,  
 	 	 	 ticrp001.rqca,  
 	 	 	 ticrp001.mmrt,  
 	 	 	 ticrp001.mcno) then  
 	 	 continue  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:200
:SCPAC:ti
:SCMOD:crp
:SFLNO:001
:ICOD:S
:QURY:START
select 	 ticrp001.*  ,  
 	 tirou001.ccap, tirou001.dcru, tirou001.nosh
from 	 ticrp001, tirou001
where 	 ticrp001.cwoc refers to tirou001
order by ticrp001._index1 desc
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:200
:SCPAC:ti
:SCMOD:crp
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:200
:SCPAC:ti
:SCMOD:pcs
:SFLNO:600
:ICOD:D
:QURY:START
	 if fill.var.fields(  
 	 	 	 tipcs600.cprj,  
 	 	 	 tckoor.pcs.sfc,  
 	 	 	 tipcs600.orno,  
 	 	 	 tipcs600.opno,  
 	 	 	 tipcs600.cwoc,  
 	 	 	 tirou001.ccap,  
 	 	 	 tirou001.dcru,  
 	 	 	 tirou001.nosh,  
 	 	 	 tipcs600.stdt,  
 	 	 	 tipcs600.rqca,  
 	 	 	 tipcs600.mmrt,  
 	 	 	 tipcs600.mcno) then  
 	 	 continue  
 	 endif  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:200
:SCPAC:ti
:SCMOD:pcs
:SFLNO:600
:ICOD:S
:QURY:START
select 	 tipcs600.*  ,  
 	 tirou001.ccap, tirou001.dcru, tirou001.nosh
from 	 tipcs600, tirou001
where 	 tipcs600.cwoc refers to tirou001
order by tipcs600._index1 desc
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:rrp
:TFLNO:200
:SCPAC:ti
:SCMOD:pcs
:SFLNO:600
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:wlc
:TFLNO:200
:SCPAC:cp
:SCMOD:wlc
:SFLNO:200
:ICOD:D
:QURY:START
	 get.scenario(get.compnr(), cpwlc200.plnc, var.cpwlc200.plnc, err.mess)  
 	 if cpwlc200.bapl =  EMPTY then  
 	 	 cpwlc200.bapl =  cpcom.yeno.no  
 	 endif  
 	 if cpwlc200.fopl =  EMPTY then  
 	 	 cpwlc200.fopl =  cpcom.yeno.no  
 	 endif  
 	 if cpwlc200.bapl =  cpcom.yeno.yes and cpwlc200.bapr =  EMPTY then  
 	 	 cpwlc200.bapr =  cpwlc.prru.prod.vol  
 	 endif  
 	 if cpwlc200.fopl =  cpcom.yeno.yes and cpwlc200.fopr =  EMPTY then  
 	 	 cpwlc200.fopr =  cpwlc.prru.prod.vol  
 	 endif  
 	 if cpwlc200.prio =  EMPTY then  
 	 	 cpwlc200.prio =  cpcom.ynon.no  
 	 else  
 	 	 if cpwlc200.prio =  cpcom.ynon.only and  
 	 	 (not cpwlc200.fopr =  EMPTY or  
 	 	 not cpwlc200.bapr =  EMPTY) then  
 	 	 	 cpwlc200.prio =  cpcom.ynon.yes  
 	 	 endif  
 	 endif  
 	 if cpwlc200.caco =  EMPTY then  
 	 	 cpwlc200.caco =  cpcom.caco.freecap  
 	 endif  
 	 if cpwlc200.macs =  EMPTY then  
 	 	 cpwlc200.macs =  cpcom.yeno.no  
 	 endif  
 	 if cpwlc200.macs <>  cpcom.yeno.no and cpwlc200.prio =  cpcom.ynon.only then  
 	 	 cpwlc200.macs =  cpcom.yeno.no  
 	 endif  
 	 if cpwlc200.prcs =  EMPTY then  
 	 	 cpwlc200.prcs =  cpcom.yeno.no  
 	 endif  
 	 if cpwlc200.prcs <>  cpcom.yeno.no and cpwlc200.prio =  cpcom.ynon.only then  
 	 	 cpwlc200.prcs =  cpcom.yeno.no  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:wlc
:TFLNO:200
:SCPAC:cp
:SCMOD:wlc
:SFLNO:200
:ICOD:S
:QURY:START
select cpwlc200.*
from cpwlc200
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:cp
:TCMOD:wlc
:TFLNO:200
:SCPAC:cp
:SCMOD:wlc
:SFLNO:200
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:003
:SCPAC:bc
:SCMOD:sti
:SFLNO:000
:ICOD:D
:QURY:START
	 if bcsti000.micp =  tcyesno.yes then  
 	 	 dump 1  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:003
:SCPAC:bc
:SCMOD:sti
:SFLNO:000
:ICOD:S
:QURY:START
select 	 bcsti000.micp, bcsti000.prio, bcsti000.prid
from 	 bcsti000  
 as set with 1 rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:003
:SCPAC:bc
:SCMOD:sti
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:011
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:D
:QURY:START
	 select 	 tiedm301.*   
 	 from 	 tiedm301  
 	 where 	 tiedm301.prcd =  :tiedm310.prcd  
 	 selectdo  
 	 	 get.approval.type()  
 	 	 get.change.status()  
 	 	 dump 1  
 	 endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:011
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:S
:QURY:START
select 	 tiedm310.*
from 	 tiedm310
where 	 tiedm310.osta =  tiedm.osta.free  
 or 	 tiedm310.osta =  tiedm.osta.in.process
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:011
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:020
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:D
:QURY:START
	 get.change.proposal.status()  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:020
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:S
:QURY:START
select 	 tiedm310.*
from 	 tiedm310
where 	 tiedm310.osta =  tiedm.osta.free  
 or 	 tiedm310.osta =  tiedm.osta.in.process
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:020
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:022
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:D
:QURY:START
	 get.reviewers()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:022
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:S
:QURY:START
select 	 tiedm310.*
from 	 tiedm310
where 	 tiedm310.osta =  tiedm.osta.free  
 or 	 tiedm310.osta =  tiedm.osta.in.process
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:022
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:030
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:030
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:S
:QURY:START
select 	 tiedm310.*
from 	 tiedm310
where 	 tiedm310.osta =  tiedm.osta.free  
 or 	 tiedm310.osta =  tiedm.osta.in.process
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:030
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:040
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:D
:QURY:START
	 select tiedm303.prcd, tiedm303.step, tiedm303.txta  
 	 from 	 tiedm303  
 	 where 	 tiedm303.prcd =  :tiedm310.prcd  
 	 selectdo  
 	 	 select 	 tiedm302.dcsa  
 	 	 from 	 tiedm302  
 	 	 where 	 tiedm302._index1 =  {:tiedm303.step}  
 	 	 selectdo  
 	 	 endselect  
 	 	 dump 1  
 	 endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:040
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:S
:QURY:START
select 	 tiedm310.*
from 	 tiedm310
where 	 tiedm310.osta =  tiedm.osta.free  
 or 	 tiedm310.osta =  tiedm.osta.in.process
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:040
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:050
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:050
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:S
:QURY:START
select 	 tiedm310.*
from 	 tiedm310
where 	 tiedm310.osta =  tiedm.osta.free  
 or 	 tiedm310.osta =  tiedm.osta.in.process
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:chm
:TFLNO:050
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:com
:TFLNO:026
:SCPAC:ti
:SCMOD:edm
:SFLNO:303
:ICOD:D
:QURY:START
	 select 	 a.prcd, a.prop:posno, a.logn:chair.person  
 	 from 	 tiedm303 a  
 	 where 	 a._index1 =  {:tiedm303.prcd}  
 	 order by a._index1 desc  
 	 as set with 1 rows  
 	 selectdo  
 	 endselect  
 	 get.employee.for.logon.code(tiedm303.logn)  
 	 if tiedm303.prcd <>  proc.id or tiedm303.logn <>  stepuser then  
 	 	 if tiedm303.prop <>  posno and tiedm303.logn <>  chair.person then  
 	 	 	 dump 1  
 	 	 endif  
 	 endif  
 	 proc.id =  tiedm303.prcd  
 	 stepuser =  tiedm303.logn
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:com
:TFLNO:026
:SCPAC:ti
:SCMOD:edm
:SFLNO:303
:ICOD:S
:QURY:START
select 	 tiedm303.*
from 	 tiedm303
order by tiedm303.prcd, tiedm303.logn
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:com
:TFLNO:026
:SCPAC:ti
:SCMOD:edm
:SFLNO:303
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:com
:TFLNO:027
:SCPAC:ti
:SCMOD:edm
:SFLNO:301
:ICOD:D
:QURY:START
	 get.chair.person(tiedm301.prcd,  
 	 	 	 chair.person) | *  Reference variable  
 	 Dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:com
:TFLNO:027
:SCPAC:ti
:SCMOD:edm
:SFLNO:301
:ICOD:S
:QURY:START
select 	 tiedm301.*
from 	 tiedm301
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:dm
:TCMOD:com
:TFLNO:027
:SCPAC:ti
:SCMOD:edm
:SFLNO:301
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ec
:TCMOD:edi
:TFLNO:011
:SCPAC:tc
:SCMOD:edi
:SFLNO:011
:ICOD:D
:QURY:START
	 var.ecedi011.orga =  empty()  
 	 var.ecedi011.mess =  empty()  
 	 var.ecedi011.cvsu =  empty() 	 	 	 | #  800 -  154848.n  
 	 if not get.EDI.mappings(tcedi011.orga,  
 	 	 	 	 tcedi011.mess,  
 	 	 	 	 tcedi011.cvsu,  
 	 	 	 	 err.mess) then  
 	 	 var.ecedi011.orga =  bcstc028.norg  
 	 	 var.ecedi011.mess =  bcstc028.nmes  
 	 	 var.ecedi011.cvsu =  bcstc028.ncvs 	 | #  800 -  154848.sn  
 	 endif  
 	 if isspace(var.ecedi011.orga) then  
 	 	 if not get.EDI.mappings(  
 	 	 	 	 tcedi011.orga,  
 	 	 	 	 tcedi011.mess,  
 	 	 	 	 "",              
 	 	 	 	 err.mess) then  
 	 	 	 var.ecedi011.orga =  bcstc028.norg  
 	 	 	 var.ecedi011.mess =  bcstc028.nmes  
 	 	 endif  
 	 endif  
 	 if isspace(var.ecedi011.orga) then  
 	 	 if not get.EDI.mappings(  
 	 	 	 	 tcedi011.orga,  
 	 	 	 	 "",              
 	 	 	 	 "",              
 	 	 	 	 err.mess) then  
 	 	 	 var.ecedi011.orga =  bcstc028.norg  
 	 	 endif  
 	 endif 	 	 	 	 	 	 | #  800 -  154848.en  
 	 	 	 	 	 	 	 | #  800 -  154848.so  
 | 	 	 if var.ecedi011.orga =  bcstc028.orga then  
 | 	 	 	 select bcstc028.norg  
 | 	 	 	 from 	 bcstc028  
 | 	 	 	 where 	 bcstc028._index1 =  {:tcedi011.orga, ""}              
 | 	 	 	 as set with 1 rows  
 | 	 	 	 selectdo  
 | 	 	 	 	 var.ecedi011.orga =  bcstc028.norg  
 | 	 	 	 endselect  
 | 	 	 endif  
 | 	 endif 	 	 	 	 	 | #  800 -  154848.eo  
 	 if isspace(var.ecedi011.orga) then  
 	 	 var.ecedi011.orga =  tcedi011.orga  
 	 endif  
 	 if isspace(var.ecedi011.mess) then  
 	 	 var.ecedi011.mess =  tcedi011.mess  
 	 endif  
 	 if isspace(var.ecedi011.cvsu) then 	 	 | #  800 -  154848.sn  
 	 	 var.ecedi011.cvsu =  tcedi011.cvsu  
 	 endif 	 	 	 	 	 | #  800 -  154848.en  
 	 var.ecedi011.nrgr =  empty()  
 	 if not get.number.group.using.tcckon(tcedi011.ckon, err.mess) then  
 	 	 var.ecedi011.nrgr =  bcstc002.nrgr  
 	 else  
 	 	 var.ecedi011.nrgr =  empty()  
 	 endif  
 	 var.ecedi011.seri =  empty()  
 	 if not get.group.series.numbers(bcstc002.ckon,  
 	 	 	 	 	 tcedi011.grno,  
 	 	 	 	 	 err.mess) then  
 	 	 var.ecedi011.seri =  bcstc024.nser  
 	 else  
 	 	 var.ecedi011.seri =  empty()  
 	 endif 	  
 	 var.ecedi011.bpid =  empty()  
 	 if not get.business.partner( 	 tcedi010.suno,  
 	 	 	 	 	 bcstc.orgn.suno,  
 	 	 	 	 	 err.mess) then  
 	 	 var.ecedi011.bpid =  bcstc008.bpid  
 	 	 dump 1  
 	 endif  
 	 var.ecedi011.bpid =  empty()  
 	 if not get.business.partner( 	 tcedi010.cuno,  
 	 	 	 	 	 bcstc.orgn.cuno,  
 	 	 	 	 	 err.mess) then  
 	 	 var.ecedi011.bpid =  bcstc008.bpid  
 	 	 dump 1  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ec
:TCMOD:edi
:TFLNO:011
:SCPAC:tc
:SCMOD:edi
:SFLNO:011
:ICOD:S
:QURY:START
select 	 tcedi011.*  , tcedi010.msno, tcedi010.cuno, tcedi010.suno
from 	 tcedi010, tcedi011
where 	 tcedi011.reno refers to tcedi010
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ec
:TCMOD:edi
:TFLNO:011
:SCPAC:tc
:SCMOD:edi
:SFLNO:011
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:fm
:TCMOD:foc
:TFLNO:000
:SCPAC:tr
:SCMOD:toc
:SFLNO:000
:ICOD:D
:QURY:START
	 if not get.number.group( bcckon.toc.order, o.mess) then  
 	 	 var.fmfoc000.ngfm =  bcstc002.nrgr  
 	 else  
 	 	 var.fmfoc000.ngfm =  ""                                                
 	 endif  
 	 if not get.number.group( bcckon.fm.cluster, o.mess) then  
 	 	 var.fmfoc000.ngcl =  bcstc002.nrgr  
 	 else  
 	 	 var.fmfoc000.ngcl =  ""                                                
 	 endif  
 	 var.fmfoc000.ldtm =  tracs000.lltm *  conv.factor  
 	 var.fmfoc000.lwtm =  tracs000.lwtm *  conv.factor  
 	 var.fmfoc000.untm =  tracs000.ultm *  conv.factor  
 	 var.fmfoc000.uwtm =  tracs000.uwtm *  conv.factor  
 	 var.fmfoc000.indt =  utc(0,0)  
 	 var.fmfoc000.dsca =  form.text$("bcstc00035")  
 	 dump 1  
 	 var.fmfoc000.indt =  utc(date.num(),time.num()) | *  replace by current date function  
 	 var.fmfoc000.dsca =  form.text$("bcstc00036")  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:fm
:TCMOD:foc
:TFLNO:000
:SCPAC:tr
:SCMOD:toc
:SFLNO:000
:ICOD:S
:QURY:START
select 	 trtoc000.*
from 	 trtoc000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:fm
:TCMOD:foc
:TFLNO:000
:SCPAC:tr
:SCMOD:toc
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:fm
:TCMOD:frc
:TFLNO:010
:SCPAC:tr
:SCMOD:tcd
:SFLNO:100
:ICOD:D
:QURY:START
	 dump 1  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:fm
:TCMOD:frc
:TFLNO:010
:SCPAC:tr
:SCMOD:tcd
:SFLNO:100
:ICOD:S
:QURY:START
select 	 trtcd100.*
from 	 trtcd100
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:fm
:TCMOD:frc
:TFLNO:010
:SCPAC:tr
:SCMOD:tcd
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:fm
:TCMOD:lbd
:TFLNO:000
:SCPAC:tr
:SCMOD:top
:SFLNO:000
:ICOD:D
:QURY:START
	 if not get.number.group( bcckon.fm.shipment, o.mess) then  
 	 	 var.fmlbd000.shng =  bcstc002.nrgr  
 	 else  
 	 	 var.fmlbd000.shng =  ""              
 	 endif  
 	 if not get.number.group( bcckon.fm.load, o.mess) then  
 	 	 var.fmlbd000.nglo =  bcstc002.nrgr  
 	 else  
 	 	 var.fmlbd000.nglo =  ""              
 	 endif  
 	 if not get.number.group( bcckon.fm.plan, o.mess) then  
 	 	 var.fmlbd000.ngpl =  bcstc002.nrgr  
 	 else  
 	 	 var.fmlbd000.ngpl =  ""              
 	 endif  
 	 if trtop000.sssa =  1 then  
 	 	 var.fmlbd000.srsq =  10 | target(fmlbd.srsq.zip)  
 	 else  
 	 	 var.fmlbd000.srsq =  20 | target(fmlbd.srsq.area)  
 	 endif  
 	 var.fmlbd000.indt =  utc(0,0)  
 	 var.fmlbd000.dsca =  form.text$("bcstc00035")  
 	 dump 1  
 	 var.fmlbd000.indt =  utc(date.num(),time.num()) | *  replace by current date function  
 	 var.fmlbd000.dsca =  form.text$("bcstc00036")  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:fm
:TCMOD:lbd
:TFLNO:000
:SCPAC:tr
:SCMOD:top
:SFLNO:000
:ICOD:S
:QURY:START
select 	 trtop000.*
from 	 trtop000  
 as set with 1 rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:fm
:TCMOD:lbd
:TFLNO:000
:SCPAC:tr
:SCMOD:top
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:000
:SCPAC:tc
:SCMOD:com
:SFLNO:000
:ICOD:D
:QURY:START
	 select 	 tccom999.crtf, tccom999.trtr, tccom999.ecvr.7  
 	 from 	 tccom999  
 	 where 	 tccom999._compnr =  :tccom000.ncmp  
 	 selectdo  
 	 	 var.tccom000.fini =  tccom999.crtf  
 	 	 var.tccom000.frmi =  tccom999.trtr  
 	 	 var.tccom000.eust =  tccom999.ecvr.7  
 	 	 var.tccom000.eusl =  tccom999.ecvr.7  
 	 endselect  
 	  
 	 select 	 tppdm000.pprj  
 	 from 	 tppdm000  
 	 where 	 tppdm000._compnr =  :tccom000.ncmp  
 	 selectdo  
 	 	 var.tccom000.prji =  tppdm000.pprj  
 	 selectempty  
 	 	 var.tccom000.prji =  tppdm.yeno.no  
 	 endselect  
 	 select 	 tipcf000.ppcf  
 	 from 	 tipcf000  
 	 where 	 tipcf000._compnr =  :tccom000.ncmp  
 	 selectdo  
 	 	 var.tccom000.cfri =  tipcf000.ppcf  
 	 selectempty  
 	 	 var.tccom000.cfri =  tcyesno.no  
 	 endselect  
 	 if (etol (var.tccom000.cfri) =  0) then  
 	 	 var.tccom000.cfri =  tcyesno.no  
 	 endif  
 	 select 	 tssma102.ccon, tssma102.cgua  
 	 from 	 tssma102  
 	 where 	 tssma102.ccon <>  ""                                                              
 	 or 	 tssma102.cgua <>  ""                                                              
 	 as set with 1 rows  
 	 selectdo  
 	 	 var.tccom000.tlgi =  tcyesno.yes  
 	 selectempty  
 	 	 var.tccom000.tlgi =  tcyesno.no  
 	 endselect  
 	  
 	 select 	 tssma301.*   
 	 from 	 tssma301  
 	 where 	 tssma301._compnr =  :tccom000.ncmp  
 	 as set with 1 rows  
 	 selectdo  
 	 	 var.tccom000.srvi =  1  
 	 selectempty  
 	 	 var.tccom000.srvi =  2  
 	 endselect  
 	  
 	 select 	 tcqms000.*   
 	 from 	 tcqms000  
 	 where tcqms000._compnr =  :tccom000.ncmp  
 	 selectdo  
 	 	 if tcqms000.isls =  tcyesno.no  
 	 	 and tcqms000.ipur =  tcyesno.no  
 	 	 and tcqms000.ipds =  tcyesno.no  
 	 	 and tcqms000.imbm =  tcyesno.no  
 	 	 and tcqms000.irou =  tcyesno.no  
 	 	 and tcqms000.ipdp =  tcyesno.no  
 	 	 and tcqms000.imfm =  tcyesno.no  
 	 	 and tcqms000.ipro =  tcyesno.no  
 	 	 and tcqms000.isti =  tcyesno.no then  
 	 	 	 var.tccom000.qumi =  2  
 	 	 else  
 	 	 	 var.tccom000.qumi =  1  
 	 	 endif  
 	 endselect  
 	  
 	 select tcedi000.*   
 	 from tcedi000  
 	 where tcedi000._compnr =  :tccom000.ncmp  
 	 selectdo  
 	 	 var.tccom000.ecmi =  tcedi000.iedi  
 	 endselect  
 	 if var.tccom000.ecmi =  empty then  
 	 	 var.tccom000.ecmi =  tcyesno.no  
 	 endif  
 	  
 	 select 	 tipcs000.*   
 	 from 	 tipcs000  
 	 where 	 tipcs000._compnr =  :tccom000.ncmp  
 	 selectdo  
 	 	 var.tccom000.pcsi =  tipcs000.ipcs  
 	 endselect  
 	  
 | 	 select tisfc000.*  	 	 	 	 | #  200 -  101933.so  
 | 	 from tisfc000  
 | 	 where tisfc000._compnr =  :tccom000.ncmp 	 | #  200 -  101933.eo  
 	 	 	 	 	 	 	 	  
 	 select 	 tiedm000.*  	 	 	 	 | #  200 -  101933.sn  
 	 from 	 tiedm000  
 	 where 	 tiedm000._compnr =  :tccom000.ncmp 	 | #  200 -  101933.en  
 	 selectdo  
 | 	 	 var.tccom000.erac =  tisfc000.erac 	 | #  200 -  101933.o  
 	 	 var.tccom000.erac =  tiedm000.ecoi 	 | #  200 -  101933.n  
 	 endselect  
 	 select tirpt000.*   
 	 from tirpt000  
 	 where tirpt000._compnr =  :tccom000.ncmp  
 	 selectdo  
 	 	 var.tccom000.rpti =  tirpt000.irpt  
 	 endselect  
 	  
 	 var.tccom000.key (1;3) =  edit$ (tccom000.ncmp,"999")  
 	  
 	 if not get.addresses("tccom000", var.tccom000.key , o.errmess) then  
 	 	 var.tccom000.cadr =  bcstc004.cadr  
 	 else  
 	 	 var.tccom000.cadr =  empty.string(1;9)  
 	 endif  
 	 if (var.tccom000.pcsi =  tcyesno.yes  
 	 or var.tccom000.erac =  tcyesno.yes  
 	 or var.tccom000.rpti =  tcyesno.yes  
 	 or var.tccom000.cfri =  tcyesno.yes) then  
 	 	 var.tccom000.mnfc =  1  
 	 else  
 	 	 var.tccom000.mnfc =  2  
 	 endif  
 	  
 | #  204788.sn  
 	 if var.tccom000.mnfc =  2 then  
 	 	 select 	 tisfc001.pdno  
 	 	 from 	 tisfc001  
 	 	 where 	 tisfc001.pdno >  0  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 | *  production order present,  
 	 	 	 | *  so manufacturing is implemented  
 	 	 	 var.tccom000.mnfc =  1  
 	 	 endselect  
 	 endif  
 | #  204788.en  
 	 select 	 tfgld004.hcmp  
 	 from 	 tfgld004  
 	 where 	 tfgld004.hcmp =  :tccom000.ncmp  
 	 selectdo  
 	 	 var.tccom000.hcmp =  1  
 	 selectempty  
 	 	 var.tccom000.hcmp =  2  
 	 endselect  
 	  
 	 | *  concept "Referece Designators" is yes if                                                                                                        
 	 | *  reference designator are defined for at least one BOM -  position  
 	 var.tccom000.rdes =  tcyesno.no  
 	 select 	 tiitm013.lcid  
 	 from 	 tiitm013  
 	 as set with 1 rows  
 	 selectdo  
 	 	 var.tccom000.rdes =  tcyesno.yes  
 	 endselect  
 	  
 	 var.tccom000.indt =  utc(0,0)  
 	 var.tccom000.dsca =  form.text$("bcstc00035") | *  Actual Set  
 	 dump 1  
 	 var.tccom000.indt =  utc(date.num(), time.num())  
 	 var.tccom000.dsca =  form.text$("bcstc00036") | *  Converted from BaanIVc4  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:000
:SCPAC:tc
:SCMOD:com
:SFLNO:000
:ICOD:S
:QURY:START
select tccom000.clan, tccom000.cmai, tccom000.ccty, tccom000.nama, tccom000.ncmp,  
 	 tccom000.vatn, tccom000.vath 	 	 	 	 | #  215218.n
from tccom000
where tccom000.ncmp =  :current.compnr
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:000
:SCPAC:tc
:SCMOD:com
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:001
:SCPAC:bc
:SCMOD:sts
:SFLNO:000
:ICOD:D
:QURY:START
	 var.tccom001.emno =  bcsts000.emno 	 	 | #  sp2.n  
 	 var.tccom001.seak =  bcsts000.emdc(1; 16)  
 	 var.tccom001.cwoc =  get.default.service.department()  
 	 dump 5  
 	 if bcsts000.sexe =  empty then  
 	 	 var.bpmdm001.sexe =  target(bpmdm.sexe.not.appl)  
 	 	 | *  3 -->  Not Applicable  
 	 else  
 	 	 var.bpmdm001.sexe =  etol(bcsts000.sexe)  
 	 endif  
 	 var.bpmdm001.cist =  enum.descr$("bcsts.cist", bcsts000.cist)  
 	 dump 6  
 	 dump 7
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:001
:SCPAC:bc
:SCMOD:sts
:SFLNO:000
:ICOD:S
:QURY:START
select 	 bcsts000.emno, bcsts000.emdc, bcsts000.clan, bcsts000.sexe, bcsts000.cist, bcsts000.fdoe
from 	 bcsts000  
 as set with 1 rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:001
:SCPAC:bc
:SCMOD:sts
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:001
:SCPAC:tc
:SCMOD:com
:SFLNO:001
:ICOD:S
:QURY:START
select 	 bcsbp000.cpem 	 	 	 	 | #  205573.sn
from 	 bcsbp000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:001
:SCPAC:tc
:SCMOD:com
:SFLNO:001
:ICOD:X
:QURY:START
	 	 	 	 	 	 | #  205573.en  
 	 	 	 	 	 	  
 select 	 tccom001.*   
 from 	 tccom001  
 selectdo  
 	 get.logon.code.for.theemployee() 	 	 	 	 	 | #  215115.n  
 	 var.tccom001.seak =  tccom001.nama(1; 16)  
 	 if not isspace(tccom001.cwoc) then  
 	 	 var.tccom001.cwoc =  tccom001.cwoc  
 	 else  
 	 	 if service.employee.must.be.created(tccom001.emno) then  
 	 	 	 var.tccom001.cwoc =  get.default.service.department()  
 	 	 else  
 	 	 	 var.tccom001.cwoc =  empty()  
 	 	 endif  
 	 endif  
 	 var.tccom001.wgrt =  fill.mc.field.double(tccom001.wgrt,1)  
 	 if get.hourly.labor.rate( | tccom001.wgrt,  
 	 	 	 	 var.tccom001.wgrt,  
 	 	 	 	 tccom001.rats,  
 	 	 	 	 dummy.err.mess) =  0 then  
 	 	 var.tccom001.clrt =  bcsbp003.nrtc  
 	 else  
 	 	 var.tccom001.clrt =  empty()  
 	 endif  
 	 | *  Dump for filling tccom001 -  General Employees  
 	 dump 1  
 	 var.bpmdm001.cadr =  get.address.code(  
 	 	 	 	 "tccom001",                                                                                              
 	 	 	 	 edit$(tccom001.emno,"999999"),  
 	 	 	 	 dummy.err.mess)  
 	 | *  Dump for filling bpmdm001 -  People Employees  
 	 if tccom001.edte <>  0 then  
 	 	 dump 2  
 	 else  
 	 	 dump 8  
 	 endif  
 	 if not isspace(tccom001.ctrg) or  
 	 	 tccom001.dpwk <>  0.0 or  
 	 	 tccom001.hrsd <>  0.0 or  
 	 	 tccom001.rats <>  0.0 then  
 	 	 	 | *  Dump for filling tppdm801 -  Project Employees  
 	 	 	 dump 3  
 	 endif  
 	 if service.employee.must.be.created(tccom001.emno) then  
 	 	 | *  Dump for filling tsmdm140 -  Service Employees  
 	 	 dump 4  
 	 endif  
 endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:100
:SCPAC:tc
:SCMOD:com
:SFLNO:010
:ICOD:D
:QURY:START
	 if get.business.partner(tccom010.cuno,bcstc.orgn.cuno, o.mess) then  
 	 	 var.tccom100.bpid =  ""                                
 	 	 continue  
 | 	 else 	 	 	 	 	 	 	 | #  214051.o  
 	 endif 	 	 	 	 	 	 	 | #  214051.n  
 	 var.tccom100.bpid =  bcstc008.bpid  
 	 if bcstc008.sndr =  empty then 	 	 | #  146484.sn  
 	 	 var.tccom100.sndr =  tcyesno.no  
 	 else 	 	 	 	 	 | #  146484.en  
 	 	 var.tccom100.sndr =  bcstc008.sndr  
 	 endif 	 	 	 	 	 | #  146484.n  
 	 if var.tccom100.sndr =  tcyesno.yes then 	 	 | #  214051.sn  
 	 	 | *  Exception: if a One -  Time BP, then Parent BP  
 	 	 | *  should not be filled.  
 	 	 var.tccom100.prbp =  ""                          
 	 else  
 	 	 var.tccom100.prbp =  hold.tccom100.prbp  
 	 endif 	 	 	 	 	 	 | #  FP | #  214051.en  
 | 	 endif 	 	 	 	 	 	 	 | #  214051.o  
 	 if tccom010.inrl =  empty  
 	 or tccom010.iscn =  0 	 	 	 	 | #  FP3.sn  
 	 | *  If Affiliated Comp ==  0, then Affiliated : =  No. 	 | #  FP3.en  
 	 then  
 	 	 var.tccom100.inrl =  tcyesno.no  
 	 else  
 	 	 var.tccom100.inrl =  tccom010.inrl  
 	 endif  
 	 on case tccom010.cnpa  
 	 case tccnpa.prospect:  
 	 	 var.tccom100.prst =  1 | potential  
 	 	 var.tccom111.bpst =  1 | active  
 	 	 var.tccom112.itst =  1 	 | active  
 	 	 var.tccom114.bpst =  1 | active  
 	 	 break  
 	 case tccnpa.normal:  
 	 	 var.tccom100.prst =  2 | active  
 	 	 var.tccom111.bpst =  1 | active  
 	 	 var.tccom112.itst =  1 	 | active  
 	 	 var.tccom114.bpst =  1 | active  
 	 	 break  
 	 case tccnpa.doubtful:  
 	 	 var.tccom100.prst =  2 | active  
 	 	 var.tccom111.bpst =  1 | active  
 	 	 var.tccom112.itst =  3 	 | doubtful  
 	 	 var.tccom114.bpst =  1 | active  
 	 	 break  
 	 case tccnpa.blocked:  
 	 	 var.tccom100.prst =  3 | inactive  
 	 	 var.tccom111.bpst =  2 | inactive  
 	 	 var.tccom112.itst =  2 	 | inactive  
 	 	 var.tccom114.bpst =  2 | inactive  
 	 	 break  
 	 endcase  
 	 if ( tccom010.scom =  tcyesno.yes ) then  
 	 	 var.tccom110.scon =  4  
 	 else 	  
 	 	 var.tccom110.scon =  1  
 	 endif  
 	 if get.addresses("tccom010", tccom010.cuno, o.mess) then  
 	 	 var.tccom010.cadr =  ""                                
 	 else  
 	 	 var.tccom010.cadr =  bcstc004.cadr  
 	 endif 	 	 	 	  
 	 temp.key.ccor(1;9) =  " "  
 	 temp.key.cdel(1;9) =  " "  
 	 	  
 	 if (not isspace(tccom010.ccor)) then  
 	 	 temp.key.ccor(1;6) =  tccom010.cuno  
 	 	 temp.key.ccor(7;9) =  tccom010.ccor  
 	 	 if get.addresses("tccom012", temp.key.ccor, o.mess) then  
 	 	 	 var.tccom110.cadr =  var.tccom010.cadr  
 	 	 else  
 	 	 	 var.tccom110.cadr =  bcstc004.cadr  
 	 	 endif  
 	 else  
 	 	 var.tccom110.cadr =  var.tccom010.cadr  
 	 endif  
 	  
 	 if (not isspace(tccom010.cdel)) then  
 	 	 temp.key.cdel(1;6) =  tccom010.cuno  
 	 	 temp.key.cdel(7;9) =  tccom010.cdel  
 	 	 if get.addresses("tccom013", temp.key.cdel, o.mess) then  
 	 	 	 var.tccom111.cadr =  var.tccom010.cadr  
 	 	 else  
 	 	 	 var.tccom111.cadr =  bcstc004.cadr  
 	 	 endif  
 	 else  
 	 	 var.tccom111.cadr =  var.tccom010.cadr  
 	 endif  
 	 	  
 	 if get.cross.reference.for.contact.code("tccom010a",tccom010.cuno, o.mess) then  
 	 	 var.tccom110.ccnt =  ""                                
 	 else  
 	 	 var.tccom110.ccnt =  bcstc005.ccnt  
 	 endif  
 	 if get.cross.reference.for.contact.code("tccom010",tccom010.cuno, o.mess) then  
 	 	 var.tccom112.ccnt =  ""                                
 	 else  
 	 	 var.tccom112.ccnt =  bcstc005.ccnt  
 	 endif  
 	  
 	 if isspace(tccom010.pctx) or  
 	 isspace(var.tccom100.prbp) 	 | #  200003.n  
 	 then  
 	 	 var.tccom100.bptx =  ""                                
 	 else  
 	 	 var.tccom100.bptx =  get.business.partner.code(tccom010.pctx, bcstc.orgn.cuno, o.mess)  
 	 endif  
 	  
 	 select 	 tcedi010.cuno  
 	 from 	 tcedi010  
 	 where 	 tcedi010._index2 =  {:tccom010.cuno}  
 	 as set with 1 rows  
 	 selectdo  
 	 	 var.tccom100.edyn =  tcyesno.yes  
 	 selectempty  
 	 	 var.tccom100.edyn =  tcyesno.no  
 	 endselect  
 	  
 	 dump 1 | *  tccom100  
 	  
 	 if (tccom010.comp <>  0) then  
 	 	 if get.enterprise.unit(tccom010.comp,hold.cmpnr, o.mess) then  
 	 	 	 var.tccom110.cofc =  ""                                
 	 	 else  
 	 	 	 var.tccom110.cofc =  bcstc018.sofd  
 	 	 endif  
 	 else  
 	 	 var.tccom110.cofc =  ""                                
 	 endif  
 	 	  
 	 if isspace(var.tccom100.prbp) or 	 	 | #  200003.sn  
 	 isspace(tccom010.pcpr) then  
 	 	 var.tccom110.bppr =  ""                                
 	 else 	 	 	 	 	 | #  200003.en  
 	 	 if get.business.partner(tccom010.pcpr,bcstc.orgn.cuno, o.mess) then  
 	 	 	 var.tccom110.bppr =  ""                                
 	 	 else  
 	 	 	 var.tccom110.bppr =  bcstc008.bpid  
 	 	 endif  
 	 endif 	 | #  200003.n  
 	  
 	 dump 2 | *  tccom110  
 	 dump 3 | *  tccom111  
 	 if isspace(tccom010.cinm) then  
 	 	 var.tccom112.cinm =  bcstc000.cinm  
 	 else  
 	 	 var.tccom112.cinm =  tccom010.cinm  
 	 endif  
 	 if not isspace(tccom010.crat) then 	 	 	 | #  211670.sn  
 	 	 var.tccom112.crat =  tccom010.crat  
 	 else  
 	 	 var.tccom112.crat =  bcstc000.crat  
 	 endif 	 	 	 	 	 	 	 | #  211670.en  
 	 var.tccom112.cvyn =  get.tax.flag.via.bp(tccom010.cuno, bcstc.orgn.cuno,  
 	 	 	 o.mess)  
 	 if get.business.partner(tccom010.pctf,bcstc.orgn.cuno, o.mess) then 	 | #  148806.sn  
 	 	 var.tccom112.pfbp =  ""                                
 	 else  
 	 	 var.tccom112.pfbp =  bcstc008.bpid  
 	 endif 	 	 	 	 	 	 	 | #  148806.en  
 	 dump 4 | *  tccom112  
 	 dump 5 | *  tccom114  
 	 add.business.partner.to.list(var.tccom100.bpid) 	 | #  800 -  141749.n  
 | 	 create.bps.for.delivery.adresses() 	 | #  201931.n | #  800 -  154840.o
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:100
:SCPAC:tc
:SCMOD:com
:SFLNO:010
:ICOD:S
:QURY:START
select 	 tccom010.*
from 	 tccom010
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:100
:SCPAC:tc
:SCMOD:com
:SFLNO:010
:ICOD:X
:QURY:START
sort.bp.code.list() 	 	 	 	 	 | #  800 -  141749.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:100
:SCPAC:tc
:SCMOD:com
:SFLNO:020
:ICOD:D
:QURY:START
	 if get.business.partner(tccom020.suno, bcstc.orgn.suno, o.mess) then  
 	 	 var.tccom100.bpid =  ""                                      
 	 	 continue  
 	 else  
 	 	 var.tccom100.bpid =  bcstc008.bpid  
 	 endif  
 	 if tccom020.sndr =  empty then  
 	 	 tccom020.sndr =  tcyesno.no  
 	 endif  
 	 if tccom020.sndr =  tcyesno.yes then 	 	 	 | #  214051.sn  
 	 | *  Exception: if a One -  Time BP, then the Parent BP should not be  
 	 | *  filled.  
 	 	 var.tccom100.prbp =  ""                            
 	 else  
 	 	 var.tccom100.prbp =  hold.tccom100.prbp  
 	 endif 	 	 	 	 	 	 	 | #  214051.en  
 	 if tccom020.inrl =  empty  
 	 or tccom020.iscn =  0 	 	 	 	 | #  FP3.sn  
 	 | *  If Affiliated Comp ==  0, then Affiliated : =  No. 	 | #  FP3.en  
 	 then  
 	 	 var.tccom100.inrl =  tcyesno.no  
 	 else  
 	 	 var.tccom100.inrl =  tccom020.inrl  
 	 endif  
 	 if get.addresses("tccom020", tccom020.suno, o.mess) then  
 	 	 var.tccom020.cadr =  ""                                      
 	 else  
 	 	 var.tccom020.cadr =  bcstc004.cadr  
 	 endif  
 	 var.tccom120.cadr =  var.tccom020.cadr  
 	 if (not isspace(tccom020.ccor)) then  
 	 	 temp.key.ccor(1;6) =  tccom020.suno  
 	 	 temp.key.ccor(7;9) =  tccom020.ccor  
 	 	 if not get.addresses("tccom022", temp.key.ccor, o.mess) then  
 	 	 	 | *  no error  
 	 	 	 var.tccom120.cadr =  bcstc004.cadr  
 	 	 endif  
 	 endif  
 	 	 	 	  
 	 select 	 tcedi010.*   
 	 from 	 tcedi010  
 	 where 	 tcedi010._index3 =  {:tccom020.suno}  
 	 as set with 1 rows  
 	 selectdo  
 	 	 var.tccom100.edyn =  tcyesno.yes  
 	 selectempty  
 	 	 var.tccom100.edyn =  tcyesno.no  
 	 endselect  
 	 if (not isspace(tccom020.refs)) then  
 	 	 if get.cross.reference.for.contact.code("tccom020a",tccom020.suno, o.mess) then  
 	 	 	 var.tccom120.ccnt =  ""                            
 	 	 else  
 	 	 	 var.tccom120.ccnt =  bcstc005.ccnt  
 	 	 endif  
 	 else  
 	 	 var.tccom120.ccnt =  ""                            
 	 endif  
 	 hold.ccnt =  ""                            
 	 if (not isspace(tccom020.refa)) then  
 	 	 if get.cross.reference.for.contact.code("tccom020",tccom020.suno, o.mess) then  
 	 	 	 hold.ccnt =  ""                            
 	 	 else  
 	 	 	 hold.ccnt =  bcstc005.ccnt  
 	 	 endif  
 	 endif  
 	 if isspace(tccom020.pstx) then  
 	 	 var.tccom100.bptx =  ""                            
 	 else  
 	 	 var.tccom100.bptx =  get.business.partner.code(tccom020.pstx, bcstc.orgn.suno, o.mess)  
 	 endif  
 	 if get.business.partner(tccom020.scus, bcstc.orgn.suno, o.mess) then  
 	 	 var.tccom120.scus =  ""                            
 	 else  
 	 	 var.tccom120.scus =  bcstc008.bpid  
 	 endif  
 	 on case tccom020.sust  
 	 case tcsust.fix:  
 	 	 var.tccom100.bpst =  2  
 	 	 var.tccom120.bpst =  2  
 	 	 var.tccom121.bpst =  1  
 	 	 var.tccom122.bpst =  1  
 	 	 var.tccom124.bpst =  1  
 	 	 break  
 	 case tcsust.temporary:  
 	 	 	 	 	 	 	 | #  800 -  142237.sn  
 	 	 if purchase.contract.or.order.found(tccom020.suno) then  
 	 	 	 var.tccom100.bpst =  2 |active  
 	 	 	 var.tccom120.bpst =  3 |inactive  
 	 	 else 	 	 	 	 	 | #  800 -  142237.en  
 	 	 	 var.tccom100.bpst =  1  
 	 	 	 var.tccom120.bpst =  1  
 	 	 endif 	 	 	 	 	 | #  800 -  142237.n  
 	 	 var.tccom121.bpst =  2  
 	 	 var.tccom122.bpst =  2  
 	 	 var.tccom124.bpst =  2  
 	 	 break  
 	 case tcsust.pur.entry.blck:  
 	 	 var.tccom100.bpst =  2  
 	 	 var.tccom120.bpst =  3  
 	 	 var.tccom121.bpst =  1  
 	 	 var.tccom122.bpst =  1  
 	 	 var.tccom124.bpst =  1  
 	 	 break  
 	 case tcsust.acp.blck:  
 	 	 var.tccom100.bpst =  2  
 	 	 var.tccom120.bpst =  2  
 	 	 var.tccom121.bpst =  1  
 	 	 var.tccom122.bpst =  1  
 	 	 var.tccom124.bpst =  2 	 	 	  
 	 	 break  
 	 case tcsust.acp.pur.entr.bl: 	  
 	 	 var.tccom100.bpst =  2  
 	 	 var.tccom120.bpst =  3  
 	 	 var.tccom121.bpst =  2  
 	 	 var.tccom122.bpst =  2  
 	 	 var.tccom124.bpst =  2 	 	 	  
 	 	 break  
 	 endcase  
 	 if not bp.code.in.sorted.list(var.tccom100.bpid) then 	 | #  800 -  141749.n  
 	 	 dump 6 | *  tccom100  
 	 endif 	 	 	 	 	 	 	 | #  800 -  141749.n  
 	  
 	 if (tccom020.comp <>  0) then  
 	 	 if get.enterprise.unit(tccom020.comp, hold.cmpnr, o.mess) then  
 	 	 	 var.tccom120.cofc =  ""                            
 	 	 else  
 	 	 	 var.tccom120.cofc =  bcstc018.pofd  
 	 	 endif  
 	 else  
 	 	 var.tccom120.cofc =  ""                            
 	 endif  
 	 link.to.sub =  2  
 	 select tirou001.*   
 	 from 	 tirou001  
 	 where tirou001._index4 =  {:tccom020.suno}  
 	 as set with 1 rows  
 	 selectdo  
 	 	 link.to.sub =  1  
 	 	 if get.enterprise.unit(tirou001.ncmp, hold.cmpnr, o.mess) then  
 	 	 	 var.tccom120.cofc =  ""                            
 	 	 else  
 	 	 	 var.tccom120.cofc =  bcstc018.pofd  
 	 	 endif  
 	 endselect  
 	 	 	  
 	 dump 7 | *  tccom120  
 	 dump 8 | *  tccom121  
 	 if (link.to.sub =  1) then  
 	 	 var.tccom122.ccnt(1;9) =  ""                            
 	 else 	  
 	 	 var.tccom122.ccnt(1;9) =  hold.ccnt  
 	 endif  
 	 if tccom020.subc =  empty then  
 	 	 tccom020.subc =  tcyesno.no  
 	 endif  
 	 var.tccom122.cvyn =  get.tax.flag.via.bp(tccom020.suno, bcstc.orgn.suno,  
 	 	 	 o.mess)  
 	 if not isspace(tccom020.cfcc) then 	 	 	 | #  800 -  141749.sn  
 	 	 if get.business.partner(tccom020.cfcc, bcstc.orgn.fcomp, o.mess) then  
 	 	 	 var.tccom122.ptbp =  ""                            
 	 	 else  
 	 	 	 var.tccom122.ptbp =  bcstc008.bpid  
 	 	 endif  
 	 else  
 	 	 var.tccom122.ptbp =  ""                            
 	 endif  
 	 dump 9 | *  tccom122  
 	 dump 10 | *  tccom124
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:100
:SCPAC:tc
:SCMOD:com
:SFLNO:020
:ICOD:S
:QURY:START
select 	 tccom020.*
from 	 tccom020
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:100
:SCPAC:tc
:SCMOD:com
:SFLNO:020
:ICOD:X
:QURY:START
free.mem(bp.code.list) 	 	 	 	 	 	 | #  800 -  141749.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:100
:SCPAC:tc
:SCMOD:mcs
:SFLNO:025
:ICOD:D
:QURY:START
	 | *  Create a cuno from cfcc, just like done in bcstc008 (for future: move this code  
 	 | *  to a separate function.  
 	 converted.cuno =  string.set$(" ", 6)  
 	 converted.cuno(4;3) =  tcmcs025.cfcc  
 	 if get.business.partner(converted.cuno,bcstc.orgn.fcomp, o.mess) then  
 	 	 var.tccom100.bpid =  ""                                    
 	 	 continue  
 | 	 else 	 	 	 	 	 	 	 | #  214051.o  
 	 endif 	 	 	 	 	 	 	 | #  214051.n  
 	 var.tccom100.bpid =  bcstc008.bpid  
 	 if bcstc008.sndr =  empty then 	 	 | #  146484.sn  
 	 	 var.tccom100.sndr =  tcyesno.no  
 	 else 	 	 	 	 	 | #  146484.en  
 	 	 var.tccom100.sndr =  bcstc008.sndr 	  
 	 endif 	 	 	 	 	 | #  146484.n  
 	 if var.tccom100.sndr =  tcyesno.yes then 	 	 | #  214051.sn  
 	 	 | *  Exception: if a One -  Time BP, then Parent BP  
 	 	 | *  should not be filled.  
 	 	 var.tccom100.prbp =  ""                                
 	 else  
 	 	 var.tccom100.prbp =  hold.tccom100.prbp  
 	 endif 	 	 	 	 	 	 	 | #  214051.en  
 | 	 endif 	 	 	 	 	 	 	 | #  214051.o  
 	 if isspace(tcmcs025.nama) then  
 	 	 var.tccom100.nama =  var.tccom100.bpid  
 	 else  
 	 	 var.tccom100.nama =  tcmcs025.nama  
 	 endif  
 	 var.tccom100.seak =  var.tccom100.nama  
 	 if get.addresses("tcmcs025", tcmcs025.cfcc, o.mess) then  
 	 	 var.tccom100.cadr =  ""                                     
 	 else  
 	 	 var.tccom100.cadr =  bcstc004.cadr  
 	 endif  
 	 dump 11 | *  tccom100  
 	 dump 12 | *  tccom124
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:100
:SCPAC:tc
:SCMOD:mcs
:SFLNO:025
:ICOD:S
:QURY:START
select 	 tcmcs025.*
from 	 tcmcs025
:QURY:END
:TEXT:
SOL 146484, 14.09.2004, Henk de Jong
The sndr field in ERP LN is a mandatory field, while this in bcstc008 can be empty. Therefore a check
is built for the migrate of tcmcs025 and tccom010 to set the variable var.tccom100.sndr to tcyesno.no, when 
the field bcstc008 is empty.
:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:100
:SCPAC:tc
:SCMOD:mcs
:SFLNO:025
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:117
:SCPAC:tc
:SCMOD:com
:SFLNO:013
:ICOD:D
:QURY:START
	 if get.business.partner(tccom013.cuno, bcstc.orgn.cuno, o.mess) then  
 	 	 continue  
 	 endif  
 	  
 | 	 	 	 	 	 	 	 	 | # 800 - 154840.so  
 | 	 var.tccom117.stbp =  tccom013.cuno &  tccom013.cdel  
 | 	 | *  build id for new business partner. E.g cuno =  " ABC"; cdel =               " 1"                            
 | 	 | *  bpid will be: "ABC 1". Leading spaces are stripped from cuno,                             
 | 	 | *  not from cdel. Reasons for this:  
 | 	 | * -  minimize risks for duplicates,  
 | 	 | * -  maxime ease of use when doing a Find in session tccom1117m000  
 | 	 | *  . NB If this logic is changed, also change migration object tccom100.  
 | 	 var.tccom117.stbp =  ""                            
 | 	 var.tccom117.stbp(1;6) =  shiftl$(tccom013.cuno)  
 | 	 var.tccom117.stbp(7;3) =  tccom013.cdel 	 	 | # 800 - 154840.eo  
 	  
 	 dump 1 	  
 	 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:117
:SCPAC:tc
:SCMOD:com
:SFLNO:013
:ICOD:S
:QURY:START
select 	 tccom013.cuno 	 	 	 	 	 	 | # 800 - 154840.n  
 |select 	 tccom013.*  	 	 	 	 	 	 | # 800 - 154840.o
from 	 tccom013
group by tccom013.cuno 	 	 	 	 	 	 | # 800 - 154840.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:117
:SCPAC:tc
:SCMOD:com
:SFLNO:013
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:130
:SCPAC:bc
:SCMOD:stc
:SFLNO:004
:ICOD:D
:QURY:START
| 	 if bcstc004.reqd =  tcyesno.yes then 	 	 	 | #  City.o  
 	 	 | *  Dump selected addresses.  
 	 	 if isspace (bcstc004.nama) then  
 	 	 	 var.tccom130.nama =  bcstc004.cadr(1;9) &   
 	 	 	 	 	 	 empty.string (1;26)  
 	 	 else  
 	 	 	 var.tccom130.nama =  bcstc004.nama  
 	 	 endif  
 	 	 if (bcstc004.lvdt =  0) then  
 	 	 	 var.tccom130.lvdt =  utc(0,0)  
 	 	 else  
 	 	 	 var.tccom130.lvdt =  utc(bcstc004.lvdt,0)  
 	 	 endif  
 	 	 | *  Dump Addresses -  Freight Management.  
 	 	 if bcstc004.tadr <>  "" then                                                                                                    
 	 	 	 select tracs100.creg:var.fmfmd010.creg,  
 	 	 	 	 tracs100.lwtm:var.fmfmd010.lwtm,  
 	 	 	 	 tracs100.lltm:var.fmfmd010.ldtm,  
 	 	 	 	 tracs100.uwtm:var.fmfmd010.uwtm,  
 	 	 	 	 tracs100.ultm:var.fmfmd010.untm,  
 	 	 	 	 tracs100.hono:var.tccom130.hono,  
 	 	 	 	 tracs100.pobx:g.tccom130.pobn  
 	 	 	 from 	 tracs100  
 	 	 	 where tracs100._index1 =  {:bcstc004.tadr}  
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 	 var.fmfmd010.lwtm =  var.fmfmd010.lwtm *  g.conv.factor  
 	 	 	 	 var.fmfmd010.ldtm =  var.fmfmd010.ldtm *  g.conv.factor  
 	 	 	 	 var.fmfmd010.uwtm =  var.fmfmd010.uwtm *  g.conv.factor  
 	 	 	 	 var.fmfmd010.untm =  var.fmfmd010.untm *  g.conv.factor  
 	 	 	 	 var.tccom130.pobn =  left.align(g.tccom130.pobn,10)  
 	 	 	 	 dump 2 | *  Addresses -  Freight Management (fmfmd010)  
 	 	 	 selectempty  
 	 	 	 	 var.tccom130.hono =  empty.string(1;10)  
 	 	 	 	 var.tccom130.pobn =  empty.string(1;10)  
 	 	 	 endselect  
 	 	 else  
 	 	 	 var.tccom130.hono =  empty.string(1;10)  
 	 	 	 var.tccom130.pobn =  empty.string(1;10)  
 	 	 endif  
 	 	 | *  For CRM: 	 	 	 	 	 | #  800 -  154794.sn  
 	 	 var.tccom130.ln01 =  ""                  
 	 	 if not isspace(bcstc004.namc) then  
 	 	 	 if not isspace(var.tccom130.hono) then 	  
 	 	 	 	 var.tccom130.ln01 =  strip$(shiftl$(bcstc004.namc)) &   
 	 	 	 	 	 	 " " &  strip$(shiftl$(var.tccom130.hono))  
 	 	 	 else  
 	 	 	 	 var.tccom130.ln01 =  strip$(shiftl$(bcstc004.namc)) &   
 	 	 	 	 	 	 " " &  strip$(shiftl$(var.tccom130.pobn))  
 	 	 	 endif  
 	 	 endif 	 	 	 	 	 	 | #  800 -  154794.en  
 	 	 var.tccom130.dsca =  bcstc004.ccit 	 	 | #  City.sn  
 	 	 select 	 bcstc031.dsca  
 	 	 from 	 bcstc031  
 	 	 where 	 bcstc031._index3 =  {:bcstc004.ccty, :bcstc004.cste, :bcstc004.ccit}  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 var.tccom130.dsca =  bcstc031.dsca  
 	 	 endselect 	 	 	 	 	 	 | #  City.en  
 | #  209024.sn  
 	 	 var.tccom130.defa =  10 | *  not applicable  
 	 	 if not isspace(bcstc004.telp) then  
 	 	 	 var.tccom130.defa =  6 | *  phone  
 	 	 else  
 	 	 	 if not isspace(bcstc004.tefx) then  
 	 	 	 	 var.tccom130.defa =  2 | *  fax  
 	 	 	 else  
 	 	 	 	 if not isspace(bcstc004.telx) then  
 	 	 	 	 	 var.tccom130.defa =  3 | *  telex  
 	 	 	 	 endif  
 	 	 	 endif  
 	 	 endif  
 | #  209024.en  
 	 	 dump 1 | *  Addresses (tccom130)  
 | 	 endif 	 	 	 	 	 	 	 	 | #  City.o  
 | 	 | *  Dump Cities by Country. 	 	 	 	 	 | #  City.so  
 | 	 if 	 bcstc004.ccty <>  var.prev.country or  
 | 	 	 bcstc004.ccit <>  var.prev.city.code then  
 | 	 	 | *  Increment ID number.  
 | 	 	 bcstc.dll0004.compose.searchkey(  
 | 	 	 	 	 bcstc004.name,  
 | 	 	 	 	 var.tccom139.seak)  
 | 	 	  
 | 	 	 var.tccom139.idnr =  var.tccom139.idnr +  1  
 | 	 	 dump 3 | *  Cities by Country (tccom139)  
 | 	 endif  
 | 	 var.prev.country =  bcstc004.ccty  
 | 	 var.prev.city.code =  bcstc004.ccit 	 	 	 	 | #  City.eo
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:130
:SCPAC:bc
:SCMOD:stc
:SFLNO:004
:ICOD:S
:QURY:START
select 	 bcstc004.*
from 	 bcstc004
where 	 bcstc004.reqd =  tcyesno.yes
order by bcstc004._index4 | *  Country, City code 	 | #  City.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:130
:SCPAC:bc
:SCMOD:stc
:SFLNO:004
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:133
:SCPAC:tc
:SCMOD:com
:SFLNO:010
:ICOD:D
:QURY:START
	 dump.bp.addresses(false) 	 | *  i.single.role
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:133
:SCPAC:tc
:SCMOD:com
:SFLNO:010
:ICOD:S
:QURY:START
select 	 bcstc008.bpid:var.bpid
from 	 bcstc008
group by bcstc008.bpid
having count( *  ) =  2 	 | *  With both Customer &  Supplier roles !
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:133
:SCPAC:tc
:SCMOD:com
:SFLNO:010
:ICOD:X
:QURY:START
select 	 bcstc008.bpid:var.bpid  
 from 	 bcstc008  
 group by bcstc008.bpid  
 having count( *  ) =  1 	 | *  With either Customer OR Supplier role  
 selectdo  
 	 dump.bp.addresses(true) 	 | *  i.single.role  
 endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:133
:SCPAC:tc
:SCMOD:com
:SFLNO:012
:ICOD:D
:QURY:START
	 if get.business.partner(tccom012.cuno,bcstc.orgn.cuno, o.mess) then  
 	 	 continue  
 	 endif  
 	 var.bpid =  bcstc008.bpid  
 	 | *  determine adress codes  
 	 temp.key =  ""                          
 	 temp.key(1;6) =  tccom012.cuno  
 	 temp.key(7;3) =  tccom012.ccor  
 	 if get.addresses("tccom012", temp.key, o.mess) then  
 	 	 continue  
 	 endif 	 	  
 	 var.cadr =  bcstc004.cadr  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:133
:SCPAC:tc
:SCMOD:com
:SFLNO:012
:ICOD:S
:QURY:START
select 	 tccom012.cuno, tccom012.ccor
from 	 tccom012
where 	 not exists ( 	 select 	 tccom010.ccor  
 	 	 	 from 	 tccom010  
 	 	 	 where 	 tccom010._index1 =  { tccom012.cuno }  
 	 	 	 and 	 tccom010.ccor =  tccom012.ccor 	 )
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:133
:SCPAC:tc
:SCMOD:com
:SFLNO:012
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:133
:SCPAC:tc
:SCMOD:com
:SFLNO:013
:ICOD:D
:QURY:START
	 if get.business.partner(tccom013.cuno,bcstc.orgn.cuno, o.mess) then  
 	 	 continue  
 	 endif  
 	 var.bpid =  bcstc008.bpid  
 	 | *  determine adress codes  
 	 temp.key =  ""                          
 	 temp.key(1;6) =  tccom013.cuno  
 	 temp.key(7;3) =  tccom013.cdel  
 	 if get.addresses("tccom013", temp.key, o.mess) then  
 	 	 continue  
 	 endif 	 	  
 	 var.cadr =  bcstc004.cadr  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:133
:SCPAC:tc
:SCMOD:com
:SFLNO:013
:ICOD:S
:QURY:START
select 	 tccom013.*
from 	 tccom013
where 	 not exists ( 	 select 	 tccom010.cdel  
 	 	 	 from 	 tccom010  
 	 	 	 where 	 tccom010._index1 =  { tccom013.cuno }  
 	 	 	 and 	 tccom010.cdel =  tccom013.cdel 	 )
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:133
:SCPAC:tc
:SCMOD:com
:SFLNO:013
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:133
:SCPAC:tc
:SCMOD:mcs
:SFLNO:025
:ICOD:D
:QURY:START
	 | *  Create a cuno from cfcc, just like done in bcstc008 (for future: move this code  
 	 | *  to a separate function.  
 	 converted.cuno =  string.set$(" ", 6)  
 	 converted.cuno(4;3) =  tcmcs025.cfcc  
 	 if get.business.partner(converted.cuno,bcstc.orgn.fcomp, o.mess) then  
 	 	 continue  
 	 endif  
 	 var.bpid =  bcstc008.bpid  
 	 if get.addresses("tcmcs025", tcmcs025.cfcc, o.mess) then  
 	 	 continue  
 	 endif  
 	 var.cadr =  bcstc004.cadr  
 	 dump 1 	 | *  Addressess by BP
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:133
:SCPAC:tc
:SCMOD:mcs
:SFLNO:025
:ICOD:S
:QURY:START
select 	 tcmcs025.cfcc
from 	 tcmcs025
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:133
:SCPAC:tc
:SCMOD:mcs
:SFLNO:025
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:133
:SCPAC:td
:SCMOD:sls
:SFLNO:003
:ICOD:D
:QURY:START
	 if get.business.partner(tdsls001.cuno,bcstc.orgn.cuno, o.mess) then  
 	 	 continue  
 	 endif  
 	 var.bpid =  bcstc008.bpid  
 	 | *  determine adress codes  
 	 temp.key =  ""                  
 	 temp.key(1;6) =  edit$(tdsls003.qono,"999999")  
 	 temp.key(7;4) =  edit$(tdsls003.pono,"9999")  
 	 temp.key(11;2) =  edit$(tdsls003.ckor,"99")  
 	 if get.addresses("tdsls003", temp.key, o.mess) then  
 	 	 continue  
 	 endif  
 	 var.cadr =  bcstc004.cadr  
 	 | *  determine role  
 	 on case tdsls003.ckor  
 	 case 0 :  
 	 	 var.sold.to.amsk =  1 	 | *  Yes =>  Only a Sold -  To role  
 	 	 var.ship.to.amsk =  2 	 | *  No =>  No Ship -  To role  
 	 	 break  
 	 default :  
 	 	 var.sold.to.amsk =  2 	 | *  No =>  No Sold -  To role  
 	 	 var.ship.to.amsk =  1 	 | *  Yes =>  Only a Ship -  To role  
 	 	 break  
 	 endcase  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:133
:SCPAC:td
:SCMOD:sls
:SFLNO:003
:ICOD:S
:QURY:START
select 	 tdsls003.qono, tdsls003.pono, tdsls003.ckor, tdsls001.cuno
from 	 tdsls003, tdsls001
where 	 tdsls003.qono refers to tdsls001 unref skip
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:133
:SCPAC:td
:SCMOD:sls
:SFLNO:003
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:133
:SCPAC:td
:SCMOD:sls
:SFLNO:042
:ICOD:D
:QURY:START
	 if get.business.partner(tdsls040.cuno,bcstc.orgn.cuno, o.mess) then  
 	 	 continue  
 	 endif  
 	 var.bpid =  bcstc008.bpid  
 	 | *  determine adress codes  
 	 temp.key =  ""                      
 	 temp.key(1;6) =  edit$(tdsls042.orno,"999999")  
 	 temp.key(7;4) =  edit$(tdsls042.pono,"9999")  
 	 temp.key(11;2) =  edit$(tdsls042.ckor,"99")  
 	 if get.addresses("tdsls042", temp.key, o.mess) then  
 	 	 continue  
 	 endif 	 	  
 	 var.cadr =  bcstc004.cadr  
 	 | *  determine role  
 	 on case tdsls042.ckor  
 	 case 0 :  
 	 	 var.sold.to.amsk =  1 	 | *  Yes =>  Only a Sold -  To role  
 	 	 var.ship.to.amsk =  2 	 | *  No =>  No Ship -  To role  
 	 	 break  
 	 default :  
 	 	 var.sold.to.amsk =  2 	 | *  No =>  No Sold -  To role  
 	 	 var.ship.to.amsk =  1 	 | *  Yes =>  Only a Ship -  To role  
 	 	 break  
 	 endcase  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:133
:SCPAC:td
:SCMOD:sls
:SFLNO:042
:ICOD:S
:QURY:START
select 	 tdsls042.orno, tdsls042.pono, tdsls042.ckor, tdsls040.cuno
from 	 tdsls042, tdsls040
where 	 tdsls042.orno refers to tdsls040 unref skip
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:133
:SCPAC:td
:SCMOD:sls
:SFLNO:042
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:135
:SCPAC:bc
:SCMOD:stc
:SFLNO:014
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:135
:SCPAC:bc
:SCMOD:stc
:SFLNO:014
:ICOD:S
:QURY:START
select 	 bcstc014.*
from 	 bcstc014
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:135
:SCPAC:bc
:SCMOD:stc
:SFLNO:014
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:tc
:SCMOD:com
:SFLNO:010
:ICOD:D
:QURY:START
	 | *  Customers table...  
 	  
 	 | *  Contacts (tccom140)  
 | 	 if bcstc005.tabl =  "tccom010" then                        |#                206190.o                    
 	 init.cmsk() 	 	 	 	 	 	 | #  210314.n  
 	 if bcstc005.tabl =  "tccom010a" then                       |#           206190.n                    
 	 	 var.tccom140.surn =  tccom010.refp  
 	 	 var.tccom145.cmsk.1 =  target(tcyesno.yes) | *  Sold To role 	 | #  210314.n  
 	 else  
 	 	 var.tccom140.surn =  tccom010.refa  
 	 	 var.tccom145.cmsk.4 =  target(tcyesno.yes) | *  Pay By Role 	 | #  210314.n  
 	 endif  
 	 bcstc.dll0004.compose.searchkey(var.tccom140.surn, var.mscript.seak) | *  203913.sn  
 	 if var.mscript.seak =  "" then                                                                          
 	 	 var.mscript.seak =  empty.string (1;16)  
 	 endif 	 	 	 	 	 	 	 | *  203913.en  
 	 dump 6  
 	  
 	 | *  Contacts by Business Partner (tccom145)  
 	 if get.business.partner ( tccom010.cuno,  
 	 	 	 	 bcstc.orgn.cuno,  
 	 	 	 	 error.message) <>  0 then  
 	 	 | *  Skip business partners which are not found.  
 	 	 continue  
 	 endif 	  
 	  
 	 dump 7
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:tc
:SCMOD:com
:SFLNO:010
:ICOD:S
:QURY:START
select 	 bcstc005.ccnt,  
 	 bcstc005.tabl,  
 	 tccom010.cuno,  
 	 tccom010.ctit,  
 	 tccom010.telp,  
 	 tccom010.tefx,  
 	 tccom010.clan,  
 	 tccom010.refp, tccom010.refa
from 	 bcstc005,  
 	 tccom010
where 	 (bcstc005._index2 =  { "tccom010",                                                                          
 	 	 	 	 tccom010.cuno} or  
 	 bcstc005._index2 =  { 	 "tccom010a",                                                                          
 	 	 	 	 tccom010.cuno} 	 )  
 and 	 bcstc005.keys refers to tccom010
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:tc
:SCMOD:com
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:tc
:SCMOD:com
:SFLNO:020
:ICOD:D
:QURY:START
	 | *  Suppliers table...  
 	 | *  Contacts (tccom140) 	 	 	 	 | *  203913.sn  
 | 	 if bcstc005.tabl =  "tccom020" then                            |#               206190.o                              
 	 init.cmsk() 	 	 	 	 	 	 | #  210314.n  
 	 if bcstc005.tabl =  "tccom020a" then                          |#               206190.n                              
 	 	 var.tccom140.surn =  tccom020.refs  
 	 	 var.tccom145.cmsk.5 =  target(tcyesno.yes) | *  Buy from Role 	 | #  210314.n  
 	 else  
 	 	 var.tccom140.surn =  tccom020.refa  
 	 	 var.tccom145.cmsk.7 =  target(tcyesno.yes) | *  Pay To Role 	 | #  210314.n  
 	 endif  
 	 bcstc.dll0004.compose.searchkey(var.tccom140.surn, var.mscript.seak)  
 	 if var.mscript.seak =  "" then                                                                          
 	 	 var.mscript.seak =  empty.string (1;16)  
 	 endif 	 	 	 	 	 	 	 | *  203913.en  
 	 dump 9 | *  Contacts (tccom140)  
 	 if get.business.partner ( tccom020.suno,  
 	 	 	 	 bcstc.orgn.suno,  
 	 	 	 	 error.message) <>  0 then  
 	 	 | *  Skip business partners which are not found.  
 	 	 continue  
 	 endif  
 	 dump 10 | *  Contacts by Business Partner (tccom145)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:tc
:SCMOD:com
:SFLNO:020
:ICOD:S
:QURY:START
select 	 bcstc005.ccnt,  
 	 bcstc005.tabl,  
 	 tccom020.suno,  
 	 tccom020.ctit,  
 	 tccom020.telp,  
 	 tccom020.tefx,  
 	 tccom020.refa, 	 	 	 | *  203913.sn  
 	 tccom020.refs, 	 	 | *  203913.en  
 	 tccom020.clan
from 	 bcstc005,  
 	 tccom020
where 	 (bcstc005._index2 =  { "tccom020",                                                                          
 	 	 	 	 tccom020.suno} or  
 	 bcstc005._index2 =  { "tccom020a",                                                                          
 	 	 	 	 tccom020.suno} 	 )  
 and 	 bcstc005.keys refers to tccom020
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:tc
:SCMOD:com
:SFLNO:020
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:td
:SCMOD:smi
:SFLNO:120
:ICOD:D
:QURY:START
	 | *  Contacts table...  
 	 var.str.key =  tdsmi120.rlcd &  tdsmi120.cper  
 	 if get.cross.reference.for.contact.code( 	 "tdsmi120",                                                                          
 	 	 	 	 	 	 var.str.key,  
 	 	 	 	 	 	 error.message) <>  0 then  
 	 	 | *  Skip contacts which are not found.  
 	 	 continue  
 	 endif  
 | 	 tccom.dll0009.compose.searchkey( 	 tdsmi120.surn, 	 | *  800 -  144238.so  
 | 	 	 	 	 	 	 var.mscript.seak)  
 | 	 var.mscript.seak =  strip$(var.mscript.seak) 	 	 	 | *  800 -  144238.eo  
 	 bcstc.dll0004.compose.searchkey(tdsmi120.surn, var.mscript.seak) | *  800 -  144238.n  
 	 if var.mscript.seak =  "" then                                                                          
 	 	 var.mscript.seak =  empty.string (1;16)  
 	 endif  
 	 dump 1 | *  Contacts (tccom140)  
 	 if get.business.partner ( tdsmi120.rlcd,  
 	 	 	 	 bcstc.orgn.cuno,  
 	 	 	 	 error.message) <>  0 then  
 	 	 | *  Skip business partners which are not found.  
 	 	 continue  
 	 endif  
 	 | *  Filling of Buy From, Ship From, Inv. From and Pay To fields. 	  
 	 if isspace(bcstc008.spno) then | *  Supplier field filled ?   
 	 	 var.tccom145.cmsk =  2 | *  tcyesno.no  
 	 else  
 	 	 var.tccom145.cmsk =  1 | *  tcyesno.yes  
 	 endif  
 	 dump 2 | *  Contacts by Business Partner (tccom145)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:td
:SCMOD:smi
:SFLNO:120
:ICOD:S
:QURY:START
select 	 tdsmi120.*
from 	 tdsmi120
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:td
:SCMOD:smi
:SFLNO:120
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:tp
:SCMOD:pdm
:SFLNO:046
:ICOD:D
:QURY:START
	 | *  Third parties table...  
 	 var.str.key =  tppdm046.cint &  tppdm046.cins  
 	 if get.cross.reference.for.contact.code( 	 "tppdm046",                                                                          
 	 	 	 	 	 	 var.str.key,  
 	 	 	 	 	 	 error.message) <>  0 then  
 	 	 | *  Skip contacts which are not found.  
 	 	 continue  
 	 endif  
 | 	 tccom.dll0009.compose.searchkey( 	 tppdm046.agen, 	 | *  800 -  144238.so  
 | 	 	 	 	 	 	 var.mscript.seak)  
 | 	 var.mscript.seak =  strip$(var.mscript.seak) 	 	 	 | *  800 -  144238.eo  
 	 bcstc.dll0004.compose.searchkey(tppdm046.agen, var.mscript.seak) | *  800 -  144238.n  
 	 if var.mscript.seak =  "" then                                                                          
 	 	 var.mscript.seak =  empty.string(1;16)  
 	 endif  
 	 var.tccom140.clan =  var.default.language  
 	 dump 3 | *  Contacts (tccom140)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:tp
:SCMOD:pdm
:SFLNO:046
:ICOD:S
:QURY:START
select 	 tppdm046.cint,  
 	 tppdm046.cins,  
 	 tppdm046.agen,  
 	 tppdm046.telp,  
 	 tppdm046.telf
from 	 tppdm046
where 	 tppdm046.agen <>  ""
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:tp
:SCMOD:pdm
:SFLNO:046
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:ts
:SCMOD:sma
:SFLNO:110
:ICOD:D
:QURY:START
	 | *  Service locations table...  
 	 if get.cross.reference.for.contact.code( 	 "tssma110",                                                                          
 	 	 	 	 	 	 tssma110.cloc,  
 	 	 	 	 	 	 error.message) <>  0 then  
 	 	 | *  Skip contacts which are not found.  
 	 	 continue  
 	 endif  
 	 | *  Get language of customer.  
 	 select tccom010.clan  
 	 from tccom010  
 	 where tccom010._index1 =  {:tssma110.cuno}  
 	 as set with 1 rows  
 	 selectdo  
 	 	 var.tccom140.clan =  tccom010.clan  
 	 selectempty  
 	 	 var.tccom140.clan =  var.default.language  
 	 endselect  
 	 dump 4 | *  Contacts (tccom140)  
 	 if get.business.partner ( tssma110.cuno,  
 	 	 	 	 bcstc.orgn.cuno,  
 	 	 	 	 error.message) <>  0 then  
 	 	 | *  Skip business partners which are not found.  
 	 	 continue  
 	 endif  
 	 | *  Filling of Buy From, Ship From, Inv. From and Pay To fields. 	  
 	 if isspace (bcstc008.spno) then | *  Supplier field filled ?   
 	 	 var.tccom145.cmsk =  2 | *  tcyesno.no  
 	 else  
 	 	 var.tccom145.cmsk =  1 | *  tcyesno.yes  
 	 endif 	  
 	 dump 5 | *  Contacts by Business Partner (tccom145)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:ts
:SCMOD:sma
:SFLNO:110
:ICOD:S
:QURY:START
select 	 tssma110.cloc,  
 	 tssma110.telp,  
 	 tssma110.tefx,  
 	 tssma110.cuno
from 	 tssma110
order by tssma110._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:ts
:SCMOD:sma
:SFLNO:110
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:700
:SCPAC:tc
:SCMOD:com
:SFLNO:700
:ICOD:D
:QURY:START
	 break
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:700
:SCPAC:tc
:SCMOD:com
:SFLNO:700
:ICOD:S
:QURY:START
select 	 bcstc011.rtyp:var.tccom700.rtyp
from 	 bcstc011
where bcstc011._index1 =  {"SLS"}
as set with 1  rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:700
:SCPAC:tc
:SCMOD:com
:SFLNO:700
:ICOD:X
:QURY:START
select tccom700.*   
 from tccom700  
 selectdo  
 	 on case tccom700.corg  
 	 	 	 case tccorg.sls :  
 	 	 	 	 var.tccom700.corg =  1  
 	 	 	 	 break  
 	 	 	 case tccorg.pur :  
 	 	 	 	 var.tccom700.corg =  2  
 	 	 	 	 break  
 	 	 	 case tccorg.finance :  
 	 	 	 	 var.tccom700.corg =  3  
 	 	 	 	 break  
 	 	 	 case tccorg.service :  
 	 	 	 	 var.tccom700.corg =  4  
 	 	 	 	 break  
 	 	 	 case tccorg.manual :  
 	 	 	 	 var.tccom700.corg =  5  
 	 	 	 	 break  
 	 	 	 case tccorg.manual.corr :  
 	 	 	 	 var.tccom700.corg =  6  
 	 	 	 	 break  
 	 	 	 case tccorg.project :  
 	 	 	 	 var.tccom700.corg =  15  
 	 	 	 	 break  
 	 	 	 case tccorg.rpl :  
 	 	 	 	 var.tccom700.corg =  7  
 	 	 	 	 break  
 	 	 	 default :  
 	 	 	 	 var.tccom700.corg =  5  
 	 	 	 endcase  
 	 if get.business.partner(tccom700.cuno, bcstc.orgn.cuno, err.msg) then  
 	 	 var.tccom700.bpid =  ""                
 	 else  
 	 	 var.tccom700.bpid =  bcstc008.bpid  
 	 endif  
 	 dump 1  
 endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:999
:SCPAC:tc
:SCMOD:com
:SFLNO:999
:ICOD:D
:QURY:START
	 var.tccom999.indt =  utc(0,0)  
 	 var.tccom999.dsca =  form.text$("bcstc00035") | *  Actual Set  
 	 dump 1  
 	 var.tccom999.indt =  utc(date.num(), time.num())  
 	 var.tccom999.dsca =  form.text$("bcstc00036") | *  Converted from BaanIVc4  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:999
:SCPAC:tc
:SCMOD:com
:SFLNO:999
:ICOD:S
:QURY:START
select tccom999.*
from tccom999
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:999
:SCPAC:tc
:SCMOD:com
:SFLNO:999
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:emm
:TFLNO:170
:SCPAC:tc
:SCMOD:com
:SFLNO:000
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:emm
:TFLNO:170
:SCPAC:tc
:SCMOD:com
:SFLNO:000
:ICOD:S
:QURY:START
select tccom000.*
from tccom000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:emm
:TFLNO:170
:SCPAC:tc
:SCMOD:com
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:cp
:SCMOD:rpd
:SFLNO:100
:ICOD:D
:QURY:START
select cprpd100.*   
 	 from 	 cprpd100  
 	 where cprpd100._index2 =  {:cprpd000.aplc, :cprpd100.plni}  
 	 and 	 cprpd100.cont =  ""      
 	 as set with 1 rows  
 	 selectdo  
 	 selectempty  
 	 	 | *  Search multi -  site plan only when filled.  
 	 	 | *  If empty go immediately to the last search step.  
 	 	 if not isspace(multi.site.plan.code) then  
 	 	 	 select cprpd100.*   
 	 	 	 from 	 cprpd100  
 	 	 	 where 	 cprpd100._index2 =  { 	 :multi.site.plan.code,  
 	 	 	 	 	 	 	 :cprpd100.plni}  
 	 	 	 and 	 cprpd100.cont =  ""      
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 selectempty  
 	 	 	 	 select cprpd100.*   
 	 	 	 	 from 	 cprpd100  
 	 	 	 	 where cprpd100.plni =  :cprpd100.plni  
 	 	 	 	 and 	 cprpd100.cont =  ""      
 	 	 	 	 as set with 1 rows  
 	 	 	 	 selectdo  
 	 	 	 	 endselect  
 	 	 	 endselect  
 	 	 else  
 	 	 	 select cprpd100.*   
 	 	 	 from 	 cprpd100  
 	 	 	 where cprpd100.plni =  :cprpd100.plni  
 	 	 	 and 	 cprpd100.cont =  ""      
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 endselect  
 	 	 endif  
 	 endselect  
 	 var.tcibd001.item =  segment.item.code(cprpd100.plni, empty.string(1;9))  
 	 | *  Dump for tcibd001 from cprpd100.  
 	 dump 26 | *  tcibd001  
 | #  800 -  142891.so  
 | #  800 -  139367.sn  
 | 	 | *  Set field Minimum Order Quantity always to 1.0, because  
 | 	 | *  Order Method is always Lot for Lot and Order Quantity  
 | 	 | *  Increment is always 1.0 and thus Minimum Order Quantity  
 | 	 | *  should also have the value 1.0.  
 | 	 var.tcibd200.mioq =  1.0  
 | #  800 -  139367.en  
 | #  800 -  142891.eo  
 | #  800 -  142891.sn  
 	 | *  Fill tcibd200.maxs (Maximum Inventory) with cprpd100.mail.  
 	 if cprpd100.mail >  9999999.99 then  
 	 	 var.tcibd200.maxs =  9999999.99  
 	 else  
 	 	 var.tcibd200.maxs =  cprpd100.mail  
 	 endif  
 	 | *  Field Order Quantity Multiple Of is not allowed to be zero.  
 	 if cprpd100.oqmf =  0 then  
 	 	 var.tcibd200.oqmf =  1  
 	 else  
 	 	 var.tcibd200.oqmf =  cprpd100.oqmf  
 	 endif  
 	 | *  When field Order Method is 'Lot for Lot' then field Minimum  
 	 | *  Order Quantity should at least have the value of field Order  
 	 | *  Quantity Multiple Of.  
 	 if cprpd100.omth =  cprpd.omth.lotforlot then  
 	 	 if double.cmp(cprpd100.mioq, var.tcibd200.oqmf,  
 	 	 	 	 	 0.0001) = -  1 then  
 	 	 	 | *  Set the Minimum Order Quantity to the  
 	 	 	 | *  Order Quantity Increment value  
 	 	 	 var.tcibd200.mioq =  var.tcibd200.oqmf  
 	 	 else  
 	 	 	 var.tcibd200.mioq =  cprpd100.mioq  
 	 	 endif  
 	 else  
 	 	 var.tcibd200.mioq =  cprpd100.mioq  
 	 endif  
 	 | *  Map the domains of source and target.  
 	 | *  Domain cprpd.omth does not map, but tcomth does.  
 	 if cprpd100.omth =  cprpd.omth.lotforlot then  
 	 	 var.tcibd200.omth =  tcomth.lfl  
 	 else  
 	 	 var.tcibd200.omth =  tcomth.foq  
 	 endif  
 	 | *  Field Fixed Order Quantity should not be less than the  
 	 | *  Minimum Order Quantity, although the source version  
 	 | *  allows this.  
 	 if double.cmp(cprpd100.orqa, var.tcibd200.mioq,  
 	 	 	 	 	 0.0001) = -  1 then  
 	 	 | *  Set the Fixed Order Quantity to the Minimum  
 	 	 | *  Order Quantity.  
 	 	 var.tcibd200.fioq =  var.tcibd200.mioq  
 	 else  
 	 	 var.tcibd200.fioq =  cprpd100.orqa  
 	 endif  
 | #  800 -  142891.en  
 	 | *  Dump for tcibd200 from cprpd100.  
 	 dump 27 | *  tcibd200
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:cp
:SCMOD:rpd
:SFLNO:100
:ICOD:S
:QURY:START
select 	 cprpd100.plni
from 	 cprpd100
where 	 cprpd100.cont =  ""      
 and 	 cprpd100.plit =  cprpd.plit.productfamily  
 | *  If item is already present in tiitm001, do nothing.  
 and not exists( 	 select 	 tiitm001.item  
 	 	 from 	 tiitm001  
 	 	 where 	 tiitm001._index1 =  {cprpd100.plni})
group by cprpd100.plni
order by cprpd100.plni
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:cp
:SCMOD:rpd
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:itm
:SFLNO:001
:ICOD:D
:QURY:START
| #  800 -  138991.sn  
 	 | *  All logic is present in the function below, because it is reused  
 	 | *  for 'migrate tipcs022' and 'migrate tipcs110'.  
 	 create.item.from.tiitm001(false, "", false, "")                                                                                                                                                                                                                                                                                    
 | #  800 -  138991.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:itm
:SFLNO:001
:ICOD:S
:QURY:START
select 	 tiitm001.*
from 	 tiitm001  
 | *  Process items (tiitm001.proi =  tcyesno.yes) are migrated, but not  
 | *  the container items (tiitm001.cont =  tcyesno.yes).
where 	 tiitm001.cont =  tcyesno.no
order by tiitm001._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:itm
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:mps
:SFLNO:200
:ICOD:D
:QURY:START
	 | *  A plan item is for each master plan, so the same item code can exist  
 	 | *  more than once.  
 	 | *  Choose the most correct one by performing a search in this sequence:  
 	 | *  1. actual plan code  
 	 | *  2. multi site plan code of the actual plan code  
 	 | *  3. any place  
 	 select timps200.*   
 	 from 	 timps200  
 	 where timps200._index3 =  {:timps000.apln, :timps200.plni}  
 	 as set with 1 rows  
 	 selectdo  
 	 selectempty  
 	 	 | *  Search multi -  site plan only when filled.  
 	 	 | *  If empty go immediately to the last search step.  
 	 	 if not isspace(multi.site.plan.code) then  
 	 	 	 select timps200.*   
 	 	 	 from 	 timps200  
 	 	 	 where 	 timps200._index3 =  { 	 :multi.site.plan.code,  
 	 	 	 	 	 	 	 :timps200.plni}  
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 selectempty  
 	 	 	 	 select timps200.*   
 	 	 	 	 from 	 timps200  
 	 	 	 	 where timps200.plni =  :timps200.plni  
 	 	 	 	 as set with 1 rows  
 	 	 	 	 selectdo  
 	 	 	 	 endselect  
 	 	 	 endselect  
 	 	 else  
 	 	 	 select timps200.*   
 	 	 	 from 	 timps200  
 	 	 	 where timps200.plni =  :timps200.plni  
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 endselect  
 	 	 endif  
 	 endselect  
 	 var.tcibd001.item =  segment.item.code(timps200.plni,empty.string(1;9))  
 	 | *  Dump for tcibd001 from timps200.  
 	 dump 24 | *  tcibd001  
 | #  800 -  139367.sn  
 	 | *  Set field Minimum Order Quantity always to 1.0, because  
 	 | *  Order Method is always Lot for Lot and Order Quantity  
 	 | *  Increment is always 1.0 and thus Minimum Order Quantity  
 	 | *  should also have the value 1.0.  
 	 var.tcibd200.mioq =  1.0  
 | #  800 -  139367.en  
 	 | *  Dump for tcibd200 from timps200.  
 	 dump 25 | *  tcibd200
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:mps
:SFLNO:200
:ICOD:S
:QURY:START
select 	 timps200.plni
from 	 timps200
where 	 timps200.plit =  timps.plit.product.family  
 | *  If item is already present in tiitm001, do nothing.  
 and not exists( 	 select 	 tiitm001.item  
 	 	 from 	 tiitm001  
 	 	 where 	 tiitm001._index1 =  {timps200.plni})
group by timps200.plni
order by timps200.plni
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:mps
:SFLNO:200
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:002
:ICOD:D
:QURY:START
	 | *  Dump one item record for each Budget Calculation Code in tipcs100.  
 	 | *  Dump one item record if there are no Budget Calculation Codes  
 	 | *  for the budget (selectempty of query below).  
 	 select tipcs100.bccd  
 	 from 	 tipcs100  
 	 where tipcs100._index1 =  {:tipcs002.cbdg}  
 	 selectdo  
 	 	 | *  Construct new project code and new item code.  
 	 	 var.tcibd001.cprj =  get.budget.code(tipcs002.cbdg, tipcs100.bccd)  
 	 	 var.tcibd001.item =  segment.item.code(tipcs002.ccpc, var.tcibd001.cprj)  
 	  
 	 	 | *  Read cost prices by budget /  budget calculation code /  calculation part.  
 	 	 for element =  1 to 3  
 	 	 	 var.ticpr007.ecpr(element) =  0.0  
 	 	 endfor  
 | 	 	 select 	 tipcs150.amnt 	 | #  CNT.o  
 	 	 select 	 tipcs150.*  	 | #  CNT.n  
 	 	 from 	 tipcs150  
 	 	 where tipcs150._index1 =  {:tipcs002.cbdg,  
 	 	 	 	 	 :tipcs100.bccd, :tipcs002.ccpc}  
 	 	 selectdo  
 	 	 	 	 	 	 	 	 | #  CNT.sn  
 	 	 	 | *  CNT -  extension does not have tipcs150.amnt field. Therefor use  
 	 	 	 | *  integration function to get the est. cost. price  
 	 	 	 get.tipcs150.ecpr(tmp.ecpr) 	 	 | #  CNT.en  
 	  
 	 	 	 | *  Add up for all cost components.  
 	 	 	 for element =  1 to 3  
 	 	 	 	 var.ticpr007.ecpr(element) =  var.ticpr007.ecpr(element) +   
 | 	 	 	 	 	 fill.mc.field.double(tipcs150.amnt, element) 	 | #  CNT.o  
 	 	 	 	 	 tmp.ecpr(element) 	 	 	 	 | #  CNT.n  
 	 	 	 endfor  
 	 	 endselect  
 	  
 	 	 | *  Determine item type.  
 	 	 if (tipcs002.kitm =  tcpuma.manufacture) then  
 	 	 	 var.tcibd001.kitm =  etol(tckitm.manufacture)  
 	 	 else  
 	 	 	 var.tcibd001.kitm =  etol(tckitm.purchase)  
 	 	 endif  
 	 	 get.aggr.cost.comp.for.item(  
 	 	 	 	 (tipcs002.kitm =  tcpuma.manufacture ?   
 	 	 	 	 tckitm.manufacture : tckitm.purchase),  
 	 	 	 	 tipcs002.citg,  
 	 	 	 	 tipcs002.cpcp,  
 	 	 	 	 var.ticpr007.acpm,  
 	 	 	 	 var.ticpr007.acpo,  
 	 	 	 	 var.ticpr007.acps)  
 	 	 | *  Read cost component chart if present.  
 	 	 if get.cost.component.charts.per.item.type.and.group(  
 	 	 	 	 (tipcs002.kitm =  tcpuma.manufacture ?   
 	 	 	 	 tckitm.manufacture : tckitm.purchase),  
 	 	 	 	 tipcs002.citg,  
 	 	 	 	 error.message) =  0 then  
 	 	 	 var.ticpr007.chrt =  bcsti007.chrt  
 	 	 else  
 	 	 	 var.ticpr007.chrt =  ""        
 	 	 endif  
 	 	 | *  Dump for ticpr007 from tipcs002.  
 	 	 dump 20 | *  ticpr007  
 	 	  
 	 	 if (tipcs002.unom =  0) then  
 	 	 	 var.tiipd001.unom =  1  
 	 	 else  
 	 	 	 var.tiipd001.unom =  tipcs002.unom  
 	 	 endif  
 	 	 if (tipcs002.runi <>  0) then  
 	 	 	 var.tiipd001.runi =  tipcs002.runi  
 	 	 else  
 	 	 	 var.tiipd001.runi =  1  
 	 	 endif  
 	 	 if isspace(tipcs002.dfit) then  
 	 	 	 tmp.floor.stock =  tcyesno.no  
 	 	 else  
 	 	 	 select tiitm001.pics  
 	 	 	 from 	 tiitm001  
 	 	 	 where tiitm001._index1 =  {:tipcs002.dfit}  
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 	 tmp.floor.stock =  tiitm001.pics  
 	 	 	 endselect  
 	 	 endif  
 	 	 if tmp.floor.stock =  tcyesno.yes then  
 	 	 	 var.tiipd001.drin =  tcyesno.yes  
 	 	 	 var.tiipd001.dris =  tcyesno.yes  
 	 	 else  
 	 	 	 var.tiipd001.drin =  tcyesno.no  
 	 	 	 var.tiipd001.dris =  tcyesno.no  
 	 	 endif  
 | #  800 -  142567.so  
 | *  This is not required anymore, it has been modified by SL 143259.  
 | #  200 -  95451.sn  
 | 	 	 | *  When Backflush if Material is Yes, Direct Process Outbound is  
 | 	 	 | *  mandatory to be Yes too. Else set it to the default  
 | 	 	 | *  value: tcyesno.no.  
 | 	 	 if tipcs002.bfcp =  tcyesno.yes then  
 | 	 	 	 var.tiipd001.dris =  tcyesno.yes  
 | 	 	 else  
 | 	 	 	 var.tiipd001.dris =  tcyesno.no  
 | 	 	 endif  
 | #  200 -  95451.en  
 | #  800 -  142567.eo  
 | #  206137.sn  
 	 	 check.var.tiipd001.drin.bfcp()  
 | #  206137.en  
 	 	 | *  Dump for tiipd001 from tipcs002.  
 	 	 dump 21 | *  tiipd001  
 	 	 var.tcibd001.dfit =  segment.item.code(tipcs002.dfit, empty.string(1;9))  
 	 	 | *  Determine weigth unit.  
 	 	 determine.weight.unit(tipcs002.uset, var.tcibd001.cwun)  
 	 	 return.value =  get.cost.components(  
 	 	 	 	 	 bcorig.ticpr,  
 	 	 	 	 	 tipcs002.cpcp,  
 	 	 	 	 	 "",        
 	 	 	 	 	 error.message)  
 	 	 var.tcibd001.cpcp =  bcstc006.cost  
 	 	 | *  Read product variant for this calculation part.  
 	 	 | *  Use field bcsti002.cpva in field rule.  
 	 	 return.value =  get.product.variant.for.budget.item(  
 	 	 	 	 	 tipcs002.cbdg,  
 	 	 	 	 	 tipcs100.bccd,  
 	 	 	 	 	 tipcs002.cpvr,  
 	 	 	 	 	 error.message)  
 	 	 | *  Dump for tcibd001 from tipcs002.  
 	 	 dump 22 | *  tcibd001  
 | #  800 -  139367.sn  
 	 	 | *  Set field Minimum Order Quantity always to 1.0, because  
 	 	 | *  Order Method is always Lot for Lot and Order Quantity  
 	 	 | *  Increment is always 1.0 and thus Minimum Order Quantity  
 	 	 | *  should also have the value 1.0.  
 	 	 var.tcibd200.mioq =  1.0  
 | #  800 -  139367.en  
 | #  800 -  142863.sn  
 	 	 | *  Convert long to string.  
 	 	 var.tcibd200.cplb =  format.emno(tipcs002.cplb)  
 | #  800 -  142863.en  
 	 	 | *  Dump for tcibd200 from tipcs002.  
 	 	 dump 23 | *  tcibd200  
 | #  800 -  141474.sn  
 	 	 | *  Item Warehousing Data are also required.  
 	 	 | *  Item Type =  Equipment is not excluded, because  
 	 	 | *  tipcs002 can never deliver this item type.  
 	 	 | *  Dump for whwmd400 from tipcs002.  
 	 	 var.whwmd400.linv =  tcyesno.no 	 	 	 | #  SP2.n  
 	 	 dump 32 | *  whwmd400  
 | #  800 -  141474.en  
 	 selectempty  
 	 	 | *  Construct new project code and new item code.  
 	 	 var.tcibd001.cprj =  get.budget.code(tipcs002.cbdg, "")        
 	 	 var.tcibd001.item =  segment.item.code(tipcs002.ccpc, var.tcibd001.cprj)  
 	 	 | *  Determine item type.  
 	 	 if (tipcs002.kitm =  tcpuma.manufacture) then  
 	 	 	 var.tcibd001.kitm =  etol(tckitm.manufacture)  
 	 	 else  
 	 	 	 var.tcibd001.kitm =  etol(tckitm.purchase)  
 	 	 endif  
 	 	 get.aggr.cost.comp.for.item(  
 	 	 	 	 (tipcs002.kitm =  tcpuma.manufacture ?   
 	 	 	 	 tckitm.manufacture : tckitm.purchase),  
 	 	 	 	 tipcs002.citg,  
 	 	 	 	 tipcs002.cpcp,  
 	 	 	 	 var.ticpr007.acpm,  
 	 	 	 	 var.ticpr007.acpo,  
 	 	 	 	 var.ticpr007.acps)  
 	 	 | *  Read cost component chart if present.  
 	 	 if get.cost.component.charts.per.item.type.and.group(  
 	 	 	 	 (tipcs002.kitm =  tcpuma.manufacture ?   
 	 	 	 	 tckitm.manufacture : tckitm.purchase),  
 	 	 	 	 tipcs002.citg,  
 	 	 	 	 error.message) =  0 then  
 	 	 	 var.ticpr007.chrt =  bcsti007.chrt  
 	 	 else  
 	 	 	 var.ticpr007.chrt =  ""        
 	 	 endif  
 	 	 | *  Estimated cost price is always zero in this case.  
 	 	 for element =  1 to 3  
 	 	 	 var.ticpr007.ecpr(element) =  0.0  
 	 	 endfor  
 	 	 | *  Dump for ticpr007 from tipcs002.  
 	 	 dump 20 | *  ticpr007  
 	 	 if (tipcs002.unom =  0) then  
 	 	 	 var.tiipd001.unom =  1  
 	 	 else  
 	 	 	 var.tiipd001.unom =  tipcs002.unom  
 	 	 endif  
 	 	 if (tipcs002.runi <>  0) then  
 	 	 	 var.tiipd001.runi =  tipcs002.runi  
 	 	 else  
 	 	 	 var.tiipd001.runi =  1  
 	 	 endif  
 	 	 if isspace(tipcs002.dfit) then  
 	 	 	 tmp.floor.stock =  tcyesno.no  
 	 	 else  
 	 	 	 select tiitm001.pics  
 	 	 	 from 	 tiitm001  
 	 	 	 where tiitm001._index1 =  {:tipcs002.dfit}  
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 	 tmp.floor.stock =  tiitm001.pics  
 	 	 	 endselect  
 	 	 endif  
 	 	 if tmp.floor.stock =  tcyesno.yes then  
 	 	 	 var.tiipd001.drin =  tcyesno.yes  
 	 	 	 var.tiipd001.dris =  tcyesno.yes  
 	 	 else  
 	 	 	 var.tiipd001.drin =  tcyesno.no  
 	 	 	 var.tiipd001.dris =  tcyesno.no  
 	 	 endif  
 | #  200 -  95451.sn  
 	 	 | *  When Backflush if Material is Yes, Direct Process Outbound is  
 	 	 | *  mandatory to be Yes too. Else set it to the default  
 	 	 | *  value: tcyesno.no.  
 	 	 if tipcs002.bfcp =  tcyesno.yes then  
 	 	 	 var.tiipd001.dris =  tcyesno.yes  
 	 	 else  
 	 	 	 var.tiipd001.dris =  tcyesno.no  
 	 	 endif  
 | #  200 -  95451.en  
 	 	 | *  Dump for tiipd001 from tipcs002.  
 	 	 dump 21 | *  tiipd001  
 	 	 var.tcibd001.dfit =  segment.item.code(tipcs002.dfit, empty.string(1;9))  
 	 	 | *  Determine weigth unit.  
 	 	 determine.weight.unit(tipcs002.uset, var.tcibd001.cwun)  
 	 	 return.value =  get.cost.components(  
 	 	 	 	 	 bcorig.ticpr,  
 	 	 	 	 	 tipcs002.cpcp,  
 	 	 	 	 	 "",        
 	 	 	 	 	 error.message)  
 	 	 var.tcibd001.cpcp =  bcstc006.cost  
 	 	 | *  Read product variant for this calculation part.  
 	 	 | *  Use field bcsti002.cpva in field rule.  
 	 	 return.value =  get.product.variant.for.budget.item(  
 	 	 	 	 	 tipcs002.cbdg,  
 	 	 	 	 	 "",        
 	 	 	 	 	 tipcs002.cpvr,  
 	 	 	 	 	 error.message)  
 	 	 | *  Dump for tcibd001 from tipcs002.  
 	 	 dump 22 | *  tcibd001  
 | #  800 -  141474.sn  
 	 	 | *  Item Warehousing Data are also required.  
 	 	 | *  Item Type =  Equipment is not excluded, because  
 	 	 | *  tipcs002 can never deliver this item type.  
 	 	 | *  Dump for whwmd400 from tipcs002.  
 	 	 var.whwmd400.linv =  tcyesno.no 	 	 	 | #  SP2.n  
 	 	 dump 32 | *  whwmd400  
 | #  800 -  141474.en  
 	 endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:002
:ICOD:S
:QURY:START
select 	 tipcs002.*
from 	 tipcs002
order by tipcs002._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:002
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:021
:ICOD:D
:QURY:START
	 var.tcibd001.cprj =  get.ti.project(tipcs021.cprj)  
 	 var.tcibd001.item =  segment.item.code(tipcs021.item, var.tcibd001.cprj)  
 	 | *  Weight unit of user can only be used when present in unit set of item.  
 	 determine.weight.unit(tipcs021.uset, var.tcibd001.cwun)  
 	 | *  Determine Cost Component.  
 	 return.value =  get.cost.components(  
 	 	 	 	 bcorig.ticpr,  
 	 	 	 	 tipcs021.cpcp,  
 	 	 	 	 "",          
 	 	 	 	 error.message)  
 	 | *  Read product variant. If not present, record values are empty.  
 	 return.value =  get.new.product.variant(  
 	 	 	 	 tipcs021.cpvr,  
 	 	 	 	 error.message)  
 	 | *  Convert tcpuma to tckitm.  
 	 if (tipcs021.kitm =  tcpuma.manufacture) then  
 	 	 var.tcibd001.kitm =  etol(tckitm.manufacture)  
 	 else  
 	 	 var.tcibd001.kitm =  etol(tckitm.purchase)  
 	 endif  
 	 var.tcibd001.dfit =  segment.item.code(tipcs021.dfit, empty.string(1; 9))  
 | #  200 -  96727.sn  
 	 | *  Determine Lot Control yes /  no and Serialized yes /  no.  
 	 on case tipcs021.kltc  
 	 case tckltc.batch:  
 	 	 var.tcibd001.ltct =  tcyesno.yes  
 	 	 var.tcibd001.seri =  tcyesno.no  
 	 break  
 	 case tckltc.unit:  
 	 	 var.tcibd001.ltct =  tcyesno.no  
 	 	 var.tcibd001.seri =  tcyesno.yes  
 	 break  
 	 case tckltc.none:  
 	 	 var.tcibd001.ltct =  tcyesno.no  
 	 	 var.tcibd001.seri =  tcyesno.no  
 	 break  
 	 default:  
 	 	 var.tcibd001.ltct =  tcyesno.no  
 	 	 var.tcibd001.seri =  tcyesno.no  
 	 break  
 	 endcase  
 | #  800 -  141936.so  
 | 	 | *  If item is used in Service package, flag Serialized also  
 | 	 | *  needs to be set to 'Yes'.  
 | 	 if var.tcibd001.seri =  tcyesno.no and  
 | 	 check.tssma.for.tcibd001.seri then  
 | 	 	 if item.used.in.tssma(tipcs021.cprj, tipcs021.item) then  
 | 	 	 	 var.tcibd001.seri =  tcyesno.yes  
 | 	 	 endif  
 | 	 endif  
 | #  800 -  141936.eo  
 | #  200 -  96727.en  
 | #  200 -  96920.sn  
 	 | *  Enum values for 'Update E -  Item Relationship are changed.  
 	 on case tipcs021.umer  
 	 case tiitm.umer.yes :  
 | 	 	 var.tcibd001.umer =  target(tcibd.umer.automatic) 	 | #  SP2.o  
 	 	 var.tcibd001.umer =  target(tcibd.umer.yes) 	 	 | #  SP2.n  
 	 	 break  
 	 case tiitm.umer.freeze :  
 	 	 var.tcibd001.umer =  target(tcibd.umer.freeze) 	 	 | #  SP2.sn  
 	 	 break 	 	 	 	 	 	 	 | #  SP2.en  
 | #  800 -  142021.sn  
 	 case tiitm.umer.break :  
 | #  800 -  142021.en  
 | 	 	 var.tcibd001.umer =  target(tcibd.umer.manual) 	 | #  SP2.o  
 	 	 var.tcibd001.umer =  target(tcibd.umer.break) 	 	 | #  SP2.n  
 	 	 break  
 | #  800 -  142021.so  
 | 	 case tiitm.umer.break :  
 | #  800 -  142021.eo  
 	 case tiitm.umer.not.appl :  
 	 default :  
 	 	 var.tcibd001.umer =  target(tcibd.umer.not.appl)  
 	 	 break  
 	 endcase  
 | #  200 -  96920.en  
 | #  800 -  142542.sn  
 	 | *  In case the item will become serialized in 6.1,  
 	 | *  it may need another inventory unit.  
 	 var.tcibd001.cuni =  ""          
 	 if tipcs021.kltc =  tckltc.unit then  
 	 	 var.tcibd001.cuni =   
 	 	 get.new.inventory.unit.for.serialized.item(  
 	 	 	 tipcs021.cprj, tipcs021.item)  
 	 endif  
 	 | *  If nothing found, fill with original inventory unit.  
 	 if isspace(var.tcibd001.cuni) then  
 	 	 var.tcibd001.cuni =  tipcs021.cuni  
 	 endif  
 | #  800 -  142542.en  
 | #  800 -  142542.en  
 	 | *  Dump for tcibd001 from tipcs021.  
 	 dump 8 | *  tcibd001  
 	 | *  Determination of cost components is applicable for all  
 	 | *  item types from tipcs021.  
 	 get.aggr.cost.comp.for.item(  
 	 	 	 	 (tipcs021.kitm =  tcpuma.manufacture ?   
 	 	 	 	 tckitm.manufacture : tckitm.purchase),  
 	 	 	 	 tipcs021.citg,  
 	 	 	 	 tipcs021.cpcp,  
 	 	 	 	 var.ticpr007.acpm,  
 	 	 	 	 var.ticpr007.acpo,  
 	 	 	 	 var.ticpr007.acps)  
 	 | *  Read cost component chart if present.  
 	 if get.cost.component.charts.per.item.type.and.group(  
 	 	 	 	 (tipcs021.kitm =  tcpuma.manufacture ?   
 	 	 	 	 tckitm.manufacture : tckitm.purchase),  
 	 	 	 	 tipcs021.citg,  
 	 	 	 	 error.message) =  0 then  
 	 	 var.ticpr007.chrt =  bcsti007.chrt  
 	 else  
 	 	 var.ticpr007.chrt =  ""          
 	 endif  
 	 var.ticpr007.ltcp =  utc(tipcs021.ltcp, 0)  
 	 | *  Fill Cost Price variables  
 	 for element =  1 to 3  
 	 	 var.ticpr007.ecpr(element) =  fill.mc.field.double(  
 	 	 	 	 tipcs021.cpre,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 	 var.ticpr007.emtc(element) =  fill.mc.field.double(  
 	 	 	 	 tipcs021.mtce,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 	 var.ticpr007.eopc(element) =  fill.mc.field.double(  
 	 	 	 	 tipcs021.opce,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 	 var.ticpr007.acpr(element) =  fill.mc.field.double(  
 	 	 	 	 tipcs021.cpra,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 	 var.ticpr007.amtc(element) =  fill.mc.field.double(  
 	 	 	 	 tipcs021.mtca,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 	 var.ticpr007.aopc(element) =  fill.mc.field.double(  
 	 	 	 	 tipcs021.opca,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 endfor  
 	 | *  Dump for ticpr007 from tipcs021.  
 	 dump 9 | *  ticpr007  
 	 if is.masterdata.conversion() then  
 	 	 | *  In case only master data is migrated, the inventory  
 	 	 | *  fields in tcibd100 need to be reset. Because in the  
 	 	 | *  other situation most field rules are filled with table  
 	 	 | *  fields and no special constructions, it is chosen here  
 	 	 | *  to create a separate dump for master data migration.  
 	 	 | *  Dump for tcibd100 from tipcs021 in case of  
 	 	 | *  master data conversion.  
 	 	 dump 30 | *  tcibd100  
 	 else  
 	 	 | *  Correct Inventory on Order and Allocated Inventory for  
 	 	 | *  PRP Puchase Orders and PRP Production Orders.  
 	 	 var.tcibd100.ordr =   
 	 	 	 correct.inv.on.order.customized.item.for.prp(  
 	 	 	 	 	 tipcs021.cprj,  
 	 	 	 	 	 tipcs021.item,  
 	 	 	 	 	 tipcs021.ordr)  
 	 	 var.tcibd100.allo =   
 	 	 	 correct.allocated.inv.customized.item.for.prp(  
 	 	 	 	 	 tipcs021.cprj,  
 	 	 	 	 	 tipcs021.item,  
 	 	 	 	 	 tipcs021.allo)  
 | #  800 -  140893.sn  
 	 	 | *  Correct Blocked Quantity: approved quantity  
 	 	 | *  on an inspection location is blocked quantity  
 	 	 | *  in Baan IV but not in Baan 6.  
 	 	 var.tcibd100.blck =  tipcs021.blck  
 	 	 if tdilc000.iilc =  tcyesno.yes and  
 	 	 var.tcibd100.blck >  0.0 then  
 	 	 	 determine.blocked.quantity.decrease(  
 	 	 	 	 	 tipcs021.cprj,  
 	 	 	 	 	 tipcs021.item,  
 	 	 	 	 	 tmp.blocked.qty.decrease)  
 	 	 	 if tmp.blocked.qty.decrease >  0.0 then  
 	 	 	 	 var.tcibd100.blck =  var.tcibd100.blck -   
 	 	 	 	 	 tmp.blocked.qty.decrease  
 	 	 	 	 if var.tcibd100.blck <  0.0 then  
 	 	 	 	 	 var.tcibd100.blck =  0.0  
 	 	 	 	 endif  
 	 	 	 endif  
 	 	 endif  
 | #  800 -  140893.en  
 	 	 | *  Dump for tcibd100 from tipcs021.  
 	 	 dump 10 | *  tcibd100  
 	 endif  
 	  
 	 | *  Convert long to string.  
 	 var.tcibd200.cplb =  format.emno(tipcs021.cplb)  
 | #  800 -  139367.sn  
 	 | *  Set field Minimum Order Quantity always to 1.0, because  
 	 | *  Order Method is always Lot for Lot and Order Quantity  
 	 | *  Increment is always 1.0 and thus Minimum Order Quantity  
 	 | *  should also have the value 1.0.  
 | 	 var.tcibd200.mioq =  1.0 	 | #  207434.o  
 | #  800 -  139367.en  
 	 set.tcibd200.for.cust.items() 	 | #  207434.n  
 	 | *  Dump for tcibd200 from tipcs021.  
 	 dump 11 | *  tcibd200  
 	  
 	 if isspace(tipcs021.dfit) then  
 	 	 tmp.floor.stock =  tcyesno.no  
 	 else  
 	 	 select tiitm001.pics  
 	 	 from 	 tiitm001  
 	 	 where tiitm001._index1 =  {:tipcs021.dfit}  
 	 	 as set with 1 rows 	 	 	  
 	 	 selectdo  
 	 	 	 tmp.floor.stock =  tiitm001.pics  
 	 	 endselect  
 	 endif  
 | #  800 -  140855.sn, | #  800 -  140950.sn, | #  800 -  140967.sn  
 	 | *  When item is lot controlled, Lot Tracking should get the  
 	 | *  value of Lot Tracking Implemented (tdltc000.tltc).  
 	 if tipcs021.kltc =  tckltc.batch then  
 	 	 var.whwmd400.lttr =  tdltc000.tltc  
 	 	 var.whwmd400.linv =  tcyesno.yes 	 	 	 | #  SP2.n  
 	 else  
 	 	 var.whwmd400.lttr =  tcyesno.no  
 	 	 var.whwmd400.linv =  tcyesno.no 	 	 	 | #  SP2.n  
 	 endif  
 	 | *  When item is serialized, Serial Tracking should get the  
 	 | *  value of Lot Tracking Implemented (tdltc000.tltc).  
 	 | *  Determine Serials in Inventory value. Set to 'Yes' when item  
 	 | *  is serialized.  
 	 if tipcs021.kltc =  tckltc.unit  
 | 	 	 or (check.tssma.for.tcibd001.seri and 	 	 | #  800 -  141936.o  
 | 	 	 item.used.in.tssma(tipcs021.cprj, tipcs021.item)) | #  800 -  141936.o  
 	 then  
 	 	 var.whwmd400.srtr =  tdltc000.tltc  
 	 	 var.whwmd400.sinv =  tcyesno.yes  
 	 else  
 	 	 var.whwmd400.srtr =  tcyesno.no  
 	 	 var.whwmd400.sinv =  tcyesno.no  
 	 endif  
 | #  800 -  140855.en, | #  800 -  140950.en, | #  800 -  140967.en  
 	 | *  Dump for whwmd400 from tipcs021.  
 	 | *  Item Type =  Equipment is not excluded, because tipcs021 can  
 	 | *  never deliver this item type.  
 	 dump 12 | *  whwmd400  
 	 if (tipcs021.unom =  0) then  
 	 	 var.tiipd001.unom =  1  
 	 else  
 	 	 var.tiipd001.unom =  tipcs021.unom  
 	 endif  
 	 if (tipcs021.runi <>  0) then  
 	 	 var.tiipd001.runi =  tipcs021.runi  
 	 else  
 	 	 var.tiipd001.runi =  1  
 	 endif  
 	 if tmp.floor.stock =  tcyesno.yes then  
 	 	 var.tiipd001.drin =  tcyesno.yes  
 | #  800 -  142567.so  
 | 	 	 var.tiipd001.dris =  tcyesno.yes  
 | #  800 -  142567.eo  
 	 else  
 	 	 var.tiipd001.drin =  tcyesno.no  
 | #  800 -  142567.so  
 | 	 	 var.tiipd001.dris =  tcyesno.no  
 | #  800 -  142567.eo  
 	 endif  
 | #  800 -  142567.sn  
 	 | *  Field tiipd001.dris can only be set to 'Yes' when  
 	 | *  the item was a floor stock item in Baan IV, but  
 	 | *  not serialized.  
 	 if tmp.floor.stock =  tcyesno.yes and  
 	 not tipcs021.kltc =  tckltc.unit then  
 	 	 var.tiipd001.dris =  tcyesno.yes  
 	 else  
 	 	 var.tiipd001.dris =  tcyesno.no  
 	 endif  
 	 | *  Fields tiipd001.bfcp and tiipd001.drin cannot be 'Yes'  
 	 | *  at the same time. Therefore tiipd001.bfcp is set to  
 	 | *  'No' when tiipd001.drin is set to 'Yes'.  
 	 | *  When the item becomes serialized in SSA ERP LN,  
 	 | *  the backflush flag should also be set to 'No'.  
 	 if tmp.floor.stock =  tcyesno.yes or  
 	 tipcs021.kltc =  tckltc.unit then  
 	 	 var.tiipd001.bfcp =  tcyesno.no  
 	 else  
 	 	 var.tiipd001.bfcp =  tiitm001.bfcp  
 	 endif  
 | #  800 -  142567.en  
 | #  800 -  142567.so  
 | *  This is not required anymore, it has been modified by SL 143259.  
 | #  200 -  95451.sn  
 | 	 | *  When Backflush if Material is Yes, Direct Process Outbound is  
 | 	 | *  mandatory to be Yes too. This overrules the setting of Direct  
 | 	 | *  Process Outbound based on Floor Stock (above).  
 | 	 if tipcs021.bfcp =  tcyesno.yes then  
 | 	 	 var.tiipd001.dris =  tcyesno.yes  
 | 	 endif  
 | #  200 -  95451.en  
 | #  800 -  142567.eo  
 | #  206137.sn  
 	 	 check.var.tiipd001.drin.bfcp()  
 | #  206137.en  
 	 | *  Dump for tiipd001 from tipcs021.  
 	 dump 13 | *  tiipd001  
 	 | *  When the customized item is used on a TP project, it is  
 	 | *  required to fill tppdm005.  
 	 if check.tppdm605.for.tipcs021 then  
 	 	 select 	 tppdm605.*   
 	 	 from 	 tppdm605  
 	 	 where 	 tppdm605.ppcs =  :tipcs021.cprj  
 	 	 and 	 tppdm605.citm =  :tipcs021.item  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 | *  Set the correct Control Code.  
 	 	 	 if tppdm605.ccit =  tppdm605.item then  
 	 	 	 	 var.tppdm005.ccit.c =  var.tcibd001.item  
 | #  200 -  101794.sn  
 	 	 	 	 var.tppdm005.copt =  tppdm.copt.manu  
 | #  200 -  101794.en  
 	 	 	 else  
 	 	 	 	 | *  Select the Project Control Code  
 	 	 	 	 select 	 tppdm605.ppcs:ccit.ppcs,  
 	 	 	 	 	 tppdm605.citm:ccit.citm,  
 	 	 	 	 	 tppdm605.prit:ccit.prit  
 	 	 	 	 from 	 tppdm605  
 	 	 	 	 where 	 tppdm605._index1 =  {:tppdm605.cprj, :tppdm605.ccit}  
 	 	 	 	 as set with 1 rows  
 	 	 	 	 selectdo  
 	 	 	 	 	 | *  If it exists and is manufactured, take the related PCS item  
 	 	 	 	 	 | *  If it is purchased, take the TP item (ccit) itself  
 	 	 	 	 	 if ccit.prit =  tppdm.prit.manufactured then  
 	 	 	 	 	 	 var.tppdm005.ccit.c =  segment.item.code(ccit.citm, get.ti.project(ccit.ppcs))  
 	 	 	 	 	 	 var.tppdm005.copt =  tppdm.copt.stock  
 	 	 	 	 	 else  
 	 	 	 	 	 	 var.tppdm005.ccit.c =  segment.item.code(tppdm605.ccit, get.tp.project(tppdm605.cprj))  
 	 	 	 	 	 	 var.tppdm005.copt =  tppdm.copt.manu  
 	 	 	 	 	 endif  
 	 	 	 	 selectempty  
 	 	 	 	 	 | *  If it does not exist, take the empty Project code  
 	 	 	 	 	 var.tppdm005.ccit.c =  segment.item.code(tppdm605.ccit, "")          
 	 	 	 	 	 var.tppdm005.copt =  tppdm.copt.stock  
 	 	 	 	 endselect  
 	 	 	 endif  
 	 	 	 	 	  
 	 	 	 | *  Dump for tppdm005 from tipcs021.  
 	 	 	 dump 29 | *  tppdm005  
 	 	 endselect  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:021
:ICOD:S
:QURY:START
select 	 tipcs021.*
from 	 tipcs020, tipcs021
where 	 tipcs020._index1 =  {tipcs021.cprj}  
 and 	 tipcs020.prtp <>  tcyesno.yes  
 | *  Do not include customized items from tppdm605,  
 | *  duplicate project &  item codes can exist.
order by tipcs021._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:021
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:022
:ICOD:D
:QURY:START
	 if tipcs022.cprj =  hold.pcsbom.cprj and  
 	 tipcs022.sitm =  hold.pcsbom.sitm then  
 	 	 continue  
 	 endif  
 	 hold.pcsbom.cprj =  tipcs022.cprj  
 	 hold.pcsbom.sitm =  tipcs022.sitm  
 	 | *  All logic is present in the function below, because it is reused  
 	 | *  for 'migrate tiitm001'.  
 	 create.item.from.tiitm001(true, tipcs022.cprj, false, "")
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:022
:ICOD:S
:QURY:START
select 	 tipcs022.cprj, tipcs022.sitm, tipcs022.opol,  
 	 tipcs022.mitm, tipcs022.pono, tiitm001.*
from 	 tiitm001, tipcs022  
 | *  Standard items in the customized BOM (Item Category (tipcs022.opol) =   
 | *  Standard Item) and Order Policy (tiitm001.opol) =  To Order need to be  
 | *  customized.
where 	 tipcs022.opol =  tcittb.standard  
 and 	 tiitm001._index1 =  {tipcs022.sitm}  
 and 	 tiitm001.opol =  tcopol.on.order  
 | *  Do not customize standard items which were already customized before.  
 and not exists( 	 select 	 tipcs021.cprj  
 	 	 from 	 tipcs021  
 	 	 where 	 tipcs021._index1 =  {tipcs022.cprj, tipcs022.sitm})  
 | *  Same standard item can be present more than once in the customized BOM's  
 | *  of one project. So order by Project and Sub Item. Index 2 (opol, cprj, sitm,  
 | *  mitm, pono) can be used.
order by tipcs022._index2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:022
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:110
:ICOD:D
:QURY:START
	 if tipcs110.cbdg =  hold.pcsbom.cprj and  
 	 tipcs110.item =  hold.pcsbom.sitm then  
 	 	 continue  
 	 endif  
 	 hold.pcsbom.cprj =  tipcs110.cbdg  
 	 hold.pcsbom.sitm =  tipcs110.item  
 	 | *  All logic is present in the function below, because it is reused  
 	 | *  for 'migrate tiitm001'.  
 	 create.item.from.tiitm001(true, tipcs110.cbdg, true, tipcs110.bccd)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:110
:ICOD:S
:QURY:START
select 	 tipcs110.cbdg, tipcs110.item, tipcs110.ittp,  
 	 tipcs110.bccd, tipcs110.ccpc, tipcs110.pono, tiitm001.*
from 	 tiitm001, tipcs110  
 | *  Standard items in the customized BOM (Item Category (tipcs110.ittb) =   
 | *  Standard Item) and Order Policy (tiitm001.opol) =  To Order need to be  
 | *  customized.
where 	 tipcs110.ittp =  tcitta.standard  
 and 	 tiitm001._index1 =  {tipcs110.item}  
 and 	 tiitm001.opol =  tcopol.on.order  
 | *  Do not customize standard items which were already customized before.  
 and not exists( 	 select 	 tipcs002.cbdg  
 	 	 from 	 tipcs002  
 	 	 where 	 tipcs002._index1 =  {tipcs110.cbdg, tipcs110.item})  
 | *  Same standard item can be present more than once in the customized BOM's  
 | *  of one budget. So order by Budget and Sub Item. Index 3 (ittp, cbdg, item,  
 | *  bccd, ccpc, pono) can be used.
order by tipcs110._index3
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:110
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:tp
:SCMOD:pdm
:SFLNO:605
:ICOD:D
:QURY:START
| *  Performance optimization.  
 	 | *  Read currency only again when project changes.  
 	 if tppdm605.cprj <>  hold.cprj then  
 	 	 select tccom000.ccur  
 	 	 from 	 tccom000, tppdm600  
 	 	 where tppdm600._index1 =  {:tppdm605.cprj}  
 	 	 and 	 tccom000._index1 =  {tppdm600.ncmp}  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 endselect  
 	 	 hold.cprj =  tppdm605.cprj  
 	 endif  
 	 var.tcibd001.cprj =  get.tp.project(tppdm605.cprj)  
 	 var.tcibd001.item =  segment.item.code(tppdm605.item, var.tcibd001.cprj)  
 	 | *  Only items with Item Type (Project) =  Item are allowed in tppdm005,  
 	 | *  type =  Equipment or type =  Subcontracting are not allowed.  
 	 if tppdm605.itmt =  tppdm.itmt.item then  
 	 	 | *  Create the correct Control Code  
 	 	 if tppdm605.ccit =  tppdm605.item then  
 	 	 	 var.tppdm005.ccit.c =  var.tcibd001.item  
 | #  200 -  101794.sn  
 	 	 	 var.tppdm005.copt =  tppdm.copt.manu  
 | #  200 -  101794.en  
 	 	 else  
 	 	 	 select 	 tppdm605.ppcs:ccit.ppcs,  
 	 	 	 	 tppdm605.citm:ccit.citm,  
 	 	 	 	 tppdm605.prit:ccit.prit  
 	 	 	 from 	 tppdm605  
 	 	 	 where 	 tppdm605._index1 =  {:tppdm605.cprj, :tppdm605.ccit}  
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 	 | *  If it exists and is manufactured, take the related PCS item  
 	 	 	 	 | *  If it is purchased, take the TP item (ccit) itself  
 	 	 	 	 if ccit.prit =  tppdm.prit.manufactured then  
 	 	 	 	 	 var.tppdm005.ccit.c =  segment.item.code(ccit.citm, get.ti.project(ccit.ppcs))  
 	 	 	 	 	 var.tppdm005.copt =  tppdm.copt.stock  
 	 	 	 	 else  
 	 	 	 	 	 var.tppdm005.ccit.c =  segment.item.code(tppdm605.ccit, var.tcibd001.cprj)  
 	 	 	 	 	 var.tppdm005.copt =  tppdm.copt.manu  
 	 	 	 	 endif  
 	 	 	 selectempty  
 	 	 	 	 | *  If it does not exist, take the empty Project code  
 	 	 	 	 var.tppdm005.ccit.c =  segment.item.code(tppdm605.ccit, "")          
 	 	 	 	 var.tppdm005.copt =  tppdm.copt.stock  
 	 	 	 endselect  
 	 	 endif  
 	 	 | *  Dump for tppdm005 from tppdm605.  
 	 	 dump 14 | *  tppdm005  
 	 endif  
 	 | *  Read bcstc006.  
 	 return.value =  get.cost.components (  
 	 	 	 	 	 bcorig.tppdm,  
 	 	 	 	 	 "",          
 	 	 	 	 	 tppdm605.ccco,  
 	 	 	 	 	 error.message)  
 	 | *  Determine new item type.  
 	 if (tppdm605.itmt =  tppdm.itmt.item) then  
 	 	 if (tppdm605.prit =  tppdm.prit.purchased) then  
 	 	 	 | *  Purchased  
 	 	 	 var.tcibd001.kitm =  1  
 	 	 else  
 	 	 	 if (tppdm605.prit =  tppdm.prit.manufactured) then  
 	 	 	 	 | *  Manufactured  
 	 	 	 	 var.tcibd001.kitm =  2  
 	 	 	 endif  
 	 	 endif  
 	 else  
 	 	 if (tppdm605.itmt =  tppdm.itmt.equipment) then  
 	 	 	 | *  Equipment  
 	 	 	 var.tcibd001.kitm =  15  
 	 	 else  
 	 	 	 | *  Subcontracting  
 	 	 	 var.tcibd001.kitm =  6  
 	 	 endif  
 	 endif  
 	 | *  Determine inventory and weigth unit.  
 	 equipment.item =  left.align(tppdm605.item, 16)  
 	 equipment.item =  right.align(equipment.item, 10)  
 	 subcontracting.item =  left.align(tppdm605.item, 16)  
 	 subcontracting.item =  right.align(subcontracting.item, 8)  
 	  
 	 if ( tppdm605.itmt =  tppdm.itmt.item ) then  
 	 	 var.tcibd001.cuni =  tppdm605.cuni  
 	 	 determine.weight.unit(tppdm605.uset, var.tcibd001.cwun)  
 	 endif  
 	 if ( tppdm605.itmt =  tppdm.itmt.equipment ) then  
 	 	 select tppdm625.cuti  
 	 	 from 	 tppdm625  
 	 	 where tppdm625._index1 =  {:tppdm605.cprj, :equipment.item}  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 var.tcibd001.cuni =  tppdm625.cuti  
 	 	 	 var.tcibd001.cwun(1;3) =  ""          
 	 	 endselect  
 	 endif  
 	 if (tppdm605.itmt =  tppdm.itmt.subcontracting) then  
 	 	 select tppdm635.cuti, tppdm635.dsbc, tppdm635.cuni  
 	 	 from tppdm635  
 	 	 where tppdm635._index1 =  {:tppdm605.cprj, :subcontracting.item}  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 var.tcibd001.cwun(1;3) =  ""          
 	 	 	 if ( tppdm635.dsbc =  tppdm.dsbc.quantity) then  
 	 	 	 	 var.tcibd001.cuni =  tppdm635.cuni  
 	 	 	 else  
 	 	 	 	 var.tcibd001.cuni =  tppdm635.cuti  
 	 	 	 endif 	 	 	  
 	 	 endselect  
 	 endif  
 	 var.tcibd001.seab =  var.tcibd001.item(1;16)  
 	 | *  Dump for tcibd001 from tppdm605.  
 	 dump 15 | *  tcibd001  
 | #  800 -  142597.so  
 | *  Customized items with project segment filled with a TP project  
 | *  are never allowed in tiipd in SSA ERP LN. This applies to all items  
 | *  which originate from tppdm605.  
 | 	 | *  Do not dump to tiipd001 when item is Equipment or Subcontracting.  
 | 	 if (tppdm605.itmt <>  tppdm.itmt.equipment and  
 | 	 tppdm605.itmt <>  tppdm.itmt.subcontracting ) then  
 | 	 	 | *  Determine floor stock flag.  
 | 	 	 if isspace(tppdm605.dfit) then  
 | 	 	 	 tmp.floor.stock =  tcyesno.no  
 | 	 	 else  
 | 	 	 	 select tiitm001.pics  
 | 	 	 	 from 	 tiitm001  
 | 	 	 	 where tiitm001._index1 =  {:tppdm605.dfit}  
 | 	 	 	 as set with 1 rows 	 	 	  
 | 	 	 	 selectdo  
 | 	 	 	 	 tmp.floor.stock =  tiitm001.pics  
 | 	 	 	 endselect  
 | 	 	 endif  
 | 	 	 if tmp.floor.stock =  tcyesno.yes then  
 | 	 	 	 var.tiipd001.drin =  tcyesno.yes  
 | 	 	 	 var.tiipd001.dris =  tcyesno.yes  
 | 	 	 else  
 | 	 	 	 var.tiipd001.drin =  tcyesno.no  
 | 	 	 	 var.tiipd001.dris =  tcyesno.no  
 | 	 	 endif  
 | 	 	 | *  Dump for tiipd001 from tppdm605.  
 | 	 	 dump 16  
 | 	 endif  
 | #  800 -  142597.eo  
 	 | *  Determine order system. 	  
 	 if (tppdm605.osys =  tppdm.osyb.prp) then  
 	 	 | *  tcosys.mps (Planned)  
 	 	 var.tcibd200.osys =  2  
 	 else  
 	 	 if (tppdm605.osys =  tppdm.osyb.mnl) then  
 	 	 	 | *  tcosys.mnl (Manual)  
 	 	 	 var.tcibd200.osys =  9  
 	 	 endif  
 	 endif  
 | #  800 -  139367.sn  
 	 | *  Set field Minimum Order Quantity always to 1.0, because  
 	 | *  Order Method is always Lot for Lot and Order Quantity  
 	 | *  Increment is always 1.0 and thus Minimum Order Quantity  
 	 | *  should also have the value 1.0.  
 	 var.tcibd200.mioq =  1.0  
 | #  800 -  139367.en  
 	 | *  Dump for tcibd200 from tppdm605.  
 	 dump 17 | *  tcibd200  
 	 | *  Do not dump to ticpr007 when item is Equipment or Subcontracting.  
 	 if (tppdm605.itmt <>  tppdm.itmt.equipment and  
 	 tppdm605.itmt <>  tppdm.itmt.subcontracting ) then  
 	 	 | *  Read cost component chart if present.  
 	 	 | *  Item is Purchased or Manufactured.  
 	 	 get.aggr.cost.comp.for.item(  
 	 	 	 	 (var.tcibd001.kitm =  1 ?   
 	 	 	 	 tckitm.manufacture : tckitm.purchase),  
 	 	 	 	 tppdm605.citg,  
 	 	 	 	 tppdm605.cpcp,  
 	 	 	 	 var.ticpr007.acpm,  
 	 	 	 	 var.ticpr007.acpo,  
 	 	 	 	 var.ticpr007.acps)  
 	 	 if get.cost.component.charts.per.item.type.and.group(  
 	 	 	 	 (var.tcibd001.kitm =  1 ?   
 	 	 	 	 tckitm.manufacture : tckitm.purchase),  
 	 	 	 	 tppdm605.citg,  
 	 	 	 	 error.message) =  0 then  
 	 	 	 var.ticpr007.chrt =  bcsti007.chrt  
 	 	 else  
 	 	 	 var.ticpr007.chrt =  ""          
 	 	 endif  
 | #  200 -  97615.sn  
 	 	 | *  Surcharge by Item should only be Yes for Purchased,  
 	 	 | *  Manufactured or Generic items.  
 	 	 if var.tcibd001.kitm =  1 or  
 	 	 var.tcibd001.kitm =  2 or  
 	 	 var.tcibd001.kitm =  3 then  
 	 	 	 var.ticpr007.spit =  tcyesno.yes  
 	 	 else  
 	 	 	 var.ticpr007.spit =  tcyesno.no  
 	 	 endif  
 | #  200 -  97615.en  
 	 	 | *  Dump for ticpr007 from tppdm605.  
 	 	 dump 18 | *  ticpr007  
 	 endif  
 | #  800 -  140863.sn  
 	 | *  Do not dump to whwmd400 when Item Type =  Equipment.  
 	 if tppdm605.itmt <>  tppdm.itmt.equipment then  
 | #  800 -  140863.en  
 | #  200 -  99295.sn  
 	 	 | *  Outbound methods Fifo or Lifo are only allowed when  
 	 	 | *  item type is purchased, manufactured or generic.  
 	 	 if var.tcibd001.kitm =  1 or | *  tckitm.purchased  
 	 	 var.tcibd001.kitm =  2 or | *  tckitm.manufactured  
 	 	 var.tcibd001.kitm =  3 then | *  tckitm.generic  
 	 	 	 var.whwmd400.obpr =  tcobpr.fifo  
 	 	 else  
 	 	 	 var.whwmd400.obpr =  tcobpr.loca  
 	 	 endif  
 	 	 var.whwmd400.linv =  tcyesno.no 	 	 	 | #  SP2.n  
 	  
 | #  200 -  99295.en  
 	 	 | *  Dump for whwmd400 from tppdm605.  
 	 	 dump 19 | *  whwmd400  
 | #  800 -  140863.sn  
 	 endif  
 | #  800 -  140863.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:tp
:SCMOD:pdm
:SFLNO:605
:ICOD:S
:QURY:START
select 	 tppdm605.*
from 	 tppdm605  
 | *  When the TP Project Item is linked to a PCS Project, which is the case for all  
 | *  Project Items which have Project Item Type =  Manufactured, then the PCS  
 | *  Customized Item on the TP Project Item (tppdm605.ppcs +  tppdm605.citm)  
 | *  should be used in BaanERP 6.0.
where 	 tppdm605.prit <>  tppdm.prit.manufactured
order by tppdm605._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:tp
:SCMOD:pdm
:SFLNO:605
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:002
:SCPAC:bc
:SCMOD:stc
:SFLNO:010
:ICOD:D
:QURY:START
	 | *  For cost and service items, only the material cost component needs  
 	 | *  to be filled.  
 	 if bcstc010.kitm =  tckitm.cost or  
 	 bcstc010.kitm =  tckitm.service then  
 	 	 | *  Fill material cost component.  
 	 	 if not isspace(bcstc010.matc) then  
 	 	 	 var.ticpr008.acpm =  bcstc010.matc  
 	 	 else  
 	 	 	 var.ticpr008.acpm =  bcstc000.matc  
 	 	 endif  
 	 	 var.ticpr008.acpo =  empty()  
 	 	 var.ticpr008.acps =  empty()  
 	 else  
 	 	 | *  Fill material cost component.  
 	 	 if not isspace(bcstc010.matc) then  
 	 	 	 var.ticpr008.acpm =  bcstc010.matc  
 	 	 else  
 	 	 	 var.ticpr008.acpm =  bcstc000.matc  
 	 	 endif  
 	 	 | *  Fill operation cost component.  
 	 	 if not isspace(bcstc010.oprc) then  
 	 	 	 var.ticpr008.acpo =  bcstc010.oprc  
 	 	 else  
 	 	 	 var.ticpr008.acpo =  bcstc000.oprc  
 	 	 endif  
 	 	 | *  Fill surcharge cost component.  
 	 	 if not isspace(bcstc010.surc) then  
 	 	 	 var.ticpr008.acps =  bcstc010.surc  
 	 	 else  
 	 	 	 var.ticpr008.acps =  bcstc000.surc  
 	 	 endif  
 	 endif  
 	 | *  Read cost component chart for item type and item group  
 	 | *  from bcsti007.  
 	 return.value =  get.cost.component.charts.per.item.type.and.group(  
 	 	 	 	 bcstc010.kitm,  
 	 	 	 	 bcstc010.citg,  
 	 	 	 	 error.message)  
 	 	 var.ticpr008.chrt =  bcsti007.chrt  
 | #  200 -  97615.sn  
 	 if bcstc010.kitm =  tckitm.purchase or  
 	 bcstc010.kitm =  tckitm.manufacture or  
 	 bcstc010.kitm =  tckitm.generic then  
 	 	 var.ticpr008.spit =  tcyesno.yes  
 	 else  
 	 	 var.ticpr008.spit =  tcyesno.no  
 	 endif  
 | #  200 -  97615.en  
 	 dump 8 	 | *  Dump for ticpr008.
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:002
:SCPAC:bc
:SCMOD:stc
:SFLNO:010
:ICOD:S
:QURY:START
select 	 bcstc010.*
from 	 bcstc010  
 | *  Subcontracting items do not have item costing data (defaults).  
 | *  But may be can be present in bcstc010.
where 	 bcstc010.kitm <>  tckitm.subcontracting  
 | *  Skip the records which were already migrated from tiitm002.  
 and not exists( 	 select 	 tiitm002.kitm  
 	 	 from 	 tiitm002  
 	 	 where 	 tiitm002._index1 =  {bcstc010.kitm, bcstc010.citg})
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:002
:SCPAC:bc
:SCMOD:stc
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:002
:SCPAC:ti
:SCMOD:itm
:SFLNO:002
:ICOD:D
:QURY:START
| #  800 -  139498.sn  
 	 | *  When ILC is implemented and Item Type is not equal to  
 	 | *  Cost or Service, field Location Controlled Item should be  
 	 | *  set to Yes. Else it is set to No.  
 	 if tdilc000.iilc =  tcyesno.yes and tiitm002.kitm <>  tckitm.cost and  
 	 tiitm002.kitm <>  tckitm.service then  
 	 	 var.whwmd401.locc =  tcyesno.yes  
 	 else  
 	 	 var.whwmd401.locc =  tcyesno.no  
 	 endif  
 | #  800 -  139498.en  
 | #  200 -  99295.sn  
 	 | *  Outbound methods Fifo or Lifo are only allowed when  
 	 | *  item type is purchased, manufactured or generic.  
 	 if tiitm002.kitm =  tckitm.purchase or  
 	 tiitm002.kitm =  tckitm.manufacture or  
 	 tiitm002.kitm =  tckitm.generic then  
 	 	 var.whwmd401.obpr =  tiitm002.obpr  
 	 else  
 	 	 var.whwmd401.obpr =  tcobpr.loca  
 	 endif  
 | #  200 -  99295.en  
 	 	 	 	 	 	 	 	 | #  SP2.sn  
 	 if tiitm002.kltc =  tckltc.batch then  
 	 	 var.whwmd401.linv =  tcyesno.yes  
 	 else  
 	 	 var.whwmd401.linv =  tcyesno.no  
 	 endif  
 	 if tiitm002.kltc =  tckltc.unit then  
 	 	 var.whwmd401.sinv =  tcyesno.yes  
 	 else  
 	 	 var.whwmd401.sinv =  tcyesno.no  
 	 endif  
 	 	 	 	 	 	 	 	 | #  SP2.en  
 	 dump 1 | *  Dump for whwmd401.  
 	 if tiitm002.kitm <>  tckitm.subcontracting then 	 	 | #  214022.n  
 	 | *  No Project Default Data for Item Type ==  Subcontracting.  
 	 	 dump 2 | *  Dump for tppdm006.  
 	 endif 	 	 	 	 	 	 	 | #  214022.n  
 	 if (tiitm002.kitm =  tckitm.purchase or  
 	 tiitm002.kitm =  tckitm.manufacture or  
 	 tiitm002.kitm =  tckitm.generic ) then  
 	 	 | *  Determine RPT Item.  
 	 	 if tiitm002.kitm =  tckitm.generic or  
 	 	 tiitm002.kitm =  tckitm.purchase then  
 	 	 	 var.tiipd002.repi =  tcyesno.no  
 	 	 else  
 	 	 	 var.tiipd002.repi =  tiitm002.repi  
 	 	 endif  
 	 	 | *  Determine Rate Factor for Planning.  
 	 	 if tiitm002.repi =  tcyesno.no then  
 	 	 	 var.tiipd002.pcrp =  0  
 	 	 else  
 	 	 	 var.tiipd002.pcrp =  tiitm002.pcrp  
 	 	 endif  
 	 	 | *  Determine BOM Quantity.  
 	 	 if tiitm002.unom =  0 then  
 	 	 	 var.tiipd002.unom =  1  
 	 	 else  
 	 	 	 var.tiipd002.unom =  tiitm002.unom  
 	 	 endif  
 	 	 | *  Determine Routing Unit.  
 	 	 if (tiitm002.runi =  0) then  
 	 	 	 var.tiipd002.runi =  1  
 	 	 else  
 	 	 	 var.tiipd002.runi =  tiitm002.runi  
 	 	 endif  
 | #  200 -  95451.sn  
 	 	 if tiitm002.pics =  tcyesno.yes then  
 	 	 	 var.tiipd002.drin =  tcyesno.yes  
 	 	 	 var.tiipd002.dris =  tcyesno.yes  
 	 	 else  
 	 	 	 var.tiipd002.drin =  tcyesno.no  
 	 	 	 var.tiipd002.dris =  tcyesno.no  
 	 	 endif  
 	 	 | *  When Backflush if Material is Yes, Direct Process Outbound  
 	 	 | *  is mandatory to be Yes too. This overrules the setting of  
 	 	 | *  Direct Process Outbound based on Floor Stock (above).  
 	 	 if tiitm002.bfcp =  tcyesno.yes then  
 	 	 	 var.tiipd002.dris =  tcyesno.yes  
 	 	 endif  
 | #  200 -  95451.en  
 	 	 dump 3 | *  Dump for tiipd002.  
 	 endif  
 | #  800 -  139560.sn  
 	 | *  Do not create tcibd201 for cost and subcontracting items.  
 	 | *  Skip all logic for determining tcibd201 variables.  
 	 if tiitm002.kitm <>  tckitm.cost and  
 	 tiitm002.kitm <>  tckitm.subcontracting then 	  
 | #  800 -  139560.en  
 	 	 | *  Domain tcemno (for tiitm002.cplb) is long 6 in Baan IV.  
 	 	 | *  This needs to be converted to a string.  
 	 	 var.tcibd201.cplb =  format.emno(tiitm002.cplb)  
 	 	 | *  When Order System =  MRP in Baan IV, convert to  
 	 	 | *  Planned in Baan 6.0.  
 	 	 if (tiitm002.osys =  tcosys.mrp) then  
 	 	 	 var.tcibd201.osys =  2  
 	 	 else  
 	 	 	 var.tcibd201.osys =  etol(tiitm002.osys)  
 	 	 endif  
 | #  200 -  97803.sn  
 	 	 | *  When field Order Method is 'Lot for Lot' or 'Replenish  
 	 	 | *  to Max. Inv.' then field Minimum Order Quantity should at  
 	 	 | *  least have the value of field Order Quantity Multiple Of.  
 	 	 if tiitm002.omth =  tcomth.lfl or  
 	 	 tiitm002.omth =  tcomth.max then  
 	 	 	 if double.cmp(tiitm002.mioq, tiitm002.oqmf,  
 	 	 	 	 	 	 	 0.0001) = -  1 then  
 	 	 	 	 | *  Set the minimum order quantity to the  
 	 	 	 	 | *  order quantity increment value.  
 	 	 	 	 var.tcibd201.mioq =  tiitm002.oqmf  
 	 	 	 else  
 	 	 	 	 var.tcibd201.mioq =  tiitm002.mioq  
 	 	 	 endif  
 	 	 else  
 	 	 	 var.tcibd201.mioq =  tiitm002.mioq  
 	 	 endif  
 	 	 | *  Field Fixed Order Quantity should not be less than the  
 	 	 | *  Minimum Order Quantity, although the source version  
 	 	 | *  allows this.  
 	 	 if double.cmp(tiitm002.fioq, var.tcibd201.mioq,  
 	 	 	 	 	 	 	 0.0001) = -  1 then  
 	 	 	 | *  Set the fixed order quantity to the minimum  
 	 	 	 | *  order quantity.  
 	 	 	 var.tcibd201.fioq =  var.tcibd201.mioq  
 	 	 else  
 	 	 	 var.tcibd201.fioq =  tiitm002.fioq  
 	 	 endif  
 | #  200 -  97803.en  
 	 	 dump 4 | *  Dump for tcibd201.  
 | #  800 -  139560.sn  
 	 endif  
 | #  800 -  139560.en  
 	 if (tiitm002.kitm <>  tckitm.subcontracting) then  
 	 	 | *  For cost and service items, only the material cost  
 	 	 | *  component needs to be filled. This cost component is  
 	 	 | *  read from bcstc006.  
 	 	 if tiitm002.kitm =  tckitm.cost or  
 	 	 tiitm002.kitm =  tckitm.service then  
 	 	 	 | *  Read bcstc006.  
 	 	 	 return.value =  get.cost.components(  
 	 	 	 	 	 	 bcorig.ticpr,  
 	 	 	 	 	 	 tiitm002.cpcp,  
 	 	 	 	 	 	 "",                                                                                                                                                                                                            
 	 	 	 	 	 	 error.message)  
 	 	 	 var.ticpr008.acpm =  bcstc006.cost  
 	 	 	 var.ticpr008.acpo =  empty.string(1;8)  
 	 	 	 var.ticpr008.acps =  empty.string(1;8)  
 	 	 else  
 	 	 	 | *  Read bcstc010.  
 	 	 	 return.value =  get.aggregated.costs(  
 	 	 	 	 	 	 tiitm002.kitm,  
 	 	 	 	 	 	 tiitm002.citg,  
 	 	 	 	 	 	 error.message)  
 	 	 	 | *  Fill material cost component.  
 	 	 	 if not isspace(bcstc010.matc) then  
 	 	 	 	 var.ticpr008.acpm =  bcstc010.matc  
 	 	 	 else  
 	 	 	 	 var.ticpr008.acpm =  bcstc000.matc  
 	 	 	 endif  
 	 	 	 | *  Fill operation cost component.  
 	 	 	 if not isspace(bcstc010.oprc) then  
 	 	 	 	 var.ticpr008.acpo =  bcstc010.oprc  
 	 	 	 else  
 	 	 	 	 var.ticpr008.acpo =  bcstc000.oprc  
 	 	 	 endif  
 	 	 	 | *  Fill surcharge cost component.  
 	 	 	 if not isspace(bcstc010.surc) then  
 	 	 	 	 var.ticpr008.acps =  bcstc010.surc  
 	 	 	 else  
 	 	 	 	 var.ticpr008.acps =  bcstc000.surc  
 	 	 	 endif  
 	 	 endif  
 	 	 | *  Read cost component chart for item type and item group  
 	 	 | *  from bcsti007.  
 	 	 return.value =   
 	 	 	 get.cost.component.charts.per.item.type.and.group(  
 	 	 	 	 	 tiitm002.kitm,  
 	 	 	 	 	 tiitm002.citg,  
 	 	 	 	 	 error.message)  
 	 	 var.ticpr008.chrt =  bcsti007.chrt  
 | #  800 -  97615.sn  
 	 	 if tiitm002.kitm =  tckitm.purchase or  
 	 	 tiitm002.kitm =  tckitm.manufacture or  
 	 	 tiitm002.kitm =  tckitm.generic then  
 	 	 	 var.ticpr008.spit =  tcyesno.yes  
 	 	 else  
 	 	 	 var.ticpr008.spit =  tcyesno.no  
 	 	 endif  
 | #  800 -  97615.en  
 	 	 dump 5 | *  Dump for ticpr008.  
 	 endif  
 	  
 	 if (not isspace(tiitm002.ccco)) then  
 	 	 | *  Read bcstc006 for tppdm cost component type.  
 	 	 return.value =  get.cost.components(  
 	 	 	 	 	 bcorig.tppdm,  
 	 	 	 	 	 "",                                                                                                                                                                                                            
 	 	 	 	 	 tiitm002.ccco,  
 	 	 	 	 	 error.message)  
 	 	 var.tcibd002.cpcp =  bcstc006.cost  
 	 else  
 	 	 | *  Read bcstc006 for ticpr cost component type.  
 	 	 return.value =  get.cost.components(  
 	 	 	 	 	 bcorig.ticpr,  
 	 	 	 	 	 tiitm002.cpcp,  
 	 	 	 	 	 "",                                                                                                                                                                                                            
 	 	 	 	 	 error.message)  
 	 	 | *  Field bcstc006.cost is empty when record not found.  
 	 	 if not isspace(bcstc006.cost) then  
 	 	 	 var.tcibd002.cpcp =  bcstc006.cost  
 	 	 else  
 	 	 	 | *  Field tcibd002.cpcp is mandatory for cost and service items.  
 	 	 	 | *  So fill with default material cost component when other  
 	 	 	 | *  sources do not contain data.  
 	 	 	 if tiitm002.kitm =  tckitm.cost or  
 	 	 	 tiitm002.kitm =  tckitm.service then  
 	 	 	 	 var.tcibd002.cpcp =  bcstc000.matc  
 	 	 	 else  
 	 	 	 	 var.tcibd002.cpcp =  empty.string(1;8)  
 	 	 	 endif  
 	 	 endif  
 	 endif  
 	 	 	 	 	 	 	 	 | #  214022.sn  
 | *  Migrate subentity -  fields based on function tcibd0003.handle.ui.entities()  
 | *  NOTE: based on the real coding, the matrix is adjusted !!   
 | *  	 (compared to #  include tcibd0003)  
 | *   
 | *  	 The next matrix shows the current situation:  
 | *  	 1: enabled  
 | *  	 0: disabled  
 | *   
 | *  type | sald | prod | cosd | ward | prtd | purd | ordd | plnd | serd | fmgd  
 | *-----------------------------------------------------------------------------   
 | *  COST | 1 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 1 | 1  
 | *  SERV | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 0  
 | *  SUBC | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0  
 | *  GEN | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1  
 | *  LIST | 1 | 0 | 0 | 1 <  | 1 | 1 | 1 | 1 | 0 | 1  
 | *  EQUIP | 1 | 0 | 0 | 0 | 1 <  | 1 | 0 | 0 | 0 | 0  
 | *  MANUF | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1  
 | *  PURCH | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1  
 | *  ENG -  M | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0  
 | *-----------------------------------------------------------------------------   
 	 var.tcibd002.sald =  1 | *  Yes  
 	 var.tcibd002.prod =  1 | *  Yes  
 	 var.tcibd002.cosd =  1 | *  Yes  
 	 var.tcibd002.ward =  1 | *  Yes  
 	 var.tcibd002.prtd =  1 | *  Yes  
 	 var.tcibd002.purd =  1 | *  Yes  
 	 var.tcibd002.ordd =  1 | *  Yes  
 	 if (tiitm002.osys =  tcosys.mrp) or  
 	 (tiitm002.osys =  tcosys.mps) then  
 	 	 var.tcibd002.plnd =  1 | *  tcyesno.yes  
 	 else  
 	 	 var.tcibd002.plnd =  2 | *  tcyesno.no  
 	 endif  
 	 var.tcibd002.serd =  1 | *  Yes  
 	 var.tcibd002.fmgd =  1 | *  Yes  
 	 on case tiitm002.kitm  
 	 case tckitm.purchase 	 :  
 	 	 break  
 	 case tckitm.manufacture 	 :  
 	 	 break  
 	 case tckitm.generic 	 :  
 	 	 break  
 	 case tckitm.cost 	 :  
 	 	 var.tcibd002.prod =  2 | *  No  
 	 	 var.tcibd002.ordd =  2 | *  No  
 	 	 var.tcibd002.plnd =  2 | *  No  
 	 	 break  
 	 case tckitm.service 	 :  
 	 	 var.tcibd002.prod =  2 | *  No  
 	 	 var.tcibd002.plnd =  2 | *  No  
 	 	 var.tcibd002.fmgd =  2 | *  No  
 	 	 break  
 	 case tckitm.subcontracting 	 :  
 	 	 var.tcibd002.sald =  2 | *  No  
 	 	 var.tcibd002.prod =  2 | *  No  
 	 	 var.tcibd002.cosd =  2 | *  No  
 	 	 var.tcibd002.prtd =  2 | *  No  
 	 	 var.tcibd002.ordd =  2 | *  No  
 	 	 var.tcibd002.plnd =  2 | *  No  
 	 	 var.tcibd002.serd =  2 | *  No  
 	 	 var.tcibd002.fmgd =  2 | *  No  
 	 	 break  
 | 	 case tckitm.list 	 :  
 | 	 	 var.tcibd002.prod =  2 | *  No  
 | 	 	 var.tcibd002.cosd =  2 | *  No  
 | 	 	 var.tcibd002.serd =  2 | *  No  
 | 	 	 break  
 | 	 case tckitm.equipment 	 :  
 | 	 	 var.tcibd002.prod =  2 | *  No  
 | 	 	 var.tcibd002.cosd =  2 | *  No  
 | 	 	 var.tcibd002.ward =  2 | *  No  
 | 	 	 var.tcibd002.ordd =  2 | *  No  
 | 	 	 var.tcibd002.plnd =  2 | *  No  
 | 	 	 var.tcibd002.serd =  2 | *  No  
 | 	 	 var.tcibd002.fmgd =  2 | *  No  
 | 	 	 break  
 | 	 case tckitm.engineering 	 :  
 | 	 	 var.tcibd002.sald =  2 | *  No  
 | 	 	 var.tcibd002.prod =  2 | *  No  
 | 	 	 var.tcibd002.cosd =  2 | *  No  
 | 	 	 var.tcibd002.ward =  2 | *  No  
 | 	 	 var.tcibd002.prtd =  2 | *  No  
 | 	 	 var.tcibd002.purd =  2 | *  No  
 | 	 	 var.tcibd002.ordd =  2 | *  No  
 | 	 	 var.tcibd002.plnd =  2 | *  No  
 | 	 	 var.tcibd002.serd =  2 | *  No  
 | 	 	 var.tcibd002.fmgd =  2 | *  No  
 | 	 	 break  
 	 default: break  
 	 endcase 	 	 	 	 	 	 	 | #  214022.en  
 	 | *  Determine Lot Control yes /  no and Serialized yes /  no.  
 	 on case tiitm002.kltc  
 	 case tckltc.batch:  
 	 	 var.tcibd002.ltct =  tcyesno.yes  
 	 	 var.tcibd002.seri =  tcyesno.no  
 	 break  
 	 case tckltc.unit:  
 	 	 var.tcibd002.ltct =  tcyesno.no  
 	 	 var.tcibd002.seri =  tcyesno.yes  
 	 break  
 	 case tckltc.none:  
 	 default:  
 	 	 var.tcibd002.ltct =  tcyesno.no  
 	 	 var.tcibd002.seri =  tcyesno.no  
 	 break  
 	 endcase  
 | 	 if (tiitm002.osys =  tcosys.mrp) or 	 | #  205411.sn | #  214022.so  
 | 	 (tiitm002.osys =  tcosys.mps) then  
 | 	 	 var.tcibd002.plnd =  tcyesno.yes  
 | 	 else  
 | 	 	 var.tcibd002.plnd =  tcyesno.no  
 | 	 endif 	 	 	 	 	 | #  205411.en | #  214022.eo  
 	 if tiitm002.kitm =  tckitm.cost then  
 	 endif  
 	 dump 6 | *  Dump for tcibd002.  
 	 | *  Dump for cprpd101. But not for all item types...  
 	 if tiitm002.kitm =  tckitm.purchase or  
 	 tiitm002.kitm =  tckitm.manufacture or  
 	 tiitm002.kitm =  tckitm.generic then  
 	 	 dump 7 | *  Dump for cprpd101. But not for all item types...  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:002
:SCPAC:ti
:SCMOD:itm
:SFLNO:002
:ICOD:S
:QURY:START
select 	 tiitm002.*
from 	 tiitm002
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:002
:SCPAC:ti
:SCMOD:itm
:SFLNO:002
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:401
:SCPAC:td
:SCMOD:ltc
:SFLNO:001
:ICOD:D
:QURY:START
	 var.tcibd401.item =  segment.item.code(tdltc001.item, "")                                                                                                            
 	 dump 1  
 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:401
:SCPAC:td
:SCMOD:ltc
:SFLNO:001
:ICOD:S
:QURY:START
select 	 tdltc001.*  	 	 | *  For standard Items
from 	 tdltc001, tiitm001
where 	 tdltc001.cprj =  ""                                                                                                                    
 and 	 tdltc001.item =  tiitm001.item  
 and 	 tiitm001.kltc =  tckltc.unit  
 and 	 tiitm001.cntr =  ""
order by tdltc001._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:401
:SCPAC:td
:SCMOD:ltc
:SFLNO:001
:ICOD:X
:QURY:START
	  
 select 	 tdltc001.*  	 	 | *  For Customized Items  
 from 	 tdltc001, tipcs021  
 where 	 tdltc001.cprj <>  ""                                                                                                                    
 and 	 tdltc001.item =  tipcs021.item  
 and 	 tipcs021.kltc =  tckltc.unit  
 order by tdltc001._index1  
 selectdo  
 	 if not isspace (tdltc001.cprj) then  
 	 	 tmp.cprj =  get.ti.project(tdltc001.cprj)  
 	 else  
 	 	 tmp.cprj =  empty()  
 	 endif  
 	  
 	 var.tcibd401.item =  segment.item.code(tdltc001.item, tmp.cprj)  
 	 	  
 	 dump 1  
 endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:401
:SCPAC:ts
:SCMOD:sma
:SFLNO:102
:ICOD:D
:QURY:START
	 | *  only migrate this record if related (customized) item is serialized.  
 	 if not item.is.serialized(tssma102.cprj, tssma102.item) then  
 	 	 continue  
 	 endif  
 	  
 	 if dummy.item.has.to.be.used ( 	 tssma102.cprj,  
 	 	 	 	 	 tssma102.item ) then  
 	 	 var.tcibd401.item =   
 	 	 	 segment.item.code ( bcsts000.item, empty.string(1;9))  
 	 else  
 	 	 if isspace(tssma102.cprj) then  
 	 	 	 var.tcibd401.item =   
 	 	 	 	 segment.item.code ( tssma102.item, empty.string(1;9))  
 	 	 else  
 	 	 	 var.tcibd401.item =   
 	 	 	 	 segment.item.code ( tssma102.item,get.ti.project(tssma102.cprj))  
 	 	 endif  
 	 endif  
 	  
 	  
 	 dump 3
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:401
:SCPAC:ts
:SCMOD:sma
:SFLNO:102
:ICOD:S
:QURY:START
select 	 tssma102.*
from 	 tssma102
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:401
:SCPAC:ts
:SCMOD:sma
:SFLNO:102
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:401
:SCPAC:ts
:SCMOD:sma
:SFLNO:105
:ICOD:D
:QURY:START
	 | *  only migrate this record if related (customized) item is serialized.  
 	 if not item.is.serialized("", tssma105.item) then  
 	 	 continue  
 	 endif  
 	 var.tcibd401.item =  segment.item.code(tssma105.item, "")                                                              
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:401
:SCPAC:ts
:SCMOD:sma
:SFLNO:105
:ICOD:S
:QURY:START
select 	 tssma105.*
from 	 tssma105
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ibd
:TFLNO:401
:SCPAC:ts
:SCMOD:sma
:SFLNO:105
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:000
:SCPAC:tc
:SCMOD:mcs
:SFLNO:000
:ICOD:D
:QURY:START


	 var.tcmcs000.indt =  utc(0,0)  
 	 var.tcmcs000.dsca =  form.text$("bcstc00035") 	 | *  Actual Set  
 	 if isspace(var.tcmcs000.ctim) then  
 	 	 var.tcmcs000.ctim =  tcmcs000.ctim  
 	 endif  
 	 Dump 1  
 	 var.tcmcs000.indt =  utc(date.num(), time.num())  
 	 var.tcmcs000.dsca =  form.text$("bcstc00036") 	 | *  Converted from BaanIVc4  
 	 Dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:000
:SCPAC:tc
:SCMOD:mcs
:SFLNO:000
:ICOD:S
:QURY:START


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

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:000
:SCPAC:tc
:SCMOD:mcs
:SFLNO:000
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:002
:SCPAC:tc
:SCMOD:mcs
:SFLNO:002
:ICOD:D
:QURY:START
	 Dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:002
:SCPAC:tc
:SCMOD:mcs
:SFLNO:002
:ICOD:S
:QURY:START
select tcmcs002.*
from tcmcs002
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:002
:SCPAC:tc
:SCMOD:mcs
:SFLNO:002
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:003
:SCPAC:tc
:SCMOD:mcs
:SFLNO:003
:ICOD:D
:QURY:START
	 var.tcmcs003.cwar =  tcmcs003.cwar(1; 3)  
 	 result =  get.addresses( "tcmcs003",                                        
 	 	 	 	 var.tcmcs003.cwar,  
 	 	 	 	 dummy.err.mess)  
 	 dump 1 | *  Warehouses (tcmcs003)  
 	 if tcmcs003.sloc =  tcyesno.yes then  
 	 	 var.whwmd200.stlo =  bcswh000.sloc  
 	 	 var.whwmd200.ialt =  5 | *  whwmd.loct.bulk  
 	 else  
 	 	 var.whwmd200.stlo =  string.set$(" ",10)  
 	 	 var.whwmd200.ialt =  20 | *  whwmd.loct.not.appl  
 	 endif  
 	 if get.enterprise.unit( 	 tcmcs003.comp,  
 	 	 	 	 l.logistic.company,  
 	 	 	 	 dummy.err.mess) =  0 then  
 	 	 var.whwmd200.wvgr =  bcstc018.entc  
 	 else  
 	 	 var.whwmd200.wvgr =  string.set$(" ",6)  
 	 endif  
 	 dump 2 | *  Warehouses (whwmd200)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:003
:SCPAC:tc
:SCMOD:mcs
:SFLNO:003
:ICOD:S
:QURY:START
select 	 tcmcs003.typw,  
 	 tcmcs003.cwar,  
 	 tcmcs003.dsca,  
 	 tcmcs003.sloc,  
 	 tcmcs003.comp,  
 	 tcmcs003.itlo,  
 	 tcmcs003.lolo,  
 	 tcmcs003.arlo,  
 	 tcmcs003.free
from 	 tcmcs003
where 	 tcmcs003.typw <>  tctypw.transito
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:003
:SCPAC:tc
:SCMOD:mcs
:SFLNO:003
:ICOD:X
:QURY:START
| *  Project Warehouse (bcstp000.cwar) may never be an existing warehouse  
 | *  (This is already checked in session bcstp0100m000). The warehouse that is  
 | *  generated will be of a different type, compared to the warehouses of tcmcs003.  
 if not isspace(bcstp000.cwar) then  
 	 var.tcmcs003.cwar =  bcstp000.cwar(1; 6)  
 	 result =  get.addresses( "tcmcs003",                                        
 	 	 	 	 var.tcmcs003.cwar,  
 	 	 	 	 dummy.err.mess)  
 	 var.tcmcs003.comp =  l.logistic.company  
 	 dump 5 | *  Warehouses (tcmcs003)  
 	 if get.enterprise.unit( l.logistic.company,  
 	 	 	 	 var.tcmcs003.comp,  
 	 	 	 	 dummy.err.mess) =  0 then  
 	 	 var.whwmd200.wvgr =  bcstc018.entc  
 	 else  
 	 	 var.whwmd200.wvgr =  string.set$(" ",6)  
 	 endif  
 	 var.whwmd200.ialt =  20 | *  whwmd.loct.not.appl 	 | #  200 -  96789.n  
 	 dump 6 | *  Warehouses (whwmd200)  
 endif  
 	 	 	 	 	 	 	 | #  200 -  96592.eo
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:005
:SCPAC:bc
:SCMOD:stc
:SFLNO:017
:ICOD:D
:QURY:START
	 on case bcstc017.orig  
 	 case bcreje.tdilc006 :  
 	 	 var.tcmcs005.rstp =  target(tcmcs.rstp.blocking)  
 	 	 | *  Inventory Blocking Excluding EP  
 	 	 break  
 	 case bcreje.tcmcs005 :  
 	 	 var.tcmcs005.rstp =  target(tcmcs.rstp.ret.goods)  
 	 	 | *  Return of Goods  
 	 	 break  
 	 case bcreje.tcmcs141:  
 	 	 var.tcmcs005.rstp =  target(tcmcs.rstp.tax.exem)  
 	 	 | *  Tax Exemption  
 	 	 break  
 	 case bcreje.tdsls015 :  
 	 	 var.tcmcs005.rstp =  target(tcmcs.rstp.rej.quot)  
 	 	 | *  Rejection of Quotation  
 	 	 break  
 	 case bcreje.tdinv105 :  
 	 	 var.tcmcs005.rstp =  target(tcmcs.rstp.inv.adjustment)  
 	 	 | *  Inventory Adjustment  
 	 	 break  
 	 case bcreje.trtop800 :  
 	 	 var.tcmcs005.rstp =  target(tcmcs.rstp.damaged)  
 	 	 | *  Damaged during Transport  
 	 	 break  
 	 default:  
 	 	 var.tcmcs005.rstp =  target(tcmcs.rstp.undefined)  
 	 	 | *  Undefined  
 	 endcase  
 	 Dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:005
:SCPAC:bc
:SCMOD:stc
:SFLNO:017
:ICOD:S
:QURY:START
select 	 bcstc017.*
from 	 bcstc017
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:005
:SCPAC:bc
:SCMOD:stc
:SFLNO:017
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:013
:SCPAC:tc
:SCMOD:mcs
:SFLNO:013
:ICOD:D
:QURY:START
	 | *  Field PASH  
 	 if payment.schedule.present(tcmcs013.cpay) then  
 	 	 var.tcmcs013.pash =  tcmcs013.cpay  
 	 else  
 	 	 var.tcmcs013.pash =  empty()  
 	 endif  
 	 | *  Field PPER  
 	 if tcmcs013.pper <>  0 and  
 	 payment.schedule.present(tcmcs013.cpay) then  
 	 	 var.tcmcs013.pper =  0  
 	 else  
 	 	 var.tcmcs013.pper =  tcmcs013.pper  
 	 endif  
 	 | *  Field DISA  
 	 if tcmcs013.disa <>  0 and  
 	 payment.schedule.present(tcmcs013.cpay) then  
 	 	 var.tcmcs013.disa =  0  
 	 else  
 	 	 var.tcmcs013.disa =  tcmcs013.disa  
 	 endif  
 	 | *  Field DISB  
 	 if tcmcs013.disb <>  0 and  
 	 payment.schedule.present(tcmcs013.cpay) then  
 	 	 var.tcmcs013.disb =  0  
 	 else  
 	 	 var.tcmcs013.disb =  tcmcs013.disb  
 	 endif  
 	 | *  Field DISC  
 	 if tcmcs013.disc <>  0 and  
 	 payment.schedule.present(tcmcs013.cpay) then  
 	 	 var.tcmcs013.disc =  0  
 	 else  
 	 	 var.tcmcs013.disc =  tcmcs013.disc  
 	 endif  
 	 | *  Field PRCA  
 	 if tcmcs013.prca <>  0 and  
 	 payment.schedule.present(tcmcs013.cpay) then  
 	 	 var.tcmcs013.prca =  0  
 	 else  
 	 	 var.tcmcs013.prca =  tcmcs013.prca  
 	 endif  
 	 | *  Field PRCB  
 	 if tcmcs013.prcb <>  0 and  
 	 payment.schedule.present(tcmcs013.cpay) then  
 	 	 var.tcmcs013.prcb =  0  
 	 else  
 	 	 var.tcmcs013.prcb =  tcmcs013.prcb  
 	 endif  
 	 | *  Field PRCC  
 	 if tcmcs013.prcc <>  0 and  
 	 payment.schedule.present(tcmcs013.cpay) then  
 	 	 var.tcmcs013.prcc =  0  
 	 else  
 	 	 var.tcmcs013.prcc =  tcmcs013.prcc  
 	 endif  
 	 | *  Field CDIS  
 	 if isspace(tcmcs013.cdis) then  
 	 	 var.tcmcs013.cdis =  target(tccdde.direct)  
 	 	 | *  tccdde.direct (Immediately)  
 	 else  
 	 	 var.tcmcs013.cdis =  etol(tcmcs013.cdis)  
 	 endif  
 	 | *  Field FDUE  
 	 if tcmcs013.cdde =  tccdde.end.month and  
 	 tcmcs013.fdue >  31 then  
 	 	 var.tcmcs013.fdue =  31  
 	 else  
 	 	 var.tcmcs013.fdue =  tcmcs013.fdue  
 	 endif  
 	 | *  Field FDIS  
 	 if tcmcs013.cdis =  tccdde.end.month and  
 	 tcmcs013.fdis >  31 then  
 	 	 var.tcmcs013.fdis =  31  
 	 else  
 	 	 var.tcmcs013.fdis =  tcmcs013.fdis  
 	 endif  
 	 | *  Field PTYP  
 	 if isspace(tcmcs013.ptyp) then  
 	 	 var.tcmcs013.ptyp =  target(tfacp.ptyp.days)  
 	 	 | *  tfacp.ptyp.days (Days)  
 	 else  
 	 	 var.tcmcs013.ptyp =  etol(tcmcs013.ptyp)  
 	 endif  
 	 | *  Field PRIO  
 	 if isspace(tcmcs013.prio) then  
 	 	 var.tcmcs013.prio =  target(tcmcs.prio.not.app)  
 	 	 | *  tcmcs.prio.not.app (Not Applicable)  
 	 else  
 	 	 if tcmcs013.cdde =  tccdde.direct then  
 	 	 	 var.tcmcs013.prio =  target(tcmcs.prio.not.app)  
 	 	 else  
 	 	 	 var.tcmcs013.prio =  etol(tcmcs013.prio)  
 	 	 endif  
 	 endif  
 	 | *  Field PDYN  
 	 if isspace(tcmcs013.pdyn) then  
 	 	 var.tcmcs013.pdyn =  target(tcyesno.no)  
 	 	 | *  tcyesno.no (No)  
 	 else  
 	 	 var.tcmcs013.pdyn =  etol(tcmcs013.pdyn)  
 	 endif  
 	 | *  Field PDIS  
 	 if isspace(tcmcs013.pdis) then  
 	 	 var.tcmcs013.pdis =  target(tcmcs.prio.not.app)  
 	 	 | *  tcmcs.prio.not.app (Not Applicable)  
 	 else  
 	 	 if var.tcmcs013.cdis =  target(tccdde.direct) then  
 	 	 	 var.tcmcs013.pdis =  target(tcmcs.prio.not.app)  
 	 	 else  
 	 	 	 var.tcmcs013.pdis =  etol(tcmcs013.pdis)  
 	 	 endif  
 	 endif  
 	 Dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:013
:SCPAC:tc
:SCMOD:mcs
:SFLNO:013
:ICOD:S
:QURY:START
select 	 tcmcs013.*
from 	 tcmcs013
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:013
:SCPAC:tc
:SCMOD:mcs
:SFLNO:013
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:018
:SCPAC:tc
:SCMOD:mcs
:SFLNO:018
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:018
:SCPAC:tc
:SCMOD:mcs
:SFLNO:018
:ICOD:S
:QURY:START
select 	 tcmcs018.*
from 	 tcmcs018
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:018
:SCPAC:tc
:SCMOD:mcs
:SFLNO:018
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:036
:SCPAC:tc
:SCMOD:mcs
:SFLNO:036
:ICOD:D
:QURY:START
	 if tcmcs036.extx =  empty then  
 	 	 var.tcmcs036.extx =  tcyesno.no  
 	 else  
 	 	 var.tcmcs036.extx =  tcmcs036.extx  
 	 endif  
 	  
 | #  sp1.sn  
 	 | *  Baan IV Round up (yes /  no). ERP LN: rounding method  
 	 if tcmcs036.rnva =  tcyesno.yes then  
 	 	 | *  Round up  
 	 	 var.tcmcs036.rnva =  3  
 	 else  
 	 	 | *  On the target not rounding up does not mean always round down !   
 	 	 | *  set to default rounding (0.5 is round up; <  0.5 =  round down)  
 	 	 | *  ( =  2 : 'normal')  
 	 	 var.tcmcs036.rnva =  2  
 	 endif  
 | #  sp1.en  
 | #  sp1.so  
 | 	 if tcmcs036.rnva =  empty then  
 | 	 	 var.tcmcs036.rnva =  2 | *  normal, which is default | #  sp1.n  
 | 	 else  
 | 	 	 var.tcmcs036.rnva =  tcmcs036.rnva  
 | 	 endif  
 | #  sp1.eo  
 	  
 	 dump 1  
 	 if tcmcs036.smpl =  tcyesno.yes then 	 	 | #  209288.n  
 	 	 dump 2  
 	 endif 	 	 	 	 	 	 | #  209288.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:036
:SCPAC:tc
:SCMOD:mcs
:SFLNO:036
:ICOD:S
:QURY:START
select 	 tcmcs036.*  , bcstc030.*
from 	 tcmcs036, bcstc030
where 	 tcmcs036.ccty =  bcstc030.ccty  
 and 	 tcmcs036.cvat =  bcstc030.cvat  
 and 	 bcstc030.fcmp =  :current.company 	 | #  210859.n  
 and 	 bcstc030.expi =  tcyesno.no
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:036
:SCPAC:tc
:SCMOD:mcs
:SFLNO:036
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:036
:SCPAC:tc
:SCMOD:mcs
:SFLNO:037
:ICOD:D
:QURY:START
	 dump 3
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:036
:SCPAC:tc
:SCMOD:mcs
:SFLNO:037
:ICOD:S
:QURY:START
select 	 tcmcs037.*
from 	 tcmcs037
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:036
:SCPAC:tc
:SCMOD:mcs
:SFLNO:037
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:052
:SCPAC:bc
:SCMOD:stc
:SFLNO:016
:ICOD:D
:QURY:START
	 var.tcmcs052.seak =  strip$(bcstc016.dsca(1; 16))  
 | #  800 -  142861.sn  
 	 var.tcmcs052.seab =  strip$(bcstc016.dscb(1; 16))  
 | #  800 -  142861.en  
 	 if bcstc016.oprj =  bcstc.oprj.budget or  
 	 bcstc016.oprj =  bcstc.oprj.ti.project then  
 	 	 var.tcmcs052.plnk =  20  
 	 else  
 	 	 var.tcmcs052.plnk =  30  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:052
:SCPAC:bc
:SCMOD:stc
:SFLNO:016
:ICOD:S
:QURY:START
select 	 bcstc016.*
from 	 bcstc016
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:052
:SCPAC:bc
:SCMOD:stc
:SFLNO:016
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:055
:SCPAC:tc
:SCMOD:mcs
:SFLNO:055
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:055
:SCPAC:tc
:SCMOD:mcs
:SFLNO:055
:ICOD:S
:QURY:START
select 	 tcmcs055.*
from 	 tcmcs055
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:055
:SCPAC:tc
:SCMOD:mcs
:SFLNO:055
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:220
:SCPAC:tc
:SCMOD:mcs
:SFLNO:014
:ICOD:D
:QURY:START
	 if tcmcs014.cpay <>  hold.terms.of.payment then  
 	 	 var.tcmcs220.dsca =  sprintf$(form.text$("bcstc00099"), tcmcs014.cpay)  
 	 	 dump 1  
 	 	 hold.terms.of.payment =  tcmcs014.cpay  
 	 endif  
 	 var.tcmcs221.seqn =  get.sequence.number(tcmcs014.cpay)  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:220
:SCPAC:tc
:SCMOD:mcs
:SFLNO:014
:ICOD:S
:QURY:START
select 	 tcmcs014.*  ,  
 	 tcmcs013.*
from 	 tcmcs014, tcmcs013
where 	 tcmcs014.cpay refers to tcmcs013
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:220
:SCPAC:tc
:SCMOD:mcs
:SFLNO:014
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ppl
:TFLNO:060
:SCPAC:bc
:SCMOD:sti
:SFLNO:000
:ICOD:D
:QURY:START
	 if bcsti000.micp =  tcyesno.yes then  
 	 	 dump 1  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ppl
:TFLNO:060
:SCPAC:bc
:SCMOD:sti
:SFLNO:000
:ICOD:S
:QURY:START
select 	 bcsti000.micp, bcsti000.role, bcsti000.rold
from 	 bcsti000  
 as set with 1 rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ppl
:TFLNO:060
:SCPAC:bc
:SCMOD:sti
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ppl
:TFLNO:090
:SCPAC:bc
:SCMOD:sbp
:SFLNO:003
:ICOD:D
:QURY:START


	 | *  The wage rate code is stored as labor rate code in tcppl090  
 	 dump 4  
 	 | *  The rates are stored in table tcppl091  
 	 dump 5
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ppl
:TFLNO:090
:SCPAC:bc
:SCMOD:sbp
:SFLNO:003
:ICOD:S
:QURY:START


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

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ppl
:TFLNO:090
:SCPAC:bc
:SCMOD:sbp
:SFLNO:003
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ppl
:TFLNO:090
:SCPAC:tp
:SCMOD:pdm
:SFLNO:067
:ICOD:D
:QURY:START


	 | *  The wage rate code is stored as labor rate code in tcppl090  
 	 dump 1  
 	 if tppdm067.ltcr <  tppdm067.ltsr then  
 	 	 if tppdm067.ltcr <>  0 then  
 	 	 	 var.tcppl091.ecdt =  utc(tppdm067.ltcr, 0)  
 	 	 else  
 	 	 	 var.tcppl091.ecdt =  utc(JAN_3_1970, 0)  
 	 	 endif  
 	 else  
 	 	 if tppdm067.ltsr <>  0 then  
 	 	 	 var.tcppl091.ecdt =  utc(tppdm067.ltsr, 0)  
 	 	 else  
 	 	 	 var.tcppl091.ecdt =  utc(JAN_3_1970, 0)  
 	 	 endif  
 	 endif  
 	 | *  The rates are stored in table tcppl091  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ppl
:TFLNO:090
:SCPAC:tp
:SCMOD:pdm
:SFLNO:067
:ICOD:S
:QURY:START


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

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ppl
:TFLNO:090
:SCPAC:tp
:SCMOD:pdm
:SFLNO:067
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ppl
:TFLNO:090
:SCPAC:tp
:SCMOD:pdm
:SFLNO:667
:ICOD:D
:QURY:START


	 | *  The wage rate codes are already stored in tcppl090 via migration of tppdm067.  
 	 | *  The project -  related rates are stored in table tcppl092.  
 	 if tppdm667.ltcr <  tppdm667.ltsr then  
 	 	 if tppdm667.ltcr <>  0 then  
 	 	 	 var.tcppl092.ecdt =  utc(tppdm667.ltcr, 0)  
 	 	 else  
 	 	 	 var.tcppl092.ecdt =  utc(JAN_3_1970, 0)  
 	 	 endif  
 	 else  
 	 	 if tppdm667.ltsr <>  0 then  
 	 	 	 var.tcppl092.ecdt =  utc(tppdm667.ltsr, 0)  
 	 	 else  
 	 	 	 var.tcppl092.ecdt =  utc(JAN_3_1970, 0)  
 	 	 endif  
 	 endif  
 	 if double.cmp(tppdm667.cort, 0.0, 0.0001) then  
 	 	 var.tcppl092.crac =  tcyesno.yes  
 	 	 if tppdm667.dcor =  tppdm.yeno.yes then  
 	 	 	 var.tcppl092.dcrt =  tcyesno.yes  
 	 	 else  
 	 	 	 var.tcppl092.dcrt =  tcyesno.no  
 	 	 endif  
 	 else  
 	 	 var.tcppl092.crac =  tcyesno.no  
 	 	 var.tcppl092.dcrt =  tcyesno.no  
 	 endif  
 	 if double.cmp(tppdm667.sart, 0.0, 0.0001) then  
 	 	 var.tcppl092.srac =  tcyesno.yes  
 	 	 if tppdm667.dsar =  tppdm.yeno.yes then  
 	 	 	 var.tcppl092.dsrt =  tcyesno.yes  
 	 	 else  
 	 	 	 var.tcppl092.dsrt =  tcyesno.no  
 	 	 endif  
 	 else  
 	 	 var.tcppl092.srac =  tcyesno.no  
 	 	 var.tcppl092.dsrt =  tcyesno.no  
 	 endif  
 	 dump 3
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ppl
:TFLNO:090
:SCPAC:tp
:SCMOD:pdm
:SFLNO:667
:ICOD:S
:QURY:START


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

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:ppl
:TFLNO:090
:SCPAC:tp
:SCMOD:pdm
:SFLNO:667
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:tax
:TFLNO:400
:SCPAC:bc
:SCMOD:stc
:SFLNO:008
:ICOD:D
:QURY:START
	 | *  Jan 1st, 1992, birth of EU  
 	 var.tctax400.efdt =  727198  
 	 if bcstc008.bpid =  previous.bpid and  
 	 bcstc008.ccty =  previous.ccty then  
 	 	 | *  Skip duplicate keys of tctax400  
 	 	 continue  
 	 endif  
 	 dump 1  
 	 previous.bpid =  bcstc008.bpid  
 	 previous.ccty =  bcstc008.ccty
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:tax
:TFLNO:400
:SCPAC:bc
:SCMOD:stc
:SFLNO:008
:ICOD:S
:QURY:START
select 	 bcstc008.bpid, bcstc008.ccty, bcstc008.fovn
from 	 bcstc008
where 	 bcstc008.fovn <>  ""
order by bcstc008.bpid, bcstc008.ccty, bcstc008.fovn
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:tax
:TFLNO:400
:SCPAC:bc
:SCMOD:stc
:SFLNO:008
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:cms
:TFLNO:050
:SCPAC:td
:SCMOD:cms
:SFLNO:050
:ICOD:D
:QURY:START
| 	 convert.print.date.process.id() 	 	 	 | #  SP2.o  
 	 fill.order.related.data() 	 	 	 	 | #  SP2.sn  
 	 fill.invoice.related.data() 	 	 	 | #  SP2.en  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:cms
:TFLNO:050
:SCPAC:td
:SCMOD:cms
:SFLNO:050
:ICOD:S
:QURY:START
select 	 tdcms010.cupf, tdcms010.rtyp, 	 	 	 | #  SP2.n  
 	 tdcms010.suno, tdcms010.cuno, tdcms050.*  	 | #  SP2.n
from 	 tdcms050, tdcms010
where 	 tdcms010._index1 =  {tdcms050.reln}
order by tdcms050._index5 asc
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:cms
:TFLNO:050
:SCPAC:td
:SCMOD:cms
:SFLNO:050
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:cms
:TFLNO:051
:SCPAC:td
:SCMOD:cms
:SFLNO:051
:ICOD:D
:QURY:START
	 fill.order.related.data() 	 	 	 	 	 |SP2.n  
 	 fill.invoice.related.data() 	 	 	 	 |SP2.n  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:cms
:TFLNO:051
:SCPAC:td
:SCMOD:cms
:SFLNO:051
:ICOD:S
:QURY:START
select 	 tdcms010.cupf, tdcms010.rtyp, 	 	 	 	 | #  SP2.n  
 	 tdcms010.suno, tdcms010.cuno, 	 	 	 | #  SP2.n  
 	 tdcms051.*   
 |from 	 tdcms051 	 	 	 	 	 	 | #  SP2.o
from 	 tdcms051, tdcms010
where 	 tdcms010._index1 =  {tdcms051.reln} 	 	 	 | #  SP2.n
order by tdcms051._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:cms
:TFLNO:051
:SCPAC:td
:SCMOD:cms
:SFLNO:051
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:cms
:TFLNO:060
:SCPAC:td
:SCMOD:cms
:SFLNO:060
:ICOD:D
:QURY:START
	 | *  Records are sorted by tdcms060.crtt, tdcms060.crin in order to  
 	 | *  assign the same values to tdcms060.upid and tdcms060.prdt as  
 	 | *  in the conversion of table tdcms050.  
 	 convert.print.date.process.id()  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:cms
:TFLNO:060
:SCPAC:td
:SCMOD:cms
:SFLNO:060
:ICOD:S
:QURY:START
select 	 tdcms060.*  ,  
 	 tdcms010.rtyp
from 	 tdcms060, tdcms010
where 	 tdcms010._index1 =  {tdcms060.reln}  
 |order by tdcms060.crtt, tdcms060.crin, tdcms060._index1 asc 	 | #  152736.o
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:cms
:TFLNO:060
:SCPAC:td
:SCMOD:cms
:SFLNO:060
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:cms
:TFLNO:100
:SCPAC:td
:SCMOD:cms
:SFLNO:100
:ICOD:D
:QURY:START
	 fill.order.related.data() 	 	 	 	 | #  SP2.sn  
 	 fill.invoice.related.data() 	 	 	 | #  SP2.en  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:cms
:TFLNO:100
:SCPAC:td
:SCMOD:cms
:SFLNO:100
:ICOD:S
:QURY:START
select 	 tdcms010.cupf, tdcms010.rtyp, 	 	 	 | #  SP2.n  
 	 tdcms010.suno, tdcms010.cuno, 	 	 | #  SP2.n  
 	 tdcms100.*
from 	 tdcms100, tdcms010 	 	 	 	 | #  SP2.n  
 | from 	 tdcms100 	 	 	 	 	 | #  SP2.o
where 	 tdcms010._index1 =  {tdcms100.reln} 	 	 | #  SP2.n
order by tdcms100.orno
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:cms
:TFLNO:100
:SCPAC:td
:SCMOD:cms
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:ipu
:TFLNO:001
:SCPAC:ti
:SCMOD:itm
:SFLNO:001
:ICOD:D
:QURY:START
	 convert.purchase.and.price.unit()  
 	 dump 1 | *  Migrate tiitm001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:ipu
:TFLNO:001
:SCPAC:ti
:SCMOD:itm
:SFLNO:001
:ICOD:S
:QURY:START
select 	 tiitm001.*
from 	 tiitm001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:ipu
:TFLNO:001
:SCPAC:ti
:SCMOD:itm
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:ipu
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:002
:ICOD:D
:QURY:START
	 | *  Dump one item record for each Budget Calculation Code in tipcs100.  
 	 | *  Dump one item record if there are no Budget Calculation Codes  
 	 | *  for the budget ( selectempty of query below ) .  
 	 | *  Only if the new project code is filled the record is dumped.  
 	 budg.calc.code =  ""                                                                                                                                                                                                                                                                                            
 	 select 	 tipcs100.bccd:budg.calc.code  
 	 from 	 tipcs100  
 	 where 	 tipcs100._index1 =  {:tipcs002.cbdg}  
 	 selectdo  
 	 	 | *  Construct new project code and new item code.  
 	 	 var.project.code =  get.budget.code(  
 	 	 	 	 	 tipcs002.cbdg,  
 	 	 	 	 	 budg.calc.code)  
 	 	 if not isspace(var.project.code) then  
 	 	 	 var.tdipu001.item =  segment.item.code(  
 	 	 	 	 	 	 	 tipcs002.ccpc,  
 	 	 	 	 	 	 	 var.project.code)  
 	 	 	 dump 4 | *  Migrate tipcs002  
 	 	 endif  
 	 selectempty  
 	 	 | *  Construct new project code and new item code.  
 	 	 var.project.code =  get.budget.code(  
 	 	 	 	 	 tipcs002.cbdg,  
 	 	 	 	 	 budg.calc.code)  
 	 	 if not isspace(var.project.code) then  
 	 	 	 var.tdipu001.item =  segment.item.code(  
 	 	 	 	 	 	 	 tipcs002.ccpc,  
 	 	 	 	 	 	 	 var.project.code)  
 	 	 	 dump 4 | *  Migrate tipcs002  
 	 	 endif  
 	 endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:ipu
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:002
:ICOD:S
:QURY:START
select 	 tipcs002.*  , 	 tiitm001.cwar, tiitm001.csgp, tiitm001.cpgp, tiitm001.qual, tiitm001.oltm
from 	 tipcs002, tiitm001
where 	 tipcs002.dfit refers to tiitm001 unref clear
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:ipu
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:002
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:ipu
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:021
:ICOD:D
:QURY:START
	 var.project.code =  get.project(tipcs021.cprj)  
 	 var.tdipu001.item =  segment.item.code(  
 	 	 	 	 	 tipcs021.item,  
 	 	 	 	 	 var.project.code)  
 	 dump 2 | *  Migrate tipcs021
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:ipu
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:021
:ICOD:S
:QURY:START
select 	 tipcs021.*  , tiitm001.cpgp
from 	 tipcs021, tiitm001
where 	 tipcs021.dfit refers to tiitm001 unref clear  
 and not exists(  
 	 	 select tppdm605.item  
 	 	 from 	 tppdm605  
 	 	 where tppdm605._index1 =  {  
 	 	 	 	 	 tipcs021.cprj,  
 	 	 	 	 	 tipcs021.item})
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:ipu
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:021
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:ipu
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:022
:ICOD:D
:QURY:START
	 if tipcs022.cprj =  g.hold.pcsbom.cprj and  
 	 tipcs022.sitm =  g.hold.pcsbom.sitm then  
 	 	 continue  
 	 endif  
 	 g.hold.pcsbom.cprj =  tipcs022.cprj  
 	 g.hold.pcsbom.sitm =  tipcs022.sitm  
 	 var.project.code =  get.ti.project(tipcs022.cprj)  
 	 var.tdipu001.item =  segment.item.code(  
 	 	 	 	 	 tiitm001.item,  
 	 	 	 	 	 var.project.code)  
 	 convert.purchase.and.price.unit()  
 	 dump 5 | *  Migrate tipcs022
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:ipu
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:022
:ICOD:S
:QURY:START
select 	 tipcs022.cprj, tipcs022.sitm, tipcs022.opol, tipcs022.mitm,  
 	 tipcs022.pono,  
 	 tiitm001.*
from 	 tipcs022, tiitm001  
 | *  Standard items in the customized BOM (Item Category (tipcs022.opol) =   
 | *  Standard Item) and Order Policy (tiitm001.opol) =  To Order, need to be  
 | *  customized.
where 	 tipcs022.opol =  tcittb.standard  
 and 	 tiitm001._index1 =  {tipcs022.sitm}  
 and 	 tiitm001.opol =  tcopol.on.order  
 | *  Do not customize standard items which were already customized before.  
 and not exists( 	 select 	 tipcs021.cprj  
 	 	 from 	 tipcs021  
 	 	 where 	 tipcs021._index1 =  {tipcs022.cprj, tipcs022.sitm})  
 | *  Same standard item can be present more than once in the customized BOM's  
 | *  of one project. So order by Project and Sub Item. Index 2 (opol, cprj, sitm,  
 | *  mitm, pono) is used.
order by tipcs022._index2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:ipu
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:022
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:ipu
:TFLNO:001
:SCPAC:tp
:SCMOD:pdm
:SFLNO:605
:ICOD:D
:QURY:START
	 var.tdipu001.cuqp =  tppdm605.cuqp  
 	 var.tdipu001.cupp =  tppdm605.cupp  
 	 if tppdm605.itmt =  tppdm.itmt.equipment then  
 	 	 eq.item =  left.align(tppdm605.item, 16)  
 	 	 eq.item =  right.align(eq.item, 10)  
 	 	  
 	 	 select tppdm625.cuti  
 	 	 from tppdm625  
 	 	 where tppdm625._index1 =  { 	 :tppdm605.cprj,  
 	 	 	 	 	 	 :eq.item}  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 var.tdipu001.cuqp =  tppdm625.cuti  
 	 	 	 var.tdipu001.cupp =  tppdm625.cuti  
 	 	 endselect  
 	 endif  
 	 if tppdm605.itmt =  tppdm.itmt.subcontracting then  
 	 	 sub.item =  left.align(tppdm605.item, 16)  
 	 	 sub.item =  right.align(sub.item, 8)  
 	 	 select tppdm635.cuti, tppdm635.dsbc, tppdm635.cuni  
 	 	 from tppdm635  
 	 	 where tppdm635._index1 =  { 	 :tppdm605.cprj,  
 	 	 	 	 	 	 :sub.item}  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 if tppdm635.dsbc =  tppdm.dsbc.quantity then  
 	 	 	 	 var.tdipu001.cuqp =  tppdm635.cuni  
 	 	 	 	 var.tdipu001.cupp =  tppdm635.cuni  
 	 	 	 else  
 	 	 	 	 var.tdipu001.cuqp =  tppdm635.cuti  
 	 	 	 	 var.tdipu001.cupp =  tppdm635.cuti  
 	 	 	 endif  
 	 	 endselect  
 	 endif  
 	 var.project.code =  get.tp.project(tppdm605.cprj)  
 	 var.tdipu001.item =  segment.item.code(  
 	 	 	 	 	 tppdm605.item,  
 	 	 	 	 	 var.project.code)  
 	 dump 3 | *  Migrate tppdm605
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:ipu
:TFLNO:001
:SCPAC:tp
:SCMOD:pdm
:SFLNO:605
:ICOD:S
:QURY:START
select 	 tppdm605.*  , tiitm001.buyr, tiitm001.cwar, tiitm001.cpgp
from 	 tppdm605, tiitm001
where 	 tppdm605.dfit refers to tiitm001 unref clear
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:ipu
:TFLNO:001
:SCPAC:tp
:SCMOD:pdm
:SFLNO:605
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:ipu
:TFLNO:002
:SCPAC:ti
:SCMOD:itm
:SFLNO:002
:ICOD:D
:QURY:START
	 var.tdipu002.otbp =  ""                
 	 if not get.business.partner(tiitm002.suno, bcstc.orgn.suno, errmess) then  
 	 	 var.tdipu002.otbp =  bcstc008.bpid  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:ipu
:TFLNO:002
:SCPAC:ti
:SCMOD:itm
:SFLNO:002
:ICOD:S
:QURY:START
select 	 tiitm002.*
from 	 tiitm002
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:ipu
:TFLNO:002
:SCPAC:ti
:SCMOD:itm
:SFLNO:002
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:000
:SCPAC:td
:SCMOD:pur
:SFLNO:000
:ICOD:D
:QURY:START
	 	 var.tdpur000.indt =  utc(0,0)  
 	 	 var.tdpur000.dsca =  form.text$("bcstc00035")  
 	 	 | *  Actual Set  
 	 	 dump 1  
 	 	 var.tdpur000.indt =  utc(date.num(), time.num())  
 	 	 var.tdpur000.dsca =  form.text$("bcstc00036")  
 	 	 | *  Converted from BaanIVc4  
 	 	 dump 1  
 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:000
:SCPAC:td
:SCMOD:pur
:SFLNO:000
:ICOD:S
:QURY:START
select 	 tdpur000.*
from 	 tdpur000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:000
:SCPAC:td
:SCMOD:pur
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:060
:SCPAC:bc
:SCMOD:std
:SFLNO:004
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:060
:SCPAC:bc
:SCMOD:std
:SFLNO:004
:ICOD:S
:QURY:START
select 	 bcstd004.*
from 	 bcstd004
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:060
:SCPAC:bc
:SCMOD:std
:SFLNO:004
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:094
:SCPAC:tc
:SCMOD:mcs
:SFLNO:042
:ICOD:D
:QURY:START
| 	 set.mem(var.tdpur094.pmsk, "n", 20) 	  	  	 |# FP3.so  
 | 	 select 	 bcstd004.acno  
 | 	 from 	 bcstd004  
 | 	 where 	 bcstd004._index1 =  {:tcmcs042.cotp}  
 | 	 selectdo  
 | 	 	 var.tdpur094.pmsk(bcstd004.acno;1) =  "y"    
 | 	 endselect 	 	 	 	 	 	 | # FP3.eo  
 	 get.new.order.type(  
 	 	 bcosrc.pur,  
 	 	 tcmcs042.cotp,  
 	 	 err.mess) 	  
 	 var.tdpur094.wrhp =  bcswh003.ntyp  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:094
:SCPAC:tc
:SCMOD:mcs
:SFLNO:042
:ICOD:S
:QURY:START
select 	 tcmcs042.*
from 	 tcmcs042
where 	 tcmcs042.modc =  tcmodc.pur
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:094
:SCPAC:tc
:SCMOD:mcs
:SFLNO:042
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:100
:SCPAC:td
:SCMOD:pur
:SFLNO:001
:ICOD:D
:QURY:START
	 dump 1  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:100
:SCPAC:td
:SCMOD:pur
:SFLNO:001
:ICOD:S
:QURY:START
select 	 tdpur001.*
from 	 tdpur001
order by tdpur001._index2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:100
:SCPAC:td
:SCMOD:pur
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:101
:SCPAC:td
:SCMOD:pur
:SFLNO:002
:ICOD:D
:QURY:START
	 dump 1  
 	 convert.tax()  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:101
:SCPAC:td
:SCMOD:pur
:SFLNO:002
:ICOD:S
:QURY:START
select 	 tdpur002.*  ,  
 	 tdpur001.cdec, tdpur001.comp, 	 	 	 	 | #  SP2.n  
 	 tdpur001.suno, tdpur001.ccor, tdpur001.ccur, tdpur001.qdat,  
 	 tdpur001.ratp, tdpur001.ratf, tdpur001.odis
from 	 tdpur002, tdpur001
where 	 tdpur001._index1 =  {tdpur002.qono}
order by tdpur002._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:101
:SCPAC:td
:SCMOD:pur
:SFLNO:002
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:150
:SCPAC:td
:SCMOD:pur
:SFLNO:010
:ICOD:D
:QURY:START
	 dump 1  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:150
:SCPAC:td
:SCMOD:pur
:SFLNO:010
:ICOD:S
:QURY:START
select 	 tdpur010.*
from 	 tdpur010
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:150
:SCPAC:td
:SCMOD:pur
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:151
:SCPAC:td
:SCMOD:pur
:SFLNO:011
:ICOD:D
:QURY:START
| 	 select 	 tdpur010._index1, 	 	 | #  213903.so  
 | 	 	 tdpur010.comp 	 	 	 | #  213903.eo  
 	 | *  Fields from tdpur010 are used in bcintdll1100.  
 	 select 	 tdpur010.*  	 	 	 | #  213903.n  
 	 from 	 tdpur010  
 	 where 	 tdpur010._index1 =  {:tdpur011.qono}  
 	 order by tdpur010._index1 desc  
 	 as set with 1 rows  
 	 selectdo  
 	 endselect  
 	 dump 1 	 	 | *  tdpur151  
 	 convert.tax() 	 	 	 	 | #  SP2.o | #  210859.n  
 	 dump 2 	 	 | *  tdpur156
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:151
:SCPAC:td
:SCMOD:pur
:SFLNO:011
:ICOD:S
:QURY:START
select 	 tdpur011.*
from 	 tdpur011
order by tdpur011._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:151
:SCPAC:td
:SCMOD:pur
:SFLNO:011
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:300
:SCPAC:td
:SCMOD:pur
:SFLNO:300
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:300
:SCPAC:td
:SCMOD:pur
:SFLNO:300
:ICOD:S
:QURY:START
select 	 tdpur300.*
from 	 tdpur300
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:300
:SCPAC:td
:SCMOD:pur
:SFLNO:300
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:301
:SCPAC:td
:SCMOD:pur
:SFLNO:301
:ICOD:D
:QURY:START
	 read.contract.header.data() 	 	 	 | #  206214.sn  
 	 read.supplier.data()  
 	 get.advised.and.called.quantity(  
 	 	 var.tdpur301.qiap,  
 	 	 var.tdpur301.qicl) 	 	 	 | #  206214.en  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:301
:SCPAC:td
:SCMOD:pur
:SFLNO:301
:ICOD:S
:QURY:START
select 	 tdpur301.*  	 	 	 	 	 | #  206214.sn
from 	 tdpur301
order by tdpur301.suno, tdpur301._index1 	 	 | #  206214.en  
 |select 	 tdpur300.*  , tdpur301.*  	 	 	 | #  206214.so  
 |from 	 tdpur300, tdpur301  
 |where 	 tdpur300._index1 =  {tdpur301.cono} 	 | #  206214.eo
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:301
:SCPAC:td
:SCMOD:pur
:SFLNO:301
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:350
:SCPAC:td
:SCMOD:pur
:SFLNO:305
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:350
:SCPAC:td
:SCMOD:pur
:SFLNO:305
:ICOD:S
:QURY:START
select 	 tdpur305.*
from 	 tdpur305
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:350
:SCPAC:td
:SCMOD:pur
:SFLNO:305
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:351
:SCPAC:td
:SCMOD:pur
:SFLNO:306
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:351
:SCPAC:td
:SCMOD:pur
:SFLNO:306
:ICOD:S
:QURY:START
select tdpur306.*
from tdpur306
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:351
:SCPAC:td
:SCMOD:pur
:SFLNO:306
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:400
:SCPAC:td
:SCMOD:pur
:SFLNO:040
:ICOD:D
:QURY:START
	 read.purchase.order.type()  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:400
:SCPAC:td
:SCMOD:pur
:SFLNO:040
:ICOD:S
:QURY:START
select 	 tdpur040.*
from 	 tdpur040
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:400
:SCPAC:td
:SCMOD:pur
:SFLNO:040
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:401
:SCPAC:td
:SCMOD:pur
:SFLNO:045
:ICOD:D
:QURY:START
	 initialize.prev.variables()  
 	 read.item.data()  
 	 if g.item.type <>  tckitm.cost and 	 	 	 | #  203846.sn  
 	 g.item.type <>  tckitm.service and  
 	 tdpur041.oqua =  0 and  
 	 tdpur045.date =  0 then  
 	 	 | *  It's not possible anymore in SSA ERP LN to  
 	 	 | *  purchase stock keeping items with an ordered  
 	 	 | *  quantity of zero. So order lines that are not  
 	 	 | *  received yet, are not migrated.  
 	 	 continue  
 	 endif 	 	 	 	 	 	 	 | #  203846.en  
 	 read.purchase.order.and.related.data()  
 	 g.order.activity =  true 	 	 	 	 	 | #  FP3.sn  
 	 fill.purchase.order.activities()  
 	 g.order.activity =  false 	 	 	 	 	 | #  FP3.en  
 	 g.no.of.receipt.lines =  get.number.of.receipt.lines()  
 	 var.receipt.number =  get.receipt.number() 	 	 | #  205206.n  
 	  
 	 | *  Insert Order Line  
 	 | *************************************************************   
 	 | *  The following line types will be inserted in tdpur401 in  
 	 | *  the next cases:  
 	 | *  1. Only one record in tdpur045 with srnb =  0:  
 	 | *  	 	 	 1 order line  
 	 | *  2. A record in tdpur045 with srnb =  0 and a record with  
 	 | *  srnb =  1: 	 1 order line  
 	 | *  3. A record in tdpur045 with srnb =  0, a record with  
 	 | *  srnb =  1 and a record with srnb =  2:  
 	 | *  	 	 	 1 total line  
 	 | *  	 	 	 1 detail line  
 	 | *  	 	 	 1 backorder line  
 	 | *************************************************************   
 	 if g.no.of.receipt.lines =  0 or  
 	 tdpur045.srnb <>  0 then  
 	 	 dump 1 	 | *  tdpur401  
 	 	 if linked.order.line.data.present() then  
 	 	 	 dump 2 	 | *  tdpur402  
 	 	 endif  
 	 	 	 	 	 	 	 	 | #  SP2.sn  
 	 	 if get.order.line.type() =  target(tdgen.oltp.orderline) then  
 	 	 	 | *  tdpur411 is only created for type 'order line' and  
 	 	 	 | *  for type 'total'. For type 'total', see section  
 	 	 	 | *  'Insert Total Line'.  
 	 	 	 dump 4 	 | *  tdpur411  
 	 	 endif 	 	 	 	 	 	 | #  SP2.en  
 	 	 fill.purchase.order.line.activities() 	 	 | #  FP3.n  
 	 endif  
 	 | *  Insert Total Line  
 	 if tdpur045.srnb =  0 and  
 	 g.no.of.receipt.lines >  1 then  
 	 	 | *  When there is more than one receipt, then there  
 	 	 | *  is a backorder line, so a total line must be  
 	 	 | *  created.  
 	 	 g.total.line =  true  
 	 	 get.total.line.values()  
 	 	 dump 1 	 | *  tdpur401  
 	 	 	 	 	 	 	 	 | #  SP2.sn  
 	 	 | *  tdpur411 will be connected to the total.  
 	 	 dump 4 	 | *  tdpur411  
 	 	 	 	 	 	 	 	 | #  SP2.en  
 	 	 g.total.line =  false  
 	 endif  
 	  
 	 | *  Insert extra Backorder Line for Direct Delivery  
 	 if tdpur045.srnb =  g.last.sequence.number and  
 	 g.extra.bo.line.must.be.inserted then  
 	 	 g.extra.dir.del.bo.line =  true  
 	 	 dump 1 	 | *  tdpur401  
 	 	 dump 2 	 | *  tdpur402  
 	 	 fill.purchase.order.line.activities() 	 	 | #  FP3.n  
 	 	 g.extra.dir.del.bo.line =  false  
 	 endif  
 	 | *  Insert Actual Receipt  
 	 if tdpur045.date <>  0 then  
 	 	 | *  When the actual receipt date is filled, a receipt  
 	 	 | *  is done and a record in tdpur406 must be entered.  
 	 	 dump 3 	 | *  tdpur406  
 	 	 dump 5 	 | *  tdpur456  
 	 endif  
 	  
 	 g.pot.bo.qty =  get.potential.backorder.quantity(g.prev.bqua)  
 	 g.prev.bqua =  tdpur045.bqua  
 	 g.prev.amld =  tdpur045.ldam  
 	 g.prev.amod =  tdpur045.odam
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:401
:SCPAC:td
:SCMOD:pur
:SFLNO:045
:ICOD:S
:QURY:START
select 	 tdpur045.*  , tdpur041.*
from 	 tdpur045, tdpur041
where 	 tdpur041._index1 =  { 	 tdpur045.orno,  
 	 	 	 	 tdpur045.pono}
order by tdpur045._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:401
:SCPAC:td
:SCMOD:pur
:SFLNO:045
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:450
:SCPAC:td
:SCMOD:pur
:SFLNO:050
:ICOD:D
:QURY:START
	 var.tdpur450.address =  get.bp.address()  
 	 var.tdpur450.contact =  get.bp.contact()  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:450
:SCPAC:td
:SCMOD:pur
:SFLNO:050
:ICOD:S
:QURY:START
select 	 tdpur050.*
from 	 tdpur050
order by tdpur050._index1 desc 	 	 	 	 | #  210077.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:450
:SCPAC:td
:SCMOD:pur
:SFLNO:050
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:451
:SCPAC:td
:SCMOD:pur
:SFLNO:051
:ICOD:D
:QURY:START
	 read.purchase.order.history()  
 	 read.item.data()  
 	 dump 1 	 | *  tdpur451
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:451
:SCPAC:td
:SCMOD:pur
:SFLNO:051
:ICOD:S
:QURY:START
select 	 tdpur051.*
from 	 tdpur051
order by tdpur051._index1 desc
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:pur
:TFLNO:451
:SCPAC:td
:SCMOD:pur
:SFLNO:051
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:060
:SCPAC:bc
:SCMOD:std
:SFLNO:001
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:060
:SCPAC:bc
:SCMOD:std
:SFLNO:001
:ICOD:S
:QURY:START
select bcstd001.*
from bcstd001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:060
:SCPAC:bc
:SCMOD:std
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:094
:SCPAC:tc
:SCMOD:mcs
:SFLNO:042
:ICOD:D
:QURY:START
| 	 set.mem(var.tdsls094.pmsk, "n", 20)  	    	    	  |#  FP3.so    
 | 	 select 	 bcstd001.acno  
 | 	 from 	 	 bcstd001  
 | 	 where 	 bcstd001._index1 =  {:tcmcs042.cotp}  
 | 	 selectdo  
 | 	 	 var.tdsls094.pmsk(bcstd001.acno;1) =  "y"                                                                          
 | 	 endselect 	 	 	 	 	 	 | #  FP3.eo  
 	 get.new.order.type(  
 	 	 	 bcosrc.sls,  
 	 	 	 tcmcs042.cotp,  
 	 	 	 err.mess) 	  
 	 var.tdsls094.wrhp =  bcswh003.ntyp  
 	 var.tdsls094.blcs =  empty()  
 	 select tcmcs039.sess  
 	 from 	 tcmcs039  
 	 where tcmcs039._index2 =  {tcmodc.sls, :tcmcs042.blcs}  
 	 as set with 1 rows  
 	 selectdo 	  
 	 	 if shiftl$(strip$(tcmcs039.sess)) =  "tdilc4201m000" or                                                                          
 	 	 shiftl$(strip$(tcmcs039.sess)) =  "tdilc4202m000" or                                                                          
 	 	 shiftl$(strip$(tcmcs039.sess)) =  "tdsls4120m000" or                                                                          
 	 	 shiftl$(strip$(tcmcs039.sess)) =  "tdsls4402m000" or                                                                          
 	 	 shiftl$(strip$(tcmcs039.sess)) =  "tdsls4403m000" then                                                                          
 	 	 	 var.tdsls094.blcs =  "tdsls4246m000"                                                                          
 	 	 endif  
 	 	 if shiftl$(strip$(tcmcs039.sess)) =  "tdsls4223m000" or                                                                          
 	 	 shiftl$(strip$(tcmcs039.sess)) =  "tdsls4240m000" or                                                                          
 	 	 shiftl$(strip$(tcmcs039.sess)) =  "tdsls4401m000" then                                                                          
 	 	 	 var.tdsls094.blcs =  tcmcs039.sess  
 	 	 endif  
 	 endselect  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:094
:SCPAC:tc
:SCMOD:mcs
:SFLNO:042
:ICOD:S
:QURY:START
select tcmcs042.*
from tcmcs042
where tcmcs042.modc =  tcmodc.sls
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:094
:SCPAC:tc
:SCMOD:mcs
:SFLNO:042
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:100
:SCPAC:td
:SCMOD:sls
:SFLNO:001
:ICOD:D
:QURY:START
	 var.tdsls100.business.partner =  get.business.partner.code(  
 	 	 	 	 	 	 	 tdsls001.cuno,  
 	 	 	 	 	 	 	 bcstc.orgn.cuno,  
 	 	 	 	 	 	 	 o.errmess)  
 	 ret =  get.cross.reference.for.contact.code(  
 	 	 	 	 	 "tccom010a",                                                  
 	 	 	 	 	 tdsls001.cuno,  
 	 	 	 	 	 o.errmess)  
 	  
 	 set.freight.invoice.fields()  
 	 | *  Set var.tdsls100.frin and var.tdsls100.infr  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:100
:SCPAC:td
:SCMOD:sls
:SFLNO:001
:ICOD:S
:QURY:START
select tdsls001.*
from tdsls001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:100
:SCPAC:td
:SCMOD:sls
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:101
:SCPAC:td
:SCMOD:sls
:SFLNO:002
:ICOD:D
:QURY:START
	 e =  get.tax.by.country.code.and.financial.company(  
 	 	 tdsls002.ccty,  
 	 	 tdsls002.cvat,  
 	 	 tdsls001.comp,  
 	 	 var.tdsls101.ccty,  
 	 	 var.tdsls101.cvat,  
 	 	 g.error.mess)  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:101
:SCPAC:td
:SCMOD:sls
:SFLNO:002
:ICOD:S
:QURY:START
select 	 tdsls002.*  ,  
 	 tdsls001.comp, tdsls001.cdec, tdsls001.scom,  
 	 tdsls001.cdel 	
from 	 tdsls002
where 	 tdsls001._index1 =  {tdsls002.qono}
order by tdsls002._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:101
:SCPAC:td
:SCMOD:sls
:SFLNO:002
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:150
:SCPAC:td
:SCMOD:sls
:SFLNO:010
:ICOD:D
:QURY:START
	 var.tdsls150.business.partner =  get.business.partner.code(  
 	 	 	 	 	 	 	 tdsls010.cuno,  
 	 	 	 	 	 	 	 bcstc.orgn.cuno,  
 	 	 	 	 	 	 	 o.errmess)  
 	 ret =  get.cross.reference.for.contact.code("tccom010a",  
 	 	 	 	 	 tdsls010.cuno,  
 	 	 	 	 	 o.errmess)  
 	  
 	 set.freight.invoice.fields()  
 	 | *  Set var.tdsls150.frin and var.tdsls150.infr  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:150
:SCPAC:td
:SCMOD:sls
:SFLNO:010
:ICOD:S
:QURY:START
select tdsls010.*
from tdsls010
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:150
:SCPAC:td
:SCMOD:sls
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:151
:SCPAC:td
:SCMOD:sls
:SFLNO:011
:ICOD:D
:QURY:START
	 var.tdsls151.stad =  convert.address(  
 	 	 	 tdsls011.cdel,  
 	 	 	 tdsls011.cuno,  
 	 	 	 tdsls011.qono,  
 	 	 	 0,  
 	 	 	 0)  
 	 e =  get.tax.by.country.code.and.financial.company(  
 	 	 tdsls011.ccty,  
 	 	 tdsls011.cvat,  
 	 	 tdsls010.comp,  
 	 	 var.tdsls151.ccty,  
 	 	 var.tdsls151.cvat,  
 	 	 g.error.mess)  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:151
:SCPAC:td
:SCMOD:sls
:SFLNO:011
:ICOD:S
:QURY:START
select 	 tdsls011.*  ,  
 	 tdsls010.comp, tdsls010.cdec, tdsls010.scom,  
 	 tdsls010.cdel 	 	 	
from 	 tdsls011,  
 	 tdsls010 	 	 	
where 	 tdsls010._index1 =  {tdsls011.qono}
order by tdsls011._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:151
:SCPAC:td
:SCMOD:sls
:SFLNO:011
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:300
:SCPAC:td
:SCMOD:sls
:SFLNO:300
:ICOD:D
:QURY:START
	 read.customer() 	 	 	 	 | #  Sp2.n  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:300
:SCPAC:td
:SCMOD:sls
:SFLNO:300
:ICOD:S
:QURY:START
select tdsls300.*
from tdsls300
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:300
:SCPAC:td
:SCMOD:sls
:SFLNO:300
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:301
:SCPAC:td
:SCMOD:sls
:SFLNO:301
:ICOD:D
:QURY:START
	 read.customer() 	 	 	 	  
 	 convert.tax() 	 	 	 	 	  
 	 var.discount.schedule1 =  get.discount.schedule(1)  
 	 var.discount.schedule2 =  get.discount.schedule(2)  
 	 var.discount.schedule3 =  get.discount.schedule(3)  
 	 var.contract.pricebook =  get.pricebook()  
 	 | *  1st array element of the discount schedule array in target version  
 	 | *  cannot be empty.  
 	 if isspace(var.discount.schedule2) then  
 	 	 var.discount.schedule2 =  var.discount.schedule3  
 	 	 var.discount.schedule3 =  ""                                                                                                            
 	 endif  
 	 if isspace(var.discount.schedule1) then  
 	 	 var.discount.schedule1 =  var.discount.schedule2  
 	 	 var.discount.schedule2 =  var.discount.schedule3  
 	 	 var.discount.schedule3 =  ""                                                                                                            
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:301
:SCPAC:td
:SCMOD:sls
:SFLNO:301
:ICOD:S
:QURY:START
select 	 tdsls300.sdat, tdsls300.edat, tdsls300.icap,  
 	 tdsls300.cdec, 	 	 	 	 	  
 	 tdsls301.*
from 	 tdsls300, tdsls301
where 	 tdsls300._index1 =  {tdsls301.cono}
order by tdsls301._index1  
 | *  Order by required to get the price books and discount schedules  
 | *  in PCG and in Sales Contract Lines in synch.
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:301
:SCPAC:td
:SCMOD:sls
:SFLNO:301
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:350
:SCPAC:td
:SCMOD:sls
:SFLNO:305
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:350
:SCPAC:td
:SCMOD:sls
:SFLNO:305
:ICOD:S
:QURY:START
select 	 tdsls305.*
from 	 tdsls305
order by tdsls305.cono
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:350
:SCPAC:td
:SCMOD:sls
:SFLNO:305
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:351
:SCPAC:td
:SCMOD:sls
:SFLNO:306
:ICOD:D
:QURY:START
	 read.sales.contract.header.history()  
 	 convert.tax()  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:351
:SCPAC:td
:SCMOD:sls
:SFLNO:306
:ICOD:S
:QURY:START
select 	 tdsls306.*
from 	 tdsls306
order by tdsls306._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:351
:SCPAC:td
:SCMOD:sls
:SFLNO:306
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:400
:SCPAC:td
:SCMOD:sls
:SFLNO:040
:ICOD:D
:QURY:START
	 set.freight.invoice.fields()  
 	 | *  Set var.tdsls400.frin and var.tdsls400.infr  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:400
:SCPAC:td
:SCMOD:sls
:SFLNO:040
:ICOD:S
:QURY:START
select tdsls040.*
from tdsls040
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:400
:SCPAC:td
:SCMOD:sls
:SFLNO:040
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
: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()  
 	 read.item.data() 	 	 	 	  
 	 g.total.line =  false  
 	 var.shipment =  ""                                 	                                                                  	                                                                  	                                                                  	                                 |#                                 SL204550.sn                                                                  
 	 var.shipment.line =  0  
 	 | *  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  
 	 | *  Dump1 For tdsls401:  
 	 | *  	 	 -  Total lines  
 	 | *  	 	 -  Detail lines (sqnb =  0)  
 	 | *  	 	 -  Backorder lines (sqnb >  0)  
 	 | *  Dump2 For tdsls402:  
 	 | *  	 	 -  Linked order line data  
 	 | *  Dump3 For tdsls406:  
 	 | *  	 	 -  Actual order lines (tdsls045.date <>  0)  
 	 | *  Dump4 For tcibd410:  
 	 | *  	 	 -  Lot and serial set for the actual delivery line  
 	 | *  Dump5 For tcibd411:  
 	 | *  	 	 -  Lot and serial set detail for the actual delivery line  
 	 | *  Dump6 For tdsls409:  
 	 | *  	 	 -  actual cogs record for the actual delivery line (1:1)  
 	 | *  Dump7 For tdsls411:  
 	 | *  	 	 -  Sales order line item data  
 	 | *  Dump8 For tdsls413:  
 	 | *  	 	 -  Sales order line activities  
 	 | *  Dump9 For tdsls415:  
 	 | *  	 	 -  Sales order Estimated COGS  
 	 | *************************************************************   
 	  
 	 g.order.activity =  true 	 	 	 	 | #  FP3.sn  
 	 fill.sales.order.activities()  
 	 | *  This function performs a dump 8 for the order header.  
 	 g.order.activity =  false 	 	 	 	 | #  FP3.en  
 	  
 	 if g.ilc.implemented then  
 	 	 migrate.outbound.data.to.sales.order.deliveries()  
 	 	 | *  This function will perform a dump1 and dump2  
 	 	 | *  for each tdilc401 record.  
 	 	 fill.sales.order.line.activities() 	 	 | #  FP #  .sn  
 	 	 | *  This function performs a dump 8 for the order line  
 	 	 dump 9 | *  tdsls415 Sales Order Estimated COGS  
 	 	 	 	 	 	 	 	 | #  FP3.en  
 	 else  
 	 	 determine.var.shpm.and.shln()  
 	 	 dump 1 | *  tdsls401 (convert detail or backorder record)  
 	 	 if convert.linked.order.line.data() then  
 	 	 	 dump 2 | *  tdsls402 (linked order line data)  
 	 	 endif  
 	 	 fill.sales.order.line.activities() 	 	 | #  FP3.sn  
 	 	 | *  This function performs a dump 8 for the order line  
 	 	 dump 9 | *  tdsls415 Sales Order Estimated COGS  
 	 	 	 	 	 	 	 	 | #  FP3.en  
 	 endif  
 	 | *  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()  
 	 	 determine.var.shpm.and.shln()  
 	 	 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 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  
 	 	 if isspace(var.shipment) then  
 	 	 	 determine.var.shpm.and.shln()  
 	 	 endif  
 	 	 dump.actual.delivery()  
 	 endif  
 	 	 	 	 	 	 	 	  
 	 | *  tdsls411 will always be created for sequence 0 (total or detail).  
 	 dump 7 	 | *  tdsls411 -  Sales order line item data  
 	 	 	 	 	 	 	 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:401
:SCPAC:td
:SCMOD:sls
:SFLNO:045
:ICOD:S
:QURY:START
select 	 tdsls045.*  , tdsls041.*  ,  
 	 tdsls045.orno 	 	 	 	 	 | #  FP3.n  
 	 | *  Select tdsls045.orno explicitly: This forces the Query  
 	 | *  Optimization in Conversion  
 	 | *  Build to remain the select on tdsls045.*  . This is needed  
 	 | *  for variable and full cost price field selection in  
 	 | *  controlling. (Fields are used in bc -  package only).
from 	 tdsls045, tdsls041
where 	 tdsls041._index1 =  { 	 tdsls045.orno,  
 	 	 	 	 tdsls045.pono}
order by tdsls045._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:401
:SCPAC:td
:SCMOD:sls
:SFLNO:045
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:410
:SCPAC:td
:SCMOD:sls
:SFLNO:048
:ICOD:D
:QURY:START
	 read.sales.order.data(tdsls048.orno)  
 	 convert.tax() 	 	 	  
 	 dump 3
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:410
:SCPAC:td
:SCMOD:sls
:SFLNO:048
:ICOD:S
:QURY:START
select 	 tdsls048.*
from 	 tdsls048
order by tdsls048._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:410
:SCPAC:td
:SCMOD:sls
:SFLNO:048
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:410
:SCPAC:tf
:SCMOD:cmg
:SFLNO:600
:ICOD:D
:QURY:START
	 read.sales.order.data(tfcmg600.orno)  
 	 setvar.tdsls410.ccty() 	 	 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:410
:SCPAC:tf
:SCMOD:cmg
:SFLNO:600
:ICOD:S
:QURY:START
select 	 tfcmg600.*
from 	 tfcmg600
order by tfcmg600._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:410
:SCPAC:tf
:SCMOD:cmg
:SFLNO:600
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:410
:SCPAC:tf
:SCMOD:cmg
:SFLNO:602
:ICOD:D
:QURY:START
	 read.sales.order.data(tfcmg602.orno)  
 	 setvar.tdsls410.ccty() 	 	 	  
 	 convert.invoice.date()  
 	 g.amnt.to.be.settled =  tfcmg602.amta  
 	 var.tdsls410.srna =  1  
 	 var.tdsls410.srnb =  0  
 	 while g.amnt.to.be.settled >  0  
 	 	 g.amnt.settled =  false  
 	 	 while not g.amnt.settled  
 	 	 	 select 	 tfcmg600.amdu:g.amnt.can.be.settled  
 	 	 	 from 	 tfcmg600  
 	 	 	 where 	 tfcmg600.orno =  :tfcmg602.orno  
 	 	 	 and 	 tfcmg600.srno =  :var.tdsls410.srna  
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 selectempty  
 	 	 	 	 g.amnt.can.be.settled =  0.0  
 	 	 	 endselect  
 	 	 	 if g.amnt.can.be.settled >  0 then  
 	 	 	 	 g.amnt.settled =  true  
 	 	 	 else  
 	 	 	 	 var.tdsls410.srna =  var.tdsls410.srna +  1  
 	 	 	 endif  
 	 	 endwhile  
 	 	 if g.amnt.settled then  
 	 	 	 var.tdsls410.srnb =  var.tdsls410.srnb +  1  
 	 	 	 if g.amnt.can.be.settled <  g.amnt.to.be.settled then  
 	 	 	 	 var.tdsls410.amta =  g.amnt.can.be.settled  
 	 	 	 else  
 	 	 	 	 var.tdsls410.amta =  g.amnt.to.be.settled  
 	 	 	 endif  
 	 	 	 dump 2  
 	 	 endif  
 	 	 g.amnt.to.be.settled =  g.amnt.to.be.settled -  var.tdsls410.amta  
 	 	 var.tdsls410.srna =  var.tdsls410.srna +  1  
 	 endwhile
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:410
:SCPAC:tf
:SCMOD:cmg
:SFLNO:602
:ICOD:S
:QURY:START
select 	 tfcmg602.*
from 	 tfcmg602
where 	 tfcmg602.invn >  0
order by tfcmg602.orno
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:410
:SCPAC:tf
:SCMOD:cmg
:SFLNO:602
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:450
:SCPAC:td
:SCMOD:sls
:SFLNO:050
:ICOD:D
:QURY:START
	 | *  Determine Business patner based upon tdsls050.cuno and bcstc008  
 	 var.tdsls450.business.partner =  get.business.partner.code(  
 	 	 	 	 	 	 	 tdsls050.cuno,  
 	 	 	 	 	 	 	 bcstc.orgn.cuno,  
 	 	 	 	 	 	 	 o.errmess)  
 	 | *  Determine Address based upon tdsls040.ccor (postal address) and bcstc004  
 	 var.tdsls450.adress =  convert.sales.address(  
 	 	 	 	 	 	 tdsls050.ccor,  
 	 	 	 	 	 	 tdsls050.cuno,  
 	 	 	 	 	 	 tdsls050.orno,  
 	 	 	 	 	 	 0,  
 	 	 	 	 	 	 1)  
 	 | *  Determine Business Partner Contact based upon tdsls050.cper and bcstc005  
 	 var.tdsls450.contact =  get.contact(tdsls050.cuno, tdsls050.cper)  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:450
:SCPAC:td
:SCMOD:sls
:SFLNO:050
:ICOD:S
:QURY:START
select tdsls050.*
from tdsls050
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:450
:SCPAC:td
:SCMOD:sls
:SFLNO:050
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:451
:SCPAC:td
:SCMOD:sls
:SFLNO:051
:ICOD:D
:QURY:START
	 read.sales.order.header.history()  
 	 read.item.data()  
 	 convert.tax() 	 	 	 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:451
:SCPAC:td
:SCMOD:sls
:SFLNO:051
:ICOD:S
:QURY:START
select 	 tdsls051.*  ,  
 	 tdsls051.orno 	 	 	 	 	 | #  FP3.n  
 | *  Select tdsls051.orno explicitly: This forces the Query Optimization in Conversion  
 | *  Build to remain the select on tdsls051.*  . This is needed for variable and full  
 | *  cost price field selection in controlling. (Fields are used in bc -  package only)
from 	 tdsls051
order by tdsls051._index1 desc
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:td
:TCMOD:sls
:TFLNO:451
:SCPAC:td
:SCMOD:sls
:SFLNO:051
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:000
:SCPAC:tf
:SCMOD:acp
:SFLNO:000
:ICOD:D
:QURY:START
ret.long =  get.addresses(  
 	 	 	 "tfacp000",                                                                                                  
 	 	 	 str$(tfacp000.sern),  
 	 	 	 error.message)  
 	 ret.long =  get.bank.code(  
 	 	 	 "tfacp000",                                                                                                  
 	 	 	 str$(tfacp000.sern),  
 	 	 	 error.message)  
 	  
 	 var.tfacp000.aspe =  get.default.serie(tfacp000.ttap)  
 	 if isspace(tfacp000.vacc) then  
 	 	 var.tfacp000.naet =  target(tcyesno.no)  
 	 else  
 	 	 var.tfacp000.naet =  target(tcyesno.yes)  
 	 endif 	  
 	 	  
 	 var.tfacp000.indt =  utc(0,0)  
 	 var.tfacp000.dsca =  form.text$("bcstc00035") 	 | *  Actual Set  
 	 dump 1  
 	 var.tfacp000.indt =  utc(date.num(), time.num())  
 	 var.tfacp000.dsca =  form.text$("bcstc00036") 	 | *  Converted from BaanIVc4  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:000
:SCPAC:tf
:SCMOD:acp
:SFLNO:000
:ICOD:S
:QURY:START
select 	 tfacp000.*
from 	 tfacp000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:000
:SCPAC:tf
:SCMOD:acp
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:001
:SCPAC:tf
:SCMOD:acp
:SFLNO:001
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:001
:SCPAC:tf
:SCMOD:acp
:SFLNO:001
:ICOD:S
:QURY:START
select tfacp001.*
from tfacp001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:001
:SCPAC:tf
:SCMOD:acp
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:006
:SCPAC:tf
:SCMOD:acp
:SFLNO:006
:ICOD:D
:QURY:START
	 if tfacp006.lppd =  100.00 then 	 | *  Indicates full authorization, Lower amount  
 	 	 var.tfacp006.falo =  etol(tcyesno.yes)  
 	 	 var.tfacp006.lppd =  0  
 	 	 var.tfacp006.lapd =  0.0  
 	 else  
 	 	 var.tfacp006.falo =  etol(tcyesno.no)  
 	 	 var.tfacp006.lppd =  round(tfacp006.lppd, 0, 1)  
 	 	 var.tfacp006.lapd =  tfacp006.lapd  
 	 endif  
 	 if tfacp006.hppd =  100.00 then 	 | *  Indicates full authorization, Higher Amount  
 	 	 var.tfacp006.fahi =  etol(tcyesno.yes)  
 	 	 var.tfacp006.hppd =  0  
 	 	 var.tfacp006.hapd =  0.0  
 	 else  
 	 	 var.tfacp006.fahi =  etol(tcyesno.no)  
 	 	 var.tfacp006.hppd =  round(tfacp006.hppd, 0, 1)  
 	 	 var.tfacp006.hapd =  tfacp006.hapd  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:006
:SCPAC:tf
:SCMOD:acp
:SFLNO:006
:ICOD:S
:QURY:START
select tfacp006.*
from tfacp006
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:006
:SCPAC:tf
:SCMOD:acp
:SFLNO:006
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:102
:SCPAC:tf
:SCMOD:acp
:SFLNO:102
:ICOD:D
:QURY:START
	 if isspace(tfacp102.ttyp) then  
 	 	 if get.business.partner.from.invoices.received(  
 	 	 	 tfacp102.ninv,  
 	 	 	 var.tfacp102.ifbp) then  
 	 	 	 dump 1  
 	 	 endif 	  
 	 else  
 | 	 	 if get.business.partner.from.open.entries( 	 | #  FP3.o  
 	 	 if get.attributes.from.open.entries( 	 	 | #  FP3.n  
 	 	 	 tfacp102.ttyp,  
 	 	 	 tfacp102.ninv,  
 	 	 	 var.tfacp102.ifbp,  
 	 	 	 var.tfacp102.bloc, 	 	 	 | #  FP3.sn  
 	 	 	 var.tfacp102.papr) then 	 	 | #  FP3.en  
 	 	 	 dump 1  
 	 	 endif 	  
 	 endif 	  
 	 | *  Record is only dumped if a related record exists in Received  
 	 | *  Purchase Invoices or Purchase Invoices. Field tfacp102.ifbp is  
 	 | *  mandatory. It is possible in BaanIV to leave tfacp100.suno empty  
 	 | *  but this is noticed by sesion bcstf0200m000.
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:102
:SCPAC:tf
:SCMOD:acp
:SFLNO:102
:ICOD:S
:QURY:START
select 	 tfacp102.*
from 	 tfacp102
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:102
:SCPAC:tf
:SCMOD:acp
:SFLNO:102
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:200
:SCPAC:tf
:SCMOD:acp
:SFLNO:200
:ICOD:D
:QURY:START
	 if hold.business.partner <>  tfacp200.suno then  
 	 	 business.partner =  get.business.partner.code(  
 	 	 	 	 	 tfacp200.suno,  
 	 	 	 	 	 bcstc.orgn.suno,  
 	 	 	 	 	 error.message)  
 	 	 hold.business.partner =  tfacp200.suno  
 	 	 if factor.company.linked.to.business.partner(  
 	 	 	 tfacp200.suno,  
 	 	 	 hold.factor.company,  
 	 	 	 factor.bank) then  
 	 	 	 var.tfacp200.ptbp =  get.business.partner.code(  
 	 	 	 	 	 	 shiftr$(hold.factor.company),  
 	 	 	 	 	 	 bcstc.orgn.fcomp,  
 	 	 	 	 	 	 error.message)  
 	 	 	 | *  Pay -  to business partner is the converted factor  
 	 	 	 | *  company  
 	 	 else  
 	 	 	 var.tfacp200.ptbp =  business.partner  
 	 	 	 factor.bank =  ""                                                                                                   
 	 	 	 hold.factor.company =  ""                                                                                                          
 	 	 endif 	  
 	 endif 	  
 	  
 	 if (tfacp200.spot =  tcyesno.yes) then  
 	 	 var.tfacp200.rade =  target(tcfcrt.fixed) | *  Fixed  
 	 else  
 | 	 	 var.tfacp200.rade =  target(tcfcrt.manual) 	 | #  200704.so  
 | 	 	 	 	 	 	 | *  Manually entered  
 | 	 	 	 	 	 	 	 	 | #  200704.eo  
 	 	 var.tfacp200.rade =  target(tcfcrt.docd) 	 | #  200704.sn  
 	 	 	 	 	 	 | *  Document Date | #  200704.en  
 	 endif  
 	  
 	 if not isspace(hold.factor.company) then  
 	 	 var.tfacp200.bank =  factor.bank  
 	 else  
 	 	 var.tfacp200.bank =  tfacp200.bank  
 	 endif 	  
 	  
 	 | *  Baan IV 	 	 Baan 6  
 	 | *  no 	 	 	 1 	 expence 	 	 1  
 	 | *  pur 	 	 2 	 purchase 	 	 2  
 	 | *  tran 	 	 3 	 expence 	 	 1  
 	 if tfacp200.appr =  tfacp.matc.tran then  
 	 	 var.tfacp200.appr =  target(tfacp.inv.expence)  
 	 	 var.tfacp200.link =  0.0  
 	 else  
 	 	 var.tfacp200.appr =  etol(tfacp200.appr)  
 	 	 var.tfacp200.link =  tfacp200.link  
 	 endif  
 	 | *  Old function for reading mapping table activated again 	 | #  210859.n  
 	 	 	 	 	 	 	 	 | #  210859.so  
 | 	 ret.long =  get.tax.by.country.code(  
 | 	 	 	 tfacp200.vatc,  
 | 	 	 	 tfacp200.cvat,  
 | 	 	 	 var.tfacp200.vatc,  
 | 	 	 	 var.tfacp200.cvat,  
 | 	 	 	 error.message)  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 ret.long =  get.tax.by.country.code.and.financial.company(  
 	 	 	 tfacp200.vatc,  
 	 	 	 tfacp200.cvat,  
 	 	 	 current.company,  
 	 	 	 var.tfacp200.vatc,  
 	 	 	 var.tfacp200.cvat,  
 	 	 	 error.message)  
 | 	 if not isspace(tfacp200.vatc) then 	 | #  SP2.sn 	 | #  210859.so  
 | 	 	 var.tfacp200.vatc =  get.country.of.financial.company(  
 | 	 	 	 	 	 current.company)  
 | 	 endif 	 	 	 	 	 | #  SP2.en 	 | #  210859.eo  
 	  
 	 if tfacp200.step <>  empty then  
 	 	 convert.payment.procedure.step(  
 	 	 	 tfacp200.step,  
 	 	 	 var.tfacp200.step)  
 	 else  
 	 	 var.tfacp200.step =  0  
 	 endif  
 	 if tfacp200.vatp =  0 or tfacp200.vaty =  0 then  
 	 | *  Vat period is mandatory in BaanIV and SSA ERP LN (Baan 6).  
 	 | *  It turns out that in some rare cases tfacp200.vatp is empty (0).  
 	 | *  So, to be sure vatp and vaty are always filled.  
 	 	 itfgld0012.get.year.prno.from.date(  
 	 	 	 current.company,  
 	 	 	 tfgld.ptyp.vat,  
 	 	 	 tfacp200.docd)  
 	 	 var.tfacp200.vaty =  igld0012.year  
 	 	 var.tfacp200.vatp =  igld0012.prno  
 	 else  
 	 	 var.tfacp200.vaty =  tfacp200.vaty  
 	 	 var.tfacp200.vatp =  tfacp200.vatp  
 	 endif  
 	 if tfacp200.blac =  empty then  
 	 	 var.tfacp200.blac =  target(tfcmg.blac.na) | *  Not applicable  
 	 else  
 	 	 var.tfacp200.blac =  etol(tfacp200.blac)  
 	 endif 	  
 	 	 	 	 	 	 	 	 | #  FP3.sn  
 	 if isspace(tfacp200.tdoc) and  
 	 ((tfacp200.tpay =  tfacp.tpay.invoice) or  
 	 (tfacp200.tpay =  tfacp.tpay.credit) or  
 	 (tfacp200.tpay =  tfacp.tpay.advance) or  
 	 (tfacp200.tpay =  tfacp.tpay.unallocated)) then 	  
 	 	 get.control.account(  
 	 	 current.company,  
 	 	 tfacp200.year,  
 	 	 tfacp200.btno,  
 	 	 tfacp200.ttyp,  
 	 	 tfacp200.ninv,  
 	 	 tfacp200.line,  
 	 	 tfacp200.tpay,  
 	 	 var.tfacp200.leac) 	 	 	  
 	 else  
 	 	 var.tfacp200.leac =  ""    
 	 endif 	 	 	 	 	 	 	 | #  FP3.en  
 	  
 	 for element =  1 to 3  
 	 	 var.tfacp200.rate(element) =  fill.mc.field.double(  
 	 	 	 	 tfacp200.rate, element, 0.000001) 	  
 	 	 var.tfacp200.ratf(element) =  fill.mc.field.long(  
 	 	 	 	 tfacp200.ratf, element, 1) 	  
 	 	 var.tfacp200.amth(element) =  fill.mc.field.double(  
 	 	 	 	 tfacp200.amth, element, 0.0)  
 	 	 var.tfacp200.vath(element) =  fill.mc.field.double(  
 	 	 	 	 tfacp200.vath, element, 0.0)  
 	 	 var.tfacp200.svah(element) =  fill.mc.field.double(  
 	 	 	 	 tfacp200.svah, element, 0.0)  
 	 	 var.tfacp200.laph(element) =  fill.mc.field.double(  
 	 	 	 	 tfacp200.laph, element, 0.0)  
 	 	 var.tfacp200.dc1h(element) =  fill.mc.field.double(  
 	 	 	 	 tfacp200.dc1h, element, 0.0)  
 	 	 var.tfacp200.dc2h(element) =  fill.mc.field.double(  
 	 	 	 	 tfacp200.dc2h, element, 0.0)  
 	 	 var.tfacp200.dc3h(element) =  fill.mc.field.double(  
 	 	 	 	 tfacp200.dc3h, element, 0.0)  
 	 	 var.tfacp200.padh(element) =  fill.mc.field.double(  
 	 	 	 	 tfacp200.padh, element, 0.0)  
 	 	 var.tfacp200.cdam(element) =  fill.mc.field.double(  
 	 	 	 	 tfacp200.cdam, element, 0.0)  
 	 	 var.tfacp200.tore(element) =  fill.mc.field.double(  
 	 	 	 	 tfacp200.tore, element, 0.0)  
 	 	 var.tfacp200.baca(element) =  fill.mc.field.double(  
 	 	 	 	 tfacp200.baca, element, 0.0)  
 	 	 var.tfacp200.balh(element) =  fill.mc.field.double(  
 	 	 	 	 tfacp200.balh, element, 0.0)  
 	 	 var.tfacp200.bahc(element) =  fill.mc.field.double(  
 	 	 	 	 tfacp200.bahc, element, 0.0)  
 	 endfor 	 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:200
:SCPAC:tf
:SCMOD:acp
:SFLNO:200
:ICOD:S
:QURY:START
select 	 tfacp200.*
from 	 tfacp200
order by tfacp200._index2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:200
:SCPAC:tf
:SCMOD:acp
:SFLNO:200
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:201
:SCPAC:tf
:SCMOD:acp
:SFLNO:201
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:201
:SCPAC:tf
:SCMOD:acp
:SFLNO:201
:ICOD:S
:QURY:START
select 	 tfacp201.*
from 	 tfacp201
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:201
:SCPAC:tf
:SCMOD:acp
:SFLNO:201
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:240
:SCPAC:td
:SCMOD:pur
:SFLNO:045
:ICOD:D
:QURY:START
	 ret.long =  get.enterprise.unit(  
 	 	 	 current.company,  
 	 	 	 logistic.company,  
 	 	 	 error.message)  
 	 | *  Makes EU record current, contains the Purchase Office  
 	 select tdpur045.*  , tdpur041.*   
 	 from 	 tdpur045, tdpur041 	  
 	 where 	 tdpur045._compnr =  :logistic.company  
 	 and 	 tdpur041._compnr =  :logistic.company  
 	 and 	 tdpur041._index1 =  {tdpur045.orno, tdpur045.pono}  
 	 and 	 tdpur045.fico =  :current.company  
 	 order by tdpur045._index1  
 	 selectdo  
 	 	 if (prev.040.orno <>  tdpur045.orno) then  
 	 	 	 read.purchase.order.and.order.type.data(  
 	 	 	 	 tdpur045.orno,  
 	 	 	 	 logistic.company)  
 	 	 	 | *  Order header fields and related data (order type)  
 	 	 	 | *  are current.  
 	 	 	 var.tfacp240.byer =  format.emno(tdpur040.ccon)  
 	 	 	 var.tfacp240.orno =  convert.number(  
 	 	 	 	 	 	 bcckon.act.pur,  
 	 	 	 	 	 	 tdpur045.orno)  
 	 	 	 var.tfacp240.sfad =  get.bp.address(  
 	 	 	 	 	 	 logistic.company,  
 	 	 	 	 	 	 tdpur040.orno,  
 	 	 	 	 	 	 tdpur040.suno,  
 	 	 	 	 	 	 tdpur040.ccor)  
 	 	 	 prev.040.orno =  tdpur045.orno  
 	 	 endif  
 	 	 if tcmcs042.coun =  tcyesno.yes and tdpur045.date =  0 then  
 	 	 | *  Collect order which is not received  
 	 	 	 continue  
 	 	 endif 	  
 	  
 	 	 if (prev.041.orno <>  tdpur041.orno) or  
 	 	 (prev.041.pono <>  tdpur041.pono) then  
 	 	 	 if (prev.item <>  tdpur041.item) then  
 	 	 	 	 var.tfacp240.item =  get.item(  
 	 	 	 	 	 	 	 logistic.company,  
 	 	 	 	 	 	 	 tdpur041.item,  
 	 	 	 	 	 	 	 tdpur041.opol,  
 	 	 	 	 	 	 	 tdpur041.cprj)  
 	 	 	 	 get.item.attributes(  
 	 	 	 	 	 tdpur041.item,  
 	 	 	 	 	 tdpur041.opol,  
 	 	 	 	 	 tdpur041.cprj,  
 	 	 	 	 	 item.type,  
 	 	 	 	 	 var.tfacp240.itgr,  
 	 	 	 	 	 var.tfacp240.iuni)  
 	 	 	 	 prev.item =  tdpur041.item  
 	 	 	 endif  
 	 	 	 get.number.of.receipt.lines(  
 	 	 	 	 tdpur041.orno,  
 	 	 	 	 tdpur041.pono,  
 	 	 	 	 logistic.company,  
 	 	 	 	 no.of.receipt.lines)  
 	 	 	 var.tfacp240.cadr =  get.delivery.address ()  
 	 	 	 | *  Function to retrieve GL -  code  
 	 	 	 | *  tdpur041.pacn, dim1 -  dim5  
 	 	 	 var.tfacp240.glco =  transform.leac.and.dim.in.gl.code(  
 	 	 	 	 	 	 tdpur041.pacn,  
 	 	 	 	 	 	 tdpur041.dim1,  
 	 	 	 	 	 	 tdpur041.dim2,  
 	 	 	 	 	 	 tdpur041.dim3,  
 	 	 	 	 	 	 tdpur041.dim4,  
 	 	 	 	 	 	 tdpur041.dim5)  
 	 	 	 var.tfacp240.vatc =  ""                  	                                    	                    |#                  210859.n                                    
 	 	 	 var.tfacp240.cvat =  ""                  	                                    	                    |#                  210859.n                                    
 	 	 	 if not isspace(tdpur041.ccty) then 	 | #  SP2.sn  
 	 	 	 	 	 	 	 	 | #  210859.so  
 | 	 	 	 	 var.tfacp240.vatc =   
 | 	 	 	 	 	 get.country.of.financial.company(  
 | 	 	 	 	 	 	 	 current.company)  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 	 	 	 	 	 | #  210859.so  
 | 	 	 	 	 get.tax.by.country.code( 	 | #  210859.sn  
 | 	 	 	 	 	 	 tdpur041.ccty,  
 | 	 	 	 	 	 	 tdpur041.cvat,  
 | 	 	 	 	 	 	 var.tfacp240.vatc,  
 | 	 	 	 	 	 	 var.tfacp240.cvat,  
 | 	 	 	 	 	 	 error.message) | #  210859.en  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 	 	 	 	 	 | #  210859.sn  
 	 	 	 	 get.tax.by.country.code.and.financial.company(  
 	 	 	 	 	 	 tdpur041.ccty,  
 	 	 	 	 	 	 tdpur041.cvat,  
 	 	 	 	 	 	 current.company,  
 	 	 	 	 	 	 var.tfacp240.vatc,  
 	 	 	 	 	 	 var.tfacp240.cvat,  
 	 	 	 	 	 	 error.message) | #  210859.en  
 	 	 	 endif 	 	 	 	 	 | #  SP2.en  
 	 	 	 	 	  
 	 	 	 prev.041.orno =  tdpur041.orno  
 	 	 	 prev.041.pono =  tdpur041.pono  
 	 	 endif  
 	 	 if item.type <>  tckitm.cost and 	 	 	 | #  203846.sn  
 	 	 item.type <>  tckitm.service and  
 	 	 tdpur041.oqua =  0 and  
 	 	 tdpur045.date =  0 then  
 	 	 	 | *  It's not possible anymore in SSA ERP LN to  
 	 	 	 | *  purchase stock keeping items with an ordered  
 	 	 	 | *  quantity of zero. So order lines that are not  
 	 	 	 | *  received yet, are not migrated.  
 	 	 	 continue  
 	 	 endif 	 	 	 	 	 	 | #  203846.en  
 	 	 | *  Next situations are possible:  
 	 	 | * -  One entry in tdpur045 for order /  position  
 	 	 | *  	 -  no.of.receipt.lines =  0 (no receipts yet)  
 	 	 | *  	 -  tdpur045.srnb =  0  
 	 	 | *  	 -  one record added to tfacp240  
 	 	 | * -  One entry in tdpur045 for order /  position  
 	 	 | *  	 -  no.of.receipt.lines =  1 (1 receipt)  
 	 	 | *  	 -  tdpur045.srnb =  1  
 	 	 | *  	 -  one record added to tfacp240  
 	 	 | *  	 -  one record added to tfacp245  
 	 	 | *  	 -  This is a collect order (order and receipt in once)  
 	 	 | * -  Two entries in tdpur045 for order /  position  
 	 	 | *  	 -  no.of.repeipt.lines =  1 (first receipt)  
 	 	 | *  	 -  one record added to tfacp240  
 	 	 | *  	 -  one record added to tfacp245, if tdpur045.date <>  0  
 	 	 | * -  More than two entries in tdpur045 for order /  position  
 	 	 | *  	 (backorders present)  
 	 	 | *  	 -  no.of.receipt.lines >=  2  
 	 	 | *  	 -  one record added to tfacp240 (original order line)  
 	 	 | *  	 -  one record added to tfacp240 for each backorder  
 	 	 | *  	 -  for each record of tdpur045 with tdpur045.date <>  0  
 	 	 | *  	 	 (actual receipt date) a record is added to  
 	 	 | *  	 	 tfacp245.  
 	 	 if no.of.receipt.lines =  0 or tdpur045.srnb >=  1 then  
 	 	 	 | *  Original order line and the backorders are inserted  
 	 	 	 | *  in tfacp240  
 	 	 	 | *  Only if there is no receipt tfacp240 record is  
 	 	 	 | *  added seperately. Else tfacp240 is inserted when  
 	 	 	 | *  tfacp245 is inserted.  
 	 	 	 var.tfacp240.sqnb =  get.order.line.sequence(  
 	 	 	 	 	 	 tdpur045.srnb)  
 	 	 	 var.tfacp240.otbp =  get.business.partner.code(  
 	 	 	 	 	 	 tdpur040.suno,  
 	 	 	 	 	 	 bcstc.orgn.suno,  
 	 	 	 	 	 	 error.message)  
 	 	 	 | *  Also used for ifbp and sfbp  
 	 	 	 var.tfacp240.proj =  get.project.by.company(  
 	 	 	 	 	 	 tdpur045.cprj,  
 	 	 	 	 	 	 logistic.company)  
 	 	 	 if not isspace(tdpur045.cprj) then  
 	 	 	 	 var.tfacp240.bppr =  get.baan.project(  
 	 	 	 	 	 	 	 logistic.company,  
 	 	 	 	 	 	 	 tdpur045.cprj)  
 	 	 	 else  
 	 	 	 	 var.tfacp240.bppr =  tcyesno.no  
 	 	 	 endif 	  
 	 	 	 if tdpur045.srnb <  2 then  
 	 	 	 	 | *  Normal order  
 	 	 	 	 convert.quantity.from.order.unit.to.inventory.unit(  
 	 	 	 	 	 tdpur041.oqua,  
 	 	 	 	 	 var.tfacp240.iuni,  
 	 	 	 	 	 tdpur041.cvqp,  
 	 	 	 	 	 "",                                                                                                                                                                                                                               
 	 	 	 	 	 "",                                                                                                                                                                                                                              
 	 	 	 	 	 "tcqrd1",                                                                                                                                                                                                                       
 	 	 	 	 	 var.tfacp240.oqan)  
 	 	 	 else  
 	 	 	 	 convert.quantity.from.order.unit.to.inventory.unit (  
 	 	 	 	 	 prev.bqua,  
 	 	 	 	 	 var.tfacp240.iuni,  
 	 	 	 	 	 tdpur041.cvqp,  
 	 	 	 	 	 "",                                                                                                                                                                                                                                  
 	 	 	 	 	 "",                                                                                                                                                                                                                                 
 	 	 	 	 	 "tcqrd1",                                                                                                                                                                                                                          
 	 	 	 	 	 var.tfacp240.oqan)  
 	 	 	 	 | *  Back order  
 	 	 	 endif 	  
 	 	 	 get.order.amount(var.tfacp240.oamt)  
 	 	 	 | *  Calculate amount in home currencies  
 	 	 	 for element =  1 to 3  
 	 	 	 	 ret.long =  calculate.amount.in.home.currency(  
 	 	 	 	 	 	 var.tfacp240.oamt,  
 	 	 	 	 	 	 tdpur040.ccur,  
 	 	 	 	 	 	 tdpur040.ratp,  
 	 	 	 	 	 	 tdpur040.ratf,  
 	 	 	 	 	 	 element,  
 	 	 	 	 	 	 var.tfacp240.amth(element),  
 	 	 	 	 	 	 error.message)  
 	 	 	 endfor  
 	 	 	 | *  In Baan IV only one receipt per order line.  
 	 	 	 | *  Quantities can be taken from the receipt.  
 | 	 	 	 if tcmcs042.reto =  tcyesno.yes then 	 | #  207117.o  
 	 	 	 	 	 	 	 	 | #  207117.sn  
 	 	 	 if double.cmp(tdpur041.oqua, 0.0, 0.00001) = -  1 then  
 	 	 	 	 	 	 	 	 | #  207117.en  
 	 	 	 | *  Return order  
 	 	 	 	 convert.quantity.from.order.unit.to.inventory.unit (  
 	 	 	 	 	 	 tdpur045.quad,  
 	 	 	 	 	 	 var.tfacp240.iuni,  
 	 	 	 	 	 	 tdpur041.cvqp,  
 	 	 	 	 	 	 "",                                                                                                                                                                                                                         
 	 	 	 	 	 	 "",                                                                                                                                                                                                                        
 	 	 	 	 	 	 "tcqrd1",                                                                                                                                                                                                                     
 	 	 	 	 	 	 var.tfacp240.tapq)  
 	 	 	 	 | *  Approved quantity equals rejected quantity  
 	 	 	 	 var.tfacp240.trqu =  0.0  
 	 	 	 	 | *  Rejected quantity is zero  
 | 	 	 	 	 	 	 	 	 | #  215078.so  
 | 	 	 	 	 var.tfacp245.rcno =  bcswh000.prsh  
 | 	 	 	 	 | *  Purchace Return Order  
 | 	 	 	 	 	 &  edit$(tdpur045.reno, "999999")                
 | 	 	 	 	 	 	 	 	 | #  215078.eo  
 	 	 	 	 get.shipment.number.and.line( 	 | #  215078.sn  
 	 	 	 	 	 tckoor.act.pur,  
 	 	 	 	 	 tdpur045.orno,  
 	 	 	 	 	 tdpur045.pono,  
 	 	 	 	 	 var.tfacp240.sqnb,  
 	 	 	 	 	 0,  
 	 	 	 	 	 error.message) 	 | *  ref  
 	 	 	 	 var.tfacp245.rcno =  bcswh008.shpm  
 	 	 	 	 	 	 	 	 | #  215078.en  
 	 	 	 else  
 	 	 	 	 convert.quantity.from.order.unit.to.inventory.unit (  
 	 	 	 	 	 	 tdpur045.quap,  
 	 	 	 	 	 	 var.tfacp240.iuni,  
 	 	 	 	 	 	 tdpur041.cvqp,  
 	 	 	 	 	 	 "",                                                                                                                                                                                                                      
 	 	 	 	 	 	 "",                                                                                                                                                                                                                    
 	 	 	 	 	 	 "tcqrd1",                                                                                                                                                                                                                        
 	 	 	 	 	 	 var.tfacp240.tapq) 	  
 	 	 	 	 convert.quantity.from.order.unit.to.inventory.unit (  
 	 	 	 	 	 	 tdpur045.quad,  
 	 	 	 	 	 	 var.tfacp240.iuni,  
 	 	 	 	 	 	 tdpur041.cvqp,  
 	 	 	 	 	 	 "",                                                                                                                                                                                                                       
 	 	 	 	 	 	 "",                                                                                                                                                                                                                      
 	 	 	 	 	 	 "tcqrd1",                                                                                                                                                                                                                    
 	 	 	 	 	 	 var.tfacp240.trqu)  
 	 	 	 	 var.tfacp245.rcno =  convert.number(  
 	 	 	 	 	 	 	 bcckon.receipt.number,  
 	 	 	 	 	 	 	 tdpur045.reno)  
 	 	 	 endif  
 	 	 	 convert.quantity.from.order.unit.to.inventory.unit (  
 	 	 	 	 	 tdpur045.dqua,  
 	 	 	 	 	 var.tfacp240.iuni,  
 	 	 	 	 	 tdpur041.cvqp,  
 	 	 	 	 	 "",                                                                                                                                                                                                                                
 	 	 	 	 	 "",                                                                                                                                                                                                                               
 	 	 	 	 	 "tcqrd1",                                                                                                                                                                                                                        
 	 	 	 	 	 var.tfacp240.rqty)  
 	 	 	  
 	 	 	 if (tdpur045.matc =  tdpur.matc.complete) or  
 	 	 	 (tdpur045.date <>  0 and zero.receipt(  
 	 	 	 	 	 	 	 tdpur045.dqua,  
 	 	 	 	 	 	 	 tdpur045.quap,  
 	 	 	 	 	 	 	 tdpur045.quad,  
 	 	 	 	 	 	 	 tdpur041.oqua)) then  
 	 	 	 	 | *  Zero receipt. In BaanIV there is only 1  
 	 	 	 	 | *  receipt per orderline /  sequence number.  
 	 	 	 	 | *  If thereis no receipt a back order with  
 	 	 	 	 | *  a new sequence number is made.  
 	 	 	 	 var.tfacp240.toma =  tcyesno.yes  
 	 	 	 else  
 	 	 	 	 var.tfacp240.toma =  tcyesno.no  
 	 	 	 endif  
 	 	 	 if tdpur045.date <>  0 then  
 	 	 	 	 var.tfacp240.fire =  tcyesno.yes  
 	 	 	 else  
 	 	 	 	 var.tfacp240.fire =  tcyesno.no  
 	 	 	 endif 	  
 	 	 	 var.tfacp240.mcfr =  get.tfacp240.mcfr()  
 	 	 	 | *  Fill Rates  
 	 	 	 for element =  1 to 3  
 	 	 	 	 var.tfacp240.rate(element) =  fill.mc.field.double(  
 	 	 	 	 	 	 tdpur040.ratp,  
 	 	 	 	 	 	 element,  
 	 	 	 	 	 	 0.000001) 	  
 	 	 	 	 var.tfacp240.ratf(element) =  fill.mc.field.long(  
 	 	 	 	 	 	 tdpur040.ratf,  
 	 	 	 	 	 	 element,  
 	 	 	 	 	 	 1) 	  
 	 	 	 endfor  
 	 	 	 dump 1  
 	 	 endif  
 	 	 if (tdpur045.date <>  0) and not zero.receipt(  
 	 	 	 	 	 	 	 tdpur045.dqua,  
 	 	 	 	 	 	 	 tdpur045.quap,  
 	 	 	 	 	 	 	 tdpur045.quad,  
 	 	 	 	 	 	 	 tdpur041.oqua) then  
 	 	 	 | *  Actual receipt  
 	 	 	 var.tfacp245.borf =  make.business.obj.ref(  
 	 	 	 	 	 	 tdpur045.pono,  
 	 	 	 	 	 	 tdpur045.srnb)  
 	 	 	 dump 3  
 	 	 endif 	  
 	 	 prev.bqua =  tdpur045.bqua  
 	 	 prev.orno =  tdpur045.orno  
 	 	 prev.pono =  tdpur045.pono  
 	 endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:240
:SCPAC:td
:SCMOD:pur
:SFLNO:045
:ICOD:S
:QURY:START
select 	 tfgld000.loco:logistic.company
from 	 tfgld000
where 	 tfgld000._index1 =  {:current.company}
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:240
:SCPAC:td
:SCMOD:pur
:SFLNO:045
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:000
:SCPAC:tf
:SCMOD:acr
:SFLNO:000
:ICOD:D
:QURY:START
var.tfacr000.indt =  utc(0,0)  
 	 var.tfacr000.dsca =  form.text$("bcstc00035") | *  Actual Set  
 	 dump 1  
 	 var.tfacr000.indt =  utc(date.num(),time.num())  
 	 var.tfacr000.dsca =  form.text$("bcstc00036") | *  Converted from Baan IVc4  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:000
:SCPAC:tf
:SCMOD:acr
:SFLNO:000
:ICOD:S
:QURY:START
select tfacr000.*
from tfacr000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:000
:SCPAC:tf
:SCMOD:acr
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:001
:SCPAC:tf
:SCMOD:acr
:SFLNO:001
:ICOD:D
:QURY:START
dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:001
:SCPAC:tf
:SCMOD:acr
:SFLNO:001
:ICOD:S
:QURY:START
select tfacr001.*
from tfacr001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:001
:SCPAC:tf
:SCMOD:acr
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:005
:SCPAC:tf
:SCMOD:acr
:SFLNO:005
:ICOD:D
:QURY:START
var.tran.counter =  etol(tfacr005.tran)  
 	 if tfacr005.tran =  tfacr.tran.control then  
 	 	 var.tfacr005.control.leac =  tfacr005.leac  
 	 	 if not isspace(var.tfacr005.control.leac) then  
 	 	 	 dump 999  
 	 	 	 continue  
 	 	 endif  
 	 else  
 	 	 if not isspace(var.tfacr005.control.leac) then  
 	 	 	 var.tfacr005.tran =  var.tran.counter -  1  
 	 	 	 if var.tran.counter >=  16 then 	  
 	 	 	 	 for var.tran.counter =  15 to 34  
 	 	 	 	 	 if var.tran.counter =  15 then  
 	 	 	 	 	 	 var.tfacr005.leac =  tfacr005.leac  
 	 	 	 	 	 else  
 	 	 	 	 	 	 var.tfacr005.leac =  empty.string(1;12)  
 	 	 	 	 	 endif  
 	 	 	 	 	 dump 15  
 	 	 	 	 endfor  
 	 	 	 else  
 	 	 	 	 dump 1  
 	 	 	 endif  
 	 	 endif  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:005
:SCPAC:tf
:SCMOD:acr
:SFLNO:005
:ICOD:S
:QURY:START
select tfacr005.*
from tfacr005
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:005
:SCPAC:tf
:SCMOD:acr
:SFLNO:005
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:200
:SCPAC:tf
:SCMOD:acr
:SFLNO:200
:ICOD:D
:QURY:START
	 	 	 	 	 	 	 | #  200 -  101927.sn  
 	 initialize.variables()  
 	 fill.positive.amounts.invoice()  
 	 	 	 	 	 	 	 | #  148886.so 	 	  
 | 	 if tfacr200.trec =  tfacr.trec.credit and tfacr200.amnt >  0 then  
 | 	 	 fill.negative.amounts.credit.note()  
 | 	 endif  
 	 	 	 	 	 	 	 | #  148886.eo  
 	 	 	 	 	 	 	 | #  200 -  101927.en  
 	 if tfacr200.vatp =  0 or tfacr200.vaty =  0 then  
 	 	 itfgld0012.get.year.prno.from.date( get.compnr(),  
 	 	 	 	 	 	 tfgld.ptyp.vat,  
 	 	 	 	 	 	 tfacr200.docd)  
 	 	 vat.year =  igld0012.year  
 	 	 vat.prod =  igld0012.prno  
 	 else  
 	 	 vat.year =  tfacr200.vaty  
 	 	 vat.prod =  tfacr200.vatp  
 	 endif  
 	 	 	 	 	 	 	 	  
 	 	 new.country =  ""                                                                                                                                                                                                                                    
 	 	 new.tax =  ""                                                                                                                                                                                                                                    
 	 	 	 	 	 	 	 	 | #  210859.so  
 | 	 	 get.tax.by.country.code(  
 | 	 	 	 tfacr200.vatc,  
 | 	 	 	 tfacr200.cvat,  
 | 	 	 	 new.country,  
 | 	 	 	 new.tax,  
 | 	 	 	 var.err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 	 	 	 	 	 | #  210859.sn  
 	 	 get.tax.by.country.code.and.financial.company(  
 	 	 	 tfacr200.vatc,  
 	 	 	 tfacr200.cvat,  
 	 	 	 get.compnr(),  
 	 	 	 new.country,  
 	 	 	 new.tax,  
 	 	 	 var.err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.en  
 	 	 if (tfacr200.spot =  tcyesno.yes) then  
 | 	 	 	 var.tfacr200.rade =  1 	 | #  200704.o  
 	 	 	 var.tfacr200.rade =  10 	 | #  200704.n  
 	 	 else  
 	 	 	 var.tfacr200.rade =  6 	  
 	 	 endif  
 	 	 var.str.temp.key (1;6) =  tfacr200.cuno  
 	 	 var.str.temp.key (7;9) =  tfacr200.adrs  
 	 	 	 	 	 	 	 	 	 | #  ms.so 	 	  
 | 	 	 if determine.bccnv901.address ("tccom012",var.str.temp.key) =  0 then  
 | 	 	 	 bccnv901.cadr =  empty.string (1;9)  
 | 	 	 endif  
 | 	 	 var.str.bpid =  get.bpid (tfacr200.cuno,bccom.orgn.cuno) 	  
 	 	 	 	 	 	 	 	 	 | #  ms.eo  
 	 	  
 	 	 if not get.addresses("tccom012", var.str.temp.key,var.err.mess) then  
 	 	 	 var.tfacr200.adrs =  bcstc004.cadr  
 	 	 else  
 	 	 	 var.tfacr200.adrs =  ""                                                                                                                                                                                                                                                                            
 	 	 endif  
 	 	  
 	 	 if not get.business.partner(tfacr200.cuno,bcstc.orgn.cuno,var.err.mess) then  
 	 	 	 var.str.bpid =  bcstc008.bpid  
 	 	 else  
 	 	 	 var.str.bpid =  ""                                                                                                                                                                                                                                                                            
 	 	 endif  
 	 	 	 	 	 	 	 	 	 | #  FP3.sn  
 	 	 fill.tfacr200.pysh()  
 	 	 if tfacr200.trec =  tfacr.trec.invoice or tfacr200.trec =  tfacr.trec.credit or  
 	 	 	 tfacr200.trec =  tfacr.trec.advance or tfacr200.trec =  tfacr.trec.unallocated then  
 	 	 	 fill.tfacr200.leac()  
 	 	 else  
 	 	 	 var.tfacr200.leac =  ""            
 	 	 endif  
 	 	 	 	 	 	 	 	 	 | #  FP3.en  
 	 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:200
:SCPAC:tf
:SCMOD:acr
:SFLNO:200
:ICOD:S
:QURY:START
select tfacr200.*
from tfacr200 	 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:200
:SCPAC:tf
:SCMOD:acr
:SFLNO:200
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:201
:SCPAC:tf
:SCMOD:acr
:SFLNO:201
:ICOD:D
:QURY:START
dump 999
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:201
:SCPAC:tf
:SCMOD:acr
:SFLNO:201
:ICOD:S
:QURY:START
select tfacr201.*
from tfacr201
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:201
:SCPAC:tf
:SCMOD:acr
:SFLNO:201
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:303
:SCPAC:tf
:SCMOD:acr
:SFLNO:303
:ICOD:D
:QURY:START
if not get.business.partner(tfacr303.cuno,bcstc.orgn.cuno,var.str.err.mess) then  
 	 var.tfacr303.itbp =  bcstc008.bpid  
 else  
 	 var.tfacr303.itbp =  ""                                        
 endif 	  
 fill.tfacr303.refr() | #  FP3.n 	  
 dump 999
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:303
:SCPAC:tf
:SCMOD:acr
:SFLNO:303
:ICOD:S
:QURY:START
select tfacr303.*
from tfacr303
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:303
:SCPAC:tf
:SCMOD:acr
:SFLNO:303
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:306
:SCPAC:tf
:SCMOD:acr
:SFLNO:306
:ICOD:D
:QURY:START
if not get.business.partner(tfacr306.cuno,bcstc.orgn.cuno,var.str.err.mess) then  
 	 var.tfacr306.itbp =  bcstc008.bpid  
 else  
 	 var.tfacr306.itbp =  ""                  
 endif  
 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:306
:SCPAC:tf
:SCMOD:acr
:SFLNO:306
:ICOD:S
:QURY:START
select tfacr306.*
from tfacr306
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:306
:SCPAC:tf
:SCMOD:acr
:SFLNO:306
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:501
:SCPAC:tf
:SCMOD:acr
:SFLNO:501
:ICOD:D
:QURY:START
dump 999
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:501
:SCPAC:tf
:SCMOD:acr
:SFLNO:501
:ICOD:S
:QURY:START
select tfacr501.*
from tfacr501
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:501
:SCPAC:tf
:SCMOD:acr
:SFLNO:501
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:000
:SCPAC:tf
:SCMOD:cmg
:SFLNO:000
:ICOD:D
:QURY:START
if isspace(tfcmg000.supa) then  
 	 	 var.tfcmg000.supa =  bcgct000.user  
 	 else  
 	 	 var.tfcmg000.supa =  tfcmg000.supa  
 	 endif  
 var.tfcmg000.indt =  utc(0,0)  
 	 var.tfcmg000.desc =  form.text$("bcstc00035") | *  Actual Set  
 	 dump 1  
 	 var.tfcmg000.indt =  utc(date.num(),time.num())  
 	 var.tfcmg000.desc =  form.text$("bcstc00036") | *  Converted from Baan IVc4  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:000
:SCPAC:tf
:SCMOD:cmg
:SFLNO:000
:ICOD:S
:QURY:START
select tfcmg000.*
from tfcmg000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:000
:SCPAC:tf
:SCMOD:cmg
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:007
:SCPAC:tf
:SCMOD:cmg
:SFLNO:007
:ICOD:D
:QURY:START


on case tfcmg007.step  
 	 	 case tfcmg.step.doc.selected :  
 	 	 	 var.tfcmg007.step =  1  
 	 	 	 break  
 	 	 case tfcmg.step.doc.to.cust :  
 	 	 	 var.tfcmg007.step =  5  
 	 	 	 break  
 	 	 case tfcmg.step.doc.acc.by.cust :  
 	 	 	 var.tfcmg007.step =  6  
 	 	 	 break  
 	 	 case tfcmg.step.doc.to.bank :  
 	 	 	 var.tfcmg007.step =  10  
 	 	 	 break  
 	 	 case tfcmg.step.doc.received :  
 	 	 	 var.tfcmg007.step =  3  
 	 	 	 break  
 	 	 case tfcmg.step.doc.acc.sent :  
 	 	 	 var.tfcmg007.step =  7  
 	 	 	 break  
 	 	 case tfcmg.step.doc.paid :  
 	 	 	 var.tfcmg007.step =  16  
 	 	 	 break  
 	 	 case tfcmg.step.doc.rejected :  
 	 	 	 var.tfcmg007.step =  17  
 	 	 	 break  
 	 endcase  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:007
:SCPAC:tf
:SCMOD:cmg
:SFLNO:007
:ICOD:S
:QURY:START


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

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:101
:SCPAC:tf
:SCMOD:cmg
:SFLNO:101
:ICOD:D
:QURY:START
new.country =  ""                                                                                
 	 new.tax =  ""                                          
 	 	 	 	 	 	 	 | #  210859.so  
 | 	 get.tax.by.country.code(tfcmg101.vatc, tfcmg101.cvat, new.country,  
 | 	 	 	 new.tax, var.str.err.mess)  
 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 	 	 	 	 | #  210859.sn  
 	 get.tax.by.country.code.and.financial.company(  
 	 	 	 tfcmg101.vatc, tfcmg101.cvat, tfcmg101.comp,  
 	 	 	 new.country, new.tax, var.str.err.mess)  
 	 	 	 	 	 	 	 | #  210859.en  
 	 var.tfcmg101.adty =  0  
 	  
 	 on case tfcmg101.tadv  
 | 	 if tfcmg101.tadv =  tfcmg.tadv.purinv or  
 | 	 tfcmg101.tadv =  tfcmg.tadv.purcred then  
 	 	 case tfcmg.tadv.purinv: 	 	  
 	 	 case tfcmg.tadv.purcred:  
 	 	 select 	 tfacp200.docd  
 	 	 from 	 tfacp200  
 	 	 where 	 tfacp200._index1 =  {:tfcmg101.ttyp, :tfcmg101.ninv, :tfcmg101.srno, "",0,0}                                                                                                                            
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 var.str.rdat =  utc (tfacp200.docd,0)  
 	 	 	 var.str.rtyp =  var.str.pur.rtyp  
 	 	 selectempty  
 	 	 	 var.str.rdat =  utc (tfcmg101.plan,0)  
 	 	 	 var.str.rtyp =  var.str.pur.rtyp  
 	 	 endselect  
 	 	 break  
 	  
 | 	 else  
 	 	 case tfcmg.tadv.slsinv: 	 	  
 	 	 case tfcmg.tadv.slscred:  
 | 	 	 if (tfcmg101.tadv =  tfcmg.tadv.slsinv)  
 | 	 	 or (tfcmg101.tadv =  tfcmg.tadv.purcred) then  
 	 	 	 select 	 tfacr200.docd  
 	 	 	 from 	 tfacr200  
 	 	 	 where 	 tfacr200._index1 =  {:tfcmg101.ttyp, :tfcmg101.ninv, :tfcmg101.srno, "",0,0}                                                                                                                            
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 	 var.str.rdat =  utc (tfacr200.docd,0)  
 	 	 	 	 var.str.rtyp =  var.str.sls.rtyp  
 	 	 	 selectempty  
 	 	 	 	 var.str.rdat =  utc (tfcmg101.plan,0)  
 	 	 	 	 var.str.rtyp =  var.str.sls.rtyp  
 	 	 	 endselect  
 	 	 	 break  
 	 	 case tfcmg.tadv.advance: 	 	  
 	 	 	 var.tfcmg101.adty =  1  
 	 	 case tfcmg.tadv.unallocated:  
 	 	 case tfcmg.tadv.standing: 	 	  
 	 	 	 if standing.is.advance() then  
 	 	 	 	 var.tfcmg101.adty =  1  
 	 	 	 endif 	  
 	 	 case tfcmg.tadv.alone:  
 	 	 	 var.str.rdat =  utc (tfcmg101.plan,0)  
 	 	 	 var.str.rtyp =  var.str.pur.rtyp  
 	 	 	 break  
 	 endcase 	  
 | 	 	 else  
 | 	 	 	 var.str.rdat =  utc (tfcmg101.plan,time.num ())  
 | 	 	 	 var.str.rtyp =  var.str.pur.rtyp  
 | 	 	 endif  
 | 	 endif 	  
 	 	 	  
 	  
 	 if not get.business.partner(tfcmg101.suno,bcstc.orgn.suno,var.str.err.mess) then  
 	 	 var.tfcmg101.bpid =  bcstc008.bpid  
 	 else  
 	 	 var.tfcmg101.bpid =  ""                                                                                                                            
 	 endif  
 | 	 var.tfcmg101.bpid =  get.bpid (tfcmg101.suno,bccom.orgn.suno) 	 | #  ms.o  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:101
:SCPAC:tf
:SCMOD:cmg
:SFLNO:101
:ICOD:S
:QURY:START
select tfcmg101.*
from tfcmg101
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:101
:SCPAC:tf
:SCMOD:cmg
:SFLNO:101
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:104
:SCPAC:tf
:SCMOD:cmg
:SFLNO:104
:ICOD:D
:QURY:START
new.country =  ""                                              
 	 new.tax =  ""                          
 	 	 	 	 	 	 	 | #  210859.so  
 | 	 get.tax.by.country.code(tfcmg104.vatc, tfcmg104.cvat, new.country,  
 | 	 	 	 new.tax, err.mess)  
 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 	 	 	 	 | #  210859.sn  
 	 get.tax.by.country.code.and.financial.company(  
 	 	 	 tfcmg104.vatc, tfcmg104.cvat,  
 	 	 	 current.company, new.country,  
 	 	 	 new.tax, err.mess)  
 	 	 	 	 	 	 	 | #  210859.en  
 if (tfcmg104.spot =  tcyesno.yes) then  
 	 	 var.tfcmg104.rade =  1  
 else  
 | 	 	 if (tfcmg104.spot =  tcyesno.no) then  
 	 	 	 var.tfcmg104.rade =  6  
 | 	 	 endif  
 endif  
 | 	 if tfcmg104.rate =  0 then 	 	 	 	 	 | #  ravi.so  
 | 	 	 tfcmg104.rate =  1.0  
 | 	 endif 	 	 	 	 	 	 	 	 | #  ravi.eo  
 | 	 var.str.bpid =  get.bpid (tfcmg104.suno,bccom.orgn.suno)  
 	 if get.business.partner(tfcmg104.suno,bcstc.orgn.suno,err.mess) then  
 	 var.tfcmg104.bpid =  ""                                                          
 	 else  
 	 var.tfcmg104.bpid =  bcstc008.bpid  
 	 endif  
 	 if (tfcmg104.unip =  tcyesno.yes) then  
 	 	 	 var.str.rdat =  utc (tfcmg104.pdat,0)  
 	 else  
 	 	 	 select 	 tfcmg105.pdat,tfcmg105.suno,tfcmg105.orno  
 	 	 	 from 	 tfcmg105  
 	 	 	 where 	 tfcmg105._index1 =  {:tfcmg104.suno, :tfcmg104.orno}  
 	 	 	 order by tfcmg105.suno,tfcmg105.orno  
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 	 var.str.rdat =  utc (tfcmg105.pdat,0)  
 	 	 	 endselect  
 	 endif  
 	 if etol(tfcmg104.post) =  1 then 	 	 	 	 	 | #  ravi.sn  
 	 	 var.tfcmg104.adty =  1  
 	 else  
 	 	 var.tfcmg104.adty =  0  
 	 endif 	 	 	 	 	 	 	 	 | #  ravi.en  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:104
:SCPAC:tf
:SCMOD:cmg
:SFLNO:104
:ICOD:S
:QURY:START
select tfcmg104.*
from tfcmg104
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:104
:SCPAC:tf
:SCMOD:cmg
:SFLNO:104
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:107
:SCPAC:tf
:SCMOD:cmg
:SFLNO:107
:ICOD:D
:QURY:START
dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:107
:SCPAC:tf
:SCMOD:cmg
:SFLNO:107
:ICOD:S
:QURY:START
select tfcmg107.*
from tfcmg107
:QURY:END
:TEXT:
Direct Mapping. No conversion logic implemented.
:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:107
:SCPAC:tf
:SCMOD:cmg
:SFLNO:107
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:109
:SCPAC:tf
:SCMOD:cmg
:SFLNO:109
:ICOD:D
:QURY:START
| 	 if tfcmg109.stpp =  tfcmg.stpp.audited then  
 | 	 	 	 tfcmg109.stpp =  tfcmg.stpp.assigned  
 | 	 else  
 | 	 	 if tfcmg109.stpp =  tfcmg.stpp.assigned then  
 | 	 	 	 tfcmg109.stpp =  tfcmg.stpp.audited  
 | 	 	 endif  
 | 	 endif  
 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:109
:SCPAC:tf
:SCMOD:cmg
:SFLNO:109
:ICOD:S
:QURY:START
select tfcmg109.*
from tfcmg109
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:109
:SCPAC:tf
:SCMOD:cmg
:SFLNO:109
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:110
:SCPAC:tf
:SCMOD:cmg
:SFLNO:110
:ICOD:D
:QURY:START
|var.str.rdat =  utc (tfcmg110.crea,time.num ())  
 var.str.rdat =  utc (tfcmg110.crea,0)  
 	 	 	  
 	 if (not isspace (tfcmg110.cuno)) then  
 	 	 if get.business.partner(tfcmg110.cuno,bcstc.orgn.cuno,err.mess) then  
 	 	 	 var.tfcmg110.bpid =  ""                                        
 	 	 else  
 	 	 	 var.tfcmg110.bpid =  bcstc008.bpid  
 	 	 endif  
 	 	 var.str.rtyp =  var.str.sls.rtyp 	 	 	 	  
 	 else  
 	 	 if get.business.partner(tfcmg110.suno,bcstc.orgn.suno,err.mess) then  
 	 	 	 var.tfcmg110.bpid =  ""                                        
 	 	 else  
 	 	 	 var.tfcmg110.bpid =  bcstc008.bpid  
 	 	 endif  
 	 	 var.str.rtyp =  var.str.pur.rtyp 	 	 	 	  
 	 endif  
 	 if etol(tfcmg110.stbk) =  0 then  
 	 	 var.tfcmg110.stbk =  1  
 	 else  
 	 	 var.tfcmg110.stbk =  etol(tfcmg110.stbk)  
 	 endif  
 	 on case tfcmg110.step  
 	 	 case tfcmg.step.doc.selected :  
 	 	 	 var.tfcmg110.step =  1  
 	 	 	 break  
 	 	 case tfcmg.step.doc.to.cust :  
 	 	 	 var.tfcmg110.step =  5  
 	 	 	 break  
 	 	 case tfcmg.step.doc.acc.by.cust :  
 	 	 	 var.tfcmg110.step =  6  
 	 	 	 break  
 	 	 case tfcmg.step.doc.to.bank :  
 	 	 	 var.tfcmg110.step =  10  
 	 	 	 break  
 	 	 case tfcmg.step.doc.received :  
 	 	 	 var.tfcmg110.step =  3  
 	 	 	 break  
 	 	 case tfcmg.step.doc.acc.sent :  
 	 	 	 var.tfcmg110.step =  7  
 	 	 	 break  
 	 	 case tfcmg.step.doc.paid :  
 	 	 	 var.tfcmg110.step =  16  
 	 	 	 break  
 	 	 case tfcmg.step.doc.rejected :  
 	 	 	 var.tfcmg110.step =  17  
 	 	 	 break  
 	 endcase  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:110
:SCPAC:tf
:SCMOD:cmg
:SFLNO:110
:ICOD:S
:QURY:START
select tfcmg110.*
from tfcmg110
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:110
:SCPAC:tf
:SCMOD:cmg
:SFLNO:110
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:111
:SCPAC:tf
:SCMOD:cmg
:SFLNO:111
:ICOD:D
:QURY:START
new.country =  ""                                                                                        
 	 new.tax =  ""                        
 	 	 	 	 	 	 	 	 | #  210859.so  
 | 	 get.tax.by.country.code(tfcmg111.vatc, tfcmg111.cvat, new.country,  
 | 	 	 	 new.tax, err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 	 	 	 	 	 | #  210859.sn  
 	 get.tax.by.country.code.and.financial.company(  
 	 	 	 tfcmg111.vatc, tfcmg111.cvat,  
 	 	 	 tfcmg111.cono, new.country,  
 	 	 	 new.tax, err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.en  
 var.tfcmg111.adty =  0 	 	 	 	 	 	 | #  ravi.n  
 var.str.rdin =  utc.default 	 	 	 	 	 | #  200 -  97654 -  1.n  
 on case tfcmg111.tant  
 	 case tfcmg.tant.invoice :  
 	 	 if not isspace (tfcmg111.cuno) then  
 	 	 	 get.rate.date.and.rate.type.acr.record()  
 	 	 else  
 	 	 	 if not isspace (tfcmg111.suno) then  
 	 	 	 	 get.rate.date.and.rate.type.acp.record()  
 	 	 	 endif  
 	 	 endif  
 	 	 break  
 	 case tfcmg.tant.purchase.inv :  
 	 	 get.rate.date.and.rate.type.acp.record()  
 	 	 break  
 	 case tfcmg.tant.sales.inv :  
 	 	 get.rate.date.and.rate.type.acr.record()  
 	 	 break  
 	 case tfcmg.tant.advance :  
 	 	 if not isspace(tfcmg111.suno) then 	 	 	 	  
 	 	 	 var.tfcmg111.adty =  1  
 	 	 endif 	 	 	 	  
 	 	 select 	 tfcmg110.crea 	 	 	 | #  200 -  97654 -  2.sn  
 	 	 from 	 tfcmg110  
 	 	 where 	 tfcmg110._index1 =  {:tfcmg111.bank, :tfcmg111.tdoc, :tfcmg111.pdoc} 	 	  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 var.str.rdin =  utc (tfcmg110.crea,0)  
 	 	 selectempty  
 	 	 	 var.str.rdin =  utc.default  
 	 	 endselect  
 	 	 	 	 	 	 	 | #  200 -  97654 -  2.en  
 	 case tfcmg.tant.unallocated :  
 	 case tfcmg.tant.journal :  
 	 case tfcmg.tant.standing :  
 	 	 	 select 	 tfcmg110.crea,tfcmg110.suno,tfcmg110.cuno  
 	 	 	 from 	 tfcmg110  
 	 	 	 where 	 tfcmg110._index1 =  {:tfcmg111.bank, :tfcmg111.tdoc, :tfcmg111.pdoc} 	 	  
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 | 	 	 	 	 var.str.rdin =  utc (tfcmg110.crea,time.num ()) | #  200 -  97654 -  3.0  
 	 	 	 	 var.str.rdin =  utc (tfcmg110.crea, 0) 	 | #  200 -  97654 -  3.n  
 	 	 	 	 if (not isspace (tfcmg110.cuno)) then  
 	 	 	 	 	 	 var.str.rtin =  var.str.sls.rtyp  
 	 	 	 	 else  
 	 	 	 	 	 if (not isspace (tfcmg110.suno)) then  
 	 	 	 	 	 	 var.str.rtin =  var.str.pur.rtyp  
 	 	 	 	 	 endif  
 	 	 	 	 endif  
 	 	 	 selectempty  
 	 	 	 	 var.str.rdin =  utc.default  
 	 	 	 	 var.str.rtin =  " "  
 	 	 	 endselect  
 	 	 	 break  
 	 endcase  
 | 	 if (not isspace (tfcmg111.rcur)) then  
 | 	 	 select 	 tfcmg204.docd,tfcmg204.tran  
 | 	 	 from 	 tfcmg204,tfcmg110  
 | 	 	 where 	 tfcmg110._index1 =  {:tfcmg111.bank, :tfcmg111.tdoc, :tfcmg111.pdoc}  
 | 	 	 	 and 	 tfcmg204._index1 =  {tfcmg110.pyer,tfcmg110.pbat,tfcmg110.ptyp,tfcmg110.docn,1}  
 | 	 	 as set with 1 rows  
 | 	 	 selectdo  
 | 	 	 	 var.str.rrdt =  utc (tfcmg204.docd,0)  
 | 	 	 	 on case tfcmg204.tran  
 | 	 	 	 	 case tfcmg.tran.supplier :  
 | 	 	 	 	 case tfcmg.tran.unalloc.paym :  
 | 	 	 	 	 case tfcmg.tran.advance.paym :  
 | 	 	 	 	 	 	 var.str.rrty =  var.str.pur.rtyp  
 | 	 	 	 	 	 	 break  
 | 	 	 	 	 case tfcmg.tran.customer :  
 | 	 	 	 	 case tfcmg.tran.unalloc.rec :  
 | 	 	 	 	 case tfcmg.tran.advance.rec :  
 | 	 	 	 	 	 	 var.str.rrty =  var.str.sls.rtyp  
 | 	 	 	 	 	 	 break  
 | 	 	 	 	 case tfcmg.tran.reconc.suppl :  
 | 	 	 	 	 	 	 var.str.rrty =  var.str.pur.rtyp  
 | 	 	 	 	 	 	 break  
 | 	 	 	 	 case tfcmg.tran.reconc.cust :  
 | 	 	 	 	 	 	 var.str.rrty =  var.str.sls.rtyp  
 | 	 	 	 	 	 	 break  
 | 	 	 	 	 case tfcmg.tran.journal :  
 | 	 	 	 	 	 	 var.str.rrty =  var.str.eu.rtyp  
 | 	 	 	 	 	 	 break  
 | 	 	 	 	 endcase  
 | 	 	 selectempty  
 | 	 	 	 	 var.str.rrdt =  utc.default  
 | 	 	 	 	 var.str.rrty =  " "  
 | 	 	 endselect  
 	 if (not isspace (tfcmg111.rcur)) then 	 	 	 	 	 | #  ravi.sn  
 	 	 if not isspace(tfcmg111.cuno) then  
 	 	 	 var.str.rrty =  var.str.sls.rtyp  
 	 	 else  
 	 	 	 if not isspace(tfcmg111.suno) then  
 	 	 	 	 var.str.rrty =  var.str.pur.rtyp  
 	 	 	 endif  
 	 	 endif  
 	 	 select tfcmg110.pdat  
 	 	 from 	 tfcmg110  
 	 	 where 	 tfcmg110._index1 =  {:tfcmg111.bank, :tfcmg111.tdoc, :tfcmg111.pdoc}  
 	 	 selectdo  
 	 	 	 var.str.rrdt =  utc(tfcmg110.pdat,0)  
 	 	 selectempty  
 	 	 	 var.str.rrdt =  utc.default  
 	 	 	 var.str.rrty =  " "  
 	 	 endselect  
 	 else 	  
 	 	 	 	 	 	 	 	 	 | #  ravi.en  
 	 	 var.str.rrdt =  utc.default  
 	 	 var.str.rrty =  " "  
 	 endif  
 	 	 	 	  
 	 var.tfcmg111.bpid (1;9) =  " "  
 	 if (not isspace (tfcmg111.cuno)) then  
 | 	 	 var.tfcmg111.bpid =  get.bpid (tfcmg111.cuno,bccom.orgn.cuno)  
 	 	 if get.business.partner(tfcmg111.cuno,bcstc.orgn.cuno,err.mess) then  
 	 	 	 var.tfcmg111.bpid =  ""                                                                                                                                            
 	 	 else  
 	 	 	 var.tfcmg111.bpid =  bcstc008.bpid  
 	 	 endif  
 	 else  
 | 	 	 var.tfcmg111.bpid =  get.bpid (tfcmg111.suno,bccom.orgn.suno)  
 	 	 if get.business.partner(tfcmg111.suno,bcstc.orgn.suno,err.mess) then  
 	 	 	 var.tfcmg111.bpid =  ""                                                                                                                                            
 	 	 else  
 	 	 	 var.tfcmg111.bpid =  bcstc008.bpid  
 	 	 endif  
 	 endif  
 	 if etol(tfcmg111.blac) =  0 then 	 	 	 	 	 | #  ravi.sn  
 	 	 var.tfcmg111.blac =  4  
 	 else  
 	 	 var.tfcmg111.blac =  etol(tfcmg111.blac)  
 	 endif 	 	 	 	 	 	 	 	 	 | #  ravi.en  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:111
:SCPAC:tf
:SCMOD:cmg
:SFLNO:111
:ICOD:S
:QURY:START
select tfcmg111.*
from tfcmg111
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:111
:SCPAC:tf
:SCMOD:cmg
:SFLNO:111
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:115
:SCPAC:tf
:SCMOD:cmg
:SFLNO:115
:ICOD:D
:QURY:START
dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:115
:SCPAC:tf
:SCMOD:cmg
:SFLNO:115
:ICOD:S
:QURY:START
select tfcmg115.*
from tfcmg115
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:115
:SCPAC:tf
:SCMOD:cmg
:SFLNO:115
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:204
:SCPAC:tf
:SCMOD:cmg
:SFLNO:204
:ICOD:D
:QURY:START
new.country =  ""                                                        
 	 new.tax =  ""                                                        
 	 	 	 	 	 	 	 	 | #  210859.so  
 | 	 get.tax.by.country.code(tfcmg204.vatc, tfcmg204.cvat, new.country,  
 | 	 	 	 new.tax, err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 	 	 	 	 	 | #  210859.sn  
 	 get.tax.by.country.code.and.financial.company(  
 	 	 	 tfcmg204.vatc, tfcmg204.cvat,  
 	 	 	 current.company, new.country,  
 	 	 	 new.tax, err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.en  
 	 var.tfcmg204.adty =  0 	 	 	 	 	 	 	  
 	 var.tfcmg204.bpid (1;9) =  " "  
 	 var.tfcmg204.pbpt (1;9) =  " "  
 	 if isspace(tfcmg204.cuno) and isspace(tfcmg204.suno) then  
 	 	 var.tfcmg204.pbpt =  ""                                                                            
 	 else  
 	 	 if not isspace(tfcmg204.cuno) then  
 	 	 	 if get.business.partner(tfcmg204.cuno,bcstc.orgn.cuno,err.mess) then  
 	 	 	 	 var.tfcmg204.pbpt =  ""                                                                                                      
 	 	 	 else  
 	 	 	 	 var.tfcmg204.pbpt =  bcstc008.bpid  
 	 	 	 endif  
 	 	 	 var.str.rtyp =  var.str.sls.rtyp  
 	 	 else  
 	 	 	 if not isspace(tfcmg204.suno) then  
 	 	 	 	 if get.business.partner(tfcmg204.suno,bcstc.orgn.suno,err.mess) then  
 	 	 	 	 	 var.tfcmg204.pbpt =  ""                                                                                                      
 	 	 	 	 else  
 	 	 	 	 	 var.tfcmg204.pbpt =  bcstc008.bpid  
 	 	 	 	 endif  
 	 	 	 	 var.str.rtyp =  var.str.pur.rtyp  
 	 	 	 endif  
 	 	 endif  
 	 endif 	 	  
 	  
 	 	 	 on case 	 tfcmg204.tran  
 	 	 	 case 	 tfcmg.tran.advance.paym :  
 	 	 	 	 var.tfcmg204.adty =  1  
 	 	 	 	 break  
 	 	 	 	  
 	 	 	 case 	 tfcmg.tran.journal :  
 	 	 	 	 	 var.str.rtyp =  var.str.eu.rtyp  
 	 	 	 	 	 var.tfcmg204.pbpt (1;9) =  " "  
 	 	 	 	 break  
 	 	 	 case 	 tfcmg.tran.reconc.cust :  
 	 	 	 	 var.str.rtyp =  var.str.sls.rtyp  
 	 	 	 	 var.tfcmg204.pbpt (1;9) =  " "  
 	 	 	 	 break  
 	 	 	 case 	 tfcmg.tran.reconc.suppl :  
 	 	 	 	 var.str.rtyp =  var.str.pur.rtyp  
 	 	 	 	 var.tfcmg204.pbpt (1;9) =  " "  
 	 	 	 break  
 	 	 	 default :  
 	 	 	 	 break  
 	 	 	 endcase  
 	 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:204
:SCPAC:tf
:SCMOD:cmg
:SFLNO:204
:ICOD:S
:QURY:START
select tfcmg204.*
from tfcmg204
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:204
:SCPAC:tf
:SCMOD:cmg
:SFLNO:204
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:301
:SCPAC:tf
:SCMOD:cmg
:SFLNO:301
:ICOD:D
:QURY:START
var.tfcmg301.ftyp =  0  
 	 var.tfcmg301.bpid =  ""        	          |#        200-        98027.n        	                	                	                        
 on case (tfcmg301.forc)  
 	 	 case tfcmg.forc.pur.order :  
 	 	 	 var.tfcmg301.forc =  1  
 	 	 	 var.tfcmg301.orig =  concat$ (" ",var.comp, tfcmg301.orno,tfcmg301.pono)  
 	 	 	 break  
 	 	 case tfcmg.forc.sls.order :  
 	 	 	 var.tfcmg301.forc =  2  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101736.sn  
 	 	 	 if tfcmg301.nins <>  0 then  
 	 	 	 	 var.tfcmg301.orig =  concat$ (" ",var.comp, tfcmg301.orno,tfcmg301.pono,tfcmg301.nins)  
 	 	 	 else  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101736.en  
 	 	 	 	 var.tfcmg301.orig =  concat$ (" ",var.comp, tfcmg301.orno,tfcmg301.pono)  
 	 	 	 endif 	 	 	 	 	 	 	 | #  200 -  101736.n  
 	 	  
 	 	 	 break  
 	 	 case tfcmg.forc.pur.invoice :  
 	 	 	 var.tfcmg301.forc =  3  
 	 	 	 var.tfcmg301.orig =  "0"                                                    
 	 	 	 break  
 	 	 case tfcmg.forc.sls.invoice :  
 	 	 	 var.tfcmg301.forc =  4  
 	 	 	 var.tfcmg301.orig =  "0"                                                    
 	 	 	 break  
 	 	 case tfcmg.forc.budget.inf :  
 	 	 	 var.tfcmg301.forc =  6  
 	 	 	 var.tfcmg301.orig =  concat$ (" ", tfcmg301.budg , tfcmg301.leac)  
 	 	 	 break  
 	 	 case tfcmg.forc.budget.outf :  
 	 	 	 var.tfcmg301.forc =  7  
 	 	 	 var.tfcmg301.orig =  concat$ (" ", tfcmg301.budg , tfcmg301.leac)  
 	 	 	 break  
 	 	 case tfcmg.forc.sls.quotation :  
 	 	 	 var.tfcmg301.forc =  9  
 	 	 	 var.tfcmg301.orig =  concat$ (" ",var.comp, tfcmg301.orno,tfcmg301.pono)  
 	 	 	 break  
 	 	 case tfcmg.forc.sta.order :  
 	 	 	 var.tfcmg301.forc =  8  
 	 	 	 if tfcmg301.pono <>  0 then  
 	 	 	 	 var.tfcmg301.orig =  str$ (tfcmg301.pono)  
 	 	 	 else  
 	 	 	 	 var.tfcmg301.orig =  empty.string(1;30)  
 	 	 	 endif  
 	 	 	 | orig =  concat$ ( " ",tfcmg301.orno, tfcmg301.pono )  
 	 	 	 tfcmg301.ninv =  tfcmg301.orno  
 	 	 	 break  
 	 	 case tfcmg.forc.pro.order :  
 	 	 	 var.tfcmg301.forc =  10  
 	 	 	 var.tfcmg301.orig =  concat$ (" ", var.comp,tfcmg301.cprj, tfcmg301.nins)  
 	 	 	 var.tfcmg301.ftyp =  2  
 	 	 	 break  
 	 	 endcase  
 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:301
:SCPAC:tf
:SCMOD:cmg
:SFLNO:301
:ICOD:S
:QURY:START
select tfcmg301.*
from tfcmg301
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:301
:SCPAC:tf
:SCMOD:cmg
:SFLNO:301
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:401
:SCPAC:tf
:SCMOD:cmg
:SFLNO:401
:ICOD:D
:QURY:START
new.country =  ""                                                        
 	 new.tax =  ""                                                
 	 	 	 	 	 	 	 	 | #  210859.so  
 | 	 get.tax.by.country.code(tfcmg401.vatc, tfcmg401.cvat, new.country,  
 | 	 	 	 new.tax, err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 	 	 	 	 	 | #  210859.sn  
 	 get.tax.by.country.code.and.financial.company(  
 	 	 	 tfcmg401.vatc, tfcmg401.cvat,  
 	 	 	 tfcmg401.comp, new.country,  
 	 	 	 new.tax, err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.en  
 if get.business.partner(tfcmg401.cuno,bcstc.orgn.cuno,err.mess) then  
 	 var.bcstc008.itbp =  ""                                                                    
 else  
 	 var.bcstc008.itbp =  bcstc008.bpid  
 	  
 endif  
 if get.business.partner(tfcmg401.pcun,bcstc.orgn.cuno,err.mess) then  
 	 var.bcstc008.pbbp =  ""                                                                    
 else  
 	 var.bcstc008.pbbp =  bcstc008.bpid  
 	  
 endif  
 on case tfcmg401.tadv  
 	 	 	 case tfcmg.dbdv.purinv :  
 	 	 	 case tfcmg.dbdv.purcred :  
 	 	 	 	 select 	 tfacp200.docd  
 	 	 	 	 from 	 tfacp200  
 	 	 	 	 where 	 tfacp200._index1 =  {:tfcmg401.ttyp, :tfcmg401.ninv, :tfcmg401.srno, "",0,0}                                                                    
 	 	 	 	 as set with 1 rows  
 	 	 	 	 selectdo  
 	 	 	 	 	 var.str.rdat =  utc (tfacp200.docd,0)  
 	 	 	 	 endselect  
 	 	 	 	 var.str.rtyp =  var.str.pur.rtyp  
 	 	 	 break  
 	 	 	 case tfcmg.dbdv.slsinv :  
 	 	 	 case tfcmg.dbdv.slscred :  
 	 	 	 	 select 	 tfacr200.docd  
 	 	 	 	 from 	 tfacr200  
 	 	 	 	 where 	 tfacr200._index1 =  {:tfcmg401.ttyp, :tfcmg401.ninv, :tfcmg401.srno, "",0,0}                                                                    
 	 	 	 	 as set with 1 rows  
 	 	 	 	 selectdo  
 	 	 	 	 	 var.str.rdat =  utc (tfacr200.docd,0)  
 	 	 	 	 endselect  
 	 	 	 	 var.str.rtyp =  var.str.sls.rtyp  
 	 	 	 break  
 	 	 	 case tfcmg.dbdv.advance :  
 	 	 	 case tfcmg.dbdv.unallocated :  
 	 	 	 	 var.str.rdat =  utc (tfcmg401.plan,0)  
 	 	 	 	 var.str.rtyp =  var.str.sls.rtyp  
 	 	 	 break  
 	 	 endcase  
 	 	 If isspace (var.str.rdat) then  
 	 	 	 var.str.rdat =  utc.default  
 	 	 endif  
 	  
 	 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:401
:SCPAC:tf
:SCMOD:cmg
:SFLNO:401
:ICOD:S
:QURY:START
select tfcmg401.*
from tfcmg401
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:401
:SCPAC:tf
:SCMOD:cmg
:SFLNO:401
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:409
:SCPAC:tf
:SCMOD:cmg
:SFLNO:409
:ICOD:D
:QURY:START
dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:409
:SCPAC:tf
:SCMOD:cmg
:SFLNO:409
:ICOD:S
:QURY:START
select tfcmg409.*
from tfcmg409
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:409
:SCPAC:tf
:SCMOD:cmg
:SFLNO:409
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:503
:SCPAC:tf
:SCMOD:cmg
:SFLNO:503
:ICOD:D
:QURY:START
new.country =  ""                                                      
 	 new.tax =  ""                     
 	 	 	 	 	 	 	 	 | #  210859.so  
 | 	 get.tax.by.country.code(tfcmg503.vatc, tfcmg503.cvat, new.country,  
 | 	 	 	 new.tax, err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 	 	 	 	 	 | #  210859.sn  
 	 get.tax.by.country.code.and.financial.company(  
 	 	 	 tfcmg503.vatc, tfcmg503.cvat,  
 	 	 	 tfcmg503.cono, new.country,  
 	 	 	 new.tax, err.mess)  
 	 	 	 	 	 	 	 	 | #  210859.en  
 var.tfcmg503.adty =  0  
 if not isspace (tfcmg503.cuno) then  
 	 	 if get.business.partner(tfcmg503.cuno,bcstc.orgn.cuno,err.mess) then  
 	 	 	 var.tfcmg503.bpid =  ""                                                                          
 	 	 else  
 	 	 	 var.tfcmg503.bpid =  bcstc008.bpid  
 	 	 endif  
 else  
 	 	 if get.business.partner(tfcmg503.suno, bcstc.orgn.suno,err.mess) then  
 	 	 	 var.tfcmg503.bpid =  ""                                                                          
 	 	 else  
 	 	 	 var.tfcmg503.bpid =  bcstc008.bpid  
 	 	 endif  
 endif  
 	  
 	 on case tfcmg503.tran  
 	 	 case tfcmg.tran.customer :  
 	 	 case tfcmg.tran.unalloc.rec :  
 	 	 case tfcmg.tran.advance.rec :  
 	 	 case tfcmg.tran.reconc.cust :  
 	 	 	 	 var.str.rtyp =  var.str.sls.rtyp  
 	 	 	 	 break 	  
 	 	 case tfcmg.tran.advance.paym :  
 	 	 	 	 var.tfcmg503.adty =  1  
 	 	 case tfcmg.tran.supplier :  
 	 	 case tfcmg.tran.unalloc.paym :  
 	 	 case tfcmg.tran.reconc.suppl :  
 	 	 	 	 var.str.rtyp =  var.str.pur.rtyp  
 	 	 	 	 break 	  
 	 	 case tfcmg.tran.journal :  
 	 	 	 	 var.str.rtyp =  var.str.eu.rtyp  
 	 	 	 	 break  
 	 endcase  
 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:503
:SCPAC:tf
:SCMOD:cmg
:SFLNO:503
:ICOD:S
:QURY:START
select tfcmg503.*
from tfcmg503
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:503
:SCPAC:tf
:SCMOD:cmg
:SFLNO:503
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:fam
:TFLNO:710
:SCPAC:tf
:SCMOD:fas
:SFLNO:002
:ICOD:D
:QURY:START
| #  200 -  100992.sn  
 	 var.dbl.tffam710.life =  0  
 	  
 	 select max (tffas009.year):var.dbl.tffam710.life  
 	 from tffas009  
 	 where tffas009.depc =  :tffas002.depc  
 	 selectdo  
 	 endselect  
 	 	 	 	 	 	 	 	 	 | #  200 -  100992.en  
 	  
 var.str.tffam710.meth =  "B" &                         tffas002.depc                                                
 	 on case tffas002.sdpr  
 	  
 	 case tffas.sdpr.date.use :  
 	 	 var.lng.tffam710.conv =  1  
 	 	 break  
 	  
 	 case tffas.sdpr.per.after.use :  
 	 	 var.lng.tffam710.conv =  11  
 	 	 break  
 	  
 	 case tffas.sdpr.per.use :  
 	 	 var.lng.tffam710.conv =  8  
 	 	 break  
 	 case tffas.sdpr.first.per.use :  
 	 	 var.lng.tffam710.conv =  9  
 	 	 break  
 	 case tffas.sdpr.first.per.use.n :  
 	 	 var.lng.tffam710.conv =  10  
 	 	 break  
 	 case tffas.sdpr.first.second :  
 	 	 var.lng.tffam710.conv =  12  
 	 	 break  
 	 case tffas.sdpr.second.half :  
 	 	 var.lng.tffam710.conv =  13  
 	 	 break  
 	  
 	 endcase  
 	  
 	 var.lng.tffam710.dbpt =  0 	  
 	 var.tfgld.amnt.tffam710.fixa =  0  
 	 var.dbl.tffam710.intr =  0  
 	 var.lng.tffam710.rtty =  1  
 	 if etol (tffas002.stdp) =  3 then  
 	 	 var.lng.tffam710.depl =  2  
 	 else  
 	 	 var.lng.tffam710.depl =  1  
 	 endif  
 	 	 	  
 	 on case tffas002.desy  
 	 case tffas.desy.fix.perc.base :  
 	 	 var.dbl.dbpt =  tffas002.fixp  
 	 	 var.lng.tffam710.dbpt =  round (var.dbl.dbpt,2,1)  
 	 	 if etol (tffas002.babo) =  2 then  
 | 	 	 	 var.lng.tffam710.type =  2 	 	 	 | #  209423.so  
 | 	 	 	 var.str.tffam710.desc =  "Declining Balance"   |#              209423.eo                            
 	 	 	 var.lng.tffam710.type =  1 	 	 	 | #  209423.sn  
 	 	 	 var.str.tffam710.desc =  "Straight line"              	              |#              209423.en                                  
 	 	 else  
 | 	 	 	 var.lng.tffam710.type =  10 	 	 	 | #  209423.so  
 | 	 	 	 var.str.tffam710.desc =  "NBV -Oriented Depreciation"     |#              209423.eo                            
 	 	 	 var.lng.tffam710.type =  2 	 	 	 | #  209423.sn  
 	 	 	 var.str.tffam710.desc =  "Declining Balance"   |#              209423.en                              
 	 	 endif  
 	 	 break  
 	 case tffas.desy.var.perc.base :  
 	 	 var.lng.tffam710.type =  8  
 	 	 var.str.tffam710.desc =  "Custom method"                                                
 	 	 var.lng.tffam710.rtty =  3  
 	 	 break  
 	 case tffas.desy.sum.digits :  
 	 	 var.lng.tffam710.type =  3  
 	 	 var.str.tffam710.desc =  "Sum of the year digits"                                                
 	 	 break  
 	 case tffas.desy.annuity :  
 	 	 var.lng.tffam710.type =  6  
 	 	 var.str.tffam710.desc =  "Annunity"                                                
 	 	 break  
 	 case tffas.desy.fix.amnt :  
 	 	 var.lng.tffam710.type =  7  
 	 	 var.str.tffam710.desc =  "Fixed Amount"                                                
 	 	 var.tfgld.amnt.tffam710.fixa =  tffas002.fixa  
 	 	 break  
 	 case tffas.desy.var.amnt :  
 	 	 var.lng.tffam710.type =  9  
 	 	 var.str.tffam710.desc =  "None"                                                
 	 	 var.dbl.tffam710.intr =  tffas002.annp  
 	 	 var.dbl.tffam710.life =  0 	 	 	 	 | #  200 -  100992.n  
 	 	 break  
 	 case tffas.desy.years.use :  
 	 	 var.lng.tffam710.type =  1  
 	 	 var.str.tffam710.desc =  "Straight line"                                                
 	 	 break  
 	 case tffas.desy.act.performed :  
 	 	 var.lng.tffam710.type =  4  
 	 	 var.str.tffam710.desc =  "Units of production"                                                
 	 	 var.dbl.tffam710.life =  0 	 	 	 	 | #  200 -  100992.n  
 	 	 break  
 	 endcase  
 	  
 	 var.str.tffam710.desc =  to.native (var.str.tffam710.desc)  
 	 	 	 	 	 	 	 	 	 | #  200 -  100992.so  
 | 	 var.dbl.tffam710.life =  0  
 | 	  
 | 	 select max (tffas009.year):var.dbl.tffam710.life  
 | 	 from tffas009  
 | 	 where tffas009.depc =  :tffas002.depc  
 | 	 selectdo  
 | 	 endselect  
 	 	 	 	 	 	 	 	 	 | #  200 -  100992.en  
 	 dump 3
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:fam
:TFLNO:710
:SCPAC:tf
:SCMOD:fas
:SFLNO:002
:ICOD:S
:QURY:START
select tffas002.*
from tffas002
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:fam
:TFLNO:710
:SCPAC:tf
:SCMOD:fas
:SFLNO:002
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:fam
:TFLNO:710
:SCPAC:tf
:SCMOD:fas
:SFLNO:005
:ICOD:D
:QURY:START
| #  200 -  100992.sn  
 	 var.dbl.tffam710.life =  0  
 	 	 	 	 	 	 	 	  
 	 select max (tffas009.year):var.dbl.tffam710.life  
 	 from tffas009  
 	 where tffas009.fasc =  :tffas005.ngrp and tffas009.depc =  :tffas005.depc  
 	 selectdo  
 	 endselect  
 	 	 	 	 	 	 	 	 | #  200 -  100992.en  
 	 var.str.tffam710.meth =  "C" &                         tffas005.ngrp &                         "B" &                         tffas005.depc                                                
 	 on case tffas005.sdpr  
 	  
 	 case tffas.sdpr.date.use :  
 	 	 var.lng.tffam710.conv =  1  
 	 	 break  
 	  
 	 case tffas.sdpr.per.after.use :  
 	 	 var.lng.tffam710.conv =  11  
 	 	 break  
 	  
 	 case tffas.sdpr.per.use :  
 	 	 var.lng.tffam710.conv =  8  
 	 	 break  
 	 case tffas.sdpr.first.per.use :  
 	 	 var.lng.tffam710.conv =  9  
 	 	 break  
 	 case tffas.sdpr.first.per.use.n :  
 	 	 var.lng.tffam710.conv =  10  
 	 	 break  
 	 case tffas.sdpr.first.second :  
 	 	 var.lng.tffam710.conv =  12  
 	 	 break  
 	 case tffas.sdpr.second.half :  
 	 	 var.lng.tffam710.conv =  13  
 	 	 break  
 	  
 	 endcase  
 	  
 	 var.lng.tffam710.dbpt =  0 	  
 	 var.tfgld.amnt.tffam710.fixa =  0  
 	 var.dbl.tffam710.intr =  0  
 	 var.lng.tffam710.rtty =  1  
 	 if etol (tffas005.stdp) =  3 then  
 	 	 var.lng.tffam710.depl =  2  
 	 else  
 	 	 var.lng.tffam710.depl =  1  
 	 endif  
 	 	 	  
 	 on case tffas005.desy  
 	 case tffas.desy.fix.perc.base :  
 	 	 var.dbl.dbpt =  tffas005.fixp  
 	 	 var.lng.tffam710.dbpt =  round (var.dbl.dbpt,2,1)  
 	 	 if etol (tffas005.babo) =  2 then  
 | 	 	 	 var.lng.tffam710.type =  2 	 	 	 | #  209423.so  
 | 	 	 	 var.str.tffam710.desc =  "Declining Balance"   |#              209423.eo                            
 	 	 	 var.lng.tffam710.type =  1 	 	 	 | #  209423.sn  
 	 	 	 var.str.tffam710.desc =  "Straight line"                	              |#              209423.en                                  
 	 	 else  
 | 	 	 	 var.lng.tffam710.type =  10 	 	 	 | #  209423.so  
 | 	 	 	 var.str.tffam710.desc =  "NBV -Oriented Depreciation"     |#              209423.eo                            
 	 	 	 var.lng.tffam710.type =  2 	 	 	 | #  209423.sn  
 	 	 	 var.str.tffam710.desc =  "Declining Balance"              	              |#              209423.en                                           
 	 	 endif  
 	 	 break  
 	 case tffas.desy.var.perc.base :  
 	 	 var.lng.tffam710.type =  8  
 	 	 var.str.tffam710.desc =  "Custom method"                                                
 	 	 var.lng.tffam710.rtty =  3  
 	 	 break  
 	 case tffas.desy.sum.digits :  
 	 	 var.lng.tffam710.type =  3  
 	 	 var.str.tffam710.desc =  "Sum of the year digits"                                                
 	 	 break  
 	 case tffas.desy.annuity :  
 	 	 var.lng.tffam710.type =  6  
 	 	 var.str.tffam710.desc =  "Annunity"                                                
 	 	 break  
 	 case tffas.desy.fix.amnt :  
 	 	 var.lng.tffam710.type =  7  
 	 	 var.str.tffam710.desc =  "Fixed Amount"                                                
 	 	 var.tfgld.amnt.tffam710.fixa =  tffas005.fixa  
 	 	 break  
 	 case tffas.desy.var.amnt :  
 	 	 var.lng.tffam710.type =  9  
 	 	 var.str.tffam710.desc =  "None"                                                
 	 	 var.dbl.tffam710.intr =  tffas005.annp  
 	 	 var.dbl.tffam710.life =  0 	 	 	 | #  200 -  100992.n  
 	 	 break  
 	 case tffas.desy.years.use :  
 	 	 var.lng.tffam710.type =  1  
 	 	 var.str.tffam710.desc =  "Straight line"                                                
 	 	 break  
 	 case tffas.desy.act.performed :  
 	 	 var.lng.tffam710.type =  4  
 	 	 var.str.tffam710.desc =  "Units of production"                                                
 	 	 var.dbl.tffam710.life =  0 	 	 	 | #  200 -  100992.n  
 	 	 break  
 	 endcase  
 	  
 	 var.str.tffam710.desc =  to.native (var.str.tffam710.desc)  
 	  
 	 	 	 	 	 	 	 	 | #  200 -  100992.so  
 | 	 var.dbl.tffam710.life =  0  
 	 	 	 	 	 	 	 	  
 | 	 select max (tffas009.year):var.dbl.tffam710.life  
 | 	 from tffas009  
 | 	 where tffas009.fasc =  :tffas005.ngrp and tffas009.depc =  :tffas005.depc  
 | 	 selectdo  
 | 	 endselect  
 	 	 	 	 	 	 	 	 | #  200 -  100992.eo  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:fam
:TFLNO:710
:SCPAC:tf
:SCMOD:fas
:SFLNO:005
:ICOD:S
:QURY:START
select tffas005.*
from tffas005
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:fam
:TFLNO:710
:SCPAC:tf
:SCMOD:fas
:SFLNO:005
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:fam
:TFLNO:710
:SCPAC:tf
:SCMOD:fas
:SFLNO:008
:ICOD:D
:QURY:START
| #  200 -  100992.sn  
 	 var.dbl.tffam710.life =  0  
 	 	 	 	 	 	 	 	 	  
 	 select max (tffas009.year):var.dbl.tffam710.life  
 	 from tffas009  
 	 where tffas009.fasc =  :tffas008.fasc and tffas009.depc =  :tffas008.depc  
 	 selectdo  
 	 endselect  
 	 	 	 	 	 	 	 	 	 | #  200 -  100992.en  
 var.str.tffam710.meth =  get.string(32) &  tffas008.fasc &  get.string(33) &  tffas008.depc  
 	 on case tffas008.sdpr  
 	 case tffas.sdpr.date.use :  
 	 	 var.lng.tffam710.conv =  1  
 	 	 break  
 	 case tffas.sdpr.per.after.use :  
 	 	 var.lng.tffam710.conv =  11  
 	 	 break  
 	 case tffas.sdpr.per.use :  
 	 	 var.lng.tffam710.conv =  8  
 	 	 break  
 	 case tffas.sdpr.first.per.use :  
 	 	 var.lng.tffam710.conv =  9  
 	 	  
 	 	 break  
 	 case tffas.sdpr.first.per.use.n :  
 	 	 var.lng.tffam710.conv =  10  
 	 	 break  
 	 case tffas.sdpr.first.second :  
 	 	 var.lng.tffam710.conv =  12  
 	 	 break  
 	 case tffas.sdpr.second.half :  
 	 	 var.lng.tffam710.conv =  13  
 	 	 break  
 	 endcase  
 	  
 	 var.lng.tffam710.dbpt =  0 	  
 	 var.tfgld.amnt.tffam710.fixa =  0  
 	 var.dbl.tffam710.intr =  0  
 	 var.lng.tffam710.rtty =  1  
 	 if etol (tffas008.stdp) =  3 then  
 	 	 var.lng.tffam710.depl =  2  
 	 else  
 	 	 var.lng.tffam710.depl =  1  
 	 endif  
 	 	 	  
 	 on case tffas008.desy  
 	 case tffas.desy.fix.perc.base :  
 	 	 var.dbl.dbpt =  tffas008.fixp  
 	 	 var.lng.tffam710.dbpt =  round (var.dbl.dbpt,2,1)  
 	 	 if etol (tffas008.babo) =  2 then  
 | 	 	 	 var.lng.tffam710.type =  2 	 	 	 | #  209423.so  
 | 	 	 	 var.str.tffam710.desc =  get.string(9) 	 | #  209423.eo  
 	 	 	 var.lng.tffam710.type =  1 	 	 	 | #  209423.sn  
 	 	 	 var.str.tffam710.desc =  get.string(16) 	 	 | #  209423.en  
 	 	 else  
 | 	 	 	 var.lng.tffam710.type =  10 	 	 	 | #  209423.so  
 | 	 	 	 var.str.tffam710.desc =  get.string(10) 	 | #  209423.eo  
 	 	 	 var.lng.tffam710.type =  2 	 	 	 | #  209423.sn  
 	 	 	 var.str.tffam710.desc =  get.string(9) 	 	 | #  209423.en  
 	 	 endif  
 	 	 break  
 	 case tffas.desy.var.perc.base :  
 	 	 var.lng.tffam710.type =  8  
 	 	 var.str.tffam710.desc =  get.string(11)  
 	 	 var.lng.tffam710.rtty =  3  
 	 	 break  
 	 case tffas.desy.sum.digits :  
 	 	 var.lng.tffam710.type =  3  
 	 	 var.str.tffam710.desc =  get.string(12)  
 	 	 break  
 	 case tffas.desy.annuity :  
 	 	 var.lng.tffam710.type =  6  
 	 	 var.str.tffam710.desc =  get.string(13)  
 	 	 break  
 	 case tffas.desy.fix.amnt :  
 	 	 var.lng.tffam710.type =  7  
 	 	 var.str.tffam710.desc =  get.string(14)  
 	 	 var.tfgld.amnt.tffam710.fixa =  tffas008.fixa  
 	 	 break  
 	 case tffas.desy.var.amnt :  
 	 	 var.lng.tffam710.type =  9  
 	 	 var.str.tffam710.desc =  get.string(15)  
 	 	 var.dbl.tffam710.intr =  tffas008.annp  
 	 	 var.dbl.tffam710.life =  0 	 	 	 	 	 | #  200 -  100992.n  
 	 	 break  
 	 case tffas.desy.years.use :  
 	 	 var.lng.tffam710.type =  1  
 	 	 var.str.tffam710.desc =  get.string(16)  
 	 	 break  
 	 case tffas.desy.act.performed :  
 	 	 var.lng.tffam710.type =  4  
 	 	 var.str.tffam710.desc =  get.string(17)  
 	 	 var.dbl.tffam710.life =  0 	 	 	 	 	 | #  200 -  100992.n 	  
 	 	 break  
 	 endcase  
 	  
 	 var.str.tffam710.desc =  to.native (var.str.tffam710.desc)  
 	 	 	 	 	 	 	 	 	 | #  200 -  100992.so  
 | 	 var.dbl.tffam710.life =  0  
 	 	 	 	 	 	 	 	 	  
 | 	 select max (tffas009.year):var.dbl.tffam710.life  
 | 	 from tffas009  
 | 	 where tffas009.fasc =  :tffas008.fasc and tffas009.depc =  :tffas008.depc  
 | 	 selectdo  
 | 	 endselect  
 	 	 	 	 	 	 	 	 	 | #  200 -  100992.eo  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:fam
:TFLNO:710
:SCPAC:tf
:SCMOD:fas
:SFLNO:008
:ICOD:S
:QURY:START
select tffas008.*
from tffas008
where NOT EXISTS (select tffas101.*   
 	 	 from tffas101  
 	 	 where tffas101.fasc =  tffas008.fasc)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:fam
:TFLNO:710
:SCPAC:tf
:SCMOD:fas
:SFLNO:008
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:004
:SCPAC:tf
:SCMOD:gld
:SFLNO:004
:ICOD:D
:QURY:START
	 var.tfgld004.indt =  utc(0,0)  
 	 var.tfgld004.dsca =  form.text$("bcstc00035") | *  Actual Set  
 	 dump 1  
 	 var.tfgld004.indt =  utc(date.num(), time.num())  
 	 var.tfgld004.dsca =  form.text$("bcstc00036") | *  Converted from BaanIVc4  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:004
:SCPAC:tf
:SCMOD:gld
:SFLNO:004
:ICOD:S
:QURY:START
select 	 tfgld004.*
from 	 tfgld004
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:004
:SCPAC:tf
:SCMOD:gld
:SFLNO:004
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:008
:SCPAC:bc
:SCMOD:stf
:SFLNO:008
:ICOD:D
:QURY:START
	 var.tfgld008.atyp =  get.account.type(bcstf008.leac)  
 	 dump 3 | *  Currency Difference Contra account is added.
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:008
:SCPAC:bc
:SCMOD:stf
:SFLNO:008
:ICOD:S
:QURY:START
select 	 bcstf008.*
from 	 bcstf008
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:008
:SCPAC:bc
:SCMOD:stf
:SFLNO:008
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:008
:SCPAC:tf
:SCMOD:gld
:SFLNO:008
:ICOD:D
:QURY:START
	 set.common.attributes() 	  
 	 if bcstf007.uia6 =  tcyesno.yes then  
 	 	 dump 2 | *  Integration Accounts  
 	 else  
 	 	 set.attributes.non.integration.account()  
 	 	 if tfgld008.icur =  tcicur.difference then  
 	 	 	 dummy.long =  get.curr.diff.contra.account(  
 	 	 	 	 	 tfgld008.leac,  
 	 	 	 	 	 error.mess)  
 	 	 	 var.tfgld008.cdca =  bcstf008.cdca  
 	 	 else  
 	 	 	 var.tfgld008.cdca =  ""                                                                                                                                                     
 	 	 endif  
 	 	 dump 1 | *  Other, non integration accounts  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:008
:SCPAC:tf
:SCMOD:gld
:SFLNO:008
:ICOD:S
:QURY:START
select 	 tfgld008.*  , bcstf007.uia6
from 	 tfgld008, bcstf007
where 	 tfgld008.leac refers to bcstf007 unref SETUNREF
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:008
:SCPAC:tf
:SCMOD:gld
:SFLNO:008
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:008
:SCPAC:tf
:SCMOD:gld
:SFLNO:009
:ICOD:D
:QURY:START
	 dump 6 | *  Existing dimension ranges
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:008
:SCPAC:tf
:SCMOD:gld
:SFLNO:009
:ICOD:S
:QURY:START
select 	 tfgld009.*
from 	 tfgld009
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:008
:SCPAC:tf
:SCMOD:gld
:SFLNO:009
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:016
:SCPAC:tf
:SCMOD:gld
:SFLNO:016
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:016
:SCPAC:tf
:SCMOD:gld
:SFLNO:016
:ICOD:S
:QURY:START
select 	 tfgld016.*
from 	 tfgld016
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:016
:SCPAC:tf
:SCMOD:gld
:SFLNO:016
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:102
:SCPAC:tf
:SCMOD:gld
:SFLNO:102
:ICOD:D
:QURY:START
	 var.str.bpid =  ""                                            
 	 var.str.rtyp =  var.str.eu.rtyp  
 	 if not isspace (tfgld102.cuno) then  
 	 	 var.str.bpid =  get.business.partner.code(  
 	 	 	 	 	 tfgld102.cuno,  
 	 	 	 	 	 bcstc.orgn.cuno,  
 	 	 	 	 	 error.message)  
 	 	 var.str.rtyp =  var.str.sls.rtyp  
 	 else  
 	 	 if not isspace (tfgld102.suno) then  
 	 	 	 var.str.bpid =  get.business.partner.code(  
 	 	 	 	 	 	 tfgld102.suno,  
 	 	 	 	 	 	 bcstc.orgn.suno,  
 	 	 	 	 	 	 error.message)  
 	 	 	 var.str.rtyp =  var.str.pur.rtyp  
 	 	 endif  
 	 endif  
 	 if tfgld102.tcsh =  tfcmg.tcsh.empt then  
 	 	 | *  Baan4 enum 20 ( =  empt) changes into 23( =  empty)  
 	 	 | *  in baan6  
 	 	 var.tfgld102.tcsh =  target(tfcmg.tcsh.empty)  
 	 else  
 	 	 if tfgld102.tcsh =  tfcmg.tcsh.ssgn.ant then  
 	 	 	 | *  Baan4 enum 21 ( =  ssgn.ant) changes into  
 	 	 	 | *  20( =  ssgn.ant) in baan6  
 	 	 	 var.tfgld102.tcsh =  target(tfcmg.tcsh.ssgn.ant)  
 	 	 else  
 	 	 	 | *  Baan4 enum 1 till 19 have same value as baan6  
 	 	 	 var.tfgld102.tcsh =  etol(tfgld102.tcsh)  
 	 	 endif  
 	 endif  
 | 	 ret.long =  get.tax.by.country.code( 	 	 	 | #  SP2.so  
 | 	 	 	 tfgld102.ccty,  
 | 	 	 	 tfgld102.cvat,  
 | 	 	 	 var.tfgld102.ccty,  
 | 	 	 	 var.tfgld102.cvat,  
 | 	 	 	 error.message) 	 	 	 | #  SP2.eo  
 	 var.tfgld102.ccty =  ""             	                          	                          	                          	                          	             |#             210859.n                          
 	 var.tfgld102.cvat =  ""             	                          	                          	                          	                          	             |#             210859.n                          
 	 if not isspace(tfgld102.ccty) then 	 	 	 | #  SP2.sn  
 	 	 	 	 	 	 	 	 | #  210859.so  
 | 	 	 var.tfgld102.ccty =  get.country.of.financial.company(  
 | 	 	 	 	 	 tfgld102.cono)  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 	 	 	 	 	 | #  210859.so  
 | 	 	 ret.long =  get.tax.by.country.code( 	 | #  210859.sn  
 | 	 	 	 	 tfgld102.ccty,  
 | 	 	 	 	 tfgld102.cvat,  
 | 	 	 	 	 var.tfgld102.ccty,  
 | 	 	 	 	 var.tfgld102.cvat,  
 | 	 	 	 	 error.message) 	 	 | #  210859.en  
 	 	 	 	 	 	 	 	 | #  210859.eo  
 	 	 	 	 	 	 	 	 | #  210859.sn  
 	 	 ret.long =  get.tax.by.country.code.and.financial.company(  
 	 	 	 	 tfgld102.ccty,  
 	 	 	 	 tfgld102.cvat,  
 	 	 	 	 tfgld102.cono,  
 	 	 	 	 var.tfgld102.ccty,  
 	 	 	 	 var.tfgld102.cvat,  
 	 	 	 	 error.message)  
 	 	 	 	 	 	 	 	 | #  210859.en  
 	 endif 	 	 	 	 	 	 	 | #  SP2.en  
 	 for element =  1 to 3  
 	 	 var.tfgld102.rate(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld102.rate,  
 	 	 	 	 element,  
 	 	 	 	 0.000001)  
 | 	 	 	 	 	 	 	 	 | #  jv.so  
 | 	 	 var.tfgld102.irat(element) =  fill.mc.field.double(  
 | 	 	 	 	 0.000001, 	  
 | 	 	 	 	 element,  
 | 	 	 	 	 0.000001) 	 	 	 | #  jv.eo  
 	 	 | *  Rate fields must always be filled.  
 	 	 var.tfgld102.fact(element) =  fill.mc.field.long(  
 	 	 	 	 tfgld102.fact,  
 	 	 	 	 element,  
 	 	 	 	 1)  
 | 	 	 	 	 	 	 	 	 | #  jv.so  
 | 	 	 var.tfgld102.ifac(element) =  fill.mc.field.long(  
 | 	 	 	 	 1, 	 	  
 | 	 	 	 	 element,  
 | 	 	 	 	 1) 	 	 	 	 | #  jv.eo  
 	 	 | *  Intercompany Rate Factor is set to 1.  
 	 	 var.tfgld102.amth(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld102.amth,  
 	 	 	 	 element,  
 	 	 	 	 0.0)  
 	 	 var.tfgld102.vamh(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld102.vamh,  
 	 	 	 	 element,  
 	 	 	 	 0.0)  
 	 endfor  
 	 if tfgld102.vtyp =  empty then  
 	 	 var.tfgld102.vtyp =  target(tfgld.vtyp.not.applicable)  
 	 else  
 	 	 var.tfgld102.vtyp =  etol(tfgld102.vtyp)  
 	 endif  
 	 if tfgld102.catg =  empty then  
 	 	 var.tfgld102.catg =  target(tfgld.catg.not.applicable)  
 	 else  
 	 	 var.tfgld102.catg =  etol(tfgld102.catg)  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:102
:SCPAC:tf
:SCMOD:gld
:SFLNO:102
:ICOD:S
:QURY:START
select tfgld102.*
from tfgld102
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:102
:SCPAC:tf
:SCMOD:gld
:SFLNO:102
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tg
:TCMOD:brg
:TFLNO:030
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:D
:QURY:START
	 var.desc =  form.text$("bcstc00052")  
 	 var.desc =  sprintf$(var.desc, bcstc018.fcmp, bcstc018.lcmp)  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tg
:TCMOD:brg
:TFLNO:030
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:S
:QURY:START
select 	 bcstc018.*
from 	 bcstc018
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tg
:TCMOD:brg
:TFLNO:030
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:bom
:TFLNO:010
:SCPAC:ti
:SCMOD:bom
:SFLNO:010
:ICOD:D
:QURY:START
	 fill.expiry.date(tibom010.exdt)  
 | #  SP1.sn  
 	 var.tibom010.rdsp =  tcyesno.no  
 	 select 	 tibom020.lcid  
 	 from 	 tibom020  
 	 where 	 tibom020.cmba =  {:tibom010.mitm,  
 	 	 	 	 	 :tibom010.pono,  
 	 	 	 	 	 :tibom010.seqn}  
 	 as set with 1 rows  
 	 selectdo  
 	 	 var.tibom010.rdsp =  tcyesno.yes  
 	 endselect  
 | #  SP1.en  
 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:bom
:TFLNO:010
:SCPAC:ti
:SCMOD:bom
:SFLNO:010
:ICOD:S
:QURY:START
select 	 tibom010.*
from 	 tibom010
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:bom
:TFLNO:010
:SCPAC:ti
:SCMOD:bom
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:bom
:TFLNO:010
:SCPAC:ti
:SCMOD:pcs
:SFLNO:022
:ICOD:D
:QURY:START
	 | *  in case of standard order policy, then read Item tabel for sub -  item.  
 	 | *  only once per sub -  item.  
 	 if tipcs022.opol =  tcittb.standard and tipcs022.sitm <>  prev.sitm then  
 	 	 select 	 tiitm001.opol  
 	 	 from 	 tiitm001  
 	 	 where 	 tiitm001.item =  :tipcs022.sitm  
 	 	 selectdo  
 	 	 endselect  
 	 endif  
 	 	  
 	 | *  build sub item code  
 	 if (tipcs022.opol =  tcittb.standard) then  
 	 	 if (tiitm001.opol =  tcopol.anonymous) then  
 	 	 	 var.tibom010.sitm =  segment.item.code (tipcs022.sitm, "")                                                                                                                        
 	 	 else  
 	 	 	 var.tibom010.sitm =  segment.item.code (tipcs022.sitm, get.ti.project(tipcs022.cprj))  
 	 	 endif  
 	 else  
 	 	 var.tibom010.sitm =  segment.item.code (tipcs022.sitm, get.ti.project(tipcs022.cprj))  
 	 endif  
 	  
 | #  SP1.sn  
 	 | *  reference designators present ?  	  
 	 var.tibom010.rdsp =  tcyesno.no  
 	 select 	 tipcs030.lcid  
 	 from 	 tipcs030  
 	 where 	 tipcs030.cmba =  {:tipcs022.cprj,  
 	 	 	 	 	 :tipcs022.mitm,  
 	 	 	 	 	 :tipcs022.pono}  
 	 	 	 	 	  
 	 as set with 1 rows  
 	 selectdo  
 	 	 var.tibom010.rdsp =  tcyesno.yes  
 	 endselect  
 | #  SP1.en 	  
 	 | *  dump  
 	 dump 2  
 	  
 	 | *  save current sub item  
 	 prev.sitm =  tipcs022.sitm
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:bom
:TFLNO:010
:SCPAC:ti
:SCMOD:pcs
:SFLNO:022
:ICOD:S
:QURY:START
select 	 tipcs022.*
from 	 tipcs022
order by tipcs022._index3 	 | *  opol, sitm, cprj, mitm
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:bom
:TFLNO:010
:SCPAC:ti
:SCMOD:pcs
:SFLNO:022
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:bom
:TFLNO:010
:SCPAC:ti
:SCMOD:pcs
:SFLNO:110
:ICOD:D
:QURY:START
	 | *  in case of standard order policy, then read Item tabel for item.  
 	 | *  only once per tem  
 	 if tipcs110.ittp =  tcitta.standard and tipcs110.item <>  prev.item then  
 	 	 select 	 tiitm001.opol  
 	 	 from 	 tiitm001  
 	 	 where 	 tiitm001.item =  :tipcs110.item  
 	 	 selectdo  
 	 	 endselect  
 	 endif  
 	  
 	 | *  build item code  
 	 if tipcs110.ittp =  tcitta.standard then  
 	 	 if (tiitm001.opol =  tcopol.anonymous) then  
 	 	 	 var.tibom010.sitm =  segment.item.code (tipcs110.item, "")                                                                                                                        
 	 	 else  
 	 	 	 var.tibom010.sitm =  get.part.item.code(tipcs110.cbdg, tipcs110.bccd,tipcs110.item)  
 	 	 endif  
 	 else  
 	 	 var.tibom010.sitm =  get.part.item.code(tipcs110.cbdg, tipcs110.bccd,tipcs110.item)  
 	 endif  
 	  
 	 | *  dump  
 	 dump 3  
 	 | *  store current item code  
 	 prev.item =  tipcs110.item
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:bom
:TFLNO:010
:SCPAC:ti
:SCMOD:pcs
:SFLNO:110
:ICOD:S
:QURY:START
select 	 tipcs110.*
from 	 tipcs110
order by tipcs110._index4 	 | *  ittp, item
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:bom
:TFLNO:010
:SCPAC:ti
:SCMOD:pcs
:SFLNO:110
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:cst
:TFLNO:300
:SCPAC:tf
:SCMOD:gld
:SFLNO:410
:ICOD:D
:QURY:START
	 	  
 	 | *------------------------------------------------------------------------------   
 	 | *  Production Order related data  
 	 | *  (PCS releated data will be handled in next select; also in this migrate  
 	 | *--------------------------------------------------------------------------------   
 	  
 	 	 	 	 	 	 	 	 | #  213542.sn  
 	 | *  skip not -  for -  finance transactions  
 	 | *  NB. Testing has shown this this non -  join approach is faster then  
 	 | *  a join of tfgld410 and tfgld418.  
 	 if integration.is.not.for.finance(  
 	 	 	 tfgld410.ocom, tfgld410.tror,  
 	 	 	 tfgld410.fitr, tfgld410.trdt,  
 	 	 	 tfgld410.trtm, tfgld410.sern,  
 	 	 	 tfgld410.line) then  
 	 	 continue  
 	 endif 	 	 	 	 	 	 	 | #  213542.en  
 	 handle.credit.amounts()  
 	 set.var.calc.office( 	 tfgld410.fcom, | *  fin. comp  
 	 	 	 	 tfgld410.ocom) | *  log. comp  
 	 if prev.cprj <>  tfgld410.cprj then  
 	 	 set.var.cprj(tfgld410.cprj)  
 	 	  
 	 endif  
 	  
 	 | *  process fin. transactions for PCS WIP  
 	 if not isspace(tfgld410.cprj) and convert.to.tipcs300(tmp.correct.tipcs360) then  
 	 	 dump.tipcs300()  
 	  
 	 	 if tmp.correct.tipcs360 then  
 	 	 	 | *  this transaction is migrated 2 times:  
 	 	 	 | *  1: via ticp360, 2: via tfgld410.  
 	 	 	 | *  So correct amount based on tipcs360.  
 	 	 	 dump.ticpr360.correction()  
 	 	 endif  
 	 endif  
 	  
 	 | *  process financial transactions for SFC WIP  
 	 if convert.to.ticst300() then  
 	  
 	 	 | *  dump production order transactions  
 	 	 dump.ticst300()  
 	  
 	 	 | *  in case of Receipt posting: also insert Completion Postings  
 	 	 if tfgld410.tror =  tctror.prd and tfgld410.fitr =  tcfitr.receipt then  
 	 	 	 define.completion.postings()  
 	 	 	 dump.ticst300()  
 	 	 endif  
 	  
 	 endif  
 	 | *  save project  
 	 prev.cprj =  tfgld410.cprj
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:cst
:TFLNO:300
:SCPAC:tf
:SCMOD:gld
:SFLNO:410
:ICOD:S
:QURY:START
select 	 tfgld410.tror , tfgld410.fitr , tfgld410.cprj, tfgld410.orno ,  
 	 tfgld410.ocom , tfgld410.amnt , tfgld410.fcom , tfgld410.trdt ,  
 	 tfgld410.item , tfgld410.trtm, tfgld410.cuni,  
 	 tfgld410.pono, tfgld410.nuni , tfgld410.ccur , tfgld410.cpcp,  
 	 tfgld410.cwar, tfgld410.pono, tfgld410.dbcr,  
 	 tfgld410.amth,  
 	 tfgld410.sern, tfgld410.line, 	 	 	 	 | #  213542.n  
 	 ticpr010.cref,  
 	 tisfc001.osta
from 	 tfgld410, ticpr010, tisfc001
where 	 tfgld410.ocom =  :var.current.company 	 | *  only records for current logistical company !   
 and 	 tfgld410.tror =  tctror.prd  
 and 	 tfgld410.cpcp refers to ticpr010  
 and 	 tfgld410.orno refers to tisfc001  
 and 	 tisfc001.osta <  tcosta.closed 	 	 | *  no closed order  
 | and 	 tfgld410.sint <>  tfgld.sint.no.fin 	 | #  213542.o | *  skip "not for finance" transactions
order by tfgld410.ocom, tfgld410.tror, tfgld410.fitr 	 | *  index 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:cst
:TFLNO:300
:SCPAC:tf
:SCMOD:gld
:SFLNO:410
:ICOD:X
:QURY:START
	  
 select 	 tfgld410.tror , tfgld410.fitr , tfgld410.cprj, tfgld410.orno ,  
 	 tfgld410.ocom , tfgld410.amnt , tfgld410.fcom , tfgld410.trdt ,  
 	 tfgld410.item , tfgld410.trtm, tfgld410.cuni,  
 	 tfgld410.pono, tfgld410.nuni , tfgld410.ccur , tfgld410.cpcp,  
 	 tfgld410.cwar, tfgld410.pono, tfgld410.dbcr,  
 	 tfgld410.amth,  
 	 tfgld410.sern, tfgld410.line, 	 	 	 	 | #  213542.n  
 	 ticpr010.cref,  
 	 tipcs020.psts  
 from 	 tfgld410, ticpr010, tipcs020  
 where 	 tfgld410.ocom =  :var.current.company 	 | *  only records for current logistical company !   
 and 	 ( 	 tfgld410.tror =  tctror.pcs or  
 	 	 tfgld410.tror =  tctror.sls or  
 	 	 tfgld410.tror =  tctror.pur or  
 	 	 tfgld410.tror =  tctror.sma.order or  
 	 	 tfgld410.tror =  tctror.prp.wrh)  
 	  
 and 	 ( 	  
 | 	 	 tfgld410.fitr =  tcfitr.acp.sales or 	 | #  213976.o  
 | 	 	 tfgld410.fitr =  tcfitr.ecp.sales or 	 | #  213976.o  
 	 	 tfgld410.fitr =  tcfitr.gen.result or  
 	 	 tfgld410.fitr =  tcfitr.revenue or  
 	 	 tfgld410.fitr =  tcfitr.surcharge or  
 	 	 tfgld410.fitr =  tcfitr.prd.result or  
 	 	 tfgld410.fitr =  tcfitr.revaluation or  
 	 	 tfgld410.fitr =  tcfitr.revenue or  
 	 	 tfgld410.fitr =  tcfitr.general or  
 	 	 tfgld410.fitr =  tcfitr.operation)  
 	  
 and 	 tfgld410.cpcp refers to ticpr010  
 and 	 tfgld410.cprj refers to tipcs020  
 and 	 (tfgld410.cprj >  "")                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
 and 	 tipcs020.psts <  tcpsts.closed 	 	 | *  no closed projects  
 | and 	 tfgld410.sint <>  tfgld.sint.no.fin 	 | *  skip "not for finance" transactions  |#                                                               209375.o                                                                                                                                                
 | #  213542.so  
 | and 	 (tfgld410.sint <>  tfgld.sint.no.fin or 	 | #  209375.sn  
 | 	 (tfgld410.sint =  tfgld.sint.no.fin and 	 | *  skip "not for finance" transactions, except                                                                                                                                                 
 | 	 tfgld410.tror =  tctror.pcs and 	 	 | *  for pcs /  general  
 | 	 tfgld410.fitr =  tcfitr.general)) 	 	 | #  209375.en  
 | #  213542.eo  
 order by tfgld410.ocom, tfgld410.tror, tfgld410.fitr 	 | *  index 1  
 selectdo  
 	 | *-----------------------------------------------------------------------   
 	 | *  Select tfgld410 for other PCS -  related tror's.  
 	 | *  This select is for revenues and results.  
 	 | *  Transactions for PCS costs are calculated from tipcs360  
 	 | *------------------------------------------------------------------------   
 	 	 	 	 	 	 | #  213542.sn  
 	 | *  skip "not for finance" transactions, except  for pcs /                                                            general                                                                                                                     
 	 if not ( tfgld410.tror =  tctror.pcs and tfgld410.fitr =  tcfitr.general)  
 	 then  
 	 	 if integration.is.not.for.finance(  
 	 	 	 tfgld410.ocom, tfgld410.tror,  
 	 	 	 tfgld410.fitr, tfgld410.trdt,  
 	 	 	 tfgld410.trtm, tfgld410.sern,  
 	 	 	 tfgld410.line)  
 	 	 then  
 	 	 	 continue  
 	 	 endif  
 	 endif 	 	 	 	 	 | #  213542.en  
 	 handle.credit.amounts()  
 	 set.var.calc.office( 	 tfgld410.fcom, | *  fin. comp  
 	 	 	 	 tfgld410.ocom) | *  log. comp  
 	 if prev.cprj <>  tfgld410.cprj then  
 	 	 set.var.cprj(tfgld410.cprj)  
 	 endif  
 	  
 	 | *  process fin. transactions for PCS WIP  
 	 if not isspace(tfgld410.cprj) and convert.to.tipcs300(tmp.correct.tipcs360) then  
 	 	 dump.tipcs300()  
 	  
 	 	 if tmp.correct.tipcs360 then  
 	 	 	 | *  this transaction is migrated 2 times:  
 	 	 	 | *  1: via ticp360, 2: via tfgld410.  
 	 	 	 | *  So correct amount based on tipcs360.  
 	 	 	 dump.ticpr360.correction()  
 	 	 endif  
 	 endif  
 endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:cst
:TFLNO:300
:SCPAC:ti
:SCMOD:cst
:SFLNO:001
:ICOD:D
:QURY:START
	 | *------------------------------------------------------------------------------   
 	 | *  No prd /  issue postings for customized materials in tfgld410.  
 	 | *  These are posted on tror pcs  
 	 | *  So use ticst001 to create these for tror prd in ticst300 (SFC -  WIP)  
 	 | *---------------------------------------------------------------------------------   
 	  
 	 if prev.cprj <>  ticst001.cprj then 	 	  
 	 	 var.cprj =  get.ti.project(ticst001.cprj) 	  
 	 endif  
 	  
 	 | *  read unit code of customized item  
 	 if (prev.cprj <>  ticst001.cprj) or (prev.item <>  ticst001.sitm) then  
 	 	 fill.var.cuni.for.customized.item(ticst001.cprj, ticst001.sitm)  
 	 endif  
 	 	  
 	 | *  NB. From -  posting is on PCS calc. office ( =  SFC -  calculation office).  
 	 var.tror 	 =  target(tctror.prd)  
 	 var.fitr 	 	 =  target(tcfitr.issue)  
 	 var.orno 	 =  convert.number( bcckon.act.sfc, ticst001.pdno)  
 	 var.koor 	 =  target(tckoor.act.sfc)  
 	 var.pono 	 =  ticst001.pono  
 	 var.entp.f 	 =  target(tcemm.enty.workcenter)  
 	 var.entc.f 	 =  var.tisfc001.clco  
 	 var.entp.t 	 =  target(tcemm.enty.workcenter)  
 	 var.entc.t 	 =  var.tisfc001.clco  
 	 var.ccur.f 	 =  var.company.currency  
 	 var.ccur.t 	 =  var.company.currency  
 	 var.item 	 =  get.item.code(ticst001.cprj, ticst001.opol, ticst001.sitm)  
 	 var.nuni 	 =  ticst001.qucs  
 	 var.cpcp.f 	 =  ticst001.cpcp  
 	 var.cpcp.t 	 =  var.cpcp.f 	 	 	 	 	 | #  213976.n  
 	 var.cprj.f 	 =  ""                                                	                                                                                                 	                                                                                                 	                                                                                                 	                                                                                                 	                                                                                                 	                                                 | #                                                  213976.n                                                                                                  
 	 var.cprj.t 	 =  var.cprj 	 	 	 	 	 | #  213976.n  
 	  
 	 | *  use actual costs and cost component from ticst001  
 	 for element =  1 to 3  
 	 	 var.amnt(element) =  fill.mc.field.double(  
 | 	 	 	 	 	 ticst001.cpcs, 	 	 	 | #  209555.o  
 | 	 	 	 	 	 ticst001.cpcs *  ticst001.qucs, 	 | #  209555.o | #  FPRG.o  
 	 	 	 	 	 ticst001.cpcs, 	 	 	 | #  FPRG.n  
 	 	 	 	 	 element,  
 	 	 	 	 	 0.0)  
 	 	 var.amnt(element) =  var.amnt(element) *  ticst001.qucs | #  FPRG.n  
 	 endfor  
 	  
 	 	 	 	 	 	 | #  214068.so 	 	 	 | #  213976.sn  
 	 | *  actual prices for customized materials are filled by running tipcs3250 (calc. projects)  
 	 | *  but this is only done when the production order is closed. If not then eact. price =  0  
 	 | *  and we will have to use the estimated price.  
 | 	 if ticst001.cpcs =  0.0 then  
 | 	 	 for element =  1 to 3  
 | 	 	 	 var.amnt(element) =  fill.mc.field.double(  
 | 	 	 	 	 	 ticst001.cpes *  ticst001.qucs, 	  
 | 	 	 	 	 	 element,  
 | 	 	 	 	 	 0.0)  
 | 	 	 endfor  
 | 	 endif 	 	 	 	 	 | #  214068.so 	 	 	 | #  213976.en  
 	 | *  dump data  
 	 dump.ticst300()  
 	  
 | 	  
 | 	 | *  fill dump fields cost components and prices from tipcs350 (Cost Prices by Customized Item)  
 | 	 select 	 tipcs350.amte, tipcs350.cpcp, ticpr010.cref  
 | 	 from 	 tipcs350, ticpr010  
 | 	 where 	 tipcs350._index1 =  {:ticst001.cprj, :ticst001.sitm}  
 | 	 and 	 tipcs350.cpcp =  ticpr010.cpcp  
 | 	 selectdo 	  
 | 	 	 var.cpcp.f 	 =  get.eff.cpcp( 	 tipcs350.cpcp,  
 | 	 	 	 	 	 	 	 tipcs350.item,  
 | 	 	 	 	 	 	 	 tipcs350.cprj,  
 | 	 	 	 	 	 	 	 ticpr010.cref)  
 | 	 	 var.cpcp.t 	 =  var.cpcp.f  
 | 	 | 	 var.amnt 	 =  ticst001.qucs *  tipcs350.amte | *  actual qty *  cost price | #  MCR.o  
 | 	 	 for element =  1 to 3 	 	 	 	 	 	 	 	 | #  MCR.sn  
 | 	 	 	 var.amnt(element) =  ticst001.qucs *  fill.mc.field.double(  
 | 	 	 	 	 	 	 	 	 tipcs350.amte ,  
 | 	 	 	 	 	 	 	 	 element,  
 | 	 	 	 	 	 	 	 	 0.0)  
 | 	 	 endfor 	 	 	 	 	 	 	 	 	 	 | #  MCR.en  
 | 	  
 | 	 dump.ticst300()  
 | 	 endselect  
 	  
 	 | *  save project, order  
 	 prev.orno =  ticst001.pdno  
 	 prev.cprj =  ticst001.cprj  
 	 prev.item =  ticst001.sitm
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:cst
:TFLNO:300
:SCPAC:ti
:SCMOD:cst
:SFLNO:001
:ICOD:S
:QURY:START
select 	 ticst001.pdno, ticst001.pono, ticst001.cprj, ticst001.sitm, ticst001.opol,  
 	 ticst001.cwar, ticst001.qucs, ticst001.cpcs,  
 	 ticst001.cpcp, 	 	 	 	 	 	 	 | #  214914.n  
 	 tisfc001.pdno, tisfc001.osta, tisfc001.cprj
from 	 ticst001, tisfc001
where 	 ticst001.pdno =  tisfc001.pdno  
 and 	 tisfc001.osta >=  tcosta.in.prod  
 and 	 tisfc001.osta <  tcosta.closed 	 	 | *  not for closed production orders  
 and 	 tisfc001.cprj <>  ""                                                                                                                                                                                                                                                                                                                                                                                                                                  
 and 	 ticst001.cprj <>  ""                                |*                                                                                                                                                                                                  only customized materials                                                                                                                                                                                                                                                                                                                                                                                              
 and 	 ticst001.opol =  tcittb.customized 	 | *  customized material  
 and 	 ticst001.qucs <>  0.0 	 	 	 | *  actual quantity
order by ticst001.cprj, ticst001.sitm 	 	 | *  index 4
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:cst
:TFLNO:300
:SCPAC:ti
:SCMOD:cst
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:cst
:TFLNO:300
:SCPAC:ti
:SCMOD:pcs
:SFLNO:360
:ICOD:D
:QURY:START
	 | ---------------------------------------------------------------------------   
 	 | *  Create the transactions for the incoming PCS WIP -  transactions.  
 	 | *  All Costs are logged on fixed tror /  fitr  
 	 | *-------------------------------------------------------------------------   
 	  
 	 | *  get target project code  
 	 if prev.cprj <>  tipcs360.cprj then 	  
 	 	 var.cprj 	 =  get.ti.project(tipcs360.cprj) 	  
 	 endif  
 	  
 	 | *  fill var fields  
 	 var.date 	 =  date.num()  
 | 	 var.cprj.f 	 =  var.cprj 	 	 | #  213976.o  
 	 var.cprj.f 	 =  ""                                                       	                                                                                                      	                                                                                                      	                                                   |#                                                     213976.n                                                                                                            
 	 var.cprj.t 	 =  var.cprj  
 	 var.nuni 	 =  tipcs360.nuna  
 	 var.entc.f 	 =  var.tipcs020.clco  
 	 var.entc.t 	 =  var.entc.f  
 	 var.cpcp.f 	 =  get.mapped.cpcp(tipcs360.cpcp)  
 	 var.cpcp.t 	 =  var.cpcp.f  
 	 | var.amnt 	 =  tipcs360.amta 	 	 | #  MCR.o 	  
 	 for element =  1 to 3 	 	 	 	 | #  MCR.sn  
 	 	 var.amnt(element) =  fill.mc.field.double(tipcs360.amta,  
 	 	 	 	 	 	 	 element,  
 	 	 	 	 	 	 	 0.0)  
 	 endfor 	 	 	 	 	 	 | #  MCR.en  
 	  
 	 | *  dump  
 	 dump.tipcs300()  
 	  
 	 | *  remember project  
 	 prev.cprj =  tipcs360.cprj
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:cst
:TFLNO:300
:SCPAC:ti
:SCMOD:pcs
:SFLNO:360
:ICOD:S
:QURY:START
select 	 tipcs360.cprj , tipcs360.cpcp, tipcs360.nuna, tipcs360.amta,  
 	 tipcs020.psts
from 	 tipcs360, tipcs020
where 	 tipcs360.cprj =  tipcs020.cprj  
 and 	 tipcs020.psts <  tcpsts.closed 	 | *  no closed projects
order by tipcs360.cprj 	 | *  index 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:cst
:TFLNO:300
:SCPAC:ti
:SCMOD:pcs
:SFLNO:360
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:cst
:TFLNO:300
:SCPAC:ti
:SCMOD:sfc
:SFLNO:001
:ICOD:D
:QURY:START
	 | *---------------------------------------------------------------------------------   
 	 | *  No prd /  receipts postings for customized materials in tfgld410.  
 	 | *  These are posted on tror pcs.  
 	 | *  Use ticst001 to create these for tror prd in ticst300 (SFC WIP)  
 	 | *---------------------------------------------------------------------------------   
 	  
 	 if prev.cprj <>  tisfc001.cprj then 	  
 	 	 var.cprj 	 =  get.ti.project(tisfc001.cprj) 	  
 	 endif  
 	  
 	 | *  read unit code of customized item  
 	 if (prev.cprj <>  tisfc001.cprj) or (prev.item <>  tisfc001.mitm) then  
 	 	 fill.var.cuni.for.customized.item(tisfc001.cprj, tisfc001.mitm)  
 	 endif  
 	  
 	 | *  fill fixed dump fields (for receipt AND completion)  
 	 var.ccur.f 	 =  var.company.currency  
 	 var.ccur.t 	 =  var.company.currency  
 | 	 var.item 	 =  segment.item.code(tisfc001.mitm , tisfc001.cprj) | #  200314.o  
 	 var.item 	 =  segment.item.code(tisfc001.mitm , var.cprj) 	 | #  200314.n  
 	 var.nuni 	 =  tisfc001.qdlv  
 	 var.orno 	 =  convert.number( bcckon.act.sfc, tisfc001.pdno)  
 	 var.koor 	 =  target(tckoor.act.sfc)  
 	 var.cprj.f 	 =  var.cprj 	 	 	 	 	 | #  213976.n  
 	 var.cprj.t 	 =  var.cprj 	 	 	 	 	 | #  213976.n  
 	  
 	 | *  fill dump fields cost components and prices from tipcs350 (Cost Prices by Customized Item)  
 	 select 	 tipcs350.amte, tipcs350.cpcp, ticpr010.cref  
 	 from 	 tipcs350, ticpr010  
 	 where 	 tipcs350._index1 =  {:tisfc001.cprj, :tisfc001.mitm}  
 	 and 	 tipcs350.cpcp =  ticpr010.cpcp  
 	 selectdo 	  
 	 	 | *  receipt posting. NB. To -  side is on PCS Calc. Office.  
 	 	 | *  PCS Calc. Office =  SFC calculation office.  
 	 	 var.tror 	 =  target(tctror.prd)  
 	 	 var.fitr 	 	 =  target(tcfitr.receipt)  
 	 	 var.pono 	 =  0  
 	 	 var.entp.f 	 =  target(tcemm.enty.workcenter)  
 	 	 var.entc.f 	 =  var.tisfc001.clco  
 	 	 var.entp.t 	 =  target(tcemm.enty.workcenter)  
 	 	 var.entc.t 	 =  var.tisfc001.clco  
 	 	 var.cpcp.f 	 =  get.eff.cpcp( tipcs350.cpcp,  
 	 	 	 	 	 	 tipcs350.item,  
 	 	 	 	 	 	 tipcs350.cprj,  
 	 	 	 	 	 	 ticpr010.cref)  
 	 	 var.cpcp.t 	 =  var.cpcp.f  
 	 	 | var.amnt 	 =  tisfc001.qdlv *  tipcs350.amte | *  delivered qty *  cost price | #  MCR.o  
 	 	 for element =  1 to 3 	 	 	 	 	 	 	 | #  MCR.sn  
 	 	 	 var.amnt(element) =  tisfc001.qdlv *  fill.mc.field.double(  
 	 	 	 	 	 	 	 	 tipcs350.amte ,  
 	 	 	 	 	 	 	 	 element,  
 	 	 	 	 	 	 	 	 0.0)  
 	 	 endfor 	 	 	 	 	 	 	 	 	 | #  MCR.en 	  
 	  
 	 	 | *  dump production receipt posting  
 	 	 dump.ticst300()  
 	  
 	 	 | *  completion posting (amount does not change)  
 	 	 var.fitr 	 	 =  target(tcfitr.completion)  
 	 	 var.entp.f 	 =  target(tcemm.enty.workcenter)  
 	 	 var.entc.f 	 =  var.tisfc001.clco  
 	 	 var.entp.t 	 =  target(tcemm.enty.workcenter)  
 	 	 var.entc.t 	 =  var.tisfc001.clco  
 	  
 	 	 var.cpcp.f 	 =  get.mapped.cpcp(tipcs350.cpcp)  
 	 	 var.cpcp.t 	 =  get.eff.cpcp( tipcs350.cpcp,  
 	 	 	 	 	 	 tipcs350.item,  
 	 	 	 	 	 	 tipcs350.cprj,  
 	 	 	 	 	 	 ticpr010.cref)  
 	 	 | *  dump completing posting  
 	 	 dump.ticst300()  
 	 	  
 	 endselect  
 	  
 	 prev.orno =  tisfc001.pdno  
 	 prev.item =  tisfc001.mitm  
 	 prev.cprj =  tisfc001.cprj
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:cst
:TFLNO:300
:SCPAC:ti
:SCMOD:sfc
:SFLNO:001
:ICOD:S
:QURY:START
select 	 tisfc001.pdno, tisfc001.cprj, tisfc001.mitm,  
 	 tisfc001.qdlv, tisfc001.osta, tisfc001.cwar,  
 	 tipcs020.psts
from 	 tisfc001, tipcs020
where 	 tisfc001.osta >=  tcosta.in.prod  
 and 	 tisfc001.osta <  tcosta.closed 	 | *  no closed projects  
 and 	 tipcs020.cprj =  tisfc001.cprj  
 and 	 tipcs020.psts <  tcpsts.closed 	 | *  no closed projects  
 and 	 tisfc001.cprj <>  ""                                                   	                                                                                              	                                               |*                                                only cust. end items                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
 and 	 tisfc001.qdlv <>  0.0 	 	 | *  delivered qty
order by tisfc001.cprj, tisfc001.mitm 	 | *  index 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:cst
:TFLNO:300
:SCPAC:ti
:SCMOD:sfc
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:edm
:TFLNO:110
:SCPAC:ti
:SCMOD:edm
:SFLNO:110
:ICOD:D
:QURY:START
dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:edm
:TFLNO:110
:SCPAC:ti
:SCMOD:edm
:SFLNO:110
:ICOD:S
:QURY:START
select tiedm110.*
from tiedm110
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:edm
:TFLNO:110
:SCPAC:ti
:SCMOD:edm
:SFLNO:110
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:edm
:TFLNO:310
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:D
:QURY:START
	 | *  convert order status  
 	 set.var.tiedm310.osta()  
 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:edm
:TFLNO:310
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:S
:QURY:START
select tiedm310.*
from tiedm310
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:edm
:TFLNO:310
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:edm
:TFLNO:320
:SCPAC:ti
:SCMOD:edm
:SFLNO:320
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:edm
:TFLNO:320
:SCPAC:ti
:SCMOD:edm
:SFLNO:320
:ICOD:S
:QURY:START
select tiedm320.*  , tiedm310.inex
from tiedm320, tiedm310
where tiedm320.orno =  tiedm310.orno
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:edm
:TFLNO:320
:SCPAC:ti
:SCMOD:edm
:SFLNO:320
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:pcf
:TFLNO:000
:SCPAC:ti
:SCMOD:pcf
:SFLNO:000
:ICOD:D
:QURY:START
	 | *  Fields snfp and sntp should take into account the project segment,  
 	 | *  which has a length of nine positions.  
 	 var.tipcf000.snfp =  tipcf000.snfp +  9  
 	 var.tipcf000.sntp =  tipcf000.sntp +  9  
 	 var.tipcf000.indt =  utc(0,0)  
 	 var.tipcf000.dsca =  form.text$("bcstc00035") 	 | *  Actual Set  
 	 Dump 999  
 	 var.tipcf000.indt =  utc(date.num(), time.num())  
 	 var.tipcf000.dsca =  form.text$("bcstc00036") 	 | *  Converted from BaanIVc4  
 	 Dump 999
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:pcf
:TFLNO:000
:SCPAC:ti
:SCMOD:pcf
:SFLNO:000
:ICOD:S
:QURY:START
select tipcf000.*
from tipcf000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:pcf
:TFLNO:000
:SCPAC:ti
:SCMOD:pcf
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:pcf
:TFLNO:310
:SCPAC:ti
:SCMOD:pcf
:SFLNO:310
:ICOD:D
:QURY:START
| #  200 -  96564.sn  
 	 | *  Flag 'Use Lead Time Offset' needs to be set.  
 	 | *  Field 'Lead Time Offset' cannot be negative.  
 	 if tipcf310.ltmo >  0 then  
 	 	 var.tipcf310.ltom =  tcyesno.yes  
 	 else  
 	 	 var.tipcf310.ltom =  tcyesno.no  
 	 endif  
 | #  200 -  96564.en  
 	 | *  Field Expiry Date should not be empty, but greater than the  
 	 | *  maximum UTC value is also a problem (check against 18 Jan 2038).  
 	 if tipcf310.exdt =  0 or tipcf310.exdt >  744017 then  
 	 	 var.tipcf310.exdt =  utc(744017, 0)  
 	 else  
 	 	 var.tipcf310.exdt =  utc(tipcf310.exdt, 0)  
 	 endif  
 	 dump 310
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:pcf
:TFLNO:310
:SCPAC:ti
:SCMOD:pcf
:SFLNO:310
:ICOD:S
:QURY:START
select tipcf310.*
from tipcf310
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:pcf
:TFLNO:310
:SCPAC:ti
:SCMOD:pcf
:SFLNO:310
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:pcf
:TFLNO:320
:SCPAC:ti
:SCMOD:pcf
:SFLNO:320
:ICOD:D
:QURY:START
	 | *  Field Expiry Date should not be empty, but greater than the  
 	 | *  maximum UTC value is also a problem (check against 18 Jan 2038).  
 	 if tipcf320.exdt =  0 or tipcf320.exdt >  744017 then  
 	 	 var.tipcf320.exdt =  utc(744017, 0)  
 	 else  
 	 	 var.tipcf320.exdt =  utc(tipcf320.exdt, 0)  
 	 endif  
 	 dump 320
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:pcf
:TFLNO:320
:SCPAC:ti
:SCMOD:pcf
:SFLNO:320
:ICOD:S
:QURY:START
select tipcf320.*
from tipcf320
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:pcf
:TFLNO:320
:SCPAC:ti
:SCMOD:pcf
:SFLNO:320
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:pcs
:TFLNO:000
:SCPAC:ti
:SCMOD:pcs
:SFLNO:000
:ICOD:D
:QURY:START
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:26
:VERS:B4st
:RELE:61
:CUST:sy30
: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:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:pcs
:TFLNO:000
:SCPAC:ti
:SCMOD:pcs
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:pcs
:TFLNO:030
:SCPAC:ti
:SCMOD:pcs
:SFLNO:020
:ICOD:D
:QURY:START
	 if tipcs020.psts >=  tcpsts.closed then  
 	 	 | *  reopen of closed projects not possbile, because  
 	 	 | *  no migration of fin. int. transactions is done  
 	 	 | *  (see tipcs300).  
 	 	 var.tipcs030.defc =  tcyesno.yes  
 	 else  
 	 	 var.tipcs030.defc =  tcyesno.no  
 	 endif  
 	 for element =  1 to 3  
 	 	 var.tipcs030.tinv(element) =  fill.mc.field.double(  
 	 	 	 	 tipcs020.tinv,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 endfor  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:pcs
:TFLNO:030
:SCPAC:ti
:SCMOD:pcs
:SFLNO:020
:ICOD:S
:QURY:START
select tipcs020.*
from tipcs020  
 | #  200 -  96585.sn  
 | *  Similar construction as for conversion object tipcs020.
where tipcs020.prtp =  tcyesno.no  
 | #  200 -  96585.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:pcs
:TFLNO:030
:SCPAC:ti
:SCMOD:pcs
:SFLNO:020
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:rou
:TFLNO:102
:SCPAC:ti
:SCMOD:pcs
:SFLNO:023
:ICOD:D
:QURY:START
	  
 	 set.var.fields( 	 tipcs023.mnoc,  
 	 	 	 tipcs023.mcoc,  
 	 	 	 tirou001.ccap,  
 	 	 	 tipcs023.sutm,  
 	 	 	 tipcs023.rutm)  
 	  
 	 dump 9
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:rou
:TFLNO:102
:SCPAC:ti
:SCMOD:pcs
:SFLNO:023
:ICOD:S
:QURY:START
select 	 tipcs023.*  ,  
 	 tirou001.ccap 	 | *  Crit. Cap. Type Work Center
from 	 tipcs023, tirou001
where 	 tipcs023.cwoc =  tirou001.cwoc  
 and 	 tipcs023.cprj >=  ""
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:rou
:TFLNO:102
:SCPAC:ti
:SCMOD:pcs
:SFLNO:023
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:rou
:TFLNO:102
:SCPAC:ti
:SCMOD:pcs
:SFLNO:120
:ICOD:D
:QURY:START
	  
 	 set.var.fields( 	 tipcs120.mnoc,  
 	 	 	 tipcs120.mcoc,  
 	 	 	 tirou001.ccap,  
 	 	 	 tipcs120.sutm,  
 	 	 	 tipcs120.rutm)  
 	 dump 222
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:rou
:TFLNO:102
:SCPAC:ti
:SCMOD:pcs
:SFLNO:120
:ICOD:S
:QURY:START
select 	 tipcs120.*  ,  
 	 tirou001.ccap 	 | *  Crit. Cap. Type Work Center
from 	 tipcs120, tirou001
where 	 tipcs120.cwoc =  tirou001.cwoc  
 and 	 tipcs120.cbdg >=  ""
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:rou
:TFLNO:102
:SCPAC:ti
:SCMOD:pcs
:SFLNO:120
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:rou
:TFLNO:102
:SCPAC:ti
:SCMOD:rou
:SFLNO:102
:ICOD:D
:QURY:START
	 fill.introduction.date(tirou102.indt)  
 	 fill.expiry.date(tirou102.exdt)  
 	  
 	 set.var.fields( 	 tirou102.mnoc,  
 	 	 	 tirou102.mcoc,  
 	 	 	 tirou001.ccap,  
 	 	 	 tirou102.sutm,  
 	 	 	 tirou102.rutm)  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:rou
:TFLNO:102
:SCPAC:ti
:SCMOD:rou
:SFLNO:102
:ICOD:S
:QURY:START
select 	 tirou102.*  ,  
 	 tirou001.ccap 	 | *  Crit. Cap. Type Work Center
from 	 tirou102, tirou001
where 	 tirou102.cwoc =  tirou001.cwoc  
 | and 	 tirou102.mitm >=  ""
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:rou
:TFLNO:102
:SCPAC:ti
:SCMOD:rou
:SFLNO:102
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:sfc
:TFLNO:000
:SCPAC:ti
:SCMOD:sfc
:SFLNO:000
:ICOD:D
:QURY:START
	 set.number.groups.and.series()  
 	 var.tisfc000.ooda =  convert.on.order.date(etol (tisfc000.ooda))  
 	 var.tisfc000.oodb =  convert.on.order.date(etol (tisfc000.oodb))  
 	 convert.backflushing.method()  
 	 move.allocation()  
 	  
 	 var.tisfc000.aort =  1  
 	 var.tisfc000.ocow =  2  
 	 var.tisfc000.ckow =  ""                                          
 	 select 	 tihra000.aort, tihra000.ocow, tihra000.hrwb  
 	 from 	 tihra000  
 	 selectdo  
 	 	 var.tisfc000.aort =  etol(tihra000.aort)  
 	 	 var.tisfc000.ocow =  etol(tihra000.ocow)  
 	 	 var.tisfc000.ckow =  tihra000.hrwb  
 	 endselect  
 	 	  
 	 var.tisfc000.indt =  utc(0,0)  
 	 var.tisfc000.dsca =  form.text$("bcstc00035") 	 | *  Actual Set  
 	 Dump 1  
 	 var.tisfc000.indt =  utc(date.num(), time.num())  
 	 var.tisfc000.dsca =  form.text$("bcstc00036") 	 | *  Converted from BaanIVc4  
 	 Dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:sfc
:TFLNO:000
:SCPAC:ti
:SCMOD:sfc
:SFLNO:000
:ICOD:S
:QURY:START
select tisfc000.*
from tisfc000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ti
:TCMOD:sfc
:TFLNO:000
:SCPAC:ti
:SCMOD:sfc
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:pdm
:TFLNO:001
:SCPAC:tp
:SCMOD:pdm
:SFLNO:001
:ICOD:D
:QURY:START
dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:pdm
:TFLNO:001
:SCPAC:tp
:SCMOD:pdm
:SFLNO:001
:ICOD:S
:QURY:START
select 	 tppdm001.*
from 	 tppdm001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:pdm
:TFLNO:001
:SCPAC:tp
:SCMOD:pdm
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:pdm
:TFLNO:740
:SCPAC:tp
:SCMOD:pdm
:SFLNO:740
:ICOD:D
:QURY:START
get.business.partner(tppdm740.cuno,bcstc.orgn.cuno,err.mess)  
 	 if tppdm600.stdt <>  0 then  
 	 	 var.tppdm740.rdat =  utc (tppdm600.stdt,0)  
 	 else  
 	 	 var.tppdm740.rdat =  utc (date.num () ,0)  
 	 endif  
 	 get.enterprise.unit(tppdm600.ncmp,ext.lng.comp,err.mess)  
 	 if tppdm740.ccur =  comp.ccur then  
 	 	 var.tppdm740.copr =  tppdm740.copr  
 	 	 var.tppdm740.rate =  1  
 	 	 var.tppdm740.ratf =  1  
 	 else  
 	 	 if tppdm740.rate =  0 or tppdm740.ratf =  0 then  
 	 	 	 read.tcmcs008(tppdm740.ccur,  
 	 	 	 	 	 date.num(),  
 	 	 	 	 	 2,  
 	 	 	 	 	 tppdm740.rate,  
 	 	 	 	 	 tppdm740.ratf)  
 	 	 endif  
 	 	 var.tppdm740.copr =  (tppdm740.copr *  tppdm740.ratf) /  tppdm740.rate  
 	 	 var.tppdm740.rate =  tppdm740.rate  
 	 	 var.tppdm740.ratf =  tppdm740.ratf  
 	 endif  
 	 if not (tppdm600.invm =  tppdm.invm.prime.cost or  
 	 tppdm600.invm =  tppdm.invm.unit.rate) then 	  
 	 	 dump 2  
 	 	 if tppdm740.ccur <>  comp.ccur then  
 	 	 	 dump 3  
 	 	 endif  
 	 	 var.tppdm740.sdyn =  1 	 |tppdm.yeno.yes  
 	 else  
 	 	 var.tppdm740.sdyn =  2 |tppdm.sdyn.no  
 	 endif  
 	 if (tppdm600.agty =  tppdm.agty.prime.cost) then 	 	 	 | *  200 -  101063.sn  
 	 	 var.tppdm740.tins =  0  
 	 else  
 	 	 var.tppdm740.tins =  etol(tppdm740.tins)  
 	 endif 	  
 	 get.customer.country(tppdm740.cuno, 	 	 	 	 	 | #  SP2.sn 	  
 	 	 	 var.tppdm740.bptc) 	 	 	 	 	 | #  SP2.en  
 	 var.tppdm740.ccty =  ""          	                   	          	          	          	   |#     210859.sn                    
 	 var.tppdm740.cvat =  ""                  
 	 get.tax.by.country.code.and.financial.company( 	 tppdm740.ccty,  
 	 	 	 	 	 	 	 	 tppdm740.cvat,  
 	 	 	 	 	 	 	 	 tppdm600.ncmp,  
 	 	 	 	 	 	 	 	 var.tppdm740.ccty,  
 	 	 	 	 	 	 	 	 var.tppdm740.cvat,  
 	 	 	 	 	 	 	 	 err.mess) 	  
 	 	 	 	 	 	 	 	 	 	 	 | #  210859.en 	 	 	  
 	 dump 1 	 	 	 	 	 	 	 	 	 | *  200 -  101063.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:pdm
:TFLNO:740
:SCPAC:tp
:SCMOD:pdm
:SFLNO:740
:ICOD:S
:QURY:START
select tppdm740.*  ,tppdm600.stdt,tppdm600.ncmp,tppdm600.agty
from tppdm740,tppdm600
where tppdm740.cprj refers to tppdm600
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:pdm
:TFLNO:740
:SCPAC:tp
:SCMOD:pdm
:SFLNO:740
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:pin
:TFLNO:010
:SCPAC:tp
:SCMOD:pin
:SFLNO:010
:ICOD:D
:QURY:START
	 get.business.partner(tppin010.cuno,bcstc.orgn.cuno,err.mess)  
 	 if (tppdm600.stdt <>  0) then  
 	 	 var.tppin010.rdas =  utc (tppdm600.stdt,0)  
 	 else  
 	 	 var.tppin010.rdas =  utc (date.num () , 0)  
 	 endif  
 	 var.tppin010.trsl =  2  
 	 var.tppin010.invo =  etol(tppin010.invo)  
 	 var.tppin010.ityp =  " "  
 	 var.tppin010.fcmp =  0  
 	 var.tppin010.idoc =  0  
 	 if tpprc000.intf =  tppdm.yeno.yes and  
 	 (tfcmg000.advp =  tcyesno.no or tppin010.amnt <  tfcmg000.amin) then  
 	 	 var.tppin010.cvyn =  2 |tppdm.yeno.no  
 	 	 var.tppin010.cvat =  " "  
 	 else  
 	 	 var.tppin010.cvyn =  etol(tppdm740.cvyn)  
 	 	 var.tppin010.cvat =  tppdm740.cvat  
 	 endif  
 	 var.tppin010.cpay =  tppdm740.cpay  
 	 var.tppin010.ccrs =  tppdm740.ccrs  
 	 if tppin010.stin =  tppdm.stin.final then  
 	 	 select 	 tppin100.ocmp,tppin100.ninv  
 	 	 from 	 tppin100  
 	 	 where 	 tppin100._index1 =  {:tppin010.stin,:tppin010.ninv} and  
 	 	 	 tppin100.cfpo =  tppdm.yeno.yes and  
 	 	 	 tppin100.post =  tppdm.yeno.yes  
 	 	 as set with 1 rows  
 	 	 selectdo 	 	  
 	 	 	 var.tppin010.trsl =  1  
 	 	 	 var.tppin010.ityp =  tpprc000.ttys  
 	 	 	 var.tppin010.fcmp =  tppin100.ocmp  
 	 	 	 var.tppin010.idoc =  tppin100.ninv 	 	 	  
 	 	 	 var.tppin010.cpay =  tppin100.cpay  
 	 	 	 var.tppin010.ccrs =  tppin100.ccrs  
 	 	 endselect  
 	 endif  
 	 if tppin010.stin =  tppdm.stin.deleted then  
 	 	 var.tppin010.trsl =  1  
 	 	 var.tppin010.ityp =  tpprc000.ttys  
 	 	 var.tppin010.fcmp =  tppdm600.ncmp  
 	 	 var.tppin010.idoc =  tppin010.ninv  
 	 endif  
 	 if not isspace(tppin010.cact) and 	 	 	 	 | #  200 -  100404.sn  
 	 activity.is.milestone(tppin010.cprj,tppin010.cpla,tppin010.cact) then  
 	 	 var.tppin010.cact =  tppdm600.rsac  
 	 else  
 	 	 var.tppin010.cact =  tppin010.cact  
 	 endif 	 	 	 	 	 	 	 	 | #  200 -  100404.en  
 	 if var.tppin010.trsl =  1 then 	 	 	 	 	 | #  200 -  100405.sn  
 	 	 var.tppin010.invo =  1  
 	 endif 	 	 	 	 	 	 	 	 | #  200 -  100405.en  
 | 	 get.customer.country(tppin010.cuno, 	 	 	 	 | #  SP2.sn  
 | 	 	 	 var.tppin010.bptc)  
 	 var.tppin010.ccty =  get.country.of.financial.company(tppdm600.ncmp) 	 | #  SP2.n  
 	 var1.tppin010.ccty =  ""   	      	      	      	      	      	    |# 210859.sn      
 	 var1.tppin010.cvat =  ""      
 	 get.tax.by.country.code.and.financial.company( 	 var.tppin010.ccty, 	  
 	 	 	 	 	 	 	 	 var.tppin010.cvat,  
 	 	 	 	 	 	 	 	 tppdm600.ncmp,  
 	 	 	 	 	 	 	 	 var1.tppin010.ccty,  
 	 	 	 	 	 	 	 	 var1.tppin010.cvat,  
 	 	 	 	 	 	 	 	 err.mess) 	 | # 210859.en  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:pin
:TFLNO:010
:SCPAC:tp
:SCMOD:pin
:SFLNO:010
:ICOD:S
:QURY:START
select tppdm600.invm,tppdm600.stdt,tppdm600.ncmp,tppdm600.rsac,tppin010.*  ,tppdm740.cpay,tppdm740.ccrs,tppdm740.cvyn,tppdm740.cvat,tppdm740.ccty
from tppin010,tppdm600,tppdm740
where tppin010.cprj refers to tppdm600 unref clear  
 and tppdm740.cprj =  tppin010.cprj  
 and tppdm740.cuno =  tppin010.cuno
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:pin
:TFLNO:010
:SCPAC:tp
:SCMOD:pin
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:pin
:TFLNO:020
:SCPAC:tp
:SCMOD:pin
:SFLNO:020
:ICOD:D
:QURY:START
	 get.business.partner(tppin020.cuno,bcstc.orgn.cuno,err.mess)  
 	 var.tppin020.invo =  etol(tppin020.invo)  
 	 var.tppin020.trsl =  2  
 	 var.tppin020.ityp =  " "  
 	 var.tppin020.fcmp =  0  
 	 var.tppin020.idoc =  0  
 	 var.tppin020.itpa =  " "  
 	 var.tppin020.idca =  0  
 	 var.tppin020.fcma =  0  
 	 var.tppin020.cpay =  tppdm740.cpay  
 	 var.tppin020.ccrs =  tppdm740.ccrs  
 	 if tppin020.stin =  tppdm.stin.final then  
 	 	 select 	 tppin100.ocmp  
 	 	 from 	 tppin100  
 	 	 where 	 tppin100.stin =  tppdm.stin.final and  
 	 	 	 tppin100.ninv =  :tppin020.ninv and  
 	 	 	 tppin100.cfpo =  tppdm.yeno.yes and  
 	 	 	 tppin100.post =  tppdm.yeno.yes  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 var.tppin020.trsl =  1  
 	 	 	 var.tppin020.ityp =  tpprc000.ttys  
 	 	 	 var.tppin020.fcmp =  tppin100.ocmp  
 	 	 	 var.tppin020.idoc =  tppin020.ninv  
 	 	 	 var.tppin020.cpay =  tppin100.cpay  
 	 	 	 var.tppin020.ccrs =  tppin100.ccrs  
 	 	 	 if tppin020.stna =  tppdm.stin.final then  
 	 	 	 	 select 	 tppin100.ocmp  
 	 	 	 	 from 	 tppin100  
 	 	 	 	 where 	 tppin100.stin =  tppdm.stin.final and  
 	 	 	 	 	 tppin100.ninv =  :tppin020.nina and  
 	 	 	 	 	 tppin100.cfpo =  tppdm.yeno.yes and  
 	 	 	 	 	 tppin100.post =  tppdm.yeno.yes  
 	 	 	 	 selectdo  
 	 	 	 	 	 var.tppin020.itpa =  tpprc000.ttys  
 	 	 	 	 	 var.tppin020.idca =  tppin020.nina  
 	 	 	 	 	 var.tppin020.fcma =  tppin100.ocmp  
 	 	 	 	 endselect  
 	 	 	 endif 	 	 	  
 	 	 endselect  
 	 endif  
 	 if tppdm600.stdt <>  0 then  
 	 	 var.tppin020.rdat =  utc(tppdm600.stdt,0)  
 	 else  
 	 	 if tppin020.sidt <>  0 then  
 	 	 	 var.tppin020.rdat =  utc(tppin020.sidt,0)  
 	 	 else  
 	 	 	 var.tppin020.rdat =  utc(date.num(),time.num())  
 	 	 endif  
 	 endif  
 	 if var.tppin020.trsl =  1 then 	 	 	 	 | #  200 -  100405.sn  
 	 	 var.tppin020.invo =  1  
 	 endif 	 	 	 	 	 	 	 | #  200 -  100405.en  
 	 if not isspace(tppin020.cact) and 	 	 	 | #  200 -  100404.sn  
 	 activity.is.milestone(tppin020.cprj,tppin020.cpla,tppin020.cact) then  
 	 	 var.tppin020.cact =  tppdm600.rsac  
 	 else  
 	 	 var.tppin020.cact =  tppin020.cact  
 	 endif 	 	 	 	 	 	 	 | #  200 -  100404.en  
 	 if tppin020.txta =  0 then 	 	 	 	 | #  200 -  100413.sn  
 	 	 tppin020.toin =  tppdm.yeno.no  
 	 endif 	 	 	 	 	 	 	 | #  200 -  100413.en  
 	 if tppin020.clos =  tppdm.yeno.yes then  
 	 	 var.tppin020.trsl =  1  
 	 	 var.tppin020.invo =  1  
 	 endif  
 | 	 get.customer.country(tppin020.cuno, 	 	 	 | #  SP2.sn  
 | 	 	 	 var.tppin020.bptc) 	 	 	 | #  SP2.en  
 	 var.tppin020.ccty =  get.country.of.financial.company(tppdm600.ncmp) 	 | #  SP2.n  
 	 var1.tppin020.ccty =  ""       	              	              	              	              	              	       |#       210859.sn               
 	 var1.tppin020.cvat =  ""              
 	 get.tax.by.country.code.and.financial.company( 	 var.tppin020.ccty, 	  
 	 	 	 	 	 	 	 	 tppin020.cvat,  
 	 	 	 	 	 	 	 	 tppdm600.ncmp,  
 	 	 	 	 	 	 	 	 var1.tppin020.ccty,  
 	 	 	 	 	 	 	 	 var1.tppin020.cvat,  
 	 	 	 	 	 	 	 	 err.mess) 	 | #  210859.en  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:pin
:TFLNO:020
:SCPAC:tp
:SCMOD:pin
:SFLNO:020
:ICOD:S
:QURY:START
select tppdm600.ncmp,tppdm600.stdt,tppin020.*  ,tppdm740.cpay,tppdm740.ccrs, tppdm740.ccty
from tppin020,tppdm600,tppdm740
where tppin020.cprj refers to tppdm600 unref clear  
 and tppdm740.cprj =  tppin020.cprj  
 and tppdm740.cuno =  tppin020.cuno
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:pin
:TFLNO:020
:SCPAC:tp
:SCMOD:pin
:SFLNO:020
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:ppc
:TFLNO:210
:SCPAC:tp
:SCMOD:ppc
:SFLNO:210
:ICOD:D
:QURY:START


var.tpppc210.cprj =  get.tp.project(tpppc210.cprj) 	  
 	 if not isspace(tpppc210.orno) then  
 	 	 read.order.type.from.requirements()  
 	 else  
 	 	 var.tpppc210.koor =  0  
 	 endif  
 	 on case var.tpppc210.koor  
 	 case etol(tckoor.act.pur):  
 	 	 var.bcckon.orno =  convert.tckoor.to.bcckon(tckoor.act.pur)  
 	 	 var.tpppc210.orno =  convert.number(var.bcckon.orno , tpppc210.orno)  
 	 	 break  
 	 case etol(tckoor.wrh.order):  
 	 	 var.bcckon.orno =  convert.tckoor.to.bcckon(tckoor.wrh.order)  
 	 	 var.tpppc210.orno =  convert.number(var.bcckon.orno , tpppc210.orno)  
 	 	 break  
 	 default: 	 	 	  
 	 	 var.tpppc210.orno =  ""                            
 	 endcase  
 	  
 	 var.tpppc210.item =  ""                   	                                                      
 	 item.type =  read.item (tpppc210.item,tpppc210.cprj,var.tppdm.desc.descr,12,0,1)  
 	  
 	 if (item.type =  tppdm.reft.standard) then  
 	 	 temp.cprj =  ""                                    
 	 	 var.tpppc210.item =  segment.item.code (tpppc210.item,temp.cprj)  
 	 else  
 	 	 if (item.type =  tppdm.reft.project) then 	 	 	 	  
 	 	 	 	 var.tpppc210.item =  segment.item.code (tpppc210.item,var.tpppc210.cprj) 	  
 	 	 endif  
 	 endif  
 	  
 	 if not get.cost.components (bcorig.tppdm,"",tpppc210.ccco,o.err.mess) then  
 	 	 var.tpppc210.ccco =  bcstc006.cost  
 	 else  
 	 	 var.tpppc210.ccco =  ""                                    
 	 endif  
 	 if tpppc000.pfpp =  tppdm.yeno.yes then  
 	 	 var.tpppc210.cptf =  var.tpppc210.cptc  
 	 endif  
 	 get.business.partner(tpppc210.suno,bcstc.orgn.suno,o.err.mess)  
 	 get.enterprise.unit(tppdm600.ncmp,ext.lng.comp , o.err.mess)  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:ppc
:TFLNO:210
:SCPAC:tp
:SCMOD:ppc
:SFLNO:210
:ICOD:S
:QURY:START


select tppdm600.ncmp,tppdm600.cprj,tpppc210.*
from tppdm600,tpppc210
where tpppc210.cprj refers to tppdm600 unref skip
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:ppc
:TFLNO:301
:SCPAC:tp
:SCMOD:ppc
:SFLNO:301
:ICOD:D
:QURY:START
var.tpppc301.cprj =  get.tp.project(tpppc301.cprj)  
 	 if (tpppc301.tetm =  tpppc.tetm.sal.invoice.fin) then  
 	 	 var.tpppc.tetm =  5  
 	 else  
 	 	 var.tpppc.tetm =  etol(tpppc301.tetm)  
 	 endif  
 	  
 	 on case etol(tpppc301.rest)  
 	 case 3:  
 	 	 var.tpppc301.rest =  4 	  
 	 	 break  
 	 case 4:  
 	 	 var.tpppc301.rest =  5  
 	 	 break  
 	 case 5:  
 	 	 var.tpppc301.rest =  6  
 	 	 break  
 	 default:  
 	 	 var.tpppc301.rest =  etol(tpppc301.rest)  
 	 endcase  
 	  
 	 get.cost.components (bcorig.tppdm,"", tpppc301.ccco, var.o.errmess)  
 	 get.business.partner(tpppc301.cuno,bcstc.orgn.cuno,o.err.mess)  
 	 get.enterprise.unit(tppdm600.ncmp,ext.lng.comp , o.err.mess)  
 	 var.tpppc301.ccty =  get.country.of.financial.company(tppdm600.ncmp) 	 | #  SP2.n  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:ppc
:TFLNO:301
:SCPAC:tp
:SCMOD:ppc
:SFLNO:301
:ICOD:S
:QURY:START
select 	 tppdm600.ncmp, tpppc301.*  , tppdm600.cprj
from 	 tppdm600, tpppc301
where 	 tpppc301.cprj refers to tppdm600 unref skip
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:ppc
:TFLNO:301
:SCPAC:tp
:SCMOD:ppc
:SFLNO:301
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:ppc
:TFLNO:400
:SCPAC:tp
:SCMOD:ppc
:SFLNO:400
:ICOD:D
:QURY:START
var.tpppc400.cprj =  get.tp.project(tpppc400.cprj)  
 	 var.tpppc400.mprj =  get.tp.project(tpppc400.mprj)  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:ppc
:TFLNO:400
:SCPAC:tp
:SCMOD:ppc
:SFLNO:400
:ICOD:S
:QURY:START
select 	 tpppc400.*
from 	 tpppc400
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:tp
:TCMOD:ppc
:TFLNO:400
:SCPAC:tp
:SCMOD:ppc
:SFLNO:400
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:acm
:TFLNO:101
:SCPAC:ts
:SCMOD:sma
:SFLNO:120
:ICOD:D
:QURY:START
if not ( isspace ( tssma120.ctyp ) or  
 	 	 tssma120.ctyp =  tssma406.ctyp ) then  
 	 	 get.skills ( tssma120.ctyp,  
 	 	 	 var.tsacm101.skla,  
 	 	 	 var.tsacm101.sklb,  
 	 	 	 var.tsacm101.sklc )  
 	 endif  
 	 fill.item()  
 	 fill.time.frequency ()  
 	 Dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:acm
:TFLNO:101
:SCPAC:ts
:SCMOD:sma
:SFLNO:120
:ICOD:S
:QURY:START
select tssma120.*
from tssma120
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:acm
:TFLNO:101
:SCPAC:ts
:SCMOD:sma
:SFLNO:120
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:acm
:TFLNO:220
:SCPAC:ts
:SCMOD:sma
:SFLNO:121
:ICOD:D
:QURY:START


| 	 select 	 tiitm001.cpcp, tiitm001.cuni , tiitm001.copr  
 	 select 	 tiitm001.*   
 	 from 	 tiitm001  
 	 where 	 tiitm001.item =  :tssma121.item  
 	 selectdo  
 	 	 select 	 ticpr010.cref , ticpr010.dsca  
 	 	 from 	 ticpr010  
 	 	 where 	 ticpr010.cpcp =  :tiitm001.cpcp  
 	 	 selectdo  
 	 	 	 if (tssma121.cjob =  var.cjob) then  
 	 	 	 	 var.tsacm220.lino =  var.tsacm220.lino +  10  
 	 	 	 else  
 	 	 	 	 var.cjob =  tssma121.cjob  
 	 	 	 	 var.tsacm220.lino =  10  
 	 	 	 endif  
 	 	 	 fill.quantity()  
 	 	 	 fill.price()  
 	 	 	 fill.price()  
 	 	 	 dump 1  
 	 	 endselect  
 	 endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:acm
:TFLNO:220
:SCPAC:ts
:SCMOD:sma
:SFLNO:121
:ICOD:S
:QURY:START


select 	 tssma121.*
from tssma121
order by tssma121.cjob
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:bsc
:TFLNO:110
:SCPAC:ts
:SCMOD:sma
:SFLNO:102
:ICOD:D
:QURY:START
get.configuration ( tssma102.cloc, err.mess )  
 	 if ( bcsts005.clst =  var.str.prev.clst ) then  
 	 	 var.lng.curr.seqn =  var.lng.curr.seqn +  1  
 	 else  
 	 	 var.lng.curr.seqn =  1  
 	 endif  
 	 if dummy.item.has.to.be.used ( 	 tssma102.cprj,  
 	 	 	 	 	 tssma102.item ) then  
 	 	 var.str.item =  segment.item.code ( bcsts000.item,  
 	 	 	 	 empty.string(1;9))  
 	 else  
 	 	 var.str.item =  segment.item.code (  
 | 	 	 	 	 tssma102.item,tssma102.cprj ) | #  SL200314.o  
 	 	 	 	 tssma102.item, 	 	 	 | #  200314.sn  
 	 	 	 	 get.project(tssma102.cprj)) 	 | #  200314.en  
 	 endif  
 	 dump 1  
 	 var.str.prev.clst =  bcsts005.clst
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:bsc
:TFLNO:110
:SCPAC:ts
:SCMOD:sma
:SFLNO:102
:ICOD:S
:QURY:START
select tssma102.*
from tssma102  
 |order by tssma102.cloc, tssma102.cins 	 	 	 | #  207465.o
order by tssma102._index5 	 	 	 	 | #  207465.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:bsc
:TFLNO:110
:SCPAC:ts
:SCMOD:sma
:SFLNO:102
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:cfg
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:102
:ICOD:D
:QURY:START
get.configuration ( tssma102.cloc, err.mess )  
 	 fill.business.partners()  
 	 if tssma302.cloc <>  tssma110.cloc then  
 	 	 var.tscfg200.ofad =  local.get.addresses(0)  
 	 	 var.tscfg200.ladr =  local.get.addresses(1)  
 	 endif  
 	 if is.masterdata.conversion () then  
 	 	 var.str.temp1.cwte =  empty.string ( 1;16 )  
 	 	 var.tscfg200.srno =  empty.string(1;9)  
 	 	 var.tscfg200.pono =  0  
 	 else  
 	 	 var.str.temp1.cwte =  tssma102.cgua  
 	 	 var.tscfg200.srno =  convert.number(bcckon.act.sls,tssma102.orno)  
 	 	 var.tscfg200.pono =  tssma102.pono  
 	 endif  
 	 if dummy.item.has.to.be.used ( 	 tssma102.cprj,  
 	 	 	 	 	 tssma102.item ) then  
 	 	 var.bccnv.item.temp1.item =   
 	 	 	 segment.item.code ( bcsts000.item,empty.string(1;9))  
 	 	 var.str.revi =  empty.string ( 1;6 )  
 	 else  
 	 	 var.bccnv.item.temp1.item =   
 	 	 	 	 	 	 	 	 | #  Sl200314.so  
 | 	 	 	 segment.item.code ( tssma102.item,tssma102.cprj)  
 	 	 	 	 	 	 	 	 | #  SL200314.eo  
 	 	 	 	 	 	 	 	 | #  SL200314.sn  
 	 	 	 segment.item.code ( 	 tssma102.item,  
 	 	 	 	 	 	 get.project(tssma102.cprj))  
 	 	 	 	 	 	 	 	 | #  SL200314.en  
 	 	 var.str.revi =  tssma102.revi  
 	 endif  
 	 if not ISSPACE ( var.str.temp1.cwte ) then  
 	 	 var.lng.temp.term =  get.term.ids.for.serialised.item(  
 	 	 	 	 	 	 tssma102.item,  
 	 	 	 	 	 	 tssma102.cins)  
 	 else  
 	 	 var.lng.temp.term =  0.0  
 	 endif  
 	 fill.status.time()  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:cfg
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:102
:ICOD:S
:QURY:START
select 	 tssma102.*  , tssma110.*
from 	 tssma102, tssma110
where 	 tssma102.cloc refers to tssma110
order by tssma102.item
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:cfg
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:102
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:cfg
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:104
:ICOD:D
:QURY:START
select tssma104.cins, tssma102.*   
 	 from 	 tssma104, tssma102  
 	 where 	 tssma104.item =  :tssma105.item  
 	 and 	 tssma104.cser =  :tssma105.cser  
 	 and 	 tssma104.cins refers to tssma102  
 	 as set with 1 rows  
 	 selectdo  
 	 selectempty  
 	 	 tssma104.cins =  empty.string ( 1;20 )  
 	 	 tssma102.cloc =  empty.string ( 1;10 )  
 	 	 var.str.ofbp =  empty.string ( 1;9 )  
 	 	 var.str.otbp =  empty.string ( 1;9 )  
 	 endselect  
 	 get.configuration ( tssma102.cloc, err.mess )  
 	 var.str.revi =  tssma105.revi  
 	  
 	 if is.masterdata.conversion () then  
 	 	 var.str.temp2.cwte =  empty.string ( 1;16 )  
 	 	 var.tscfg200.srno =  empty.string ( 1;16 )  
 	 	 var.tscfg200.pono =  0  
 	 else  
 	 	 var.str.temp2.cwte =  tssma105.cgua  
 	 	 var.tscfg200.srno =  convert.number ( bcckon.act.sls,tssma102.orno )  
 	 	 var.tscfg200.pono =  tssma102.pono  
 	 endif  
 	 if not isspace ( var.str.temp2.cwte ) then  
 	 	 var.lng.temp.term =  get.term.ids.for.serialised.item (  
 	 	 	 	 	 	 	 tssma105.item,  
 	 	 	 	 	 	 	 tssma105.cser )  
 	 endif  
 	 if dummy.item.has.to.be.used ( 	 "",                                           
 	 	 	 	 	 tssma105.item ) then  
 	 	 temp.item =  bcsts000.item  
 	 	 var.str.revi =  empty.string ( 1;6 )  
 	 else  
 	 	 temp.item =  tssma105.item  
 	 endif  
 	 var.bccnv.item.temp2.item =   
 	 	 	 segment.item.code ( temp.item,empty.string ( 1;9 ))  
 	 select tssma110.*   
 	 from tssma110  
 	 where 	 tssma110._index1 =  {:tssma102.cloc}  
 	 as set with 1 rows  
 	 selectdo  
 	 	 fill.business.partners ()  
 	 	 var.tscfg200.ofad =  local.get.addresses ( 0 )  
 	 	 var.tscfg200.ladr =  local.get.addresses ( 1 )  
 	 selectempty  
 	 	 var.tscfg200.ofad =  empty.string ( 1;9 )  
 	 endselect  
 	 if not isspace ( tssma104.cins ) then  
 	 	 if dummy.item.has.to.be.used ( 	 tssma102.cprj,  
 	 	 	 	 	 	 tssma102.item ) then  
 	 	 	 var.tscfg200.titm =  segment.item.code (  
 	 	 	 	 bcsts000.item,empty.string(1;9) )  
 	 	 else  
 	 	 	 var.tscfg200.titm =  segment.item.code (  
 	 	 	 	 tssma102.item,tssma102.cprj )  
 	 	 endif  
 	 else  
 	 	 tssma102.idat =  0  
 	 	 tssma102.locd =  empty.string ( 1;30 )  
 	 	 tssma102.suno =  empty.string ( 1;6 )  
 	 	 var.tscfg200.titm =  var.bccnv.item.temp2.item  
 	 endif  
 	 fill.status.time ()  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:cfg
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:104
:ICOD:S
:QURY:START
select tssma105.*
from 	 tssma105
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:cfg
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:104
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:cfg
:TFLNO:210
:SCPAC:ts
:SCMOD:sma
:SFLNO:104
:ICOD:D
:QURY:START
	 if dummy.item.has.to.be.used ( 	 tssma102.cprj,  
 	 	 	 	 	 tssma102.item ) then  
 	 	 var.str.item =  segment.item.code ( bcsts000.item,  
 	 	 	 	 	 	 empty.string(1;9))  
 	 else  
 | 	 	 	 	 	 	 	 	 | #  SL200314.so  
 | 	 	 var.str.item =  segment.item.code ( tssma102.item,  
 | 	 	 	 	 	 	 tssma102.cprj )  
 | 	 	 	 	 	 	 	 	 | #  SL200314.eo  
 	 	 	 	 	 	 	 	 | #  SL200314.sn  
 	 	 var.str.item =  segment.item.code ( tssma102.item,  
 	 	 	 	 	 	 get.project(tssma102.cprj))  
 	 	 	 	 	 	 	 	 | #  SL200314.en  
 	 endif  
 	 if isspace ( tssma104.cser )  
 	 or is.item.serialized ( tssma104.item ) then  
 	 | *  If serial number is empty then it is ananymous item  
 	 	 var.str.child.item =  segment.item.code ( tssma104.item, empty.string ( 1;9 ) )  
 	 else  
 	 	 var.str.child.item =  segment.item.code ( bcsts000.item, empty.string ( 1;9 ) )  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:cfg
:TFLNO:210
:SCPAC:ts
:SCMOD:sma
:SFLNO:104
:ICOD:S
:QURY:START
select 	 tssma102.item, tssma102.cprj, tssma102.clot, tssma102.cgua, tssma104.*  | # SP3.n
from 	 tssma102, tssma104
where 	 tssma104.cins refers to tssma102
order by tssma104._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:cfg
:TFLNO:210
:SCPAC:ts
:SCMOD:sma
:SFLNO:104
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:ctm
:TFLNO:120
:SCPAC:ts
:SCMOD:sma
:SFLNO:102
:ICOD:D
:QURY:START
term.id =  get.term.ids.for.serialised.item(tssma102.item,  
 	 	 	 	 	 	 tssma102.cins)  
 	 if not term.id then  
 	 	 continue  
 	 	 | *  Incase term id is not generated, do not dump data.  
 	 endif  
 	 hold.stdt =  tssma102.idat  
 	 dump.warranty.terms()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:ctm
:TFLNO:120
:SCPAC:ts
:SCMOD:sma
:SFLNO:102
:ICOD:S
:QURY:START
select 	 tssma102.cins, tssma102.item, 	 tssma102.cgua, tssma102.idat, 	 tssma130.*
from 	 tssma102, tssma130
where 	 tssma102.cgua refers to tssma130 unref skip
order by tssma102.cgua
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:ctm
:TFLNO:120
:SCPAC:ts
:SCMOD:sma
:SFLNO:102
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:ctm
:TFLNO:120
:SCPAC:ts
:SCMOD:sma
:SFLNO:105
:ICOD:D
:QURY:START
term.id =  get.term.ids.for.serialised.item(tssma105.item,  
 	 	 	 	 	 	 tssma105.cser)  
 	 if not term.id then  
 	 	 continue  
 	 	 | *  Incase term id is not generated, do not dump data.  
 	 endif  
 	 fill.start.date.for.component()  
 	 dump.warranty.terms()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:ctm
:TFLNO:120
:SCPAC:ts
:SCMOD:sma
:SFLNO:105
:ICOD:S
:QURY:START
select 	 tssma105.item, tssma105.cser, 	 tssma105.cgua, tssma130.*
from 	 tssma105, tssma130
where 	 tssma105.cgua refers to tssma130 unref skip
order by tssma105.cgua
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:ctm
:TFLNO:120
:SCPAC:ts
:SCMOD:sma
:SFLNO:105
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:ctm
:TFLNO:120
:SCPAC:ts
:SCMOD:sma
:SFLNO:130
:ICOD:D
:QURY:START
term.id =  get.term.id.for.warranty(tssma130.cgua) 	  
 	 if not term.id then  
 	 	 continue  
 	 	 | *  Incase term id is not generated, do not dump data.  
 	 endif  
 	 dump.warranty.terms()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:ctm
:TFLNO:120
:SCPAC:ts
:SCMOD:sma
:SFLNO:130
:ICOD:S
:QURY:START
select 	 tssma130.*
from 	 tssma130
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:ctm
:TFLNO:120
:SCPAC:ts
:SCMOD:sma
:SFLNO:130
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:ctm
:TFLNO:120
:SCPAC:ts
:SCMOD:sma
:SFLNO:204
:ICOD:D
:QURY:START
term.id =  get.term.id.for.contract.template(tssma204.cpac)  
 	 if not term.id then  
 	 	 continue  
 	 	 | *  Incase term id is not generated, do not dump data.  
 	 endif  
 	 transfer.service.package()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:ctm
:TFLNO:120
:SCPAC:ts
:SCMOD:sma
:SFLNO:204
:ICOD:S
:QURY:START
select 	 tssma204.*
from 	 tssma204
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:ctm
:TFLNO:120
:SCPAC:ts
:SCMOD:sma
:SFLNO:204
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:ctm
:TFLNO:120
:SCPAC:ts
:SCMOD:sma
:SFLNO:220
:ICOD:D
:QURY:START
| *  Migrate the records for contracts and contract quotations  
 	 if prev.ccon <>  tssma220.ccon then  
 	 	 if tssma220.ctst =  tssma.ctst.quotation then  
 	 	 	 hold.appl =  bcsts.appl.quot  
 	 	 else  
 	 	 	 hold.appl =  bcsts.appl.cont  
 	 	 endif  
 	 	 hold.ccon =  convert.10.to.9(tssma220.ccon)  
 	 	 term.id =  get.term.id.for.contract.and.quot(hold.appl,  
 	 	 	 	 	 	 	 hold.ccon)  
 	 	 prev.ccon =  tssma220.ccon  
 	 	 var.lng.cfln =  0  
 	 endif  
 	 if not term.id then  
 	 	 continue  
 	 	 | *  Incase term id is not generated, do not dump data.  
 	 endif  
 	 var.lng.cfln =  var.lng.cfln +  10  
 	 transfer.service.package()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:ctm
:TFLNO:120
:SCPAC:ts
:SCMOD:sma
:SFLNO:220
:ICOD:S
:QURY:START
select 	 tssma102.ccon,tssma102.cpac, tssma220.*  , tssma204.*  	 	 	 	 	
from 	 tssma102, tssma220,tssma204
where 	 tssma102.ccon refers to tssma220 unref skip  
 and 	 tssma102.cpac refers to tssma204
order by tssma102.ccon
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:ctm
:TFLNO:120
:SCPAC:ts
:SCMOD:sma
:SFLNO:220
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:ctm
:TFLNO:300
:SCPAC:ts
:SCMOD:sma
:SFLNO:220
:ICOD:D
:QURY:START
temp.lng.nrpe =  tssma220.edat -  tssma220.sdat  
 	 on case var.tsctm.peru  
 	 	 case 5:  
 	 	 	 var.tsctm.nrpe =  temp.lng.nrpe  
 	 	 	 break  
 	 	 case 10:  
 	 	 	 var.tsctm.nrpe =  round (temp.lng.nrpe /  7,0,2)  
 	 	 	 break  
 	 	 case 15:  
 	 	 	 var.tsctm.nrpe =  round (temp.lng.nrpe /  30,0,2)  
 	 	 	 break  
 	 	 case 20:  
 	 	 	 var.tsctm.nrpe =  round (temp.lng.nrpe /  90,0,2)  
 	 	 	 break  
 	 	 case 25:  
 	 	 	 var.tsctm.nrpe =  round (temp.lng.nrpe /  365,0,2)  
 	 	 	 break  
 	 endcase  
 	 if (len (shiftl$ (shiftr$ (tssma220.ccon))) >  9) then  
 	 	 var.tsctm.desc =  tssma220.ccon  
 	 else  
 	 	 var.tsctm.desc =  tssma220.desc  
 	 endif  
 	 var.tsctm.csco =  convert.10.to.9(tssma220.ccon)  
 	 if tssma220.ctst =  tssma.ctst.quotation then  
 	 	 term.id =  get.term.id.for.contract.and.quot(bcsts.appl.quot,  
 	 	 	 	 	 	 var.tsctm.csco)  
 	 else  
 	 term.id =  get.term.id.for.contract.and.quot(bcsts.appl.cont,  
 	 	 	 	 	 	 	 var.tsctm.csco)  
 	 endif  
 	 if (not (isspace (tssma220.cvat))) then  
 	 	 var.tsctm.txyn =  1  
 | 	 	 var.tsctm.cvat =  tssma220.cvat 	 	 	 	 | #  210859.o  
 	 	 hold.tsctm.cvat =  tssma220.cvat 	 	 	 	 | #  210859.n  
 	 else  
 	 	 var.tsctm.txyn =  2  
 | 	 	 var.tsctm.cvat =  empty.string(1;9) 	 	 	 	 | #  210859.o  
 	 	 hold.tsctm.cvat =  empty.string(1;9) 	 	 	 	 | #  210859.n  
 	 endif  
 	 if (not (isspace (tssma220.ccor))) then  
 	 	 var.str.tempadd =  tssma220.cuno (1;6) &  tssma220.ccor (1;3)  
 	 	 if not get.addresses("tccom012",var.str.tempadd,err.mess) then  
 	 	 	 var.tsctm.itad =  bcstc004.cadr  
 	 	 else  
 	 	 	 var.tsctm.itad =  empty.string(1;9)  
 	 	 endif  
 	 else  
 	 	 var.str.tempadd =  tssma220.cuno  
 	 	 if not get.addresses("tccom010",var.str.tempadd,err.mess) then  
 	 	 	 var.tsctm.itad =  bcstc004.cadr  
 	 	 else  
 	 	 	 var.tsctm.itad =  empty.string(1;9)  
 	 	 endif  
 	 endif  
 	 if not isspace(tssma220.ccor) then 	 	 	 | #  200 -  101545.sn 	 	 	 	 	 	  
 	 	 select tccom012.ccty:var.tsctm.bptc  
 	 	 from 	 tccom012  
 	 	 where tccom012._index1 =  {:tssma220.cuno,:tssma220.ccor}  
 	 	 selectdo  
 	 	 endselect  
 	 else 	 	 	 	 	 	 	 | #  200 -  101545.en  
 | 	 	 select tccom010.ccty 	 	 	 	 | #  200 -  101545.o  
 	 	 select tccom010.ccty:var.tsctm.bptc 	 	 | #  200 -  101545.sn  
 	 	 from 	 tccom010  
 	 	 where tccom010._index1 =  {:tssma220.cuno}  
 	 	 selectdo  
 	 	 endselect  
 	 endif 	 	 	 	 	 	 	 | #  200 -  101545.en  
 	 if not get.exchange.rate.type("SLS",err.mess) then  
 	 	 var.str.rtyp =  bcstc011.rtyp  
 	 else  
 	 	 var.str.rtyp =  empty.string(1;3)  
 	 endif  
 	 if not get.business.partner(tssma220.cuno,bcstc.orgn.cuno,err.mess) then  
 	 	 var.str.bpid =  bcstc008.bpid  
 	 else  
 	 	 var.str.bpid =  empty.string(1;9)  
 	 endif  
 | 	 var.str.ccty =  get.country.of.financial.company(tssma220.ncmp) 	 	 | #  210859.o  
 	 hold.str.ccty =  get.country.of.financial.company(tssma220.ncmp) 	 | #  210859.sn  
 	 get.tax.by.country.code.and.financial.company(  
 	 	 	 	 	 hold.str.ccty,hold.tsctm.cvat,  
 	 	 	 	 	 tssma220.ncmp,  
 	 	 	 	 	 var.str.ccty,var.tsctm.cvat,err.mess)  
 	 	 	 	 	 	 	 	 	 	 | #  210859.en  
 	  
 	 if not get.enterprise.unit(tssma220.ncmp,ext.lng.comp,err.mess) then  
 	 	 var.tsctm.cwoc =  bcstc018.srfd  
 	 else  
 	 	 var.tsctm.cwoc =  empty.string(1;6)  
 	 endif  
 	 if tssma220.citp =  tssma.citp.once then  
 	 	 var.str.ctin =  bcsts000.ctiy  
 	 else  
 	 	 var.str.ctin =  bcsts000.ctin  
 	 endif  
 	 get.calculated.sales.amount()  
 	 get.status.of.contract(tssma220.ctst,  
 	 	 	 	 var.tsctm300.scon,  
 	 	 	 	 var.tsctm320.stat) 	  
 	 if var.tsctm300.scon then 	 	  
 	 	 dump 1  
 	 	 dump 2  
 	 | *  For Contract status free,active expired,canceled data created in the contracts  
 	 else  
 	 	 dump 3  
 	 | *  Quotations  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:ctm
:TFLNO:300
:SCPAC:ts
:SCMOD:sma
:SFLNO:220
:ICOD:S
:QURY:START
select tssma220.*
from tssma220
order by tssma220.ccon
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:ctm
:TFLNO:300
:SCPAC:ts
:SCMOD:sma
:SFLNO:220
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:mdm
:TFLNO:400
:SCPAC:ts
:SCMOD:sma
:SFLNO:310
:ICOD:D
:QURY:START
	 if not migrated.as.material.line() then  
 	 	 | *  Only material lines can have relations  
 	 	 | *  If not migrated as material line then no need of any  
 	 	 | *  entries in this table.  
 	 	 continue  
 	 endif  
 	 if purchase.order.is.lined() then  
 	 	 fill.fields.for.pur.relation()  
 	 	 dump 1  
 	 endif  
 	 fill.fields.for.wh.relation()  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:mdm
:TFLNO:400
:SCPAC:ts
:SCMOD:sma
:SFLNO:310
:ICOD:S
:QURY:START
select 	 tssma310.orno, tssma310.seqn,  
 	 tssma310.tcst, tssma310.item
from 	 tssma310
where 	 ( tssma310.tcst =  tssma.tcst.material  
 or 	 tssma310.tcst =  tssma.tcst.other )
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:mdm
:TFLNO:400
:SCPAC:ts
:SCMOD:sma
:SFLNO:310
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:soc
:TFLNO:000
:SCPAC:ts
:SCMOD:sma
:SFLNO:000
:ICOD:D
:QURY:START
var.str.indt =  utc(date.num(), 0)  
 	 var.str.dsca =  form.text$("bcstc00035") 	 | *  Actual Set  
 	 dump.parameters()  
 	 var.str.indt =  utc(0, 0)  
 	 var.str.dsca =  form.text$("bcstc00036") | *  Converted from BaanIVc4  
 	 dump.parameters()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:soc
:TFLNO:000
:SCPAC:ts
:SCMOD:sma
:SFLNO:000
:ICOD:S
:QURY:START
select 	 tssma000.*
from 	 tssma000  
 as set with 1 rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:soc
:TFLNO:000
:SCPAC:ts
:SCMOD:sma
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:soc
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:301
:ICOD:D
:QURY:START
fill.cluster ()  
 	 fill.business.partner ()  
 	 fill.item ()  
 	 var.tssoc210.desc =  (isspace(tssma120.desc) ?  tssma301.desc:tssma120.desc)  
 	 if isspace(tssma301.ccur) then  
 	 	 var.tssoc200.ccur =  home.ccur  
 	 else  
 	 	 var.tssoc200.ccur =  tssma301.ccur  
 	 endif  
 	 taxyesnoflag =  get.tax.flag.via.bp(  
 	 	 	 	 tssma301.cuno,  
 	 	 	 	 bcstc.orgn.cuno,  
 	 	 	 	 err.mess)  
 	 fill.addresses ()  
 	 fill.contract ()  
 	 var.str.cstp =  bcsts000.cstp ( 1,etol ( tssma301.sert ))  
 	 var.str.cctp =  bcsts000.cctp ( 1,etol ( tssma301.sert ))  
 	 	 	 	 	 	 	 	 | #  200 -  101936.so  
 | 	 var.str.emno =  (tssma301.emno) ?  format.emno(tssma301.emno):  
 | 	 	 	 	 	 	 bcsts000.emno | #  200 -  101936.eo  
 	 	 	 	 	 	 	 	  
 	 if tssma301.emno then 	 	 	 	 	 | #  200 -  101936.sn  
 	 	 var.str.emno =  format.emno(tssma301.emno)  
 	 else  
 	 	 if technician.present.for.order() then  
 	 	 	 var.str.emno =  	 empty.string(1;6) 	 	 	  
 	 	 else  
 	 	 	 var.str.emno =  	 bcsts000.emno  
 	 	 endif  
 	 endif 	 	 	 	 	 	 	 | #  200 -  101936.en 	 	 	 	  
 	 	 	 	 	 	 	  
 	 var.lng.b4order.stat =  etol ( tssma301.swor )  
 	 var.lng.ordstatus =  get.status ( var.lng.b4order.stat )  
 	 var.bcsts.fent.srv.off =  get.department ()  
 	 fill.dates ()  
 	 get.skills ( 	 tssma301.ctyp,  
 	 	 	 var.str.skla,  
 	 	 	 var.str.sklb,  
 	 	 	 var.str.sklc )  
 	 dump 1  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:soc
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:301
:ICOD:S
:QURY:START
select 	 tssma301.*  , tssma120.desc
from 	 tssma301, tssma120
where 	 tssma301.cjob refers to tssma120 unref clear
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:soc
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:301
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:soc
:TFLNO:220
:SCPAC:ts
:SCMOD:sma
:SFLNO:310
:ICOD:D
:QURY:START
	 get.cost.components(bcorig.ticpr, tssma310.cpcp, "",err.mess)                                                                          
 	 var.str.ccmp =  bcstc006.cost  
 	 fill.line.status()  
 	 fill.cost.type()  
 	 fill.amounts() 	 	 	 	 	 	  
 	 fill.print.on.invoice()  
 	 fill.business.partner() 	 	 	  
 	 if prev.orno <>  tssma301.orno then  
 	 	 prev.orno =  tssma301.orno  
 	 	 fill.cluster()  
 	 endif  
 	 fill.countries()  
 	 var.str.emno =  (tssma301.emno) ?   
 	 	 	 	 format.emno(tssma301.emno):bcsts000.emno  
 	 if tssma310.scos >=  tssma.scos.invoiced then  
 	 	 get.tfgld410.podt()  
 	 else  
 	 	 tfgld410.podt =  0  
 	 endif  
 	 on case var.lng.cotp  
 	 case 5:  
 	 	 fill.quantities()  
 	 	 dump 1  
 	 	 | *  tssoc220 -  Material  
 	 	 break  
 	 case 10:  
 	 	 dump 2  
 	 	 | *  tssoc230 -  Labour  
 	 	 break  
 	 default:  
 	 	 fill.travel.spec()  
 	 	 dump 3  
 	 	 | *  tssoc240 -  others  
 	 	 break  
 	 endcase  
 	 dump 4 	 	 	 	 	 	  
 	 | *  tssoc400 -  Service order gross margin analysis
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:soc
:TFLNO:220
:SCPAC:ts
:SCMOD:sma
:SFLNO:310
:ICOD:S
:QURY:START
select tssma310.*  , tssma301.orno, tssma301.ddt6, 	 tssma301.dtm6, tssma301.ccty, 	 tssma301.emno, tssma301.cloc, 	 tssma301.ccor,tssma301.cuno, tiitm001.dsca, 	 tiitm001.kitm, tiitm001.cuni,  
 	 tssma301.ncmp 	 	 	 	 	 	 | #  800 -  154796.n
from 	 tssma310, tssma301, tiitm001
where 	 tssma310.orno refers to tssma301  
 and 	 tssma310.item refers to tiitm001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:soc
:TFLNO:220
:SCPAC:ts
:SCMOD:sma
:SFLNO:310
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:soc
:TFLNO:850
:SCPAC:ts
:SCMOD:sma
:SFLNO:501
:ICOD:D
:QURY:START
	 fill.dates() 	 	 	 | #  200 -  101952.n  
 	 fill.cluster()  
 	 fill.business.partner()  
 	 fill.item()  
 	 fill.service.type()  
 	 fill.coverage.type() 	 	 | #  200 -  101953.n  
 	 fill.contract() 	  
 	 fill.addresses()  
 	 fill.appointment()  
 	 fill.department()  
 	 dump 1  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:soc
:TFLNO:850
:SCPAC:ts
:SCMOD:sma
:SFLNO:501
:ICOD:S
:QURY:START
select 	 tssma501.*
from 	 tssma501
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:soc
:TFLNO:850
:SCPAC:ts
:SCMOD:sma
:SFLNO:501
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:soc
:TFLNO:860
:SCPAC:ts
:SCMOD:sma
:SFLNO:510
:ICOD:D
:QURY:START
	 fill.sequence.number()  
 	 fill.dates() 	 	 	 	 | #  200 -  101953.n  
 	 fill.cluster()  
 	 fill.amounts()  
 	 get.posting.date()  
 	 fill.cost.component()  
 	 	 	 	 	 	 	 	 	 	 | #  210859.sn 	  
 	 get.tax.by.country.code.and.financial.company(  
 	 	 	 	 	 tssma501.ccty,tssma510.cvat,  
 	 	 	 	 	 tssma510.ncmp,  
 	 	 	 	 	 var.str.ccty,var.tsctm.cvat,err.mess)  
 	 	 	 	 	 	 	 	 	 	 | #  210859.en  
 	 on case var.cotp  
 	 case 5:  
 	 	 | *  Material  
 	 	 dump 1  
 	 	 break  
 	 case 10:  
 	 	 | *  Labor  
 	 	 dump 2  
 	 	 break  
 	 default:  
 	 	 get.item.description()  
 	 	 fill.cost.type()  
 	 	 fill.travel.type()  
 	 	 dump 3  
 	 	 break  
 	 endcase
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:soc
:TFLNO:860
:SCPAC:ts
:SCMOD:sma
:SFLNO:510
:ICOD:S
:QURY:START
select 	 tssma510.*  , tssma501.cjob, 	 tssma501,cins, tssma501.ccty
from 	 tssma510, tssma501
where 	 tssma501._index1 =  {tssma510.bkyr, tssma510.orno}
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:soc
:TFLNO:860
:SCPAC:ts
:SCMOD:sma
:SFLNO:510
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:spc
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:124
:ICOD:D
:QURY:START
var.str.crac =  tssma124.cjob  
 	 fill.cluster()  
 	 fill.seqence.number()  
 	 var.lng.psct =  tssma124.plex  
 	 var.dbl.adur =  get.activity.duration ()  
 	 fill.item.and.serial.number ()  
 	 var.lng.stat =  get.status ()  
 	 var.str.sear =  left.align ( to.native (  
 	 	 	 	 toupper$ ( tssma120.desc ( 1;16 ))) ,  
 	 	 	 	 16 )  
 	 get.enterprise.unit ( ext.lng.comp,  
 	 	 	 ext.lng.comp,  
 	 	 	 err.mess )  
 	 hold.srv.off =  bcstc018.srfd  
 	 get.skills ( tssma120.ctyp,  
 	 	 var.tsspc200.skla,  
 	 	 var.tsspc200.sklb,  
 	 	 var.tsspc200.sklc )  
 	 if tssma124.orno then  
 	 	 var.str.orno =  convert.number ( bcckon.sma.order, tssma124.orno )  
 	 	 var.lng.acln =  10  
 	 else  
 	 	 var.str.orno =  empty.string ( 1;9 )  
 	 	 var.lng.acln =  0  
 	 endif  
 	 dump 1  
 	 var.str.prev.ccfg =  var.str.ccfg  
 	 var.str.prev.crac =  var.str.crac
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:spc
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:124
:ICOD:S
:QURY:START
select 	 tssma124.*  ,tssma120.desc
from 	 tssma124, tssma120
where 	 tssma124.cjob refers to tssma120 unref clear  
 and 	 tssma124.tadv <>  tssma.tadv.cancel
order by tssma124.cloc, tssma124.cjob
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:ts
:TCMOD:spc
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:124
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:ina
:TFLNO:000
:SCPAC:td
:SCMOD:inv
:SFLNO:000
:ICOD:D
:QURY:START
	 var.whina000.indt =  utc(0,0)  
 	 var.whina000.dsca =  form.text$("bcstc00035") 	 | *  Actual Set  
 	 if tdinv000.tpop =  tcyesno.yes then  
 	 	 var.whina000.ohfs =  tdinv000.tmff  
 	 	 var.whina000.ohcs =  tdinv000.tmfc  
 	 else  
 	 	 var.whina000.ohfs =  0.0  
 	 	 var.whina000.ohcs =  0.0  
 	 endif  
 	 Dump 1  
 	 var.whina000.indt =  utc(date.num(), time.num())  
 	 var.whina000.dsca =  form.text$("bcstc00036") 	 | *  Converted from BaanIVc4  
 	 Dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:ina
:TFLNO:000
:SCPAC:td
:SCMOD:inv
:SFLNO:000
:ICOD:S
:QURY:START
select 	 tdinv000.*
from 	 tdinv000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:ina
:TFLNO:000
:SCPAC:td
:SCMOD:inv
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:ina
:TFLNO:100
:SCPAC:tc
:SCMOD:mcs
:SFLNO:023
:ICOD:D
:QURY:START
	 for i =  1 to no.of.enterprise.units  
 	 	 var.whina100.wvgr =  enterprise.units(1,i)  
 	 	 dump 1  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:ina
:TFLNO:100
:SCPAC:tc
:SCMOD:mcs
:SFLNO:023
:ICOD:S
:QURY:START
select tcmcs023.*
from tcmcs023
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:ina
:TFLNO:100
:SCPAC:tc
:SCMOD:mcs
:SFLNO:023
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:000
:SCPAC:td
:SCMOD:ilc
:SFLNO:000
:ICOD:D
:QURY:START
	 if tdilc000.iilc =  tcyesno.yes then  
 	 	 var.whinh000.bcyc =  tdilc000.take  
 	 else  
 	 	 var.whinh000.bcyc =  var.tdinv000.wist  
 	 endif  
 	  
 	 var.whinh000.indt =  utc(0,0)  
 	 var.whinh000.dsca =  form.text$("bcstc00035") 	 | *  Actual Set  
 	 Dump 1  
 	 var.whinh000.indt =  utc(date.num(), time.num())  
 	 var.whinh000.dsca =  form.text$("bcstc00036") 	 | *  Converted from BaanIVc4  
 	 Dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:000
:SCPAC:td
:SCMOD:ilc
:SFLNO:000
:ICOD:S
:QURY:START
select 	 tdilc000.rdbo, tdilc000.rdbi, tdilc000.take, tdilc000.iilc
from 	 tdilc000  
 as set with 1 rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:000
:SCPAC:td
:SCMOD:ilc
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:010
:SCPAC:bc
:SCMOD:swh
:SFLNO:003
:ICOD:D
:QURY:START
	 on case bcswh003.osrc  
 	 case bcosrc.pur:  
 	 	 if not isspace(bcswh003.rcpr) then  
 	 	 	 var.whinh010.ittp =  1  
 	 	 else  
 	 	 	 if not isspace(bcswh003.obpr) then  
 	 	 	 	 var.whinh010.ittp =  2  
 	 	 	 endif  
 	 	 endif  
 	 	 break  
 	 case bcosrc.sls:  
 	 	 if not isspace(bcswh003.obpr) then  
 	 	 	 var.whinh010.ittp =  2  
 	 	 else  
 	 	 	 if not isspace(bcswh003.rcpr) then  
 	 	 	 	 var.whinh010.ittp =  1  
 	 	 	 endif  
 	 	 endif  
 	 	 break  
 	 case bcosrc.rpl:  
 	 	 if bcswh003.wtrn =  tcyesno.yes then  
 	 	 	 var.whinh010.ittp =  5  
 	 	 else  
 	 	 	 var.whinh010.ittp =  3  
 	 	 endif  
 	 	 break  
 	 endcase  
 	 if isspace(bcswh003.rcpr) then  
 	 	 var.whinh010.rlpr =  ""                      
 	 else  
 	 	 get.procedure(bcswh003.rcpr, err.mess)  
 	 	 var.whinh010.rlpr =  bcswh002.nprc  
 	 endif  
 	 if isspace(bcswh003.inpr) then  
 	 	 var.whinh010.rapr =  ""                      
 	 else  
 	 	 get.procedure(bcswh003.inpr, err.mess)  
 	 	 var.whinh010.rapr =  bcswh002.nprc  
 	 endif  
 	 if isspace(bcswh003.obpr) then  
 	 	 var.whinh010.iapr =  ""                      
 	 else  
 	 	 get.procedure(bcswh003.obpr, err.mess)  
 	 	 var.whinh010.iapr =  bcswh002.nprc  
 	 endif  
 	 if isspace(bcswh003.shpr) then  
 	 	 var.whinh010.ispr =  ""                      
 	 else  
 	 	 get.procedure(bcswh003.shpr, err.mess)  
 	 	 var.whinh010.ispr =  bcswh002.nprc  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:010
:SCPAC:bc
:SCMOD:swh
:SFLNO:003
:ICOD:S
:QURY:START
select 	 bcswh003.*
from 	 bcswh003
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:010
:SCPAC:bc
:SCMOD:swh
:SFLNO:003
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:300
:SCPAC:td
:SCMOD:pur
:SFLNO:400
:ICOD:D
:QURY:START
	 | *  The shipping advice is removed at the moment it is received.  
 	 if tdpur400.suno <>  hold.suno or  
 	 tdpur400.dino <>  hold.dino then  
 	 	 hold.suno =  tdpur400.suno  
 	 	 hold.dino =  tdpur400.dino  
 	 	 if not get.business.partner( 	 tdpur400.suno,  
 	 	 	 	 	 	 bcstc.orgn.suno,  
 	 	 	 	 	 	 o.mess) then  
 	 	 	 var.whinh300.sfbp =  bcstc008.bpid  
 	 	 endif  
 	 	 | *  Get warehouse from the Purchase Order.  
 	 	 select tdpur041.cwar:var.whinh300.cwar  
 	 	 from 	 tdpur041  
 	 	 where 	 tdpur041._index1 =  {:tdpur400.orno,:tdpur400.pono}  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 endselect  
 	 	 if var.whinh300.cwar =  "" then                        
 	 	 	 | *  When warehouse is not filled, then the delivery address  
 	 	 	 | *  should be filled.  
 	 	 	 if var.whinh300.cwar =  "" then                        
 	 	 	 	 temp.key(1;6) =  edit$(tdpur400.orno,"999999")  
 	 	 	 	 temp.key(7;4) =  ""                  | *                                                     Position.                        
 	 	 	 	 temp.key(11;2) =  ""                | *                                                     Delivery Address.                        
 	 	 	 	 if get.addresses( 	 "tdpur042",                        
 	 	 	 	 	 	 	 temp.key,  
 	 	 	 	 	 	 	 o.mess) =  0 then  
 	 	 	 	 	 var.whinh300.dadd =  bcstc004.cadr  
 	 	 	 	 else  
 	 	 	 	 	 var.whinh300.dadd =  empty()  
 	 	 	 	 endif  
 	 	 	 endif  
 	 	 endif  
 	 	 shipment.counter =  shipment.counter +  1  
 	 	 var.whinh300.shid(1;3) =  bcswh000.insh  
 	 	 var.whinh300.shid(4;6) =  edit$(shipment.counter, "999999")                        
 	 	 dump 300 | *  ASN Header  
 	 	 dump 302 | *  ASN References  
 	 	 var.whinh301.shsq =  0  
 	 endif  
 	 | *  Get data from the Purchase Order Line.  
 	 select tdpur041.item,  
 	 	 tdpur041.cprj,  
 	 	 tdpur041.cuqp,  
 	 	 tdpur045._index1  
 	 from 	 tdpur041, tdpur045  
 	 where 	 tdpur045._index1 =  { 	 :tdpur400.orno,  
 	 	 	 	 	 :tdpur400.pono}  
 	 order by tdpur045._index1 desc  
 	 as set with 1 rows  
 	 selectdo  
 	 	 var.whinh301.wsqn =  get.pur.order.line.sequence.number(tdpur045.srnb)  
 	 endselect  
 	 | *  The shipping advice is removed at the moment it is  
 	 | *  received, so only create asn -  lines which are not yet  
 	 | *  received.  
 	 var.whinh301.shsq =  var.whinh301.shsq +  10  
 	 g.new.project.code =  get.project(tdpur041.cprj)  
 	 var.whinh301.item =  segment.item.code( 	 tdpur041.item,  
 	 	 	 	 	 	 	 g.new.project.code)  
 	 | *  Retrieve Inventory Unit.  
 	 get.inventory.unit( 	 tdpur041.cprj,  
 	 	 	 	 tdpur041.item,  
 	 	 	 	 inventory.unit)  
 	 | *  Calculate quantities in inventory unit.  
 	 var.whinh301.squa =  to.inv.unit(  
 	 	 	 	 	 tdpur400.diqu,  
 	 	 	 	 	 tdpur041.cprj,  
 	 	 	 	 	 tdpur041.item,  
 	 	 	 	 	 inventory.unit,  
 	 	 	 	 	 tdpur041.cuqp)  
 	 var.whinh301.cuni =  tdpur041.cuqp  
 	 var.whinh301.oorg =  80 | *  Purchase  
 	 dump 301 | *  ASN Line
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:300
:SCPAC:td
:SCMOD:pur
:SFLNO:400
:ICOD:S
:QURY:START
select 	 tdpur400.*
from 	 tdpur400
order by tdpur400._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:300
:SCPAC:td
:SCMOD:pur
:SFLNO:400
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:500
:SCPAC:td
:SCMOD:ilc
:SFLNO:101
:ICOD:D
:QURY:START
	 if not first.record and  
 	 (tdilc101.cwar <>  prev.cwar or  
 	 tdilc101.loca <>  prev.loca or  
 	 tdilc101.cprj <>  prev.cprj or  
 	 tdilc101.item <>  prev.item or  
 	 (tiitm001.kltc <>  tckltc.unit and  
 	 tdilc101.clot <>  prev.clot) or  
 	 (tiitm001.obpr <>  tcobpr.loca and  
 	 tdilc101.date <>  prev.date)) then  
 	 	 fill.var.whinh540.fields()  
 	 	 dump 4  
 	 endif  
 	 prev.cwar =  tdilc101.cwar  
 	 prev.loca =  tdilc101.loca  
 	 prev.item =  tdilc101.item  
 	 prev.cprj =  tdilc101.cprj  
 	 if tiitm001.obpr =  tcobpr.loca then  
 	 	 prev.date =  0  
 	 else  
 	 	 prev.date =  tdilc101.date  
 	 endif  
 	 if tiitm001.kltc =  tckltc.unit then  
 	 	 prev.clot =  ""                                                                                                  
 	 else  
 	 	 prev.clot =  tdilc101.clot  
 	 endif  
 	 prev.coun =  utc(tdilc101.coun,0)  
 	 first.record =  false
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:500
:SCPAC:td
:SCMOD:ilc
:SFLNO:101
:ICOD:F
:QURY:START
	 fill.var.whinh540.fields()  
 	 dump 4
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:500
:SCPAC:td
:SCMOD:ilc
:SFLNO:101
:ICOD:S
:QURY:START
select 	 tdilc101.*  , tiitm001.obpr, tiitm001.kltc, tiitm001.kitm
from 	 tiitm001, tdilc101
where 	 tdilc101.item =  tiitm001.item  
 and 	 tiitm001.kitm in (tckitm.purchase, tckitm.manufacture)  
 and 	 tdilc101.cntr =  ""                                                                                                                                                                                                                                                                                                                                                                                                
 and 	 tdilc101.take =  tcyesno.no  
 and 	 tdilc101.coun <>  0  
 and 	 tdilc101.cwar refers to tcmcs003  
 and 	 tcmcs003.typw <>  tctypw.transito  
 | and 	 tdilc101.loca <>  tcmcs003.arlo 	 	 	 | *  this can go wrong for warehouses not loc.controlled
order by tdilc101._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:500
:SCPAC:td
:SCMOD:ilc
:SFLNO:101
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:500
:SCPAC:td
:SCMOD:ilc
:SFLNO:501
:ICOD:D
:QURY:START
	 if prev.orno <>  tdilc501.orno or  
 	 prev.cwar <>  tdilc501.cwar then  
 	 	 var.whinh500.orno =  get.new.cycle.count.order.number(  
 	 	 	 	 	 	 tdilc501.orno,  
 	 	 	 	 	 	 tdilc501.cwar)  
 	 	 var.whinh500.cwar =  tdilc501.cwar  
 	 	 var.whinh500.odat =  get.minimum.of.ilc.order.dates(  
 	 	 	 	 	 	 tdilc501.orno,  
 	 	 	 	 	 	 tdilc501.cwar)  
 	 	 var.whinh500.prnt =  tdilc501.order.printed(tdilc501.orno, tdilc501.cwar)  
 	 	 dump 1  
 	 endif  
 	 if first.record then  
 	 	 initialize.cc.order.line.values()  
 	 	 first.record =  false  
 	 else  
 	 	 if (tdilc501.orno <>  prev.orno or  
 	 	 tdilc501.cwar <>  prev.cwar or  
 	 	 tdilc501.loca <>  prev.loca or  
 	 	 tdilc501.cprj <>  prev.cprj or  
 	 	 tdilc501.item <>  prev.item or  
 	 	 (tiitm001.kltc <>  tckltc.unit and  
 	 	 tdilc501.clot <>  prev.clot) or  
 	 	 (tiitm001.obpr <>  tcobpr.loca and  
 	 	 tdilc501.date <>  prev.date) or  
 	 	 tdilc501.stun <>  prev.stun) then  
 	 	 	 | *  Stock point changed. Create whinh501 line for previous stockpoint.  
 	 	 	 fill.var.whinh501.fields()  
 	 	 	 dump 2  
 	 	 	 if tdilc501.cwar <>  prev.cwar or  
 	 	 	 tdilc501.loca <>  prev.loca or  
 	 	 	 tdilc501.cprj <>  prev.cprj or  
 	 	 	 tdilc501.item <>  prev.item or  
 	 	 	 (tiitm001.kltc <>  tckltc.unit and  
 	 	 	 tdilc501.clot <>  prev.clot) or  
 	 	 	 (tiitm001.obpr <>  tcobpr.loca and  
 	 	 	 tdilc501.date <>  prev.date) then  
 	 	 	 	 var.whinh540.cwar =  var.whinh501.cwar  
 	 	 	 	 var.whinh540.loca =  var.whinh501.loca  
 	 	 	 	 seg.whinh540.item =  seg.whinh501.item  
 	 	 	 	 seg.whinh540.cprj =  seg.whinh501.cprj  
 	 	 	 	 var.whinh540.clot =  var.whinh501.clot  
 	 	 	 	 var.whinh540.date =  var.whinh501.idat  
 	 	 	 	 var.whinh540.lcdt =  prev.coun  
 	 	 	 	 var.whinh540.orno =  var.whinh501.orno  
 	 	 	 	 if isspace(var.whinh540.orno) then  
 	 	 	 	 	 var.whinh540.cntn =  0  
 	 	 	 	 else  
 	 	 	 	 	 var.whinh540.cntn =  1  
 	 	 	 	 endif  
 	 	 	 	 var.whinh540.pono =  var.whinh501.pono  
 	 	 	 	 dump 4  
 	 	 	 endif  
 	 	 	 initialize.cc.order.line.values()  
 	 	 endif  
 	 endif  
 	 if tiitm001.kltc =  tckltc.unit then  
 	 	 var.whinh506.orno =  var.whinh500.orno  
 	 	 if var.whinh501.pono =  0 then  
 	 	 	 var.whinh501.pono =  tdilc501.sern  
 	 	 endif  
 	 	 var.whinh506.serl =  tdilc501.clot  
 	 	 var.whinh506.qstp =  tdilc501.qstk  
 	 	 var.whinh506.qcnt =  tdilc501.cstk  
 	 	 	 	 	 	 	 	 | #  SP2.sn  
 	 	 var.whinh506.dssq =  var.whinh506.dssq +  1  
 	 	 var.whinh506.cser =  tdilc501.clot  
 	 	 var.whinh506.clot =  ""            
 	 	 var.whinh506.qvrc =  var.whinh506.qcnt -  var.whinh506.qstp  
 	 	 var.whinh506.stun =  tiitm001.cuni  
 	 	 	 	 	 	 	 	 | #  SP2.en  
 	 	 var.whinh506.stat =  1 	 | *  Initial 	 	 | #  FP3.n  
 	 	 dump 3  
 	 endif  
 	 cumulative.qstp =  cumulative.qstp +  tdilc501.qstk  
 	 cumulative.qstr =  cumulative.qstr +  tdilc501.qstr  
 	 cumulative.qcnt =  cumulative.qcnt +  tdilc501.cstk  
 	 cumulative.qcnr =  cumulative.qcnr +  tdilc501.cstr  
 	 if tdilc501.csts =  tcyesno.no then  
 	 	 cc.order.line.counted =  tcyesno.no  
 	 endif  
 	 prev.orno =  tdilc501.orno  
 	 prev.pono =  tdilc501.sern  
 	 prev.cwar =  tdilc501.cwar  
 	 if tdilc501.data =  tdilc501.coun then  
 	 	 prev.coun =  utc(tdilc501.data,tdilc501.tima)  
 	 else  
 	 	 prev.coun =  utc(tdilc501.coun,0)  
 	 endif 	 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:500
:SCPAC:td
:SCMOD:ilc
:SFLNO:501
:ICOD:F
:QURY:START
	 fill.var.whinh501.fields()  
 	 dump 2  
 	 var.whinh540.cwar =  var.whinh501.cwar  
 	 var.whinh540.loca =  var.whinh501.loca  
 	 seg.whinh540.item =  seg.whinh501.item  
 	 seg.whinh540.cprj =  seg.whinh501.cprj  
 	 var.whinh540.clot =  var.whinh501.clot  
 	 var.whinh540.date =  var.whinh501.idat  
 	 var.whinh540.lcdt =  prev.coun  
 	 var.whinh540.orno =  var.whinh501.orno  
 	 if isspace(var.whinh540.orno) then  
 	 	 var.whinh540.cntn =  0  
 	 else  
 	 	 var.whinh540.cntn =  1  
 	 endif  
 	 var.whinh540.pono =  var.whinh501.pono  
 	 dump 4
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:500
:SCPAC:td
:SCMOD:ilc
:SFLNO:501
:ICOD:S
:QURY:START
select 	 tdilc501.*  , tiitm001.kltc, tiitm001.obpr, tiitm001.kitm,  
 	 tiitm001.cuni 	 	 	 	 	 	 | #  SP2.n
from 	 tiitm001, tdilc501
where 	 tdilc501.item =  tiitm001.item  
 and 	 tiitm001.kitm in (tckitm.purchase, tckitm.manufacture)  
 and 	 tdilc501.cntr =  ""                                                                                                                                                                                   
 and 	 tdilc501.cwar refers to tcmcs003  
 and 	 tcmcs003.typw <>  tctypw.transito
order by tdilc501._index2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:500
:SCPAC:td
:SCMOD:ilc
:SFLNO:501
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:500
:SCPAC:td
:SCMOD:inv
:SFLNO:001
:ICOD:D
:QURY:START
	 var.whinh540.cwar =  tdinv001.cwar  
 	 var.whinh540.loca =  ""                                                                                                                                                                                                                                                                                                                                                                                                      
 	 seg.whinh540.item =  tdinv001.item  
 	 seg.whinh540.cprj =  ""                                                                                                                                                                                                                                                                                                                                                                                                      
 	 var.whinh540.clot =  ""                                                                                                                                                                                                                                                                                                                                                                                                      
 	 var.whinh540.date =  0  
 	 var.whinh540.lcdt =  utc(tdinv001.lcod,0)  
 	 var.whinh540.orno =  ""                                                                                                                                                                                                                                                                                                                                                                                                      
 	 var.whinh540.pono =  0  
 	 var.whinh540.cntn =  0  
 	 dump 4
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:500
:SCPAC:td
:SCMOD:inv
:SFLNO:001
:ICOD:S
:QURY:START
select 	 tdinv001.*  , tiitm001.kitm
from 	 tiitm001, tdinv001
where 	 tdinv001.item =  tiitm001.item  
 and 	 tiitm001.kitm in (tckitm.purchase, tckitm.manufacture)  
 and 	 tdinv001.cntr =  ""                                                                                                                                                                                                                                                                                                                                                                                                      
 and 	 tdinv001.lcod <>  0  
 and 	 tdinv001.wist =  tcyesno.no  
 and 	 tdinv001.cwar refers to tcmcs003  
 and 	 tcmcs003.typw <>  tctypw.transito
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:500
:SCPAC:td
:SCMOD:inv
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:500
:SCPAC:td
:SCMOD:inv
:SFLNO:120
:ICOD:D
:QURY:START
	 if prev.orno <>  tdinv120.orno or  
 	 prev.cwar <>  tdinv120.cwar then  
 	 	 var.whinh500.orno =  get.new.cycle.count.order.number(  
 	 	 	 	 	 	 tdinv120.orno,  
 	 	 	 	 	 	 tdinv120.cwar)  
 	 	 var.whinh500.cwar =  tdinv120.cwar  
 	 	 order.date =  get.minimum.of.count.dates(  
 	 	 	 	 	 tdinv120.orno,  
 	 	 	 	 	 tdinv120.cwar)  
 	 	 var.whinh500.odat =  utc(order.date, 0)  
 	 	 var.whinh500.prnt =  tdinv120.order.printed(tdinv120.orno, tdinv120.cwar)  
 	 	 dump 1  
 	 	 prev.orno =  tdinv120.orno  
 	 	 prev.cwar =  tdinv120.cwar  
 	 endif  
 	 var.whinh501.orno =  var.whinh500.orno  
 	 var.whinh501.pono =  tdinv120.sern  
 	 var.whinh501.cwar =  tdinv120.cwar  
 	 var.whinh501.loca =  ""                                                                                                                                                                                                                                                                                                                                                                                                              
 	 seg.whinh501.item =  tdinv120.item  
 	 seg.whinh501.cprj =  ""                                                                                                                                                                                                                                                                                                                                                                                                              
 	 var.whinh501.clot =  ""                                                                                                                                                                                                                                                                                                                                                                                                              
 	 var.whinh501.idat =  0  
 	  
 	 var.whinh501.qstp =  tdinv120.stoc  
 	 var.whinh501.qstr =  tdinv120.stoc  
 	 var.whinh501.qcnt =  tdinv120.cstc  
 	 var.whinh501.qcnr =  tdinv120.cstc  
 	 var.whinh501.qvrc =  tdinv120.cstc -  tdinv120.stoc  
 	 var.whinh501.qvrr =  tdinv120.cstc -  tdinv120.stoc  
 	 var.whinh501.csts =  tdinv120.csts  
 	 var.whinh501.cdat =  utc(tdinv120.cdat,0)  
 	 dump 2  
 	 var.whinh540.cwar =  tdinv120.cwar  
 	 var.whinh540.loca =  ""                                                                                                                                                                                                                                                                                                                                                                                                        
 	 seg.whinh540.item =  tdinv120.item  
 	 seg.whinh540.cprj =  ""                                                                                                                                                                                                                                                                                                                                                                                                        
 	 var.whinh540.clot =  ""                                                                                                                                                                                                                                                                                                                                                                                                        
 	 var.whinh540.lcdt =  ""                                                    
 	 select 	 tdinv001.lcod  
 	 from 	 tdinv001  
 	 where 	 tdinv001._index1 =  {:tdinv120.cwar, :tdinv120.item}  
 	 and 	 tdinv001.cntr =  ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                
 	 as set with 1 rows  
 	 selectdo  
 	 	 var.whinh540.lcdt =  utc(tdinv001.lcod,0)  
 	 endselect  
 	 var.whinh540.orno =  var.whinh501.orno  
 	 var.whinh540.pono =  var.whinh501.pono  
 	 if isspace(var.whinh540.orno) then  
 	 	 var.whinh540.cntn =  0  
 	 else  
 	 	 var.whinh540.cntn =  1  
 	 endif  
 	 dump 4
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:500
:SCPAC:td
:SCMOD:inv
:SFLNO:120
:ICOD:S
:QURY:START
select 	 tdinv120.*  , tiitm001.kitm,  
 	 tiitm001.cuni:var.whinh501.stun
from 	 tiitm001, tdinv120
where 	 tdinv120.item =  tiitm001.item  
 and 	 tiitm001.kitm in (tckitm.purchase, tckitm.manufacture)  
 and 	 tdinv120.cntr =  ""                                                                                                                                                                                                            
 and 	 tdinv120.cwar refers to tcmcs003  
 and 	 tcmcs003.typw <>  tctypw.transito
order by tdinv120.cwar
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:500
:SCPAC:td
:SCMOD:inv
:SFLNO:120
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:520
:SCPAC:td
:SCMOD:inv
:SFLNO:100
:ICOD:D
:QURY:START
	 if tdinv100.wrho <>  prev.wrho then  
 	 	 if isspace(tdinv100.recd) then  
 	 	 	 var.whinh520.adrn =  bcswh000.daor  
 	 	 else  
 	 	 	 get.reason.for.rejection(  
 	 	 	 	 bcreje.tdinv105,  
 	 	 	 	 tdinv100.recd,  
 	 	 	 	 errmess)  
 	 	 	 var.whinh520.adrn =  bcstc017.newr  
 	 	 endif  
 	 	 	 	 	 	 	 	 | #  146552.sn  
 	 	 if tdinv100.odat =  0 then  
 	 	 	 tdinv100.odat =  date.num()  
 	 	 endif  
 	 	 	 	 	 	 	 	 | #  146552.en  
 	 	 dump 1  
 	 	 prev.wrho =  tdinv100.wrho  
 	 	 var.whinh521.pono =  0  
 	 endif  
 	 if tdilc000.iilc =  tcyesno.no then  
 	 	 var.whinh521.pono =  var.whinh521.pono +  10  
 	 	 select tiitm001.cuni:var.whinh521.stun  
 	 	 from 	 tiitm001  
 	 	 where 	 tiitm001._index1 =  {:tdinv100.item}  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 endselect  
 	 	 var.whinh521.qstp =  determine.stock.point.quantity(  
 	 	 	 	 	 	 	 tdinv100.cprj,  
 	 	 	 	 	 	 	 tdinv100.wrho)  
 	 	 var.whinh521.qstr =  var.whinh521.qstp  
 	 	 var.whinh521.qadj =  var.whinh521.qstp +  tdinv100.dqan  
 	 	 var.whinh521.qadr =  var.whinh521.qstr +  tdinv100.dqan  
 	 	 dump 2  
 	 else  
 	 	 select tdilc102.*   
 	 	 from 	 tdilc102  
 	 	 where 	 tdilc102._index1 =  { 	 :tdinv100.cprj,  
 	 	 	 	 	 	 :tdinv100.item,  
 	 	 	 	 	 	 "",                                                                                                                                                          
 	 	 	 	 	 	 :tdinv100.cwar,  
 	 	 	 	 	 	 :tdinv100.idat,  
 	 	 	 	 	 	 :tdinv100.sern}  
 	 	 selectdo  
 	 	 	 var.whinh521.pono =  var.whinh521.pono +  10  
 	 	 	 var.whinh521.loca =  tdilc102.loca  
 	 	 	 if tiitm001.kltc <>  tckltc.unit then  
 	 	 	 	 var.whinh521.clot =  tdilc102.clot  
 	 	 	 else  
 	 	 	 	 var.whinh521.clot =  empty()  
 	 	 	 endif  
 	 	 	 var.whinh521.date =  tdilc102.date  
 	 	 	 var.whinh521.stun =  tdilc102.stun  
 	 	 	 if tdilc102.qstk <  0.0 then  
 	 	 	 	 var.whinh521.qstp =  tdilc102.qstk * -  1  
 	 	 	 	 var.whinh521.qadj =  0.0  
 	 	 	 else  
 	 	 	 	 var.whinh521.qstp =  0.0  
 	 	 	 	 var.whinh521.qadj =  tdilc102.qstk  
 	 	 	 endif  
 	 	 	 var.whinh521.qvrc =  tdilc102.qstk  
 	 	 	 if tdilc102.qstr <  0.0 then  
 	 	 	 	 var.whinh521.qstr =  tdilc102.qstr * -  1  
 	 	 	 	 var.whinh521.qadr =  0.0  
 	 	 	 else  
 	 	 	 	 var.whinh521.qstr =  0.0  
 	 	 	 	 var.whinh521.qadr =  tdilc102.qstr  
 	 	 	 endif  
 	 	 	 var.whinh521.qvrr =  tdilc102.qstr  
 	 	 	 dump 3  
 	 	 	 if tiitm001.kltc =  tckltc.unit and  
 	 	 	 not isspace(tdilc102.clot) then  
 	 	 	 	 	 	 	 	 | #  SP2.sn  
 	 	 	 	 var.whinh526.dssq =  1  
 	 	 	 	 var.whinh526.cser =  tdilc102.clot  
 	 	 	 	 var.whinh526.clot =  empty()  
 	 	 	 	 var.whinh526.qvrc =  var.whinh521.qvrr  
 	 	 	 	 var.whinh526.stun =  tiitm001.cuni  
 	 	 	 	 	 	 	 	 | #  SP2.en  
 	 	 	 	 dump 4  
 	 	 	 endif  
 	 	 endselect  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:520
:SCPAC:td
:SCMOD:inv
:SFLNO:100
:ICOD:S
:QURY:START
select 	 tdinv100.*  , tiitm001.kltc,  
 	 tiitm001.cuni 	 	 	 	 	 	 | #  SP2.n
from 	 tdinv100, tiitm001
where 	 tdinv100.kowt =  tckowt.stc.correction  
 and 	 tdinv100.wtst =  tcwtst.closed  
 and 	 tdinv100.cntr =  ""                                                                                                                                                          
 and 	 tdinv100.item refers to tiitm001
order by tdinv100._index2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inh
:TFLNO:520
:SCPAC:td
:SCMOD:inv
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inp
:TFLNO:100
:SCPAC:td
:SCMOD:inv
:SFLNO:150
:ICOD:D
:QURY:START
	 if not (  
 	 	 tdinv150.koor =  tckoor.act.sfc or  
 	 	 tdinv150.koor =  tckoor.act.pur or  
 	 	 tdinv150.koor =  tckoor.act.sls or  
 	 	 tdinv150.koor =  tckoor.pcs.wrh or  
 	 	 tdinv150.koor =  tckoor.sls.quot or  
 	 	 tdinv150.koor =  tckoor.wrh.order or  
 	 	 tdinv150.koor =  tckoor.sma.order or  
 	 	 tdinv150.koor =  tckoor.pss.wrh or  
 	 	 tdinv150.koor =  tckoor.act.rpl or  
 	 	 tdinv150.koor =  tckoor.ti.wrh) then  
 	 	 continue  
 	 endif  
 	 if tdinv150.qana <  0 then  
 	 	 tdinv150.qana = -  tdinv150.qana  
 	 	 if tdinv150.kotr =  tckotr.requirement then  
 	 	 	 tdinv150.kotr =  tckotr.receipt  
 	 	 else  
 	 	 	 tdinv150.kotr =  tckotr.requirement  
 	 	 endif  
 	 endif  
 	 var.whinp100.bpid =  ""                                                                                                                              
 	 get.business.partner.due.to.kind.of.order(  
 	 	 	 tdinv150.koor,  
 	 	 	 tdinv150.orno,  
 	 	 	 tdinv150.pono)  
 	 var.whinp100.pono =  tdinv150.pono 	 	 	 | #  200 -  101937.n  
 	 advice =  false  
 	 on case tdinv150.koor  
 	 case tckoor.act.rpl:  
 	 	 var.whinp100.boml =  empty()  
 	 	 var.whinp100.ponb =  tdinv150.ponb  
 	 	 select 	 tdrpl100._index1  
 	 	 from 	 tdrpl100  
 	 	 where 	 tdrpl100._index1 =  {:tdinv150.orno, :tdinv150.pono}  
 	 	 order by tdrpl100._index1 desc  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 var.whinp100.ponb =  tdrpl100.srnb  
 	 	 endselect  
 	 	 break  
 	 case tckoor.wrh.order:  
 	 	 var.whinp100.boml =  empty()  
 	 	 var.whinp100.ponb =  1  
 	 	 var.whinp100.pono =  determine.new.pono(tdinv150.orno) | #  200 -  101937.n  
 	 	 break  
 	 case tckoor.act.pur:  
 	 	 var.whinp100.boml =  tdinv150.ponb  
 	 	 var.whinp100.ponb =  0  
 	 	 select 	 tdpur045._index1, tdpur045.date, tcmcs042.coun  
 	 	 from 	 tdpur045, tdpur040, tcmcs042  
 	 	 where 	 tdpur045._index1 =  {:tdinv150.orno, :tdinv150.pono}  
 	 	 and 	 tdpur040.orno =  tdpur045.orno  
 	 	 and 	 tcmcs042.cotp =  tdpur040.cotp  
 	 	 order by tdpur045._index1 desc  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 var.whinp100.ponb =  get.pur.order.line.sequence.number(  
 	 	 	 	 	 	 	 tdpur045.srnb)  
 	 	 	 if tdpur045.date =  0 and  
 	 	 	 tcmcs042.coun =  tcyesno.yes then  
 	 	 	 	 advice =  true  
 	 	 	 endif  
 	 	 endselect  
 	 	 break  
 	 case tckoor.act.sls:  
 	 	 var.whinp100.boml =  tdinv150.ponb  
 	 	 var.whinp100.ponb =  0  
 | 	 	 select 	 tdsls045._index1  
 | 	 	 from 	 tdsls045  
 | 	 	 where 	 tdsls045._index1 =  {:tdinv150.orno, :tdinv150.pono}  
 | 	 	 order by tdsls045._index1 desc  
 | 	 	 as set with 1 rows  
 | 	 	 selectdo  
 | 	 	 	 var.whinp100.ponb =  get.sls.order.line.sequence.number(  
 | 	 	 	 	 	 	 	 tdinv150.orno,  
 | 	 	 	 	 	 	 	 tdinv150.pono,  
 | 	 	 	 	 	 	 	 tdsls045.srnb)  
 | 	 	 endselect  
 	 	 break 	 	 	 	 	 	 | #  800 -  143244.n  
 	 	 	 	 	 	 	 	 | #  200 -  101937.sn  
 	 case tckoor.pcs.wrh:  
 	 	 var.whinp100.boml =  0  
 	 	 var.whinp100.pono =  10  
 	 	 var.whinp100.ponb =  1  
 	 	 	 	 	 	 	 	 | #  200 -  101937.en  
 	 	 break  
 	 default:  
 	 	 var.whinp100.boml =  tdinv150.ponb  
 	 	 var.whinp100.ponb =  empty()  
 	 	 break  
 	 endcase  
 	 	 	 	 	 	 	 	 | #  200 -  101937.so  
 | 	 if tdinv150.koor =  tckoor.wrh.order then  
 | 	 	 var.whinp100.pono =  determine.new.pono(tdinv150.orno)  
 | 	 else  
 | 	 	 var.whinp100.pono =  tdinv150.pono  
 | 	 endif  
 	 	 	 	 	 	 	 	 | #  200 -  101937.eo  
 	 if advice then  
 	 	 var.whinp100.koor =  8 	 | *  purchase order advice  
 	 else  
 	 	 var.whinp100.koor =  convert.tckoor(tdinv150.koor, tdinv150.orno)  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inp
:TFLNO:100
:SCPAC:td
:SCMOD:inv
:SFLNO:150
:ICOD:S
:QURY:START
select 	 tdinv150.*  , tiitm001.cuni, tcmcs003.typw
from 	 tdinv150, tiitm001, tcmcs003
where 	 tdinv150.cntr =  ""                                                                                                                                              
 and 	 tiitm001.item =  tdinv150.item  
 and 	 tcmcs003.cwar =  tdinv150.cwar  
 and 	 tcmcs003.typw <>  tctypw.transito
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inp
:TFLNO:100
:SCPAC:td
:SCMOD:inv
:SFLNO:150
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inp
:TFLNO:100
:SCPAC:ti
:SCMOD:pcs
:SFLNO:500
:ICOD:D
:QURY:START
	 if not (  
 	 	 tipcs500.koor =  tckoor.act.sfc or  
 	 	 tipcs500.koor =  tckoor.act.pur or  
 	 	 tipcs500.koor =  tckoor.act.sls or  
 	 	 tipcs500.koor =  tckoor.pcs.wrh or  
 	 	 tipcs500.koor =  tckoor.sls.quot or  
 	 	 tipcs500.koor =  tckoor.wrh.order or  
 	 	 tipcs500.koor =  tckoor.sma.order or  
 	 	 tipcs500.koor =  tckoor.pss.wrh or  
 	 	 tipcs500.koor =  tckoor.act.rpl or  
 	 	 tipcs500.koor =  tckoor.ti.wrh) then  
 	 	 continue  
 	 endif  
 	 if tipcs500.qana <  0 then  
 	 	 tipcs500.qana = -  tipcs500.qana  
 	 	 if tipcs500.kotr =  tckotr.requirement then  
 	 	 	 tipcs500.kotr =  tckotr.receipt  
 	 	 else  
 	 	 	 tipcs500.kotr =  tckotr.requirement  
 	 	 endif  
 	 endif  
 	 var.whinp100.bpid =  ""                                                                                                                                      
 	 get.business.partner.due.to.kind.of.order(  
 	 	 	 tipcs500.koor,  
 	 	 	 tipcs500.orno,  
 	 	 	 tipcs500.pono)  
 	 var.whinp100.ponb =  tipcs500.sern  
 	 advice =  false  
 	 on case tipcs500.koor  
 	 case tckoor.act.pur:  
 	 	 select 	 tdpur045._index1, tdpur045.date, tcmcs042.coun  
 	 	 from 	 tdpur045, tdpur040, tcmcs042  
 	 	 where 	 tdpur045._index1 =  {:tipcs500.orno, :tipcs500.pono}  
 	 	 and 	 tdpur040.orno =  tdpur045.orno  
 	 	 and 	 tcmcs042.cotp =  tdpur040.cotp  
 	 	 order by tdpur045._index1 desc  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 var.whinp100.ponb =  get.pur.order.line.sequence.number(  
 	 	 	 	 	 	 	 tdpur045.srnb)  
 	 	 	 if tdpur045.date =  0 and  
 	 	 	 tcmcs042.coun =  tcyesno.yes then  
 	 	 	 	 advice =  true  
 	 	 	 endif  
 	 	 endselect  
 	 	 break  
 	 case tckoor.act.sls:  
 | 	 	 select 	 tdsls045._index1  
 | 	 	 from 	 tdsls045  
 | 	 	 where 	 tdsls045._index1 =  {:tipcs500.orno, :tipcs500.pono}  
 | 	 	 order by tdsls045._index1 desc  
 | 	 	 as set with 1 rows  
 | 	 	 selectdo  
 | 	 	 	 var.whinp100.ponb =  get.sls.order.line.sequence.number(  
 | 	 	 	 	 	 	 	 tipcs500.orno,  
 | 	 	 	 	 	 	 	 tipcs500.pono,  
 | 	 	 	 	 	 	 	 tdsls045.srnb)  
 | 	 	 endselect  
 	 	 break  
 	 	 	 	 	 	 	 	 	 | #  200 -  101937.sn  
 	 case tckoor.pcs.wrh:  
 	 	 tipcs500.pono =  10  
 	 	 var.whinp100.ponb =  1  
 	 	 break  
 	 	 	 	 	 	 	 	 	 | #  200 -  101937.en  
 	 endcase  
 	 if advice then  
 	 	 var.whinp100.koor =  8 	 | *  purchase order advice  
 	 else  
 	 	 var.whinp100.koor =  convert.tckoor(tipcs500.koor, tipcs500.orno)  
 	 endif  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inp
:TFLNO:100
:SCPAC:ti
:SCMOD:pcs
:SFLNO:500
:ICOD:S
:QURY:START
select 	 tipcs500.*  , tipcs021.cuni, tipcs021.cwar, tcmcs003.typw
from 	 tipcs500, tipcs021, tcmcs003
where 	 tipcs021._index1 =  {tipcs500.cprj, tipcs500.item}  
 and 	 tcmcs003.cwar =  tipcs021.cwar
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inp
:TFLNO:100
:SCPAC:ti
:SCMOD:pcs
:SFLNO:500
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inr
:TFLNO:100
:SCPAC:td
:SCMOD:ilc
:SFLNO:301
:ICOD:D
:QURY:START
	 | *  Fill Lot and Serial  
 	 var.whinr100.clot =  empty()  
 	 var.whinr100.serl =  empty()  
 	 lot.applicable =  false 	 	 	 	 | #  205264.sn  
 	 if not (hold.cprj =  tdilc301.cprj and  
 	 	 hold.item =  tdilc301.item) then  
 	 	 max.sern =  0  
 	 endif 	 	 	 	 	 	 	 | #  205264.en  
 	 if not isspace(tdilc301.clot) then  
 	 	 if lot.controlled.item(  
 	 	 	 	 tdilc301.cprj,  
 	 	 	 	 tdilc301.item) then  
 	 	 	 var.whinr100.clot =  tdilc301.clot  
 	 	 	 lot.applicable =  true  
 	 	 else  
 	 	 	 if serialized.item(  
 	 	 	 	 tdilc301.cprj,  
 	 	 	 	 tdilc301.item) then  
 	 	 	 	 var.whinr100.serl =  tdilc301.clot  
 	 	 	 	 lot.applicable =  true  
 	 	 	 endif  
 	 	 endif  
 	 endif  
 	 	 	 	 	 	 	 	 | #  205264.sn  
 	 if not lot.applicable and not isspace(tdilc301.clot) then  
 	 	 var.whinr100.seqn =  max.sern +  1  
 	 	 tdilc301.clot =  ""                    
 	 else 	 	 	 	 	 	 	 | #  205264.en  
 	 	 | *  Fill sequence for the uniqueness  
 	 	 if (hold.cprj =  tdilc301.cprj and  
 	 	 hold.item =  tdilc301.item and  
 	 	 (not lot.applicable or  
 	 	 hold.clot =  tdilc301.clot) and  
 	 	 hold.date =  tdilc301.date and  
 	 	 hold.cwar =  tdilc301.cwar and  
 	 	 hold.loca =  tdilc301.loca and  
 	 	 hold.trdt =  tdilc301.trdt and  
 	 	 hold.trtm =  tdilc301.trtm) then  
 	 	 	 var.whinr100.seqn =  var.whinr100.seqn +  1  
 	 	 else  
 	 	 	 var.whinr100.seqn =  tdilc301.sern +  1  
 	 	 endif  
 	 endif 	 	 	 	 	 	 	 | #  205264.n  
 	  
 	 if max.sern <  var.whinr100.seqn then 	 	 	 | #  205264.sn  
 	 	 max.sern =  var.whinr100.seqn  
 	 endif 	 	 	 	 	 	 	 | #  205264.en  
 	 var.whinr100.bpid =  empty()  
 	 get.business.partner.due.to.kind.of.order(  
 	 	 	 tdilc301.rlcd,  
 	 	 	 tdilc301.koor)  
 	 if tdilc301.prnt <>  empty then  
 	 	 var.whinr100.prnt =  tdilc301.prnt  
 	 else  
 	 	 var.whinr100.prnt =  tcyesno.no  
 	 endif  
 	 var.whinr100.qstk =  tdilc301.qstk  
 	 if (tdilc301.koor =  tckoor.act.sls or tdilc301.koor =  tckoor.sma.order) and 	 | #  205835.n  
 	 tdilc301.kost =  tckost.stc.transfer and tdilc301.qstk >  0 then 	 	 | #  205835.n  
 	 	 var.whinr100.kost =  5 	 |issue 	 	 	 	 	 	 | #  205835.n  
 	 else 	 	 	 	 	 	 	 	 	 	 | #  205835.n  
 	 	 var.whinr100.kost =  convert.tckost(tdilc301.kost, tdilc301.qstk)  
 	 endif 	 	 	 	 	 	 	 	 	 	 | #  205835.n  
 	 var.whinr100.pono =  tdilc301.pono  
 	 on case tdilc301.koor  
 	 case tckoor.wrh.order :  
 	 	 if tdilc301.kost <>  tckost.stc.correction then  
 	 	 	 var.whinr100.qstk =  abs(tdilc301.qstk)  
 	 	 else  
 	 	 	 var.whinr100.pono =  determine.new.pono(tdilc301.orno)  
 	 	 endif  
 	 	 break  
 	 case tckoor.act.rpl :  
 	 case tckoor.pcs.wrh :  
 	 	 if tdilc301.kost =  tckost.stc.transfer then  
 	 	 	 var.whinr100.qstk =  abs(tdilc301.qstk)  
 	 	 else  
 	 	 	 var.whinr100.qstk =  tdilc301.qstk  
 	 	 endif  
 	 	 break  
 	 endcase  
 	 	 	 	 	 	 	 	 | #  200193.sn  
 	 if tdilc301.kost =  tckost.stc.transfer then  
 	 	 | *  var.whinr100.kost is already set in convert.tckost() above  
 	 	 var.whinr100.qstk =  abs(tdilc301.qstk)  
 	 else  
 	 	 	 	 	 	 	 	 | #  200193.en  
 	 if var.whinr100.qstk <  0 then  
 	 	 if var.whinr100.kost =  3 then  
 	 	 	 var.whinr100.kost =  5  
 	 	 	 var.whinr100.qstk =  abs(tdilc301.qstk)  
 	 	 else  
 	 	 	 if var.whinr100.kost =  5 then  
 	 	 	 	 var.whinr100.kost =  3  
 	 	 	 	 var.whinr100.qstk =  abs(tdilc301.qstk)  
 	 	 	 endif  
 	 	 endif  
 	 endif  
 	 endif 	 	 	 	 	 	 	 | #  200193.n  
 	 var.whinr100.koor =  convert.tckoor(tdilc301.koor, tdilc301.orno)  
 	 if var.whinr100.koor =  51 then | cycle count  
 	 	 var.whinr100.orno =  get.new.cycle.count.order.number(  
 	 	 	 	 	 tdilc301.orno, tdilc301.cwar)  
 	 else  
 	 	 var.whinr100.orno =  convert.number(  
 	 	 	 	 	 convert.tckoor.to.bcckon(tdilc301.koor), tdilc301.orno)  
 	 endif  
 	 	 	 	 	 	 	 | #  800 -  142184.sn  
 	 if not (hold.cprj =  tdilc301.cprj and  
 	 	 hold.item =  tdilc301.item and  
 	 	 hold.clot =  tdilc301.clot and  
 	 	 hold.date =  tdilc301.date and  
 	 	 hold.cwar =  tdilc301.cwar and  
 	 	 hold.loca =  tdilc301.loca ) then  
 	 	 var.whinr100.qhnd =  0.0  
 	 endif  
 	 if var.whinr100.kost =  5 then 	 	 | *  5: issue  
 	 	 | *  for an issue, deduct  
 	 	 var.whinr100.qhnd =  var.whinr100.qhnd -  var.whinr100.qstk  
 	 else  
 	 	 | *  for all others, add; qty can be positive or negative  
 	 	 var.whinr100.qhnd =  var.whinr100.qhnd +  var.whinr100.qstk  
 	 endif  
 	 	 	 	 	 	 	 | #  800 -  142184.en  
 	 Dump 1  
 	 hold.trdt =  tdilc301.trdt  
 	 hold.trtm =  tdilc301.trtm  
 	 hold.cprj =  tdilc301.cprj  
 	 hold.item =  tdilc301.item  
 	 hold.cntr =  tdilc301.cntr  
 	 hold.clot =  tdilc301.clot  
 	 hold.date =  tdilc301.date  
 	 hold.cwar =  tdilc301.cwar  
 	 hold.loca =  tdilc301.loca  
 	 hold.sern =  tdilc301.sern
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inr
:TFLNO:100
:SCPAC:td
:SCMOD:ilc
:SFLNO:301
:ICOD:S
:QURY:START
select 	 tdilc301.*  ,  
 	 tcmcs003.typw
from 	 tdilc301, tcmcs003
where 	 tdilc301.cwar <>  ""                    
 and 	 tdilc301.cntr =  ""                    
 and 	 tdilc301.cwar refers to tcmcs003  
 and 	 tcmcs003.typw <>  tctypw.transito
order by tdilc301.cprj,  
 	 	 tdilc301.item,  
 	 	 tdilc301.cntr, 	 	 | #  205264.n  
 	 	 tdilc301.clot,  
 	 	 tdilc301.date,  
 	 	 tdilc301.cwar,  
 	 	 tdilc301.loca,  
 	 	 tdilc301.trdt,  
 	 	 tdilc301.trtm,  
 	 	 tdilc301.sern
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inr
:TFLNO:100
:SCPAC:td
:SCMOD:ilc
:SFLNO:301
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inr
:TFLNO:110
:SCPAC:td
:SCMOD:inv
:SFLNO:700
:ICOD:D
:QURY:START
	 hold.tdinv700.trdt =  tdinv700.trdt  
 	 hold.tdinv700.trtm =  tdinv700.trtm 	 	 	 	 | #  TELAIR.n  
 	 hold.tdinv700.sern =  tdinv700.sern 	 	 	 	 | #  TELAIR.n  
 | 	 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  
 	 	 	 if lot.controlled.item( 	 "",                                                                                  	                                                                                  |*                                                                                   project                                                                                  	                                                                                  |#                                                                                  fp3.sn                                                                                                                                                                    
 	 	 	 	 	 	 tdinv700.item) then 	 | #  fp3.en  
 	 	 	 	 var.whinr110.valm =  5 	 | *  lot  
 	 	 	 	 	 	 	 	 | #  800 -  145084.sn  
 	 	 	 	 determine.lot.inventory.onhand(  
 	 	 	 	 	 	 	 tdinv700.item,  
 	 	 	 	 	 	 	 tdinv700.cwar,  
 	 	 	 	 	 	 	 nr.lots,  
 	 	 	 	 	 	 	 arr.lots)  
 	 	 	 	 	 	 	 	 | #  800 -  145084.en  
 	 	 	 else 	 	 	 	 	 	 | #  fp3.sn  
 	 	 	 	 var.whinr110.valm =  6 	 | *  serial  
 	 	 	 	 determine.lot.inventory.onhand(  
 	 	 	 	 	 	 	 tdinv700.item,  
 	 	 	 	 	 	 	 tdinv700.cwar,  
 	 	 	 	 	 	 	 nr.lots,  
 	 	 	 	 	 	 	 arr.lots)  
 	 	 	 endif 	 	 	 	 	 	 | #  fp3.en  
 	 	 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.koor:curr.koor, 	 	 	 	 	 	 | #  205835.n  
 	 	 	 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 	 	 | #  205835.o  
 	 	 	 (curr.kost =  tckost.stc.transfer and curr.quan >  0 and 	 	 	 | #  205835.n  
 	 	 	 curr.koor <>  tckoor.act.sls and curr.koor <>  tckoor.sma.order) then 	 | #  205835.n  
 	 	 	 	 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  
 	 var.whinr110.shpm =  " " 	 	 	 	 	 	 | #  202924.n  
 	 var.whinr110.shpo =  0 	 	 	 	 	 	 	 | #  202924.n  
 	 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  
 	 	 get.purchase.order.line.data( 	 	 	 | #  213329.sn  
 	 	 	 	 true, 	 	 |inv  
 	 	 	 	 tdinv700.orno,  
 	 	 	 	 tdinv700.pono,  
 	 	 	 	 hold.tdinv700.trdt,  
 	 	 	 	 hold.tdinv700.trtm,  
 	 	 	 	 hold.tdinv700.sern,  
 	 	 	 	 "",                                                                                                                                                                                       	                                                                                                                                                                                       |*                                                                                                                                                                             Project                                                                                                                                                                                                                                                                                                                                                                              
 	 	 	 	 tdinv700.item, 	  
 	 	 	 	 tdinv700.quan,  
 	 	 	 	 var.whinr110.srnb,  
 	 	 	 	 bom.line) 	 	 	 | #  213329.en  
 	 	 	 	 	 	 	 	 | #  SL204550.sn  
 	 	 if tdinv700.quan <  0 then  
 | 	 	 	 get.return.purchase.order.line.data( 	 | #  213329.so  
 | 	 	 	 	 	 true, 	 	 |inv  
 | 	 	 	 	 	 tdinv700.orno,  
 | 	 	 	 	 	 tdinv700.pono,  
 | 	 	 	 	 	 hold.tdinv700.trdt,  
 | 	 	 	 	 	 hold.tdinv700.trtm,  
 | 	 	 	 	 	 hold.tdinv700.sern,  
 | 	 	 	 	 	 "",                                                                                                                                                                                  	                                                                                                                                                                                  |*                                                                                                                                                                        Project                                                                                                                                                                                                                                                                                                                                                                    
 | 	 	 	 	 	 tdinv700.item, 	  
 | 	 	 	 	 	 tdinv700.quan,  
 | 	 	 	 	 	 var.whinr110.srnb,  
 | 	 	 	 	 	 bom.line) 	 	 | #  213329.eo  
 	 	 	 errmess =  ""                                                                                                                                                                                                                                                                                                                                                                    
 	 	 	 get.shipment.number.and.line(  
 	 	 	 	 	 tdinv700.koor,  
 	 	 	 	 	 tdinv700.orno,  
 	 	 	 	 	 tdinv700.pono,  
 	 	 	 	 	 var.whinr110.srnb,  
 	 	 	 	 	 bom.line,  
 	 	 	 	 	 errmess)  
 	 	 	 if isspace(errmess) then  
 	 	 	 	 var.whinr110.shpm =  bcswh008.shpm  
 	 	 	 	 var.whinr110.shpo =  bcswh008.shln  
 	 	 	 endif  
 	 	 endif  
 	 	 	 	 	 	 	 	 | #  SL204550.en  
 	 	 break  
 	 case tckoor.act.sls:  
 	 	 if not get.business.partner(tdinv700.rlcd, bcstc.orgn.cuno, o.mess) then  
 	 	 	 var.whinr110.bpid =  bcstc008.bpid  
 	 	 endif  
 	 	 	 	 	 	 	 	 | #  SL204550.so  
 | 	 	 var.whinr110.srnb =  determine.sales.order.sequence( 	 true, 	 	 |inv 	 | #  800 -  143063.n  
 | 	 	 	 	 	 	 	 	 	 tdinv700.orno,  
 | 	 	 	 	 	 	 	 	 	 tdinv700.pono,  
 | 	 	 	 	 	 	 	 	 	 	 	 	 | #  TELAIR.so  
 | | 	 	 	 	 	 	 	 	 	 tdinv700.trdt,  
 | | 	 	 	 	 	 	 	 	 	 tdinv700.trtm, 	 	 | #  800 -  143063.n  
 | | 	 	 	 	 	 	 	 	 	 tdinv700.sern, 	 	 | #  800 -  143063.n  
 | 	 	 	 	 	 	 	 	 	 	 	 	 | #  TELAIR.eo  
 | 	 	 	 	 	 	 	 	 	 	 	 	 | #  TELAIR.sn  
 | 	 	 	 	 	 	 	 	 	 hold.tdinv700.trdt,  
 | 	 	 	 	 	 	 	 	 	 hold.tdinv700.trtm,  
 | 	 	 	 	 	 	 	 	 	 hold.tdinv700.sern,  
 | 	 	 	 	 	 	 	 	 	 	 	 	 | #  TELAIR.en  
 | 	 	 	 	 	 	 	 	 	 "",                                                                                                                                                                                                                                                                                                              	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            	                                                                                                                                                                                                                                                                                                              |#                                                                                                                                                                                                                                                                                                              800-                                                                                                                                                                                                                                                                                                              143063.n                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
 | 	 	 	 	 	 	 	 	 	 tdinv700.quan) 	 | #  800 -  143063.n  
 	 	 	 	 	 	 	 	 | #  SL204550.eo 	 	 	 	 	 	 	 	 	 | #  202924.sn  
 	 	 	 	 	 	 	 	 | #  SL204550.sn  
 	 	 get.sales.order.line.data(  
 	 	 	 	 	 true, 	 	 |inv  
 	 	 	 	 	 tdinv700.orno,  
 	 	 	 	 	 tdinv700.pono,  
 	 	 	 	 	 hold.tdinv700.trdt,  
 	 	 	 	 	 hold.tdinv700.trtm,  
 	 	 	 	 	 hold.tdinv700.sern,  
 	 	 	 	 	 "",                                                                                                                                                                                  	                                                                                                                                                                                  |*                                                                                                                                                                        Project                                                                                                                                                                                                                                                                                                                                                                    
 	 	 	 	 	 tdinv700.item, 	  
 	 	 	 	 	 tdinv700.quan,  
 	 	 	 	 	 var.whinr110.srnb,  
 	 	 	 	 	 bom.line)  
 	 	 	 	 	 	 	 	 | #  SL204550.en  
 	 	 | *  shipment /  line number are needed for COGS determination  
 	 	 | *  filling is conform include ibcswh0007  
 	 	 if tdinv700.quan >  0 then  
 	 	 	 	 	 	 	 	 | #  SL204550.sn  
 	 	 	 errmess =  ""                                                                                                                                                                                                                                                                                                                                                                    
 	 	 	 get.shipment.number.and.line(  
 	 	 	 	 	 tdinv700.koor,  
 	 	 	 	 	 tdinv700.orno,  
 	 	 	 	 	 tdinv700.pono,  
 	 	 	 	 	 var.whinr110.srnb,  
 	 	 	 	 	 bom.line,  
 	 	 	 	 	 errmess)  
 	 	 	 if isspace(errmess) then  
 	 	 	 	 var.whinr110.shpm =  bcswh008.shpm  
 	 	 	 	 var.whinr110.shpo =  bcswh008.shln  
 	 	 	 else  
 	 	 	 	 	 	 	 	 | #  SL204550.en 	  
 	 	 	 var.whinr110.shpm =  edit$(tdinv700.orno, "999999") &                                                                                                                                                                                            edit$(tdinv700.pono, "999")                                                                                                                                                                                                                                                                                                                                                                                      
 	 	 	 var.whinr110.shpo =  var.whinr110.srnb  
 	 	 	 if var.whinr110.shpo =  0 then  
 	 	 	 	 var.whinr110.shpo =  10  
 	 	 	 endif  
 	 	 	 endif 	 	 	 	 	 | #  SL204550.en  
 	 	 endif  
 	 	 break  
 	 case tckoor.sma.order :  
 	 	 if not get.business.partner(tdinv700.rlcd, bcstc.orgn.cuno, o.mess) then  
 	 	 	 var.whinr110.bpid =  bcstc008.bpid  
 	 	 endif  
 	 	 	 	 	 	 	 	 | #  SL204550.sn  
 	 	 if tdinv700.quan >  0 then  
 	 	 	 errmess =  ""                                                                                                                                                                                                                                                                                                                                                                    
 	 	 	 get.shipment.number.and.line(  
 	 	 	 	 	 tdinv700.koor,  
 	 	 	 	 	 tdinv700.orno,  
 	 	 	 	 	 tdinv700.pono,  
 	 	 	 	 	 0, 	 	 	 | *  sequence  
 	 	 	 	 	 0, 	 	 	 | *  bom line  
 	 	 	 	 	 errmess)  
 	 	 	 if isspace(errmess) then  
 	 	 	 	 var.whinr110.shpm =  bcswh008.shpm  
 	 	 	 	 var.whinr110.shpo =  bcswh008.shln  
 	 	 	 endif  
 	 	 endif  
 	 	 	 	 	 	 	 	 | #  SL204550.en  
 	 	 break  
 	 case tckoor.act.sfc: 	 	 	 	 	 | #  208542.sn  
 	 	 if tdinv700.kost =  tckost.stc.transfer then  
 	 	 	 if (tdinv700.quan <  0) then  
 	 	 	 	 var.whinr110.qstk =  abs (tdinv700.quan)  
 	 	 	 endif  
 	 	 endif  
 	 	 break 	 	 	 	 	 	 | #  208542.en  
 	 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  
 	 	 	 	 	 	 	 	 | #  SL204550.sn  
 	 	 if tdinv700.quan >  0 then  
 	 	 	 errmess =  ""                                                                                                                                                                                                                                                                                                                                                                    
 	 	 	 get.shipment.number.and.line(  
 	 	 	 	 	 tdinv700.koor,  
 	 	 	 	 	 tdinv700.orno,  
 	 	 	 	 	 tdinv700.pono,  
 	 	 	 	 	 1, 	 	 	 | *  sequence 	 	 	  
 	 	 	 	 	 0, 	 	 	 | *  bom line  
 	 	 	 	 	 errmess)  
 	 	 	 if isspace(errmess) then  
 	 	 	 	 var.whinr110.shpm =  bcswh008.shpm  
 	 	 	 	 var.whinr110.shpo =  bcswh008.shln  
 	 	 	 endif  
 	 	 endif  
 	 	 	 	 	 	 	 	 | #  SL204550.en  
 	 	 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) 	 | #  TELAIR.o  
 	 	 	 	 	 	 	 	 	 hold.tdinv700.trdt) 	 | #  TELAIR.n  
 	 	 	 	 	 	 	 	 	 | #  800 -  142206.en  
 	 	 	 	 	 	 	 	 | #  SL204550.sn  
 	 	 if tdinv700.quan >  0 then  
 	 	 	 errmess =  ""                                                                                                                                                                                                                                                                                                                                                                    
 	 	 	 get.shipment.number.and.line(  
 	 	 	 	 	 tdinv700.koor,  
 	 	 	 	 	 tdinv700.orno,  
 	 	 	 	 	 tdinv700.pono,  
 	 	 	 	 	 1, 	 	 	 | *  sequence 	 	 	  
 	 	 	 	 	 0, 	 	 	 | *  bom line  
 	 	 	 	 	 errmess)  
 	 	 	 if isspace(errmess) then  
 	 	 	 	 var.whinr110.shpm =  bcswh008.shpm  
 	 	 	 	 var.whinr110.shpo =  bcswh008.shln  
 	 	 	 endif  
 	 	 endif  
 	 	 	 	 	 	 	 	 | #  SL204550.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  
 	 	 	 	 	 	 	 	 | #  SL204550.sn  
 	 	 if tdinv700.quan >  0 then  
 	 	 	 errmess =  ""                                                                                                                                                                                                                                                                                                                                                                    
 	 	 	 get.shipment.number.and.line(  
 	 	 	 	 	 tdinv700.koor,  
 	 	 	 	 	 tdinv700.orno,  
 	 	 	 	 	 tdinv700.pono,  
 	 	 	 	 	 0, 	 	 	 | *  sequence 	 	 	  
 	 	 	 	 	 0, 	 	 	 | *  bom line  
 	 	 	 	 	 errmess)  
 	 	 	 if isspace(errmess) then  
 	 	 	 	 var.whinr110.shpm =  bcswh008.shpm  
 	 	 	 	 var.whinr110.shpo =  bcswh008.shln  
 	 	 	 endif  
 	 	 endif  
 	 	 	 	 	 	 	 	 | #  SL204550.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  
 	 if (tdinv700.koor =  tckoor.act.sls or tdinv700.koor =  tckoor.sma.order) and 	 | #  205835.n  
 	 tdinv700.kost =  tckost.stc.transfer and tdinv700.quan >  0 then 	 	 | #  205835.n  
 	 	 var.whinr110.kost =  5 	 	 |tckost.issue 	 	 	 	 | #  205835.n  
 	 else  
 	 	 	 	 	 	 	 	 	 	 	 | #  RN.sn  
 	 	 if tdinv700.koor =  tckoor.act.sfc and  
 	 	 tdinv700.kost =  tckost.stc.transfer and  
 	 	 tdinv700.pono <>  0 then 	 | material  
 	 	 	 var.whinr110.kost =  5 	 	 | issue  
 	 	 	 if tdinv700.quan >  0 then  
 	 	 	 	 var.whinr110.qstk = -  tdinv700.quan 	 | negative issue  
 	 	 	 else  
 	 	 	 	 var.whinr110.qstk =  abs(tdinv700.quan)  
 	 	 	 endif  
 	 	 else 	 	 	 	 	 	 	 	 	 | #  RN.en  
 	 	 	 var.whinr110.kost =  convert.tckost(tdinv700.kost, tdinv700.quan)  
 	 	 endif 	 	 	 	 	 	 	 	 	 | #  RN.n  
 	 endif 	 	 	 	 	 	 	 	 	 	 | #  205835.n  
 	 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  
 	 if var.whinr110.valm =  5 then 	 	 	 	 	 | #  TELAIR.sn  
 	 	 var.whinr110.clot =  determine.lot(hold.tdinv700.trdt)  
 	 else  
 	 	 var.whinr110.clot =  empty()  
 	 endif 	 	 	 	 	 	 	 	 	 | #  TELAIR.en  
 	 if var.whinr110.valm =  6 then 	 	 	 | #  fp3.sn  
 	 	 var.whinr110.serl =  determine.lot(hold.tdinv700.trdt)  
 	 else  
 	 	 var.whinr110.serl =  empty()  
 	 endif 	 	 	 	 	 	 	 | #  fp3.en  
 | 	 dump 1 	 	 	 	 	 	 	 	 | #  800 -  145084.o  
 	 	 	 	 	 	 	 	 	 	 | #  800 -  144866.so  
 | 	 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  
 | 	 	 if isspace(var.whinr110.clot) then 	 	 	 	 	 | #  TELAIR.n  
 | 	 	 	 get.standard.cost.price(tdinv700.item, dummy.receipt.qty,  
 | 	 | 	 	 	 	 	 tdinv700.trdt, true, false) 	 	 | #  TELAIR.o  
 | 	 	 	 	 	 	 hold.tdinv700.trdt, true, false) 	 | #  TELAIR.sn  
 | 	 	 else  
 | 	 	 	 get.lot.price(tdinv700.item, var.whinr110.clot, dummy.receipt.qty,  
 | 	 	 	 	 	 	 hold.tdinv700.trdt, true, false)  
 | 	 	 endif 	 	 	 	 	 	 	 	 	 | #  TELAIR.en  
 | 	 	 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  
 	 	 	 	 	 	 	 	 	 	 | #  800 -  144866.eo  
 	 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 	 	 | #  205835.o  
 	 (tdinv700.kost =  tckost.stc.transfer and tdinv700.quan >  0 and 	 	 | #  205835.n  
 	 tdinv700.koor <>  tckoor.act.sls and tdinv700.koor <>  tckoor.sma.order) then 	 | #  205835.n  
 	 	 	 	 	 	 	 	 	 	 	 | #  fp3.so  
 | 	 	 if var.whinr110.valm =  5 then 	 	 	 	 	 | #  800 -  145084.sn  
 	 	 	 	 	 	 	 	 	 	 	 | #  fp3.eo  
 	 	 	 	 	 	 	 	 	 	 	 | #  fp3.sn  
 	 	 if var.whinr110.valm =  5 or var.whinr110.valm =  6 then  
 	 	 	 	 	 	 	 	 	 	 	 | #  fp3.en  
 	 	 	 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  
 	 	 	 	 dump 1  
 	 	 	 	 var.whina112.qskt =  0.0  
 	 	 	 	 dump 3  
 | 	 	 	 	 if isspace(var.whinr110.clot) then 	 	 	 | #  fp3.o  
 	 	 	 	 	 	 	 	 	 	 	 | #  fp3.sn  
 	 	 	 	 if isspace(var.whinr110.clot) and isspace(var.whinr110.serl) then  
 	 	 	 	 	 	 	 	 	 	 	 | #  fp3.en  
 	 	 	 	 	 get.standard.cost.price(  
 	 	 	 	 	 	 	 tdinv700.item,  
 	 	 	 	 	 	 	 var.whina112.qstk,  
 	 	 	 	 	 	 	 hold.tdinv700.trdt,  
 	 	 	 	 	 	 	 true,  
 	 	 	 	 	 	 	 false)  
 	 	 	 	 else  
 	 	 	 	 	 	 	 	 	 	 	 | #  fp3.sn  
 	 	 	 	 	 if not isspace(var.whinr110.serl) then  
 	 	 	 	 	 	 lot.serial =  var.whinr110.serl  
 	 	 	 	 	 else  
 	 	 	 	 	 	 lot.serial =  var.whinr110.clot  
 	 	 	 	 	 endif  
 	 	 	 	 	 	 	 	 	 	 	 | #  fp3.en  
 	 	 	 	 	 get.lot.price( 	 tdinv700.item,  
 | 	 	 	 	 	 	 	 var.whinr110.clot, 	 	 | #  fp3.o  
 	 	 	 	 	 	 	 lot.serial, 	 	 	 | #  fp3.n  
 	 	 	 	 	 	 	 var.whina112.qstk,  
 	 	 	 	 	 	 	 hold.tdinv700.trdt,  
 	 	 	 	 	 	 	 true,  
 	 	 	 	 	 	 	 false)  
 	 	 	 	 endif  
 	 	 	 else  
 	 	 	 	 split.up.lots.inventory()  
 	 	 	 endif  
 	 	 else  
 	 	 	 dump 1 	 	 	 	 	 	 	 	 | #  800 -  145084.en  
 	 	 	 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  
 	 	 	 	 	 	 	 	 | #  fp3.so  
 | 	 	 	 if isspace(var.whinr110.clot) then 	 	 	 	 	 | #  TELAIR.n  
 | 	 	 	 	 get.standard.cost.price(tdinv700.item, abs(tdinv700.quan),  
 | | 	 	 	 	 	 	 	 tdinv700.trdt, true, false) 	 	 | #  TELAIR.o  
 | 	 	 	 	 	 	 	 hold.tdinv700.trdt, true, false) 	 | #  TELAIR.sn  
 | 	 	 	 else  
 | 	 	 	 	 get.lot.price(tdinv700.item, var.whinr110.clot, abs(tdinv700.quan),  
 | 	 	 	 	 	 	 	 hold.tdinv700.trdt, true, false)  
 | 	 	 	 endif 	 	 	 	 	 	 	 	 	 | #  TELAIR.en  
 	 	 	 	 	 	 	 	 | #  fp3.eo  
 	 	 	 	 	 	 	 	 | #  fp3.sn  
 	 	 	 if isspace(var.whinr110.clot) and isspace(var.whinr110.serl) then  
 	 	 	 	 get.standard.cost.price(  
 	 	 	 	 	 	 	 tdinv700.item,  
 	 	 	 	 	 	 	 abs(tdinv700.quan),  
 	 	 	 	 	 	 	 hold.tdinv700.trdt,  
 	 	 	 	 	 	 	 true,  
 	 	 	 	 	 	 	 false)  
 	 	 	 else  
 	 	 	 	 if not isspace(var.whinr110.serl) then  
 	 	 	 	 	 lot.serial =  var.whinr110.serl  
 	 	 	 	 else  
 	 	 	 	 	 lot.serial =  var.whinr110.clot  
 	 	 	 	 endif  
 	 	 	 	 get.lot.price( 	 tdinv700.item,  
 	 	 	 	 	 	 lot.serial,  
 	 	 	 	 	 	 abs(tdinv700.quan),  
 	 	 	 	 	 	 hold.tdinv700.trdt,  
 	 	 	 	 	 	 true,  
 	 	 	 	 	 	 false)  
 	 	 	 endif  
 	 	 	 	 	 	 	 	 | #  fp3.en  
 	 	 endif 	 	 	 	 	 	 	 	 	 | #  800 -  145084.n  
 	 else  
 	 	 dump 1 	 	 	 	 	 	 	 	 	 | #  800 -  145084.n  
 	 	 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)  
 	 	 	 	 	 	 	 	 | #  fp3.so  
 | 	 	 	 	 if isspace(var.whinr110.clot) then 	 	 	 | #  TELAIR.n  
 | 	 	 	 	 	 get.standard.cost.price(tdinv700.item, abs(tdinv700.quan),  
 | | 	 	 	 	 	 	 	 	 tdinv700.trdt, false, true) | #  TELAIR.o  
 | 	 	 	 	 	 	 	 	 hold.tdinv700.trdt, false, true) | #  TELAIR.sn  
 | 	 	 	 	 else  
 | 	 	 	 	 	 get.lot.price(tdinv700.item, var.whinr110.clot, abs(tdinv700.quan),  
 | 	 	 	 	 	 	 	 	 hold.tdinv700.trdt, false, true)  
 | 	 	 	 	 endif 	 	 	 	 	 	 	 | #  TELAIR.en  
 	 	 	 	 	 	 	 	 | #  fp3.eo  
 	 	 	 	 	 	 	 	 | #  fp3.sn  
 	 	 	 	 if isspace(var.whinr110.clot) and  
 	 	 	 	 isspace(var.whinr110.serl) then  
 	 	 	 	 	 get.standard.cost.price(  
 	 	 	 	 	 	 	 tdinv700.item,  
 	 	 	 	 	 	 	 abs(tdinv700.quan),  
 	 	 	 	 	 	 	 hold.tdinv700.trdt,  
 	 	 	 	 	 	 	 false,  
 	 	 	 	 	 	 	 true)  
 	 	 	 	 else  
 	 	 	 	 	 if not isspace(var.whinr110.serl) then  
 	 	 	 	 	 	 lot.serial =  var.whinr110.serl  
 	 	 	 	 	 else  
 	 	 	 	 	 	 lot.serial =  var.whinr110.clot  
 	 	 	 	 	 endif  
 	 	 	 	 	 get.lot.price( 	 tdinv700.item,  
 	 	 	 	 	 	 	 lot.serial,  
 	 	 	 	 	 	 	 abs(tdinv700.quan),  
 	 	 	 	 	 	 	 hold.tdinv700.trdt,  
 	 	 	 	 	 	 	 false,  
 	 	 	 	 	 	 	 true)  
 	 	 	 	 endif  
 	 	 	 	 	 	 	 	 | #  fp3.en  
 	 	 	 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  
 	 	 	 	 	 	 	 	 | #  fp3.so  
 | 	 	 	 if isspace(var.whinr110.clot) then 	 	 	 	 | #  TELAIR.n  
 | 	 	 	 	 get.standard.cost.price(tdinv700.item, var.whina114.qstk,  
 | | 	 	 	 	 	 	 	 tdinv700.trdt, false, false) 	 | #  TELAIR.o  
 | 	 	 	 	 	 	 	 hold.tdinv700.trdt, false, false) 	 | #  TELAIR.sn  
 | 	 	 	 else  
 | 	 	 	 	 get.lot.price(tdinv700.item, var.whinr110.clot, var.whina114.qstk,  
 | 	 	 	 	 	 	 	 hold.tdinv700.trdt, false, false)  
 | 	 	 	 endif 	 	 	 	 	 	 	 	 | #  TELAIR.en  
 	 	 	 	 	 	 	 	 | #  fp3.eo  
 	 	 	 	 	 	 	 	 | #  fp3.sn  
 	 	 	 if isspace(var.whinr110.clot) and  
 	 	 	 isspace(var.whinr110.serl) then  
 	 	 	 	 get.standard.cost.price(  
 	 	 	 	 	 	 	 tdinv700.item,  
 	 	 	 	 	 	 	 var.whina114.qstk,  
 	 	 	 	 	 	 	 hold.tdinv700.trdt,  
 	 	 	 	 	 	 	 false,  
 	 	 	 	 	 	 	 false)  
 	 	 	 else  
 	 	 	 	 if not isspace(var.whinr110.serl) then  
 	 	 	 	 	 lot.serial =  var.whinr110.serl  
 	 	 	 	 else  
 	 	 	 	 	 lot.serial =  var.whinr110.clot  
 	 	 	 	 endif  
 	 	 	 	 get.lot.price( 	 tdinv700.item,  
 	 	 	 	 	 	 lot.serial,  
 	 	 	 	 	 	 var.whina114.qstk,  
 	 	 	 	 	 	 hold.tdinv700.trdt,  
 	 	 	 	 	 	 false,  
 	 	 	 	 	 	 false)  
 	 	 	 endif  
 	 	 	 	 	 	 	 	 | #  fp3.en  
 	 	 	 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  
 	 	 	 	 	 	 	 	 | #  fp3.so  
 | 	 	 	 	 	 if isspace(var.whinr110.clot) then 	 	 | #  TELAIR.n  
 | 	 	 	 	 	 	 get.standard.cost.price(  
 | 	 	 	 	 	 	 	 tdinv700.item,  
 | 	 	 	 	 	 	 	 remain.quan,  
 | | 	 	 	 	 	 	 	 tdinv700.trdt, false, true) 	 | #  TELAIR.o  
 | 	 	 	 	 	 	 	 hold.tdinv700.trdt, false, true) 	 | #  TELAIR.sn  
 | 	 	 	 	 	 else  
 | 	 	 	 	 	 	 get.lot.price(tdinv700.item, var.whinr110.clot,  
 | 	 	 	 	 	 	 	 remain.quan,  
 | 	 	 	 	 	 	 	 hold.tdinv700.trdt, false, true)  
 | 	 	 	 	 	 endif 	 	 	 	 	 	 | #  TELAIR.en  
 	 	 	 	 	 	 	 	 | #  fp3.eo  
 	 	 	 	 	 	 	 	 | #  fp3.sn  
 	 	 	 	 	 if isspace(var.whinr110.clot) and  
 	 	 	 	 	 isspace(var.whinr110.serl) then  
 	 	 	 	 	 	 get.standard.cost.price(  
 	 	 	 	 	 	 	 	 tdinv700.item,  
 	 	 	 	 	 	 	 	 remain.quan,  
 	 	 	 	 	 	 	 	 hold.tdinv700.trdt,  
 	 	 	 	 	 	 	 	 false,  
 	 	 	 	 	 	 	 	 true)  
 	 	 	 	 	 else  
 	 	 	 	 	 	 if not isspace(var.whinr110.serl) then  
 	 	 	 	 	 	 	 lot.serial =  var.whinr110.serl  
 	 	 	 	 	 	 else  
 	 	 	 	 	 	 	 lot.serial =  var.whinr110.clot  
 	 	 	 	 	 	 endif  
 	 	 	 	 	 	 get.lot.price( 	 tdinv700.item,  
 	 	 	 	 	 	 	 	 lot.serial,  
 	 	 	 	 	 	 	 	 remain.quan,  
 	 	 	 	 	 	 	 	 hold.tdinv700.trdt,  
 	 	 	 	 	 	 	 	 false,  
 	 	 	 	 	 	 	 	 true)  
 	 	 	 	 	 endif  
 	 	 	 	 	 	 	 	 | #  fp3.en  
 	 	 	 	 endif  
 	 	 	 	 | *  corrupt data: more issued then received  
 	 	 	 	 break  
 	 	 	 endif  
 	 	 until remain.quan =  0  
 	 endif  
 	 	 	 	 	 	 	 	 	 	 	 | #  800 -  144866.sn  
 	 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  
 	 	 hold.qhnd =  var.whinr110.qhnd 	 	 	 	 	 	 | #  214224.n  
 	 	 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 	 	 | #  214224.o  
 	 	 var.whinr110.qhnd =  onhand.inventory 	 	 	 	 	 | #  214224.n  
 	 	 	 	 	 	 | #  800 -  142486.en  
 | 	 	 dump 1 	 	 	 	 	 	 	 	 | #  800 -  145084.o  
 	 	 	 	 	 	 	 	 	 | #  fp3.so  
 | 	 	 if var.whinr110.valm =  5 then 	 	 	 	 	 | #  800 -  145084.sn  
 	 	 	 	 	 	 	 	 	 | #  fp3.eo  
 	 	 	 	 	 	 	 	 	 | #  fp3.sn  
 	 	 if var.whinr110.valm =  5 or var.whinr110.valm =  6 then  
 	 	 	 	 	 	 	 	 	 | #  fp3.en  
 	 	 	 var.whina112.qstk =  dummy.receipt.qty  
 	 	 	 receipt.counter =  receipt.counter +  1  
 	 	 	 to.be.received =  to.be.received -  dummy.receipt.qty  
 	 	 	 if to.be.received >=  onhand.inventory then  
 	 	 	 	 | *  totally consumed  
 	 	 	 	 dump 1  
 	 	 	 	 var.whina112.qskt =  0.0  
 	 	 	 	 dump 3  
 	 	 	 	 	 	 	 	 | #  fp3.so  
 | 	 	 	 	 if isspace(var.whinr110.clot) then  
 | 	 	 	 	 	 get.standard.cost.price(tdinv700.item, var.whina112.qstk,  
 | 	 	 	 	 	 	 	 	 hold.tdinv700.trdt, true, false)  
 | 	 	 	 	 else  
 | 	 	 	 	 	 get.lot.price(tdinv700.item, var.whinr110.clot, var.whina112.qstk,  
 | 	 	 	 	 	 	 	 	 hold.tdinv700.trdt, true, false)  
 | 	 	 	 	 endif  
 	 	 	 	 	 	 	 	 | #  fp3.eo  
 	 	 	 	 	 	 	 	 | #  fp3.sn  
 	 	 	 	 if isspace(var.whinr110.clot) and  
 	 	 	 	 isspace(var.whinr110.serl) then  
 	 	 	 	 	 get.standard.cost.price(  
 	 	 	 	 	 	 	 tdinv700.item,  
 	 	 	 	 	 	 	 var.whina112.qstk,  
 	 	 	 	 	 	 	 hold.tdinv700.trdt,  
 	 	 	 	 	 	 	 true,  
 	 	 	 	 	 	 	 false)  
 	 	 	 	 else  
 	 	 	 	 	 if not isspace(var.whinr110.serl) then  
 	 	 	 	 	 	 lot.serial =  var.whinr110.serl  
 	 	 	 	 	 else  
 	 	 	 	 	 	 lot.serial =  var.whinr110.clot  
 	 	 	 	 	 endif  
 	 	 	 	 	 get.lot.price( 	 tdinv700.item,  
 	 	 	 	 	 	 	 lot.serial,  
 	 	 	 	 	 	 	 var.whina112.qstk,  
 	 	 	 	 	 	 	 hold.tdinv700.trdt,  
 	 	 	 	 	 	 	 true,  
 	 	 	 	 	 	 	 false)  
 	 	 	 	 endif  
 	 	 	 	 	 	 	 	 | #  fp3.en  
 	 	 	 else  
 	 	 	 	 split.up.lots.inventory()  
 	 	 	 endif  
 	 	 else  
 	 	 	 dump 1 	 	 	 	 	 	 	 	 | #  800 -  145084.en  
 	 	 	 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  
 	 	 	 	 	 	 	 	 | #  fp3.sn  
 	 	 	 if not isspace(var.whinr110.serl) then 	 |serialized  
 	 	 	 	 dump 14  
 	 	 	 endif  
 	 	 	 	 	 	 	 	 | #  fp3.en  
 	 	 	 	 	 	 	 	 | #  fp3.so  
 | 	 	 	 if isspace(var.whinr110.clot) then 	 	 	 	 	 | #  TELAIR.n  
 | 	 	 	 	 get.standard.cost.price(tdinv700.item, dummy.receipt.qty,  
 | 	 | 	 	 	 	 	 	 tdinv700.trdt, true, false) 	 	 | #  TELAIR.o  
 | 	 	 	 	 	 	 	 hold.tdinv700.trdt, true, false) 	 | #  TELAIR.sn  
 | 	 	 	 else  
 | 	 	 	 	 get.lot.price(tdinv700.item, var.whinr110.clot, dummy.receipt.qty,  
 | 	 	 	 	 	 	 	 hold.tdinv700.trdt, true, false)  
 | 	 	 	 endif 	 	 	 	 	 	 	 	 	 | #  TELAIR.en  
 	 	 	 	 	 	 	 	 | #  fp3.eo  
 	 	 	 	 	 	 	 	 | #  fp3.sn  
 	 	 	 if isspace(var.whinr110.clot) and  
 	 	 	 isspace(var.whinr110.serl) then  
 	 	 	 	 get.standard.cost.price(  
 	 	 	 	 	 	 	 tdinv700.item,  
 	 	 	 	 	 	 	 dummy.receipt.qty,  
 	 	 	 	 	 	 	 hold.tdinv700.trdt,  
 	 	 	 	 	 	 	 true,  
 	 	 	 	 	 	 	 false)  
 	 	 	 else  
 	 	 	 	 if not isspace(var.whinr110.serl) then  
 	 	 	 	 	 lot.serial =  var.whinr110.serl  
 	 	 	 	 else  
 	 	 	 	 	 lot.serial =  var.whinr110.clot  
 	 	 	 	 endif  
 	 	 	 	 get.lot.price( 	 tdinv700.item,  
 	 	 	 	 	 	 lot.serial,  
 	 	 	 	 	 	 dummy.receipt.qty,  
 	 	 	 	 	 	 hold.tdinv700.trdt,  
 	 	 	 	 	 	 true,  
 	 	 	 	 	 	 false)  
 	 	 	 endif  
 	 	 	 	 	 	 	 	 | #  fp3.en  
 	 	 endif 	 	 	 	 	 	 	 	 	 	 | #  800 -  145084.n  
 	 	 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  
 	 	 var.whinr110.qhnd =  hold.qhnd 	 	 	 	 	 	 | #  214224.n  
 	 endif  
 	 	 	 	 	 	 	 	 	 	 	 | #  800 -  144866.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
: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:26
:VERS:B4st
:RELE:61
:CUST:sy30
: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:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inr
:TFLNO:110
:SCPAC:td
:SCMOD:inv
:SFLNO:700
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inr
:TFLNO:110
:SCPAC:ti
:SCMOD:pcs
:SFLNO:700
:ICOD:D
:QURY:START
	 var.whinr110.cwar =  keep.cwar 	 	 	 	 	 	 | #  214852.n  
 | 	 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  
 	 	 	 	 	 	 	 	 	 | #  TELAIR.sn  
 	 hold.tipcs700.trdt =  tipcs700.trdt  
 	 hold.tipcs700.trtm =  tipcs700.trtm  
 	 hold.tipcs700.sern =  tipcs700.sern  
 	 	 	 	 	 	 	 	 	 | #  TELAIR.en  
 	 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 	 	 	 	 	 | #  214852.o  
 	 hold.item <>  tipcs700.item or 	 	 	 	 	 | #  214852.n  
 	 hold.cwar <>  keep.cwar then 	 	 	 	 	 | #  214852.n  
 	 	 var.whinr110.seqn =  1 	 	 	 	 	 | #  800 -  142000.n  
 	 	 var.whinr110.qhnd =  0.0 	 	 	 | #  800 -  142486.n  
 	 	 hold.cprj =  tipcs700.cprj  
 	 	 hold.item =  tipcs700.item  
 	 	 hold.cwar =  keep.cwar 	 	 	 	 	 	 | #  214852.n  
 	 	 if tdilc000.iilc =  tcyesno.no then 	 	 	 	 | #  214852.n  
 | 	 	 	 select 	 tipcs021.stoc 	 	 	 | #  214852.o  
 	 	 	 select 	 tipcs021.stoc:stock, tipcs021.cwar 	 	 | #  214852.n  
 	 	 	 from 	 tipcs021  
 	 	 	 where 	 tipcs021._index1 =  {:hold.cprj, :hold.item}  
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 endselect  
 	 	 else 	 	 	 	 	 	 	 	 | #  214852.sn  
 	 	 	 select 	 sum(tdilc101.stks):stock  
 	 	 	 from 	 tdilc101  
 	 	 	 where 	 tdilc101._index2 =  {:hold.cprj, :hold.item, :keep.cwar}  
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 endselect  
 	 	 endif  
 	 	 	 	 	 	 	 	 	 	 | #  214852.en  
 	 	 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)  
 	 	 	 	 	 	 	 	 	 	 	 | #  214852.so  
 | 	 	 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  
 	 	 	 	 	 	 	 	 	 	 	 | #  214852.eo  
 	 	 	 	 	 	 	 	 	 	 	 | #  214852.sn  
 	 	 for k =  1 to arr.len.tipcs700  
 	 	 	 if isspace(arr.tipcs700.cwar(1,k)) then  
 	 	 	 	 break  
 	 	 	 else  
 	 	 	 	 if arr.tipcs700.proc(k) =  1 or  
 	 	 	 	 arr.tipcs700.cwar(1,k) <>  keep.cwar then  
 	 	 	 	 	 continue  
 	 	 	 	 endif  
 	 	 	 endif  
 	 	 	 found.trdt =  arr.tipcs700.trdt(k)  
 	 	 	 found.trtm =  arr.tipcs700.trtm(k)  
 	 	 	 found.sern =  arr.tipcs700.sern(k)  
 	 	 	 select 	 tipcs700._index1,  
 	 	 	 	 tipcs700.quan:curr.quan,  
 	 	 	 	 tipcs700.kost:curr.kost  
 	 	 	 from 	 tipcs700  
 	 	 	 where 	 tipcs700._index1 =  {:keep.cprj, :keep.item, :found.trdt, :found.trtm, :found.sern}  
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 endselect  
 	 	 	 	 	 	 	 	 	 	 	 | #  214852.en  
 	 	 	 	 	 	 	 	 	 	 	 | #  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 	 	 	 	 	 	 	 	 | #  214852.o  
 	 	 endfor 	 	 	 	 	 	 	 	 	 | #  214852.n  
 | 	 	 	 onhand.inventory =  max(to.be.received -  issued, tipcs021.stoc) 	 | #  214852.o  
 	 	 	 onhand.inventory =  max(to.be.received -  issued, stock) 	 	 | #  214852.n  
 	 	 	 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 	 	 	 	 	 	 	 	 	 | #  214852.o  
 	 	 i =  1  
 	 	 prev.sern =  0  
 	 endif  
 	  
 	 var.whinr110.qstk =  tipcs700.quan  
 	 var.whinr110.bpid =  empty()  
 	 var.whinr110.srnb =  0  
 	 var.whinr110.shpm =  " " 	 	 	 	 	 	 | #  202924.n  
 	 var.whinr110.shpo =  0 	 	 	 	 	 	 	 | #  202924.n  
 	 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  
 	 	 	 get.purchase.order.line.data( 	 	 | #  213329.so  
 	 	 	 	 false, 	 	 |inv  
 	 	 	 	 tipcs700.orno,  
 	 	 	 	 tipcs700.pono,  
 	 	 	 	 hold.tipcs700.trdt,  
 	 	 	 	 hold.tipcs700.trtm,  
 	 	 	 	 hold.tipcs700.sern,  
 	 	 	 	 tipcs700.cprj,  
 	 	 	 	 tipcs700.item, 	  
 	 	 	 	 tipcs700.quan,  
 	 	 	 	 var.whinr110.srnb,  
 	 	 	 	 bom.line) 	 	 	 | #  213329.eo  
 	 	 	 	 	 	 	 	 | #  SL204550.sn  
 	 	 	 if tipcs700.quan <  0 then  
 | 	 	 	 	 get.return.purchase.order.line.data( | #  213329.so  
 | 	 	 	 	 	 false, 	 	 |inv  
 | 	 	 	 	 	 tipcs700.orno,  
 | 	 	 	 	 	 tipcs700.pono,  
 | 	 	 	 	 	 hold.tipcs700.trdt,  
 | 	 	 	 	 	 hold.tipcs700.trtm,  
 | 	 	 	 	 	 hold.tipcs700.sern,  
 | 	 	 	 	 	 tipcs700.cprj,  
 | 	 	 	 	 	 tipcs700.item, 	  
 | 	 	 	 	 	 tipcs700.quan,  
 | 	 	 	 	 	 var.whinr110.srnb,  
 | 	 	 	 	 	 bom.line) 	 	 | #  213329.eo  
 	 	 	 	 errmess =  ""                                                                                                                                                                                                                                                                                                                                                                  
 	 	 	 	 get.shipment.number.and.line(  
 	 	 	 	 	 tipcs700.koor,  
 	 	 	 	 	 tipcs700.orno,  
 	 	 	 	 	 tipcs700.pono,  
 	 	 	 	 	 var.whinr110.srnb,  
 	 	 	 	 	 bom.line,  
 	 	 	 	 	 errmess)  
 	 	 	 	 if isspace(errmess) then  
 	 	 	 	 	 var.whinr110.shpm =  bcswh008.shpm  
 	 	 	 	 	 var.whinr110.shpo =  bcswh008.shln  
 	 	 	 	 endif  
 	 	 	 endif  
 	 	 	 	 	 	 	 	 | #  SL204550.en  
 	 	 	 break  
 	 	 case tckoor.act.sls :  
 	 	 	 if not get.business.partner(tipcs700.rlcd, bcstc.orgn.cuno, o.mess) then  
 	 	 	 	 var.whinr110.bpid =  bcstc008.bpid  
 	 	 	 endif  
 	 	 	 	 	 	 	 	 | #  SL204550.so  
 | 	 	 	 var.whinr110.srnb =  determine.sales.order.sequence( 	 false, 	 |pcs 	 | #  800 -  143063.n  
 | 	 	 	 	 	 	 	 	 	 	 tipcs700.orno,  
 | 	 	 	 	 	 	 	 	 	 	 tipcs700.pono,  
 | 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  TELAIR.so  
 | | 	 	 	 	 	 	 	 	 	 	 tipcs700.trdt,  
 | | 	 	 	 	 	 	 	 	 	 	 tipcs700.trtm, 	 | #  800 -  143063.n  
 | | 	 	 	 	 	 	 	 	 	 	 tipcs700.sern, 	 | #  800 -  143063.n  
 | 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  TELAIR.eo  
 | 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  TELAIR.sn  
 | 	 	 	 	 	 	 	 	 	 	 hold.tipcs700.trdt,  
 | 	 	 	 	 	 	 	 	 	 	 hold.tipcs700.trtm,  
 | 	 	 	 	 	 	 	 	 	 	 hold.tipcs700.sern,  
 | 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  TELAIR.en  
 | 	 	 	 	 	 	 	 	 	 	 tipcs700.cprj, 	 | #  800 -  143063.n  
 | 	 	 	 	 	 	 	 	 	 	 tipcs700.quan) 	 | #  800 -  143063.n  
 	 	 	 	 	 	 	 	 | #  SL204550.eo 	 	 	 	 	 	 	 	 | #  202924.sn  
 	 	 	 	 	 	 	 	 | #  SL204550.sn  
 	 	 	 get.sales.order.line.data(  
 	 	 	 	 	 true, 	 	 |inv  
 	 	 	 	 	 tipcs700.orno,  
 	 	 	 	 	 tipcs700.pono,  
 	 	 	 	 	 hold.tipcs700.trdt,  
 	 	 	 	 	 hold.tipcs700.trtm,  
 	 	 	 	 	 hold.tipcs700.sern,  
 	 	 	 	 	 "",             |*                                                                                                                                                                   Project                                                                                                                                                                                                                                                                                                                                                                  
 	 	 	 	 	 tipcs700.item,  
 	 	 	 	 	 tipcs700.quan,  
 	 	 	 	 	 var.whinr110.srnb,  
 	 	 	 	 	 bom.line)  
 	 	 	 	 	 	 	 	 | #  SL204550.en  
 	 	 | *  shipment /  line number are needed for COGS determination  
 	 	 | *  filling is conform include ibcswh0007  
 	 	 	 if tipcs700.quan >  0 then  
 	 	 	 	 	 	 	 	 | #  SL204550.sn  
 	 	 	 	 errmess =  ""                                                                                                                                                                                                                                                                                                                                                                  
 	 	 	 	 get.shipment.number.and.line(  
 	 	 	 	 	 tipcs700.koor,  
 	 	 	 	 	 tipcs700.orno,  
 	 	 	 	 	 tipcs700.pono,  
 	 	 	 	 	 var.whinr110.srnb,  
 	 	 	 	 	 bom.line,  
 	 	 	 	 	 errmess)  
 	 	 	 	 if isspace(errmess) then  
 	 	 	 	 	 var.whinr110.shpm =  bcswh008.shpm  
 	 	 	 	 	 var.whinr110.shpo =  bcswh008.shln  
 	 	 	 	 else  
 	 	 	 	 	 	 	 	 | #  SL204550.en 	  
 	 	 	 	 var.whinr110.shpm =  edit$(tipcs700.orno, "999999") &                                                                                                                                                                                           edit$(tipcs700.pono, "999")                                                                                                                                                                                                                                                                                                                                                                                    
 	 	 	 	 var.whinr110.shpo =  var.whinr110.srnb  
 	 	 	 	 if var.whinr110.shpo =  0 then  
 	 	 	 	 	 var.whinr110.shpo =  10  
 	 	 	 	 endif  
 	 	 	 	 endif 	 	 	 	 | #  SL204550.en  
 	 	 	 endif  
 	 	 	 	 	 	 	 	 	 	 	 	 | #  202924.en  
 	 	 	 break  
 	 	 case tckoor.sma.order :  
 	 	 	 if not get.business.partner(tipcs700.rlcd, bcstc.orgn.cuno, o.mess) then  
 	 	 	 	 var.whinr110.bpid =  bcstc008.bpid  
 	 	 	 endif  
 	 	 	 	 	 	 	 	 | #  SL204550.sn  
 	 	 	 if tipcs700.quan >  0 then  
 	 	 	 	 errmess =  ""                                                                                                                                                                                                                                                                                                                                                                  
 	 	 	 	 get.shipment.number.and.line(  
 	 	 	 	 	 tipcs700.koor,  
 	 	 	 	 	 tipcs700.orno,  
 	 	 	 	 	 tipcs700.pono,  
 	 	 	 	 	 0, 	 	 	 | *  sequence  
 	 	 	 	 	 0, 	 	 	 | *  bom line  
 	 	 	 	 	 errmess)  
 	 	 	 	 if isspace(errmess) then  
 	 	 	 	 	 var.whinr110.shpm =  bcswh008.shpm  
 	 	 	 	 	 var.whinr110.shpo =  bcswh008.shln  
 	 	 	 	 endif  
 	 	 	 endif  
 	 	 	 	 	 	 	 	 | #  SL204550.en  
 	 	 	 break  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101937.sn  
 	 	 case tckoor.pcs.wrh:  
 	 	 	 tipcs700.pono =  10  
 	 	 	 var.whinr110.srnb =  1  
 	 	 	 	 	 	 	 	 | #  SL204550.sn  
 	 	 	 if tipcs700.quan >  0 then  
 	 	 	 	 errmess =  ""                                                                                                                                                                                                                                                                                                                                                                  
 	 	 	 	 get.shipment.number.and.line(  
 	 	 	 	 	 tipcs700.koor,  
 	 	 	 	 	 tipcs700.orno,  
 	 	 	 	 	 tipcs700.pono,  
 	 	 	 	 	 0, 	 	 	 | *  sequence 	 	 	  
 	 	 	 	 	 0, 	 	 	 | *  bom line  
 	 	 	 	 	 errmess)  
 	 	 	 	 if isspace(errmess) then  
 	 	 	 	 	 var.whinr110.shpm =  bcswh008.shpm  
 	 	 	 	 	 var.whinr110.shpo =  bcswh008.shln  
 	 	 	 	 endif  
 	 	 	 endif  
 	 	 	 	 	 	 	 	 | #  SL204550.en  
 	 	 	 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  
 	 var.whinr110.clot =  empty() 	 	 	 	 	 | #  TELAIR.n  
 	 var.whinr110.serl =  empty() 	 	 	 	 	 | #  fp3.n  
 	 dump 2  
 	 	 	 	 	 	 	 	 	 	 | #  800 -  144866.so  
 | 	 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  
 	 	 	 	 	 	 	 	 	 	 | #  800 -  144866.eo  
 	 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  
 	 	 	 	 	 	 	 	 	 	 | #  800 -  144866.sn  
 	 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.qhnd =  var.whinr110.qhnd 	 	 	 	 | #  214224.n  
 	 	 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 	 | #  214224.o  
 	 	 var.whinr110.qhnd =  onhand.inventory 	 	 	 	 | #  214224.n  
 	 	 	 	 	 	 | #  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  
 	 	 var.whinr110.qhnd =  hold.qhnd 	 	 	 	 | #  214224.n  
 	 endif  
 	 	 	 	 	 	 	 	 	 	 | #  800 -  144866.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inr
:TFLNO:110
:SCPAC:ti
:SCMOD:pcs
:SFLNO:700
:ICOD:S
:QURY:START
select 	 tipcs700.*
from 	 tipcs700
where 	 tipcs700._index1 =  {:keep.cprj, :keep.item, :keep.trdt, :keep.trtm, :keep.sern}
as set with 1  rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inr
:TFLNO:110
:SCPAC:ti
:SCMOD:pcs
:SFLNO:700
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inr
:TFLNO:140
:SCPAC:td
:SCMOD:ilc
:SFLNO:101
:ICOD:D
:QURY:START
	 create.stockpoint.from.stock.point()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inr
:TFLNO:140
:SCPAC:td
:SCMOD:ilc
:SFLNO:101
:ICOD:F
:QURY:START
	 handle.stock.point.end.of.set()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inr
:TFLNO:140
:SCPAC:td
:SCMOD:ilc
:SFLNO:101
:ICOD:S
:QURY:START
select 	 tdilc101.*  , tcmcs003.cwar
from 	 tdilc101, tiitm001
where 	 tdilc101.cntr =  ""            
 and 	 tdilc101.cprj =  ""            
 and 	 tcmcs003._index1 =  {tdilc101.cwar}  
 and 	 tcmcs003.typw <>  tctypw.transito  
 and 	 tiitm001.item =  tdilc101.item 	 | *  because cntr =  "", this is OK            
 and not tiitm001.kltc =  tckltc.unit
order by tdilc101._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inr
:TFLNO:140
:SCPAC:td
:SCMOD:ilc
:SFLNO:101
:ICOD:X
:QURY:START
| #  206758.en  
 reset.hold.variables()  
 reset.stock.point()  
 | #  206758.sn  
 | *  2:  
 select 	 tdilc101.*  , tcmcs003.cwar  
 from 	 tdilc101, tiitm001  
 where 	 tdilc101.cntr =  ""            
 and 	 tdilc101.cprj =  ""            
 and 	 tcmcs003._index1 =  {tdilc101.cwar}  
 and 	 tcmcs003.typw <>  tctypw.transito  
 and 	 tiitm001.item =  tdilc101.item  
 and 	 tiitm001.kltc =  tckltc.unit  
 |order by tdilc101._index6  
 | *  No existing index can be used here because tdilc101.clot must be  
 | *  the last one in the sorting order.  
 order by tdilc101.cwar, tdilc101.cprj, tdilc101.item, tdilc101.cntr,  
 	 tdilc101.date, tdilc101.loca, tdilc101.stun, tdilc101.clot  
 selectdo  
 	 create.stockpoint.from.stock.point()  
 selecteos  
 	 handle.stock.point.end.of.set()  
 endselect  
 reset.hold.variables()  
 reset.stock.point()  
 | *  3:  
 select 	 tdilc101.*  , tcmcs003.cwar  
 from 	 tdilc101, tipcs021  
 where 	 tdilc101.cntr =  ""            
 and not tdilc101.cprj =  ""            
 and 	 tcmcs003._index1 =  {tdilc101.cwar}  
 and 	 tcmcs003.typw <>  tctypw.transito  
 and 	 tipcs021.cprj =  tdilc101.cprj  
 and 	 tipcs021.item =  tdilc101.item  
 and not tipcs021.kltc =  tckltc.unit  
 order by tdilc101._index1  
 selectdo  
 	 create.stockpoint.from.stock.point()  
 selecteos  
 	 handle.stock.point.end.of.set()  
 endselect  
 | *  4:  
 select tdilc101.*  , tcmcs003.cwar  
 from 	 tdilc101, tipcs021  
 where 	 tdilc101.cntr =  ""            
 and not tdilc101.cprj =  ""            
 and 	 tcmcs003._index1 =  {tdilc101.cwar}  
 and 	 tcmcs003.typw <>  tctypw.transito  
 and 	 tipcs021.cprj =  tdilc101.cprj  
 and 	 tipcs021.item =  tdilc101.item  
 and 	 tipcs021.kltc =  tckltc.unit  
 |order by tdilc101._index6  
 | *  No existing index can be used here because tdilc101.clot must be  
 | *  the last one in the sorting order.  
 order by tdilc101.cwar, tdilc101.cprj, tdilc101.item, tdilc101.cntr,  
 	 tdilc101.date, tdilc101.loca, tdilc101.stun, tdilc101.clot  
 selectdo  
 	 create.stockpoint.from.stock.point()  
 selecteos  
 	 handle.stock.point.end.of.set()  
 endselect  
 reset.hold.variables()  
 reset.stock.point()  
 | #  206758.en  
 | *  Create OnOrder stock points on the staging locations for all open outbound advice lines.  
 select bcswh000.sloc  
 from 	 bcswh000  
 selectdo  
 endselect  
 select tdilc401.*   
 from 	 tdilc401  
 where 	 tdilc401.proc =  tcyesno.no  
 and 	 tdilc401.loca <>  ""            
 and 	 tdilc401.qsts >  0.0  
 order by tdilc401.cwar,  
 	 	 tdilc401.cprj, tdilc401.item,  
 	 	 tdilc401.clot, tdilc401.date,  
 	 	 tdilc401.stun  
 selectdo  
 	 if lot.controlled.item( tdilc401.cprj,  
 	 	 	 	 tdilc401.item) then  
 	 	 lot.present =  true  
 	 else  
 	 	 lot.present =  false  
 	 endif  
 	 | *  Note:  
 	 | * -  in case of lot.by.unit (serialized) item break on the lot code will be ignored.  
 	 | * -  in case of By Location item break on the date will be ignored.  
 	 if (hold.tdilc101.cwar <>  tdilc401.cwar or  
 	 hold.tdilc101.cprj <>  tdilc401.cprj or  
 	 hold.tdilc101.item <>  tdilc401.item or  
 	 (hold.tdilc101.clot <>  tdilc401.clot and lot.present) or  
 	 (hold.tdilc101.date <>  tdilc401.date and  
 	 	 	 fifo.lifo.item( tdilc401.cprj,  
 	 	 	 	 	 tdilc401.item) 	 and  
 	 	 	 not lot.present)) then  
 	 	 | *  dump previous stock point  
 	 	 if not isspace(hold.tdilc101.cwar) then  
 	 	 	 var.whinr140.crdt =  utc(creation.date, 0)  
 	 	 	 var.whinr140.trdt =  utc(transaction.date, 0)  
 	 	 	 var.whinr140.lsid =  utc(last.storage.insp.date, 0)  
 	 	 	 if stock.is.present() then  
 	 	 	 	 Dump 1  
 	 	 	 	 | *  Note: no inventory structure to be dumped  
 	 	 	 	 | *  because only On order quantity is present  
 	 	 	 endif  
 	 	 	 reset.stock.point()  
 	 	 endif  
 	 	 hold.tdilc101.cwar =  tdilc401.cwar  
 	 	 hold.tdilc101.loca =  tdilc401.loca  
 	 	 hold.tdilc101.cprj =  tdilc401.cprj  
 	 	 hold.tdilc101.item =  tdilc401.item  
 	 	 hold.tdilc101.clot =  tdilc401.clot  
 	 	 hold.tdilc101.date =  tdilc401.date  
 	 endif  
 	 | *  Fill inventory structure  
 	 var.whinr140.cwar =  tdilc401.cwar  
 	 var.whinr140.loca =  bcswh000.sloc  
 	 var.whinr140.crem =  empty()  
 	 seg.whinr140.item =  tdilc401.item  
 	 seg.whinr140.cprj =  get.ti.project(tdilc401.cprj)  
 	 if lot.controlled.item( tdilc401.cprj,  
 	 	 	 	 tdilc401.item) then  
 	 	 var.whinr140.clot =  tdilc401.clot  
 	 else  
 	 	 var.whinr140.clot =  empty()  
 	 endif  
 	 | *  inventory date  
 	 if fifo.lifo.item( 	 tdilc401.cprj,  
 	 	 	 	 tdilc401.item) then  
 	 	 if lot.controlled.item(  
 	 	 	 	 tdilc401.cprj,  
 	 	 	 	 tdilc401.item) then  
 	 	 	 get.lot.date( 	 tdilc401.cprj,  
 	 	 	 	 	 tdilc401.item,  
 	 	 	 	 	 tdilc401.clot,  
 	 	 	 	 	 inventory.date)  
 	 	 else  
 	 	 	 inventory.date =  tdilc401.date  
 	 	 endif  
 	 else  
 	 	 inventory.date =  0  
 	 endif  
 	 var.whinr140.idat =  utc(inventory.date, 0)  
 	 | *  fill dates  
 	 | *  creaton date  
 	 if creation.date =  0 then  
 	 	 creation.date =  tdilc401.date  
 	 else  
 	 	 creation.date =  min(creation.date, tdilc401.date)  
 	 endif  
 	 | *  transaction date  
 	 transaction.date =  0  
 	 | *  last storage inspection date  
 	 last.storage.insp.date =  0  
 	 | *  only onorder quantity must be filled  
 	 var.whinr140.qord =  var.whinr140.qord +  tdilc401.qsts  
 	 var.whinr140.ball =  tcyesno.no  
 	 var.whinr140.bout =  tcyesno.no  
 	 var.whinr140.btri =  tcyesno.no  
 	 var.whinr140.bcyc =  tcyesno.no  
 selecteos  
 	 if not isspace(hold.tdilc101.cwar) then  
 	 	 var.whinr140.crdt =  utc(creation.date, 0)  
 	 	 var.whinr140.trdt =  utc(transaction.date, 0)  
 	 	 var.whinr140.lsid =  utc(last.storage.insp.date, 0)  
 	 	 if stock.is.present() then  
 	 	 	 Dump 1  
 	 	 endif  
 	 endif  
 endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inr
:TFLNO:140
:SCPAC:td
:SCMOD:inv
:SFLNO:001
:ICOD:D
:QURY:START
	 var.whinr140.cwar =  tdinv001.cwar  
 	 var.whinr140.loca =  ""                                                                                                                                                                                                                                                                                                                                                                                                        
 	 seg.whinr140.item =  tdinv001.item  
 	 seg.whinr140.cprj =  ""                                                                                                                                                                                                                                                                                                                                                                                                        
 	 var.whinr150.cuni =  inventory.unit("", tdinv001.item)  
 	 var.whinr140.clot =  ""                                                                                                                                                                                                                                                                                                                                                                                                        
 	 var.whinr140.qhnd =  tdinv001.stoc  
 	 var.whinr140.qblk =  tdinv001.blck  
 	 | *  On order and allocated quantity in non -  ILC company is always 0.0  
 	 var.whinr140.qlal =  0.0 	 	 	  
 	 var.whinr140.qord =  0.0  
 	 var.whinr140.crem =  ""                 |*                                                                                                                  remark                                                                                                                                                                                                                                                                                                                                                    
 	 var.whinr140.ball =  tcyesno.no  
 	 var.whinr140.bout =  tcyesno.no  
 	 var.whinr140.btri =  tcyesno.no  
 	 if tdinv000.wist =  tcyesno.yes then  
 	 	 var.whinr140.bcyc =  tdinv001.wist  
 	 else  
 	 	 var.whinr140.bcyc =  tcyesno.no  
 	 endif  
 	 var.whinr140.lsid =  utc(tdinv001.lsid, 0)  
 	 var.whinr140.trdt =  utc(tdinv001.ltdt, 0)  
 	 var.whinr140.crdt =  utc(tdinv001.ltdt, 0)  
 	 if fifo.lifo.item( 	 "",                                                                                                                                                                                                                                                                                                                                                                                                        
 	 	 	 tdinv001.item) then  
 	 	 var.whinr140.idat =  utc(tdinv001.ltdt, 0)  
 	 else  
 	 	 var.whinr140.idat =  utc(0,0)  
 	 endif  
 	 if stock.is.present() then  
 	 	 Dump 1  
 	 else  
 	 	 continue  
 	 endif  
 	 var.whinr150.qhds =  tdinv001.stoc  
 	 var.whinr150.qhnd =  tdinv001.stoc  
 	 var.whinr150.qals =  0.0  
 	 determine.blocked.quantity( 	  
 	 	 	 tdinv001.cwar,  
 	 	 	 "",                                                                                                                                           	                                                                                                                                                                                                                                                                                                                                                    	                                                                                                                                                                          |*                                                                                                                                                                               location                                                                                                                                                                                                                                                                                                                                                              
 	 	 	 "",                                                                                                                                                                                	                                                                                                                                                                                  |*                                                                                                                                                                               project                                                                                                                                                                                                                                                                                                                                                                                      
 	 	 	 tdinv001.item,  
 	 	 	 "",                                                                                                                                                          	                                                                                                                                                                                                                                                                                                                                                     	                                                                                                                                                                          |*                                                                                                                                                                               lot                                                                                                                                                                                                                                                                                                                                                              
 	 	 	 tdinv001.ltdt,  
 	 	 	 inventory.unit("", tdinv001.item),  
 	 	 	 tdinv001.blck,  
 	 	 	 tdinv001.alpl,  
 	 	 	 process.blocked,  
 	 	 	 manual.blocked)  
 	 var.whinr150.prbl =  process.blocked  
 	 var.whinr150.mabl =  manual.blocked  
 	 var.whinr150.mabp =  manual.blocked  
 	 if tdinv001.qbsi >  0.0 then  
 	 	 var.whinr150.mabl =  var.whinr150.mabl +  tdinv001.qbsi  
 	 	 var.whinr150.mabp =  var.whinr150.mabp +  tdinv001.qbsi  
 	 	 if var.whinr150.mabl >  var.whinr150.qhds then  
 	 	 	 var.whinr150.mabl =  var.whinr150.qhds  
 	 	 	 var.whinr150.mabl =  var.whinr150.qhds  
 	 	 endif  
 	 endif 	  
 	 calculate.available.quantity()  
 	 if structure.is.present() then  
 	 	 Dump 2  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inr
:TFLNO:140
:SCPAC:td
:SCMOD:inv
:SFLNO:001
:ICOD:S
:QURY:START
select 	 tdinv001.*  , tcmcs003.cwar
from 	 tdinv001
where 	 tdinv001.cntr =  ""                                                                                                                                                                                                                                                                                                                                                                                                        
 and 	 tdinv001.stoc >  0  
 and 	 tcmcs003._index1 =  {tdinv001.cwar}  
 and 	 tcmcs003.typw <>  tctypw.transito
order by tdinv001._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inr
:TFLNO:140
:SCPAC:td
:SCMOD:inv
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inr
:TFLNO:140
:SCPAC:ti
:SCMOD:pcs
:SFLNO:021
:ICOD:D
:QURY:START
	 var.whinr140.cwar =  tipcs021.cwar  
 	 var.whinr140.loca =  ""                                                                                                                                                                                                                                                                                                                                                                                                        
 	 seg.whinr140.item =  tipcs021.item  
 	 seg.whinr140.cprj =  tipcs021.cprj  
 	 var.whinr140.crem =  ""                                                                                                                                                                                                     	                                                                                                                                                                                                      |  *                                                                                                                                                                                                     remark                                                                                                                                                                                                                                                                                                                                                                                                        
 	 var.whinr150.cuni =  tipcs021.cuni  
 	 | *  fill stock data from Item Inventory  
 	 var.whinr140.clot =  ""                                                                                                                                                                                                                                                                                                                                                                                                        
 	 var.whinr140.qhnd =  tipcs021.stoc  
 	 var.whinr140.qblk =  tipcs021.blck  
 	 | *  On order and allocated quantity in non -  ILC company is always 0.0  
 	 var.whinr140.qlal =  0.0 	 	 	  
 	 var.whinr140.qord =  0.0  
 	 var.whinr140.ball =  tcyesno.no  
 	 var.whinr140.bout =  tcyesno.no  
 	 var.whinr140.btri =  tcyesno.no  
 	 var.whinr140.bcyc =  tcyesno.no  
 	 var.whinr140.lsid =  utc(0,0)  
 	 var.whinr140.crdt =  utc(0,0)  
 	 var.whinr140.trdt =  utc(tipcs021.ltac, 0)  
 	 if fifo.lifo.item( 	 tipcs021.cprj,  
 	 	 	 tipcs021.item) then  
 	 	 var.whinr140.idat =  utc(date.num(), 0)  
 	 	 inventory.date =  date.num()  
 	 else  
 	 	 var.whinr140.idat =  utc(0,0)  
 	 	 inventory.date =  0  
 	 endif  
 	 if stock.is.present() then  
 	 	 Dump 1  
 	 else  
 	 	 continue  
 	 endif  
 	 var.whinr150.qhds =  tipcs021.stoc  
 	 var.whinr150.qhnd =  tipcs021.stoc  
 	 var.whinr150.qals =  0.0  
 	 determine.blocked.quantity( 	  
 	 	 	 tipcs021.cwar,  
 	 	 	 "",                                                                                                                                                     	                                                                                                                                                                                                                                                                                                                                                    	                                                                                                                                                                          |*                                                                                                                                                                               location                                                                                                                                                                                                                                                                                                                                                              
 	 	 	 tipcs021.cprj,  
 	 	 	 tipcs021.item,  
 	 	 	 "",                                                                                                                                                         	                                                                                                                                                                                                                                                                                                                                                     	                                                                                                                                                                          |*                                                                                                                                                                               lot                                                                                                                                                                                                                                                                                                                                                              
 	 	 	 inventory.date,  
 	 	 	 tipcs021.cuni,  
 	 	 	 tipcs021.blck,  
 	 	 	 tipcs021.alpl,  
 	 	 	 process.blocked,  
 	 	 	 manual.blocked)  
 	 var.whinr150.prbl =  process.blocked  
 	 var.whinr150.mabl =  manual.blocked  
 	 var.whinr150.mabp =  manual.blocked  
 	 calculate.available.quantity()  
 	 if structure.is.present() then  
 	 	 Dump 2  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inr
:TFLNO:140
:SCPAC:ti
:SCMOD:pcs
:SFLNO:021
:ICOD:S
:QURY:START
select 	 tipcs021.*  , tcmcs003
from 	 tipcs021
where 	 tipcs021.stoc >  0  
 and 	 tcmcs003._index1 =  {tipcs021.cwar}  
 and 	 tcmcs003.typw <>  tctypw.transito
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:inr
:TFLNO:140
:SCPAC:ti
:SCMOD:pcs
:SFLNO:021
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
: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:26
:VERS:B4st
:RELE:61
:CUST:sy30
: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:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:ltc
:TFLNO:100
:SCPAC:td
:SCMOD:ltc
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:ltc
:TFLNO:300
:SCPAC:td
:SCMOD:ltc
:SFLNO:102
:ICOD:D
:QURY:START
	 select tdltc001.stoc, tdltc001.revi  
 	 from 	 tdltc001  
 	 where 	 tdltc001._index1 =  { 	 :tdltc102.cprj,  
 	 	 	 	 	 :tdltc102.item,  
 	 	 	 	 	 :tdltc102.cntr,  
 	 	 	 	 	 :tdltc102.clot}  
 	 as set with 1 rows  
 	 selectdo  
 	 endselect  
 	  
 	 var.whltc300.item =  segment.item.code(  
 	 	 	 	 	 tdltc102.item,  
 	 	 	 	 	 get.project(tdltc102.cprj))  
 	 var.whltc300.quan =  tdltc001.stoc  
 	 if hold.cprj <>  tdltc102.cprj or  
 	 hold.item <>  tdltc102.item or  
 	 hold.clot <>  tdltc102.clot then  
 	 	 var.whltc300.mtim =  0  
 	 	 remain.quan =  tdltc001.stoc  
 	 	 hold.cprj =  tdltc102.cprj  
 	 	 hold.item =  tdltc102.item  
 	 	 hold.clot =  tdltc102.clot  
 	 	 hold.tord =  convert.tord(tdltc102.tord)  
 	 	 hold.orno =  convert.number(  
 	 	 	 	 	 convert.tord.to.bcckon(tdltc102.tord),  
 	 	 	 	 	 tdltc102.orno)  
 	 	 hold.pono =  tdltc102.pono  
 	 endif  
 	 var.whltc300.mtim =  var.whltc300.mtim +  1  
 	 if (tdltc102.inou =  tdltc.inout.input and  
 	 	 tdltc102.qnty >=  0.0) or  
 	 (tdltc102.inou =  tdltc.inout.output and  
 	 	 tdltc102.qnty <  0.0) then  
 	 	 var.whltc300.tord =  convert.tord(tdltc102.tord)  
 	 	 var.whltc300.orno =  convert.number(  
 	 	 	 	 	 convert.tord.to.bcckon(tdltc102.tord),  
 	 	 	 	 	 tdltc102.orno)  
 	 	 var.whltc300.pono =  tdltc102.pono  
 	 	 var.whltc300.otto =  100 	 | not applicable  
 	 	 var.whltc300.orto =  empty()  
 	 	 var.whltc300.poto =  0  
 	 	 var.whltc300.quan =  min(abs(tdltc102.qnty), remain.quan)  
 	 	 remain.quan =  max(remain.quan -  var.whltc300.quan, 0)  
 	 else  
 	 	 var.whltc300.tord =  hold.tord  
 	 	 var.whltc300.orno =  hold.orno  
 	 	 var.whltc300.pono =  hold.pono  
 	 	 var.whltc300.otto =  convert.tord(tdltc102.tord)  
 	 	 var.whltc300.orto =  convert.number(  
 	 	 	 	 	 convert.tord.to.bcckon(tdltc102.tord),  
 	 	 	 	 	 tdltc102.orno)  
 	 	 var.whltc300.poto =  tdltc102.pono  
 	 	 var.whltc300.quan =  abs(tdltc102.qnty)  
 	 endif  
 	 if lot.controlled.item( tdltc102.cprj,  
 	 	 	 	 tdltc102.item) then  
 	 	 dump 1  
 	 endif  
 	 if serialized.item( 	 tdltc102.cprj,  
 	 	 	 	 tdltc102.item) then  
 	 	 dump 2  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:ltc
:TFLNO:300
:SCPAC:td
:SCMOD:ltc
:SFLNO:102
:ICOD:S
:QURY:START
select 	 tdltc102.*
from 	 tdltc102
where 	 tdltc102.item <>  ""             	                                     
 and 	 tdltc102.cntr =  ""                
 | *  first input transaction by item
order by tdltc102.cprj, tdltc102.item, tdltc102.clot, tdltc102.inou
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:ltc
:TFLNO:300
:SCPAC:td
:SCMOD:ltc
:SFLNO:102
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:26
:VERS:B4st
:RELE:61
:CUST:sy30
: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:26
:VERS:B4st
:RELE:61
:CUST:sy30
: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:26
:VERS:B4st
:RELE:61
:CUST:sy30
:TCPAC:wh
:TCMOD:wmd
:TFLNO:215
:SCPAC:td
:SCMOD:inv
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
