QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tc
:SCMOD:mcs
:SFLNO:036
:ICOD:D
:QURY:START
| *  set 'addition fields' to maximum range  
 	 set.min.max.for.leger.account.additions()  
 	 var.trans.origin =  tctror.sls  
 	 var.fin.trans =  tcfitr.invoice  
 	 | *  Fill the relevant "additions"                                                                                                                                                                                                                                                                                              
 	 if not isspace(tcmcs036.ccty) then  
 	 	 var.country.from =  tcmcs036.ccty 	 | *  convert 1:1  
 	 	 var.country.to =  var.country.from  
 	 endif  
 	 if not isspace(tcmcs036.cvat) then  
 	 	 var.vat.code.from =  tcmcs036.cvat 	 | *  convert 1:1  
 	 	 var.vat.code.to =  var.vat.code.from  
 	 endif  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_EXCL_PRIORITY_FROM_ARRAY  
 	 	 get.priority.tcmcs036(  
 	 	 	 	 	 var.recon.area,  
 	 	 	 	 	 var.recon.sub.area,  
 	 	 	 	 	 tcmcs036.ccty,  
 	 	 	 	 	 tcmcs036.cvat,  
 	 	 	 	 	 var.priority)  
 	 	 if var.priority =  0 then  
 	 	 	 continue  
 	 	 endif  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tcmcs036.sacn  
 	 	 else  
 	 	 	 var.ledger.account =  tcmcs036.sacn  
 	 	 endif  
 	 	 if var.recon.area <>  0 then  
 	 	 	 write.dump.1()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tc
:SCMOD:mcs
:SFLNO:036
:ICOD:S
:QURY:START
select 	 tcmcs036.*
from 	 tcmcs036
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tc
:SCMOD:mcs
:SFLNO:036
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:td
:SCMOD:cms
:SFLNO:200
:ICOD:D
:QURY:START
| *  set 'addition fields' to maximum range  
 	 set.min.max.for.leger.account.additions()  
 	 | *  set the 'addition fields' of tdcms200 to minimum range,  
 	 | *  because the read action at tdcms200 also works with  
 	 | *  empty fields. See function 'search.chart.main' in tdcms0240.  
 	 EMPTY_THE_TO_ADDITIONS_OF_TDCMS200  
 	 var.trans.origin =  tctror.cms  
 	 var.fin.trans =  tcfitr.reservation  
 	 | *  Fill the relevant "additions"                                                                                                                                                                                                                                                                                                                                          
 	 if not isspace(tdcms200.cfcg) then  
 	 	 var.fin.customer.group.from =  tdcms200.cfcg 	 | *  convert 1:1  
 	 	 var.fin.customer.group.to =  var.fin.customer.group.from  
 	 endif  
 	 if not isspace(tdcms200.cfsg) then  
 	 	 var.fin.supplier.group.from =  tdcms200.cfsg 	 | *  convert 1:1  
 	 	 var.fin.supplier.group.to =  var.fin.supplier.group.from  
 	 endif  
 	 if not isspace(tdcms200.item) then  
 	 	 var.item.from =  segment.item.code(tdcms200.item, "")                                                                                                                                                                                                                                                                                                                                           
 	 	 var.item.to =  var.item.from  
 	 endif  
 	 if not isspace(tdcms200.cprj) then  
 	 	 save.project =  get.project(tdcms200.cprj)  
 	 	 var.project.from =  save.project  
 	 	 var.project.to =  var.project.from  
 	 	 var.project.package.linked.from =  target(tcmcs.plnk.ti)  
 	 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 	 | *  NO main.project requried here, because no search of main -   
 	 	 | *  project during mapping of transactions.  
 	 endif  
 	 if not isspace(tdcms200.cuno) then  
 	 	 var.customer.from =  get.business.partner.code(  
 	 	 	 	 	 tdcms200.cuno,  
 	 	 	 	 	 bcstc.orgn.cuno,  
 	 	 	 	 	 dummy.error.message)  
 	 	 var.customer.to =  var.customer.from  
 	 endif  
 	 if tdcms200.rtyp <>  empty then  
 	 	 | *  Because the baan4 enum =  baan6 enum the  
 	 	 | *  from -  To fields can be converted 1:1  
 	 	 var.relation.type.from =  tdcms200.rtyp  
 	 	 var.relation.type.to =  var.relation.type.from  
 	 else  
 	 	 if not isspace(tdcms200.reln) then  
 	 	 	 | *  Take the Relation Type of the Relation  
 	 	 	 var.relation.type.from =  base.relation.type  
 	 	 	 var.relation.type.to =  var.relation.type.from  
 	 	 endif  
 	 endif  
 	 if not isspace(tdcms200.reln) then  
 	 	 var.relation.from =  tdcms200.reln 	 	 | *  convert 1:1  
 	 	 var.relation.to =  var.relation.from  
 	 endif  
 	 if not isspace(tdcms200.agrp) then  
 	 	 var.agreement.group.from =  tdcms200.agrp 	 | *  convert 1:1  
 	 	 var.agreement.group.to =  var.agreement.group.from  
 	 endif  
 	 if not isspace(tdcms200.cmgp) then  
 	 	 var.comm.rebate.group.from =  tdcms200.cmgp 	 | *  convert 1:1  
 	 	 var.comm.rebate.group.to =  var.comm.rebate.group.from  
 	 endif  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_EXCL_PRIORITY_FROM_ARRAY  
 	 	 if var.additional.type =  8 then  
 	 	 	 | *  8 (Commission)  
 	 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 	 var.ledger.account =  tdcms200.lacd  
 	 	 	 else  
 	 	 	 	 var.ledger.account =  tdcms200.lacc  
 	 	 	 endif  
 	 	 endif  
 	 	 if var.additional.type =  7 then  
 	 	 	 | *  For 7 (Rebate) LA's must be reversed  
 	 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 	 var.ledger.account =  tdcms200.lacc  
 	 	 	 else  
 	 	 	 	 var.ledger.account =  tdcms200.lacd  
 	 	 	 endif  
 	 	 endif  
 	 	 make.dump =  false  
 	 	 if (tdcms200.rtyp =  tdcms.rtyp.customer) or  
 	 	 (tdcms200.rtyp =  empty and isspace(tdcms200.cfsg)) then  
 	 	 	 | *  For customers, the 'Rebate additions' must be used  
 	 	 	 | *  Note that filled supplier groups must be skipped,  
 	 	 	 | *  so filled or empty customer groups are selected  
 	 	 	 if var.additional.type =  7 then  
 	 	 	 	 make.dump =  true  
 	 	 	 endif  
 	 	 endif  
 	 	 if (tdcms200.rtyp =  tdcms.rtyp.supplier) or  
 	 	 (tdcms200.rtyp =  tdcms.rtyp.employee) or  
 	 	 (tdcms200.rtyp =  empty and isspace(tdcms200.cfcg)) then  
 	 	 	 | *  For suppliers &  employees, the 'Commission  
 	 	 	 | *  additions' must be used.  
 	 	 	 | *  Note that filled customer groups must be skipped,  
 	 	 	 | *  so filled or empty supplier groups are selected.  
 	 	 	 if var.additional.type =  8 then  
 	 	 	 	 make.dump =  true  
 	 	 	 endif  
 	 	 endif  
 	 	 if make.dump =  true then  
 	 	 	 get.priority.tdcms200.sp1.onwards(  
 	 	 	 	 	 	 var.recon.area,  
 	 	 	 	 	 	 var.recon.sub.area,  
 	 	 	 	 	 	 var.additional.type,  
 	 	 	 	 	 	 tdcms200.rtyp,  
 	 	 	 	 	 	 tdcms200.cfsg,  
 	 	 	 	 	 	 tdcms200.cfcg,  
 	 	 	 	 	 	 tdcms200.cuno,  
 	 	 	 	 	 	 tdcms200.reln,  
 	 	 	 	 	 	 tdcms200.agrp,  
 	 	 	 	 	 	 tdcms200.cprj,  
 	 	 	 	 	 	 tdcms200.item,  
 	 	 	 	 	 	 tdcms200.cmgp,  
 	 	 	 	 	 	 var.priority)  
 	 	 	 | *  For tdcms200 fields that are filled in contrast  
 	 	 	 | *  with the parameters of tdcms000 var.priority  
 	 	 	 | *  will be left zero. That records must be skipped.  
 	 	 	 if var.priority <>  0 then  
 	 	 	 	 write.dump.1()  
 	 	 	 endif  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:td
:SCMOD:cms
:SFLNO:200
:ICOD:S
:QURY:START
select 	 tdcms200.*  , tdcms010.rtyp:base.relation.type
from 	 tdcms200, tdcms010
where 	 tdcms200.reln refers to tdcms010
order by tdcms200._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:td
:SCMOD:cms
:SFLNO:200
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:td
:SCMOD:inv
:SFLNO:105
:ICOD:D
:QURY:START
| *  set 'addition fields' to maximum range  
 	 set.min.max.for.leger.account.additions()  
 	 var.trans.origin =  tctror.wrh.order  
 	 var.fin.trans =  tcfitr.adjustment  
 	 | *  Fill the relevant "additions"                                                                                                                                                                                                                                                                                  
 	 if not isspace(tdinv105.recd) then  
 	 	 ret.long =  get.reason.for.rejection(  
 	 	 	 	 	 	 bcreje.tdinv105,  
 	 	 	 	 	 	 tdinv105.recd,  
 	 	 	 	 	 	 dummy.error.message)  
 	 	 var.reason.code.from =  bcstc017.newr  
 	 	 var.reason.code.to =  var.reason.code.from  
 	 endif  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 | *  array contains only the credit LA  
 	 	 	 var.ledger.account =  ""                                                                                                                                                          
 	 	 	 continue  
 	 	 else  
 	 	 	 var.ledger.account =  tdinv105.sacn  
 	 	 endif  
 	 	 if var.recon.area <>  0 then  
 	 	 	 write.dump.1()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:td
:SCMOD:inv
:SFLNO:105
:ICOD:S
:QURY:START
select 	 tdinv105.*
from 	 tdinv105
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:td
:SCMOD:inv
:SFLNO:105
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:td
:SCMOD:inv
:SFLNO:850
:ICOD:D
:QURY:START
| *  set 'addition fields' to maximum range  
 	 set.min.max.for.leger.account.additions()  
 	 if tdinv850.tror <>  save.trans.origin or  
 	 tdinv850.fitr <>  save.fin.trans then  
 	 	 get.reconciliation.data.tdinv850(  
 	 	 	 	 tdinv850.tror,  
 	 	 	 	 tdinv850.fitr,  
 	 	 	 	 number.of.entries,  
 	 	 	 	 array.additional.type,  
 	 	 	 	 array.recon.area,  
 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 array.debit.credit,  
 	 	 	 	 array.order.priority)  
 	 	 save.trans.origin =  tdinv850.tror  
 	 	 save.fin.trans =  tdinv850.fitr  
 	 endif  
 	 var.trans.origin =  tdinv850.tror  
 	 var.fin.trans =  tdinv850.fitr  
 	 | *  Fill the relevant "additions"                                                                                                                                                                                                                                                                                                                                      
 	 if not isspace(tdinv850.cfsg) then  
 	 	 var.fin.supplier.group.from =  tdinv850.cfsg 	 | *  convert 1:1  
 	 	 var.fin.supplier.group.to =  var.fin.supplier.group.from  
 	 endif  
 	 if not isspace(tdinv850.cwar) then  
 	 	 var.warehouse.from =  tdinv850.cwar 	 	 | *  convert 1:1  
 	 	 var.warehouse.to =  var.warehouse.from  
 	 endif  
 	 if not isspace(tdinv850.item) then  
 	 	 var.item.from =  segment.item.code(tdinv850.item, "")                                                                                                                                                                                                                                                                                                                                       
 	 	 var.item.to =  var.item.from  
 	 endif  
 	 if not isspace(tdinv850.citg) then  
 	 	 var.item.group.from =  tdinv850.citg 	 	 | *  convert 1:1  
 	 	 var.item.group.to =  var.item.group.from  
 	 endif  
 	 if not isspace(tdinv850.cpcp) then  
 	 	 ret.long =  get.cost.components( 	 bcorig.ticpr,  
 	 	 	 	 	 tdinv850.cpcp,  
 	 	 	 	 	 "",                                                                                                                                                                                                                                                                                                                                      
 	 	 	 	 	 dummy.error.message)  
 	 	 var.item.cost.component.from =  bcstc006.cost  
 	 	 var.item.cost.component.to =  var.item.cost.component.from  
 	 endif  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_EXCL_PRIORITY_FROM_ARRAY  
 	 	 get.priority.tdinv850(  
 	 	 	 	 	 var.recon.area,  
 	 	 	 	 	 var.recon.sub.area,  
 	 	 	 	 	 tdinv850.cfsg,  
 	 	 	 	 	 tdinv850.cwar,  
 	 	 	 	 	 tdinv850.citg,  
 	 	 	 	 	 tdinv850.item,  
 	 	 	 	 	 tdinv850.cpcp,  
 	 	 	 	 	 var.priority)  
 	 	 if var.priority =  0 then  
 	 	 	 continue  
 	 	 endif  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tdinv850.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tdinv850.lacc  
 	 	 endif  
 	 	 var.people.transaction.type.from =  0  
 	 	 var.people.transaction.type.to =  0  
 	 	 if var.fin.trans =  tcfitr.operation and  
 	 	 var.debit.credit =  tfgld.dbcr.credit and  
 	 	 var.trans.origin =  tctror.prd then  
 	 	 	 	 var.people.transaction.type.from =  4 	 | *  prod.order  
 	 	 	 	 var.people.transaction.type.to =  4 	 | *  prod.order  
 	 	 endif  
 	 	 if tdinv850.tror =  tctror.prd and  
 	 	 tdinv850.fitr =  tcfitr.revaluation then  
 	 	 	 | *  Only dump data if additional type is OK.  
 	 	 	 | *  Project revaluation =  No or Cost Price Component  
 	 	 	 | *  is not the Revaluation Cost Price Component  
 	 	 	 if (ticpr000.rvpr =  tcyesno.no) or  
 	 	 	 (ticpr000.rvpr =  tcyesno.yes and  
 	 	 	 ticpr000.rvcp <>  tdinv850.cpcp) then  
 	 	 	 	 if var.additional.type =  11 then  
 	 	 	 	 	 write.dump.1()  
 	 	 	 	 endif  
 	 	 	 else  
 	 	 	 	 | *  ticpr000.rpvr =  yes and  
 	 	 	 	 | *  ticpr000.rvcp =  tdinv850.cpcp  
 	 	 	 	 | *  So Project Revaluation Cost Component is  
 	 	 	 	 | *  found here.  
 	 	 	 	 if var.additional.type =  12 then  
 	 	 	 	 	 write.dump.1()  
 	 	 	 	 endif  
 	 	 	 endif  
 	 	 else  
 	 	 	 | *  Always dump data  
 	 	 	 write.dump.1()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:td
:SCMOD:inv
:SFLNO:850
:ICOD:S
:QURY:START
select 	 tdinv850.*
from 	 tdinv850
order by tdinv850.tror, tdinv850.fitr
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:td
:SCMOD:inv
:SFLNO:850
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:td
:SCMOD:sls
:SFLNO:070
:ICOD:D
:QURY:START
| *  set 'addition fields' to maximum range  
 	 set.min.max.for.leger.account.additions()  
 	 var.trans.origin =  tctror.sls  
 	 var.fin.trans =  tcfitr.invoice  
 	 | *  Fill the relevant "additions"                                                                                                                                                                                                                                                                                              
 	 if not isspace(tdsls070.ccty) then  
 	 	 var.country.from =  tdsls070.ccty 	 | *  convert 1:1  
 	 	 var.country.to =  var.country.from  
 	 endif  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tdsls070.daod  
 	 	 else  
 	 	 	 var.ledger.account =  tdsls070.caod  
 	 	 endif  
 	 	 if var.recon.area <>  0 then  
 	 	 	 write.dump.1()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:td
:SCMOD:sls
:SFLNO:070
:ICOD:S
:QURY:START
select 	 tdsls070.*
from 	 tdsls070
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:td
:SCMOD:sls
:SFLNO:070
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:td
:SCMOD:sls
:SFLNO:071
:ICOD:D
:QURY:START
| *  set 'addition fields' to maximum range  
 	 set.min.max.for.leger.account.additions()  
 	 var.trans.origin =  tctror.sls  
 	 var.fin.trans =  tcfitr.invoice  
 	 | *  Fill the relevant "additions"                                                                                                                                                                                                                                                                                          
 	 if not isspace(tdsls071.cfcg) then  
 	 	 var.fin.customer.group.from =  tdsls071.cfcg 	 | *  convert 1:1  
 	 	 var.fin.customer.group.to =  var.fin.customer.group.from  
 	 endif  
 	 if not isspace(tdsls071.cwar) then  
 	 	 var.warehouse.from =  tdsls071.cwar 	 	 | *  convert 1:1  
 	 	 var.warehouse.to =  var.warehouse.from  
 	 endif  
 	 if not isspace(tdsls071.item) then  
 	 	 var.item.from =  segment.item.code(tdsls071.item, "")                                                                                                                                                                                                                                                                                           
 	 	 var.item.to =  var.item.from  
 	 endif  
 	 if not isspace(tdsls071.citg) then  
 	 	 var.item.group.from =  tdsls071.citg 	 	 | *  convert 1:1  
 	 	 var.item.group.to =  var.item.group.from  
 	 endif  
 	 for counter =  1 to number.of.entries  
 	 	 | *  Take the right lines of the arrays valid  
 	 	 | *  for this record.  
 	 	 if (tdsls071.ckds =  tcckds.matl.costs and  
 	 	 array.additional.type(counter) =  4) or  
 	 	 (tdsls071.ckds =  tcckds.oper.costs and  
 	 	 array.additional.type(counter) =  5) or  
 	 	 (tdsls071.ckds =  tcckds.turnover and  
 	 	 array.additional.type(counter) =  6) then  
 	 	 	 INCREASE_VAR_SEQUENCE  
 	 	 	 FILL_VAR_EXCL_PRIORITY_FROM_ARRAY  
 	 	 	 get.priority.tdsls071(  
 	 	 	 	 	 	 var.recon.area,  
 	 	 	 	 	 	 var.recon.sub.area,  
 	 	 	 	 	 	 tdsls071.cfcg,  
 	 	 	 	 	 	 tdsls071.cwar,  
 	 	 	 	 	 	 tdsls071.citg,  
 	 	 	 	 	 	 tdsls071.item,  
 	 	 	 	 	 	 var.priority)  
 	 	 	 if var.priority =  0 then  
 	 	 	 	 continue  
 	 	 	 endif  
 	 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 	 var.ledger.account =  tdsls071.dbac  
 	 	 	 else  
 	 	 	 	 var.ledger.account =  tdsls071.cdac  
 	 	 	 endif  
 	 	 	 if var.additional.type =  4 then  
 	 	 	 	 | *  4 (Material Costs)  
 	 	 	 	 var.cost.comp.type.from =  tccref.material  
 	 	 	 	 var.cost.comp.type.to =  var.cost.comp.type.from  
 	 	 	 	 write.dump.1()  
 	 	 	 	 INCREASE_VAR_SEQUENCE  
 	 	 	 	 var.cost.comp.type.from =  tccref.chg.material  
 	 	 	 	 var.cost.comp.type.to =  var.cost.comp.type.from  
 	 	 	 	 write.dump.1()  
 	 	 	 	 INCREASE_VAR_SEQUENCE  
 	 	 	 	 var.cost.comp.type.from =  tccref.general  
 	 	 	 	 var.cost.comp.type.to =  var.cost.comp.type.from  
 	 	 	 	 write.dump.1()  
 	 	 	 	 continue  
 	 	 	 endif  
 	 	 	 if var.additional.type =  5 then  
 	 	 	 	 | *  5 (Operation Costs)  
 	 	 	 	 var.cost.comp.type.from =  tccref.operation  
 	 	 	 	 var.cost.comp.type.to =  var.cost.comp.type.from  
 	 	 	 	 write.dump.1()  
 	 	 	 	 INCREASE_VAR_SEQUENCE  
 	 	 	 	 var.cost.comp.type.from =  tccref.chg.operation  
 	 	 	 	 var.cost.comp.type.to =  var.cost.comp.type.from  
 	 	 	 	 write.dump.1()  
 	 	 	 	 continue  
 	 	 	 endif  
 	 	 	 if var.additional.type =  6 then  
 	 	 	 	 | *  6 (Revenues)  
 	 	 	 	 write.dump.1()  
 	 	 	 endif  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:td
:SCMOD:sls
:SFLNO:071
:ICOD:S
:QURY:START
select 	 tdsls071.*
from 	 tdsls071
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:td
:SCMOD:sls
:SFLNO:071
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:850
:ICOD:D
:QURY:START
| *  set 'addition fields' to maximum range  
 	 set.min.max.for.leger.account.additions()  
 	 if tipcs850.tror <>  save.trans.origin or  
 	 tipcs850.fitr <>  save.fin.trans then  
 	 	 get.reconciliation.data.tipcs850(  
 	 	 	 	 tipcs850.tror,  
 	 	 	 	 tipcs850.fitr,  
 	 	 	 	 number.of.entries,  
 	 	 	 	 array.additional.type,  
 	 	 	 	 array.recon.area,  
 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 array.debit.credit,  
 	 	 	 	 array.order.priority)  
 	 	 save.trans.origin =  tipcs850.tror  
 	 	 save.fin.trans =  tipcs850.fitr  
 	 endif  
 	 var.trans.origin =  tipcs850.tror  
 	 var.fin.trans =  tipcs850.fitr  
 	 | *  Fill the relevant "additions"                                                                                                                                                                                                                                                                                                                              
 	 if not isspace(tipcs850.cfcg) then  
 	 	 var.fin.customer.group.from =  tipcs850.cfcg 	 | *  convert 1:1  
 	 	 var.fin.customer.group.to =  var.fin.customer.group.from  
 	 endif  
 	 if not isspace(tipcs850.cfsg) then  
 	 	 var.fin.supplier.group.from =  tipcs850.cfsg 	 | *  convert 1:1  
 	 	 var.fin.supplier.group.to =  var.fin.supplier.group.from  
 	 endif  
 	 if not isspace(tipcs850.cpcp) then  
 	 	 ret.long =  get.cost.components( 	 bcorig.ticpr,  
 	 	 	 	 	 tipcs850.cpcp,  
 	 	 	 	 	 "",                                                                                                                                                                                                                                                                                                                              
 	 	 	 	 	 dummy.error.message)  
 	 	 var.item.cost.component.from =  bcstc006.cost  
 	 	 var.item.cost.component.to =  var.item.cost.component.from  
 	 endif  
 	 if not isspace(tipcs850.cprj) then  
 	 	 save.project =  get.project(tipcs850.cprj)  
 	 	 var.project.from =  save.project  
 	 	 var.project.to =  var.project.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.ti)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.ti)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_EXCL_PRIORITY_FROM_ARRAY  
 	 	 get.priority.tipcs850(  
 	 	 	 	 	 var.recon.area,  
 	 	 	 	 	 var.recon.sub.area,  
 	 	 	 	 	 tipcs850.cfcg,  
 	 	 	 	 	 tipcs850.cfsg,  
 	 	 	 	 	 tipcs850.cprj,  
 	 	 	 	 	 tipcs850.cpcp,  
 	 	 	 	 	 var.priority)  
 	 	 if var.priority =  0 then  
 	 	 	 continue  
 	 	 endif  
 | Lines below not required anymore AFter introducing var.project.package.linked  
 | 	 	 if isspace(tipcs850.cprj) then  
 | 	 	 	 | *  Note that the reconciliation groups stated in  
 | 	 	 	 | *  document 34450 are not listed here, to make  
 | 	 	 	 | *  this if -  statement as simple as possible  
 | 	 	 	 var.project.from =  " !"                                                                                                                                                               	                                                                                                                                                               |*                                                                                                                                                                just higher than 'space'                                                                                                                                                                                                                                                                                                                              
 | 	 	 	 var.project.to =  MAX_STRING  
 | 	 	 endif  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tipcs850.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tipcs850.lacc  
 	 	 endif  
 	 	 var.people.transaction.type.from =  0  
 	 	 var.people.transaction.type.to =  0  
 	 	 if var.fin.trans =  tcfitr.operation and  
 	 	 var.debit.credit =  tfgld.dbcr.credit then  
 	 	 if var.trans.origin =  tctror.pcs then  
 	 	 	 var.people.transaction.type.from =  3 	 | *  pcs.project  
 	 	 	 var.people.transaction.type.to =  3 	 | *  pcs.project  
 	 	 endif  
 	 	 if var.trans.origin =  tctror.prd then  
 	 	 	 var.people.transaction.type.from =  4 	 | *  prod.order  
 	 	 	 var.people.transaction.type.to =  4 	 | *  prod.order  
 	 	 endif  
 	 	 if var.trans.origin =  tctror.sma.order then  
 	 	 	 var.people.transaction.type.from =  6 	 | *  serv.order  
 	 	 	 var.people.transaction.type.to =  6 	 | *  serv.order  
 	 	 endif  
 	 	 endif  
 	 	 if not isspace(tipcs850.cprj) and  
 	 	 kind.of.project.ti =  tckopr.main.project then  
 	 	 	 | *  Write record for project addition.  
 	 	 	 write.dump.1()  
 	 	 	 | *  write extra record for main -  project addition  
 	 	 	 var.priority =  var.priority +  2  
 	 	 	 INCREASE_VAR_SEQUENCE  
 	 	 	 var.main.project.from =  save.project  
 	 	 	 var.main.project.to =  save.project  
 	 	 	 var.project.from =  ""                                                                                                                                                                                                                                                                                                                              
 	 	 	 var.project.to =  MAX_STRING  
 	 	 	 write.dump.1()  
 	 	 	 | *  Reset project and main -  project additions because they  
 	 	 	 | *  can be disturbed from earlier part of array  
 	 	 	 var.project.from =  save.project  
 	 	 	 var.project.to =  var.project.from  
 	 	 	 var.main.project.from =  ""                                                                                                                                      
 	 	 	 var.main.project.to =  MAX_STRING  
 	 	 else  
 	 	 	 write.dump.1()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:850
:ICOD:S
:QURY:START
select 	 tipcs850.*  , tipcs020.kopr:kind.of.project.ti
from 	 tipcs850, tipcs020
where 	 tipcs850.cprj refers to tipcs020
order by tipcs850.tror, tipcs850.fitr
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:850
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:hrs
:SFLNO:000
:ICOD:D
:QURY:START
| *  set 'addition fields' to maximum range  
 	 set.min.max.for.leger.account.additions()  
 	 var.trans.origin =  tctror.project  
 	 var.fin.trans =  tcfitr.hours  
 	 | *  Fill the relevant "additions"                                                                                                                                                          
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.recon.area =  0 then  
 	 	 	 continue  
 	 	 endif  
 	 	 var.people.transaction.type.from =  0  
 	 	 var.people.transaction.type.to =  0  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 | *  No debit account present in tphrs000  
 	 	 	 var.ledger.account =  ""                                                                                                                                                          
 	 	 	 continue  
 	 	 else  
 	 	 	 var.ledger.account =  tphrs000.flac  
 	 	 	 var.people.transaction.type.from =  1 	 | *  general  
 	 	 	 var.people.transaction.type.to =  1 	 | *  general  
 	 	 endif  
 	 	 write.dump.1()  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:hrs
:SFLNO:000
:ICOD:S
:QURY:START
select 	 tphrs000.*
from 	 tphrs000
as set with 1  rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:hrs
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:pdm
:SFLNO:155
:ICOD:D
:QURY:START
| *  set 'addition fields' to maximum range  
 	 set.min.max.for.leger.account.additions()  
 	 var.trans.origin =  tctror.project  
 	 var.fin.trans =  tcfitr.prv.result  
 	 if tppdm155.prvt <>  save.result.type then  
 	 	 get.reconciliation.data.tppdm155(  
 	 	 	 	 var.trans.origin,  
 	 	 	 	 var.fin.trans,  
 	 	 	 	 tppdm155.prvt,  
 	 	 	 	 number.of.entries,  
 	 	 	 	 array.additional.type,  
 	 	 	 	 array.recon.area,  
 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 array.debit.credit,  
 	 	 	 	 array.order.priority,  
 	 	 	 	 array.priority)  
 	 	 save.result.type =  tppdm155.prvt  
 	 endif  
 	 | *  Fill the relevant "additions"                                                                                                                                                                                                                                                                        
 	 if not isspace(tppdm155.cprv) then  
 	 	 var.result.type.from =  tppdm155.cprv 	 | *  convert 1:1  
 	 	 var.result.type.to =  var.result.type.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tppdm155.clad  
 	 	 else  
 	 	 	 var.ledger.account =  tppdm155.clac  
 	 	 endif  
 	 	 if var.recon.area =  0 then  
 	 	 	 continue  
 	 	 endif  
 	 	 make.dump =  false  
 	 	 if (tppdm155.prvt =  tppdm.prvt.results and  
 	 	 var.additional.type =  6) or  
 	 	 (tppdm155.prvt =  tppdm.prvt.costs and  
 	 	 var.additional.type =  13) then  
 	 	 	 | *  For 6 -  Revenues or 13 -  Costs taken the Normal LA.  
 	 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 	 var.ledger.account =  tppdm155.nlad  
 	 	 	 else  
 	 	 	 	 var.ledger.account =  tppdm155.nlac  
 	 	 	 endif  
 	 	 	 make.dump =  true  
 	 	 endif  
 	 	 if (tppdm155.prvt =  tppdm.prvt.results and  
 	 	 var.additional.type =  16) or  
 	 	 (tppdm155.prvt =  tppdm.prvt.costs and  
 	 	 var.additional.type =  15) then  
 	 	 	 | *  For 16 -  Reversed Revenues or 15 -  Reversed Costs  
 	 	 	 | *  taken the Reverse Ledger Accounts  
 	 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 	 var.ledger.account =  tppdm155.clad  
 	 	 	 else  
 	 	 	 	 var.ledger.account =  tppdm155.clac  
 	 	 	 endif  
 	 	 	 make.dump =  true  
 	 	 endif  
 	 	 if make.dump =  true then  
 	 	 	 write.dump.1()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:pdm
:SFLNO:155
:ICOD:S
:QURY:START
select 	 tppdm155.*
from 	 tppdm155
where 	 tppdm155.prvt <>  tppdm.prvt.provision
order by tppdm155.prvt
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:pdm
:SFLNO:155
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:prc
:SFLNO:210
:ICOD:D
:QURY:START
| *  set 'addition fields' to maximum range  
 	 set.min.max.for.leger.account.additions()  
 	 if tpprc210.tent <>  save.posting.type.teta then  
 	 	 get.reconciliation.data.tpprc210(  
 	 	 	 	 	 tpprc210.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.teta =  tpprc210.tent  
 	 endif  
 	 | *  Fill the relevant "additions"                                                                                                                                                                                                                                                                    
 	 if not isspace(tpprc210.item) then  
 	 	 var.item.from =  segment.item.code(tpprc210.item, "")                                                                                                                                                                                                                                                                     
 	 	 var.item.to =  var.item.from  
 	 endif  
 	 if not isspace(tpprc210.cprj) then  
 	 	 save.project =  get.tp.project(tpprc210.cprj)  
 	 	 var.project.from =  save.project  
 	 	 var.project.to =  var.project.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.recon.area =  0 then  
 	 	 	 continue  
 	 	 endif  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc210.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc210.lacc  
 	 	 endif  
 	 	 if not isspace(tpprc210.cprj) and  
 	 	 kind.of.project.tp =  tppdm.kopr.main then  
 	 	 	 | *  Write record for project addition.  
 	 	 	 write.dump.1() 	 | *  Note do not use 'make.dump =  true here  
 	 	 	 | *  write extra record for main -  project addition  
 	 	 	 var.priority =  var.priority +  1  
 	 	 	 INCREASE_VAR_SEQUENCE  
 	 	 	 var.main.project.from =  save.project  
 	 	 	 var.main.project.to =  save.project  
 	 	 	 var.project.from =  ""                                                                                                                                                                                                                                                                    
 	 	 	 var.project.to =  MAX_STRING  
 	 	 	 write.dump.1()  
 	 	 	 | *  Reset project and main -  project additions because they  
 	 	 	 | *  can be disturbed from earlier part of array  
 	 	 	 var.project.from =  save.project  
 	 	 	 var.project.to =  var.project.from  
 	 	 	 var.main.project.from =  ""                                                                                                                                      
 	 	 	 var.main.project.to =  MAX_STRING  
 	 	 else  
 	 	 	 write.dump.1()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:prc
:SFLNO:210
:ICOD:S
:QURY:START
select 	 tpprc210.*  , tppdm600.kopr:kind.of.project.tp
from 	 tpprc210, tppdm600
where 	 tpprc210.cprj refers to tppdm600
order by tpprc210.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:prc
:SFLNO:210
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:prc
:SFLNO:211
:ICOD:D
:QURY:START
| *  set 'addition fields' to maximum range  
 	 set.min.max.for.leger.account.additions()  
 	 if tpprc211.tent <>  save.posting.type.tetb then  
 	 	 get.reconciliation.data.tpprc211(  
 	 	 	 	 	 tpprc211.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.tetb =  tpprc211.tent  
 	 endif  
 	 | *  Fill the relevant "additions"                                                                                                                                                                                                                                          
 	 if not isspace(tpprc211.task) then  
 	 	 var.task.from =  tpprc211.task 	 	 | *  Convert 1:1  
 	 	 var.task.to =  var.task.from  
 	 endif  
 	 if not isspace(tpprc211.cprj) then  
 	 	 save.project =  get.tp.project(tpprc211.cprj)  
 	 	 var.project.from =  save.project  
 	 	 var.project.to =  var.project.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.recon.area =  0 then  
 	 	 	 continue  
 	 	 endif  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc211.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc211.lacc  
 	 	 endif  
 	 	 if (var.additional.type =  13 or var.additional.type =  17) and  
 	 	 var.debit.credit =  tfgld.dbcr.credit then  
 	 	 	 | *  13 =  (Costs) /  17 =  (Hours)  
 	 	 	 var.people.transaction.type.from =  2 	 | *  project  
 	 	 	 var.people.transaction.type.to =  2 	 | *  project  
 	 	 else  
 	 	 	 var.people.transaction.type.from =  0  
 	 	 	 var.people.transaction.type.to =  0  
 	 	 endif  
 	 	 if not isspace(tpprc211.cprj) and  
 	 	 kind.of.project.tp =  tppdm.kopr.main then  
 	 	 	 | *  Write record for project addition.  
 	 	 	 write.dump.1()  
 	 	 	 | *  write extra record for main -  project addition  
 	 	 	 var.priority =  var.priority +  1  
 	 	 	 INCREASE_VAR_SEQUENCE  
 	 	 	 var.main.project.from =  save.project  
 	 	 	 var.main.project.to =  save.project  
 	 	 	 var.project.from =  ""                                                                                                                                                                                                                                          
 	 	 	 var.project.to =  MAX_STRING  
 	 	 	 write.dump.1()  
 	 	 	 | *  Reset project and main -  project additions because they  
 	 	 	 | *  can be disturbed from earlier part of array  
 	 	 	 var.project.from =  save.project  
 	 	 	 var.project.to =  var.project.from  
 	 	 	 var.main.project.from =  ""                                                                                                                                      
 	 	 	 var.main.project.to =  MAX_STRING  
 	 	 else  
 	 	 	 write.dump.1()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:prc
:SFLNO:211
:ICOD:S
:QURY:START
select 	 tpprc211.*  , tppdm600.kopr:kind.of.project.tp
from 	 tpprc211, tppdm600
where 	 tpprc211.cprj refers to tppdm600
order by tpprc211.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:prc
:SFLNO:211
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:prc
:SFLNO:212
:ICOD:D
:QURY:START
| *  set 'addition fields' to maximum range  
 	 set.min.max.for.leger.account.additions()  
 	 if tpprc212.tent <>  save.posting.type.tetd then  
 	 	 get.reconciliation.data.tpprc212(  
 	 	 	 	 	 tpprc212.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.tetd =  tpprc212.tent  
 	 endif  
 	 | *  Fill the relevant "additions"                                                                                                                                                
 	 if not isspace(tpprc212.cequ) then  
 	 	 var.equipment.from =  tpprc212.cequ 	 	 | *  Convert 1:1  
 	 	 var.equipment.to =  var.equipment.from  
 	 endif  
 	 if not isspace(tpprc212.cprj) then  
 	 	 save.project =  get.tp.project(tpprc212.cprj)  
 	 	 var.project.from =  save.project  
 	 	 var.project.to =  var.project.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.recon.area =  0 then  
 	 	 	 continue  
 	 	 endif  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc212.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc212.lacc  
 	 	 endif  
 	 	 if not isspace(tpprc212.cprj) and  
 	 	 kind.of.project.tp =  tppdm.kopr.main then  
 	 	 	 | *  Write record for project addition.  
 	 	 	 write.dump.1()  
 	 	 	 | *  write extra record for main -  project addition  
 	 	 	 var.priority =  var.priority +  1  
 	 	 	 INCREASE_VAR_SEQUENCE  
 	 	 	 var.main.project.from =  save.project  
 	 	 	 var.main.project.to =  save.project  
 	 	 	 var.project.from =  ""                                                                                                                                                
 	 	 	 var.project.to =  MAX_STRING  
 	 	 	 write.dump.1()  
 	 	 	 | *  Reset project and main -  project additions because they  
 	 	 	 | *  can be disturbed from earlier part of array  
 	 	 	 var.project.from =  save.project  
 	 	 	 var.project.to =  var.project.from  
 	 	 	 var.main.project.from =  ""                                                                                                                                      
 	 	 	 var.main.project.to =  MAX_STRING  
 	 	 else  
 	 	 	 write.dump.1()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:prc
:SFLNO:212
:ICOD:S
:QURY:START
select 	 tpprc212.*  , tppdm600.kopr:kind.of.project.tp
from 	 tpprc212, tppdm600
where 	 tpprc212.cprj refers to tppdm600  
 and 	 tpprc212.tent <>  tpprc.tetd.wip.equip.int
order by tpprc212.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:prc
:SFLNO:212
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:prc
:SFLNO:213
:ICOD:D
:QURY:START
| *  set 'addition fields' to maximum range  
 	 set.min.max.for.leger.account.additions()  
 	 if tpprc213.tent <>  save.posting.type.tetg then  
 	 	 get.reconciliation.data.tpprc213(  
 	 	 	 	 	 tpprc213.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.tetg =  tpprc213.tent  
 	 endif  
 	 | *  Fill the relevant "additions"                                                                                                                                                
 	 if not isspace(tpprc213.csub) then  
 	 	 var.subcontracting.from =  tpprc213.csub 	 | *  Convert 1:1  
 	 	 var.subcontracting.to =  var.subcontracting.from  
 	 endif  
 	 if not isspace(tpprc213.cprj) then  
 	 	 save.project =  get.tp.project(tpprc213.cprj)  
 	 	 var.project.from =  save.project  
 	 	 var.project.to =  var.project.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc213.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc213.lacc  
 	 	 endif  
 	 	 if var.recon.area =  0 then  
 	 	 	 continue  
 	 	 endif  
 	 	 if not isspace(tpprc213.cprj) and  
 	 	 kind.of.project.tp =  tppdm.kopr.main then  
 	 	 	 | *  Write record for project addition.  
 	 	 	 write.dump.1()  
 	 	 	 | *  write extra record for main -  project addition  
 	 	 	 var.priority =  var.priority +  1  
 	 	 	 INCREASE_VAR_SEQUENCE  
 	 	 	 var.main.project.from =  save.project  
 	 	 	 var.main.project.to =  save.project  
 	 	 	 var.project.from =  ""                                                                                                                                                
 	 	 	 var.project.to =  MAX_STRING  
 	 	 	 write.dump.1()  
 	 	 	 | *  Reset project and main -  project additions because they  
 	 	 	 | *  can be disturbed from earlier part of array  
 	 	 	 var.project.from =  save.project  
 	 	 	 var.project.to =  var.project.from  
 	 	 	 var.main.project.from =  ""                                                                                                                                      
 	 	 	 var.main.project.to =  MAX_STRING  
 	 	 else  
 	 	 	 write.dump.1()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:prc
:SFLNO:213
:ICOD:S
:QURY:START
select 	 tpprc213.*  , tppdm600.kopr:kind.of.project.tp
from 	 tpprc213, tppdm600
where 	 tpprc213.cprj refers to tppdm600
order by tpprc213.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:prc
:SFLNO:213
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:prc
:SFLNO:214
:ICOD:D
:QURY:START
| *  set 'addition fields' to maximum range  
 	 set.min.max.for.leger.account.additions()  
 	 if tpprc214.tent <>  save.posting.type.tetc then  
 	 	 get.reconciliation.data.tpprc214(  
 	 	 	 	 	 tpprc214.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.tetc =  tpprc214.tent  
 	 endif  
 	 | *  Fill the relevant "additions"                                                                                                                                                
 	 if not isspace(tpprc214.cico) then  
 	 	 var.sundry.cost.from =  tpprc214.cico 	 | *  Convert 1:1  
 	 	 var.sundry.cost.to =  var.sundry.cost.from  
 	 endif  
 	 if not isspace(tpprc214.cprj) then  
 	 	 save.project =  get.tp.project(tpprc214.cprj)  
 	 	 var.project.from =  save.project  
 	 	 var.project.to =  var.project.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc214.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc214.lacc  
 	 	 endif  
 	 	 if var.recon.area =  0 then  
 	 	 	 continue  
 	 	 endif  
 	 	 if (var.additional.type =  13 or var.additional.type =  17) and  
 	 	 var.debit.credit =  tfgld.dbcr.credit then  
 	 	 	 | *  13 =  (Costs) /  17 =  (Hours)  
 	 	 	 var.people.transaction.type.from =  2 	 | *  project  
 	 	 	 var.people.transaction.type.to =  2 	 | *  project  
 	 	 else  
 	 	 	 var.people.transaction.type.from =  0  
 	 	 	 var.people.transaction.type.to =  0  
 	 	 endif  
 	 	 make.dump =  false  
 	 	 if not isspace(tpprc214.cprj) and  
 	 	 kind.of.project.tp =  tppdm.kopr.main then  
 	 	 	 | *  Write record for project addition.  
 	 	 	 write.dump.1()  
 	 	 	 | *  write extra record for main -  project addition  
 	 	 	 var.priority =  var.priority +  1  
 	 	 	 INCREASE_VAR_SEQUENCE  
 	 	 	 var.main.project.from =  save.project  
 	 	 	 var.main.project.to =  save.project  
 	 	 	 var.project.from =  ""                                                                                                                                                
 	 	 	 var.project.to =  MAX_STRING  
 	 	 	 write.dump.1()  
 	 	 	 | *  Reset project and main -  project additions because they  
 	 	 	 | *  can be disturbed from earlier part of array  
 	 	 	 var.project.from =  save.project  
 	 	 	 var.project.to =  var.project.from  
 	 	 	 var.main.project.from =  ""                                                                                                                                      
 	 	 	 var.main.project.to =  MAX_STRING  
 	 	 else  
 	 	 	 write.dump.1()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:prc
:SFLNO:214
:ICOD:S
:QURY:START
select 	 tpprc214.*  , tppdm600.kopr:kind.of.project.tp
from 	 tpprc214, tppdm600
where 	 tpprc214.cprj refers to tppdm600
order by tpprc214.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:001
:SCPAC:tp
:SCMOD:prc
:SFLNO:214
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:220
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	 FILL_VAR_COMPANIES_WITH_NCMP (tpprc220)  
 	 if tpprc220.tent <>  save.posting.type.teta then  
 	 	 get.reconciliation.data.tpprc220 (  
 	 	 	 	 	 tpprc220.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.teta =  tpprc220.tent  
 	 endif  
 	  
 	 if not isspace (tpprc220.item) then  
 	 	 var.item.from =  segment.item.code (tpprc220.item, "")                                         
 	 	 var.item.to =  var.item.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc220.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc220.lacc  
 	 	 endif  
 	 	 if var.recon.area <>  0 then  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:220
:ICOD:S
:QURY:START
select 	 tpprc220.*
from tpprc220
order by tpprc220.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:220
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:221
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	 FILL_VAR_COMPANIES_WITH_NCMP (tpprc221)  
 	 if tpprc221.tent <>  save.posting.type.tetb then  
 	 	 get.reconciliation.data.tpprc221 (  
 	 	 	 	 	 tpprc221.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.tetb =  tpprc221.tent  
 	 endif  
 	  
 	 if not isspace (tpprc221.task) then  
 	 	 var.task.from =  tpprc221.task 	 	  
 	 	 var.task.to =  var.task.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc221.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc221.lacc  
 	 	 endif  
 	 	 if (var.additional.type =  13 or var.additional.type =  17) and  
 	 	 var.debit.credit =  tfgld.dbcr.credit then  
 	 	 	  
 	 	 	 var.people.transaction.type.from =  2 	  
 	 	 	 var.people.transaction.type.to =  2 	  
 	 	 else  
 	 	 	 var.people.transaction.type.from =  0  
 	 	 	 var.people.transaction.type.to =  0  
 	 	 endif  
 	 	 if var.recon.area <>  0 then  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:221
:ICOD:S
:QURY:START
select 	 tpprc221.*
from tpprc221
order by tpprc221.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:221
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:222
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	 FILL_VAR_COMPANIES_WITH_NCMP (tpprc222)  
 	 if tpprc222.tent <>  save.posting.type.tetd then  
 	 	 get.reconciliation.data.tpprc222 (  
 	 	 	 	 	 tpprc222.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.tetd =  tpprc222.tent  
 	 endif  
 	  
 	 if not isspace (tpprc222.cequ) then  
 	 	 var.equipment.from =  tpprc222.cequ 	 	  
 	 	 var.equipment.to =  var.equipment.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc222.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc222.lacc  
 	 	 endif  
 	 	 if var.recon.area <>  0 then  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:222
:ICOD:S
:QURY:START
select 	 tpprc222.*
from tpprc222
where tpprc222.tent <>  tpprc.tetd.wip.equip.int
order by tpprc222.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:222
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:223
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	 FILL_VAR_COMPANIES_WITH_NCMP (tpprc223)  
 	 if tpprc223.tent <>  save.posting.type.tetg then  
 	 	 get.reconciliation.data.tpprc223 (  
 	 	 	 	 	 tpprc223.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.tetg =  tpprc223.tent  
 	 endif  
 	  
 	 if not isspace (tpprc223.csub) then  
 	 	 var.subcontracting.from =  tpprc223.csub 	  
 	 	 var.subcontracting.to =  var.subcontracting.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc223.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc223.lacc  
 	 	 endif  
 	 	 if var.recon.area <>  0 then  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:223
:ICOD:S
:QURY:START
select 	 tpprc223.*
from tpprc223
order by tpprc223.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:223
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:224
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	 FILL_VAR_COMPANIES_WITH_NCMP (tpprc224)  
 	 if tpprc224.tent <>  save.posting.type.tetc then  
 	 	 get.reconciliation.data.tpprc224 (  
 	 	 	 	 	 tpprc224.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.tetc =  tpprc224.tent  
 	 endif  
 	  
 	 if not isspace (tpprc224.cico) then  
 	 	 var.sundry.cost.from =  tpprc224.cico 	  
 	 	 var.sundry.cost.to =  var.sundry.cost.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc224.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc224.lacc  
 	 	 endif  
 	 	 if (var.additional.type =  13 or var.additional.type =  17) and  
 	 	 var.debit.credit =  tfgld.dbcr.credit then  
 	 	 	  
 	 	 	 var.people.transaction.type.from =  2 	  
 	 	 	 var.people.transaction.type.to =  2 	  
 	 	 else  
 	 	 	 var.people.transaction.type.from =  0  
 	 	 	 var.people.transaction.type.to =  0  
 	 	 endif  
 	 	 if var.recon.area <>  0 then  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:224
:ICOD:S
:QURY:START
select 	 tpprc224.*
from tpprc224
order by tpprc224.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:224
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:230
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	 if tpprc230.tent <>  save.posting.type.tetf then  
 	 	 get.reconciliation.data.tpprc230 (  
 	 	 	 	 	 tpprc230.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.tetf =  tpprc230.tent  
 	 endif  
 	  
 	 if tpprc230.cotp <>  empty then  
 	 	 var.cost.type.tp.from =  tpprc230.cotp 	  
 	 	 var.cost.type.tp.to =  var.cost.type.tp.from  
 	 endif  
 	 if not isspace (tpprc230.cprj) then  
 	 	 save.project =  get.tp.project (tpprc230.cprj)  
 	 	 var.project.from =  save.project  
 	 	 var.project.to =  var.project.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.recon.area =  0 then  
 	 	 	 continue  
 	 	 endif  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc230.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc230.lacc  
 	 	 endif  
 	 	 if var.additional.type =  13 and 	  
 	 	 tpprc230.cotp <>  tppdm.cotp.tasks and  
 	 	 tpprc230.cotp <>  tppdm.cotp.indirect then  
 	 	 	 continue  
 	 	 endif  
 	 	 if var.additional.type =  17 and 	 	  
 	 	 tpprc230.cotp <>  tppdm.cotp.tasks then  
 	 	 	 continue  
 	 	 endif  
 	 	 if (var.additional.type =  13 or var.additional.type =  17) and  
 	 	 var.debit.credit =  tfgld.dbcr.credit then  
 	 	 	  
 	 	 	 var.people.transaction.type.from =  2 	  
 	 	 	 var.people.transaction.type.to =  2 	  
 	 	 else  
 	 	 	 var.people.transaction.type.from =  0  
 	 	 	 var.people.transaction.type.to =  0  
 	 	 endif  
 	 	 if not isspace (tpprc230.cprj) and  
 	 	 kind.of.project.tp =  tppdm.kopr.main then  
 	 	 	  
 	 	 	 write.dump.1 ()  
 	 	 	  
 	 	 	 var.priority =  var.priority +  1  
 	 	 	 INCREASE_VAR_SEQUENCE  
 	 	 	 var.main.project.from =  save.project  
 	 	 	 var.main.project.to =  save.project  
 	 	 	 var.project.from =  ""                                         
 	 	 	 var.project.to =  MAX_STRING  
 	 	 	 write.dump.1 ()  
 	 	 	  
 	 	 	 var.project.from =  save.project  
 	 	 	 var.project.to =  var.project.from  
 	 	 	 var.main.project.from =  ""                                         
 	 	 	 var.main.project.to =  MAX_STRING  
 	 	 else  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:230
:ICOD:S
:QURY:START
select 	 tpprc230.*  , tppdm600.kopr :kind.of.project.tp
from tpprc230, tppdm600
where tpprc230.cprj refers to tppdm600  
 and tpprc230.cotp <>  0
order by tpprc230.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:230
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:231
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	 FILL_VAR_COMPANIES_WITH_NCMP (tpprc231)  
 	 if tpprc231.tent <>  save.posting.type.tetf then  
 	 	 get.reconciliation.data.tpprc231 (  
 	 	 	 	 	 tpprc231.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.tetf =  tpprc231.tent  
 	 endif  
 	  
 	 if tpprc231.cotp <>  empty then  
 	 	 var.cost.type.tp.from =  tpprc231.cotp 	  
 	 	 var.cost.type.tp.to =  var.cost.type.tp.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc231.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc231.lacc  
 	 	 endif  
 	 	 if var.additional.type =  13 and 	 	 	  
 	 	 tpprc231.cotp <>  tppdm.cotp.tasks and  
 	 	 tpprc231.cotp <>  tppdm.cotp.indirect then  
 	 	 	 continue  
 	 	 endif  
 	 	 if var.additional.type =  17 and 	 	 	  
 	 	 tpprc231.cotp <>  tppdm.cotp.tasks then  
 	 	 	 continue  
 	 	 endif  
 	 	 if (var.additional.type =  13 or var.additional.type =  17) and  
 	 	 var.debit.credit =  tfgld.dbcr.credit then  
 	 	 	  
 	 	 	 var.people.transaction.type.from =  2 	  
 	 	 	 var.people.transaction.type.to =  2 	  
 	 	 else  
 	 	 	 var.people.transaction.type.from =  0  
 	 	 	 var.people.transaction.type.to =  0  
 	 	 endif  
 	 	 if var.recon.area <>  0 then  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:231
:ICOD:S
:QURY:START
select 	 tpprc231.*
from tpprc231
where tpprc231.cotp <>  0
order by tpprc231.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:231
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:232
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	 FILL_VAR_COMPANIES_WITH_NCMP (tpprc232)  
 	 if tpprc232.tent <>  save.posting.type.tetf then  
 	 	 get.reconciliation.data.tpprc232 (  
 	 	 	 	 	 tpprc232.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.tetf =  tpprc232.tent  
 	 endif  
 	  
 	 if not isspace (tpprc232.ccco) then  
 	 	 get.cost.components (bcorig.tppdm,  
 	 	 	 	 	 "",                                         
 	 	 	 	 	 tpprc232.ccco,  
 	 	 	 	 	 dummy.error.message)  
 	 	 var.cost.component.tp.from =  bcstc006.cost  
 	 	 var.cost.component.tp.to =  var.cost.component.tp.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc232.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc232.lacc  
 	 	 endif  
 	 	 if (var.additional.type =  13 or var.additional.type =  17) and  
 	 	 var.debit.credit =  tfgld.dbcr.credit then  
 	 	 	  
 	 	 	 var.people.transaction.type.from =  2 	  
 	 	 	 var.people.transaction.type.to =  2 	  
 	 	 else  
 	 	 	 var.people.transaction.type.from =  0  
 	 	 	 var.people.transaction.type.to =  0  
 	 	 endif  
 	 	 if var.recon.area <>  0 then  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:232
:ICOD:S
:QURY:START
select 	 tpprc232.*
from tpprc232
order by tpprc232.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:232
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:233
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	 if tpprc233.tent <>  save.posting.type.tetf then  
 	 	 get.reconciliation.data.tpprc233 (  
 	 	 	 	 	 tpprc233.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.tetf =  tpprc233.tent  
 	 endif  
 	  
 	 if not isspace (tpprc233.cspa) then  
 	 	 var.element.from =  tpprc233.cspa 	  
 	 	 var.element.to =  var.element.from  
 	 endif  
 	 if tpprc233.cotp <>  empty then  
 	 	 var.cost.type.tp.from =  tpprc233.cotp 	  
 	 	 var.cost.type.tp.to =  var.cost.type.tp.from  
 	 endif  
 	 if not isspace (tpprc233.cprj) then  
 	 	 save.project =  get.tp.project (tpprc233.cprj)  
 	 	 var.project.from =  save.project  
 	 	 var.project.to =  var.project.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.recon.area =  0 then  
 	 	 	 continue  
 	 	 endif  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc233.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc233.lacc  
 	 	 endif  
 	 	 if var.additional.type =  13 and 	 	 	  
 	 	 tpprc233.cotp <>  tppdm.cotp.tasks and  
 	 	 tpprc233.cotp <>  tppdm.cotp.indirect then  
 	 	 	 continue  
 	 	 endif  
 	 	 if var.additional.type =  17 and 	 	 	  
 	 	 tpprc233.cotp <>  tppdm.cotp.tasks then  
 	 	 	 continue  
 	 	 endif  
 	 	 if (var.additional.type =  13 or var.additional.type =  17) and  
 	 	 var.debit.credit =  tfgld.dbcr.credit then  
 	 	 	  
 	 	 	 var.people.transaction.type.from =  2 	  
 	 	 	 var.people.transaction.type.to =  2 	  
 	 	 else  
 	 	 	 var.people.transaction.type.from =  0  
 	 	 	 var.people.transaction.type.to =  0  
 	 	 endif  
 	 	 if not isspace (tpprc233.cprj) and  
 	 	 kind.of.project.tp =  tppdm.kopr.main then  
 	 	 	  
 	 	 	 write.dump.1 ()  
 	 	 	  
 	 	 	 var.priority =  var.priority +  1  
 	 	 	 INCREASE_VAR_SEQUENCE  
 	 	 	 var.main.project.from =  save.project  
 	 	 	 var.main.project.to =  save.project  
 	 	 	 var.project.from =  ""                                         
 	 	 	 var.project.to =  MAX_STRING  
 	 	 	 write.dump.1 ()  
 	 	 	  
 	 	 	 var.project.from =  save.project  
 	 	 	 var.project.to =  var.project.from  
 	 	 	 var.main.project.from =  ""                                         
 	 	 	 var.main.project.to =  MAX_STRING  
 	 	 else  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:233
:ICOD:S
:QURY:START
select 	 tpprc233.*  , tppdm600.kopr :kind.of.project.tp
from tpprc233, tppdm600
where tpprc233.cprj refers to tppdm600  
 and tpprc233.cotp <>  0
order by tpprc233.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:233
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:240
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	 if tpprc240.tent <>  save.posting.type.tete then  
 	 	 get.reconciliation.data.tpprc240 (  
 	 	 	 	 	 tpprc240.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.tete =  tpprc240.tent  
 	 endif  
 	  
 	 if not isspace (tpprc240.cprj) then  
 	 	 save.project =  get.tp.project (tpprc240.cprj)  
 	 	 var.project.from =  save.project  
 	 	 var.project.to =  var.project.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.recon.area =  0 then  
 	 	 	 continue  
 	 	 endif  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc240.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc240.lacc  
 	 	 endif  
 	 	 if not isspace (tpprc240.cprj) and  
 	 	 kind.of.project.tp =  tppdm.kopr.main then  
 	 	 	  
 	 	 	 write.dump.1 ()  
 	 	 	  
 	 	 	 var.priority =  var.priority +  1  
 	 	 	 INCREASE_VAR_SEQUENCE  
 	 	 	 var.main.project.from =  save.project  
 	 	 	 var.main.project.to =  save.project  
 	 	 	 var.project.from =  ""                                         
 	 	 	 var.project.to =  MAX_STRING  
 	 	 	 write.dump.1 ()  
 	 	 	  
 	 	 	 var.project.from =  save.project  
 	 	 	 var.project.to =  var.project.from  
 	 	 	 var.main.project.from =  ""                                         
 	 	 	 var.main.project.to =  MAX_STRING  
 	 	 else  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:240
:ICOD:S
:QURY:START
select 	 tpprc240.*  , tppdm600.kopr :kind.of.project.tp
from tpprc240, tppdm600
where tpprc240.cprj refers to tppdm600
order by tpprc240.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:240
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:241
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	 FILL_VAR_COMPANIES_WITH_NCMP (tpprc241)  
 	 if tpprc241.tent <>  save.posting.type.tete then  
 	 	 get.reconciliation.data.tpprc241 (  
 	 	 	 	 	 tpprc241.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.tete =  tpprc241.tent  
 	 endif  
 	  
 	 if tpprc241.coty <>  empty then  
 	 	 var.contract.execution.from =  tpprc241.coty 	  
 	 	 var.contract.execution.to =  var.contract.execution.from  
 	 endif  
 	 if not isspace (tpprc241.ccat) then  
 	 	 var.category.from =  tpprc241.ccat 	 	  
 	 	 var.category.to =  var.category.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc241.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc241.lacc  
 	 	 endif  
 	 	 if var.recon.area <>  0 then  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:241
:ICOD:S
:QURY:START
select 	 tpprc241.*
from tpprc241
order by tpprc241.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:241
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:242
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	 FILL_VAR_COMPANIES_WITH_NCMP (tpprc242)  
 	 if tpprc242.tent <>  save.posting.type.tete then  
 	 	 get.reconciliation.data.tpprc242 (  
 	 	 	 	 	 tpprc242.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.tete =  tpprc242.tent  
 	 endif  
 	  
 	 if not isspace (tpprc242.ccat) then  
 	 	 var.category.from =  tpprc242.ccat 	 	  
 	 	 var.category.to =  var.category.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc242.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc242.lacc  
 	 	 endif  
 	 	 if var.recon.area <>  0 then  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:242
:ICOD:S
:QURY:START
select 	 tpprc242.*
from tpprc242
order by tpprc242.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:242
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:243
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	 FILL_VAR_COMPANIES_WITH_NCMP (tpprc243)  
 	 if tpprc243.tent <>  save.posting.type.tete then  
 	 	 get.reconciliation.data.tpprc243 (  
 	 	 	 	 	 tpprc243.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.tete =  tpprc243.tent  
 	 endif  
 	  
 	 if tpprc243.coty <>  empty then  
 	 	 var.contract.execution.from =  tpprc243.coty 	  
 	 	 var.contract.execution.to =  var.contract.execution.from  
 	 endif  
 	 if tpprc243.agty <>  empty then  
 	 	 var.agreement.type.from =  tpprc243.agty 	  
 	 	 var.agreement.type.to =  var.agreement.type.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc243.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc243.lacc  
 	 	 endif  
 	 	 if var.recon.area <>  0 then  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:243
:ICOD:S
:QURY:START
select 	 tpprc243.*
from tpprc243
order by tpprc243.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:243
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:244
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	 FILL_VAR_COMPANIES_WITH_NCMP (tpprc244)  
 	 if tpprc244.tent <>  save.posting.type.tete then  
 	 	 get.reconciliation.data.tpprc244 (  
 	 	 	 	 	 tpprc244.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.tete =  tpprc244.tent  
 	 endif  
 	  
 	 if tpprc244.agty <>  empty then  
 	 	 var.agreement.type.from =  tpprc244.agty 	  
 	 	 var.agreement.type.to =  var.agreement.type.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc244.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc244.lacc  
 	 	 endif  
 	 	 if var.recon.area <>  0 then  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:244
:ICOD:S
:QURY:START
select 	 tpprc244.*
from tpprc244
order by tpprc244.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:244
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:245
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	 FILL_VAR_COMPANIES_WITH_NCMP (tpprc245)  
 	 if tpprc245.tent <>  save.posting.type.tete then  
 	 	 get.reconciliation.data.tpprc245 (  
 	 	 	 	 	 tpprc245.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.tete =  tpprc245.tent  
 	 endif  
 	  
 	 if not isspace (tpprc245.ccco) then  
 	 	 get.cost.components (bcorig.tppdm,  
 	 	 	 	 	 "",                                         
 	 	 	 	 	 tpprc245.ccco,  
 	 	 	 	 	 dummy.error.message)  
 	 	 var.cost.component.tp.from =  bcstc006.cost  
 	 	 var.cost.component.tp.to =  var.cost.component.tp.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc245.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc245.lacc  
 	 	 endif  
 	 	 if var.recon.area <>  0 then  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:245
:ICOD:S
:QURY:START
select 	 tpprc245.*
from tpprc245
order by tpprc245.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:245
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:246
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	 if tpprc246.tent <>  save.posting.type.tete then  
 	 	 get.reconciliation.data.tpprc246 (  
 	 	 	 	 	 tpprc246.tent,  
 	 	 	 	 	 var.trans.origin,  
 	 	 	 	 	 var.fin.trans,  
 	 	 	 	 	 number.of.entries,  
 	 	 	 	 	 array.additional.type,  
 	 	 	 	 	 array.recon.area,  
 	 	 	 	 	 array.recon.sub.area,  
 	 	 	 	 	 array.debit.credit,  
 	 	 	 	 	 array.order.priority,  
 	 	 	 	 	 array.priority)  
 	 	 save.posting.type.tete =  tpprc246.tent  
 	 endif  
 	  
 	 if not isspace (tpprc246.cprj) then  
 	 	 save.project =  get.tp.project (tpprc246.cprj)  
 	 	 var.project.from =  save.project  
 	 	 var.project.to =  var.project.from  
 	 endif  
 	 if not isspace (tpprc246.cspa) then  
 	 	 var.element.from =  tpprc246.cspa 	  
 	 	 var.element.to =  var.element.from  
 	 endif  
 	 var.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.project.package.linked.to =  var.project.package.linked.from  
 	 var.main.project.package.linked.from =  target(tcmcs.plnk.tp)  
 	 var.main.project.package.linked.to =  var.main.project.package.linked.from  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.recon.area =  0 then  
 	 	 	 continue  
 	 	 endif  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tpprc246.lacd  
 	 	 else  
 	 	 	 var.ledger.account =  tpprc246.lacc  
 	 	 endif  
 	 	 make.dump =  false  
 	 	 if not isspace (tpprc246.cprj) and  
 	 	 kind.of.project.tp =  tppdm.kopr.main then  
 	 	 	  
 	 	 	 write.dump.1 ()  
 	 	 	  
 	 	 	 var.priority =  var.priority +  1  
 	 	 	 INCREASE_VAR_SEQUENCE  
 	 	 	 var.main.project.from =  save.project  
 	 	 	 var.main.project.to =  save.project  
 	 	 	 var.project.from =  ""                                         
 	 	 	 var.project.to =  MAX_STRING  
 	 	 	 write.dump.1 ()  
 	 	 	  
 	 	 	 var.project.from =  save.project  
 	 	 	 var.project.to =  var.project.from  
 	 	 	 var.main.project.from =  ""                                         
 	 	 	 var.main.project.to =  MAX_STRING  
 	 	 else  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:246
:ICOD:S
:QURY:START
select 	 tpprc246.*  , tppdm600.kopr :kind.of.project.tp
from tpprc246, tppdm600
where tpprc246.cprj refers to tppdm600
order by tpprc246.tent
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:tp
:SCMOD:prc
:SFLNO:246
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:ts
:SCMOD:sma
:SFLNO:224
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	  
 	 if not isspace (tssma224.ctpc) then  
 	 	 var.service.contract.type.from =  tssma224.ctpc 	  
 	 	 var.service.contract.type.to =  var.service.contract.type.from  
 	 endif  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 var.fin.trans =  array.fin.trans (counter)  
 	 	 if var.fin.trans =  tcfitr.costs then  
 	 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 	 var.ledger.account =  tssma224.cdba  
 	 	 	 else  
 	 	 	 	 var.ledger.account =  tssma224.ccda  
 	 	 	 endif  
 	 	 else  
 	 	 	  
 	 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 	 var.ledger.account =  tssma224.pdba  
 	 	 	 else  
 	 	 	 	 var.ledger.account =  tssma224.pcda  
 	 	 	 endif  
 	 	 endif  
 	 	 if var.recon.area <>  0 then  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:ts
:SCMOD:sma
:SFLNO:224
:ICOD:S
:QURY:START
select 	 tssma224.*
from tssma224
order by tssma224.ctpc
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:ts
:SCMOD:sma
:SFLNO:224
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:ts
:SCMOD:sma
:SFLNO:601
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	  
 	 if not isspace (tssma601.ctpg) then  
 	 	 var.cost.type.group.from =  tssma601.ctpg 	  
 	 	 var.cost.type.group.to =  var.cost.type.group.from  
 	 endif  
 	 if tssma601.tcst <>  empty then  
 	 	 var.cost.type.ts.from =  ibcint1400.convert.cost.type.ts (tssma601.tcst)  
 	 	 var.cost.type.ts.to =  var.cost.type.ts.from  
 	 endif  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 var.ledger.account =  tssma601.dbac  
 	 	 else  
 	 	 	 var.ledger.account =  tssma601.cdac  
 	 	 endif  
 	 	 if var.recon.area <>  0 then  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:ts
:SCMOD:sma
:SFLNO:601
:ICOD:S
:QURY:START
select 	 tssma601.*
from tssma601
order by tssma601._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:ts
:SCMOD:sma
:SFLNO:601
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:ts
:SCMOD:sma
:SFLNO:602
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	  
 	 if not isspace (tssma602.cint) then  
 	 	 var.cost.analysis.type.from =  tssma602.cint 	  
 	 	 var.cost.analysis.type.to =  var.cost.analysis.type.from  
 	 endif  
 	 if tssma602.tcst <>  empty then  
 	 	 var.cost.type.ts.from =  ibcint1400.convert.cost.type.ts (tssma602.tcst)  
 	 	 var.cost.type.ts.to =  var.cost.type.ts.from  
 	 endif  
 	 if not isspace (tssma602.ctpg) then  
 	 	 var.cost.type.group.from =  tssma602.ctpg 	  
 	 	 var.cost.type.group.to =  var.cost.type.group.from  
 	 endif  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.recon.area =  0 then  
 	 	 	 continue  
 	 	 endif  
 	 	 var.fin.trans =  array.fin.trans (counter)  
 	 	 make.dump =  false  
 	 	 if var.fin.trans =  tcfitr.costs then  
 	 	 	 if (var.additional.type =  4 or  
 	 	 	 var.additional.type =  19) and 	  
 	 	 	 tssma602.tcst =  tssma.tcst.material then  
 	 	 	 	 make.dump =  true  
 	 	 	 endif  
 	 	 	 if var.additional.type <>  4 and  
 	 	 	 var.additional.type <>  19 and  
 	 	 	 tssma602.tcst <>  tssma.tcst.material then  
 	 	 	 	 make.dump =  true  
 	 	 	 endif  
 	 	 	  
 	 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 	 var.ledger.account =  tssma602.cdba  
 	 	 	 else  
 	 	 	 	 var.ledger.account =  tssma602.ccda  
 	 	 	 endif  
 	 	 else  
 	 	 	  
 	 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 	 var.ledger.account =  tssma602.pdba  
 	 	 	 else  
 	 	 	 	 var.ledger.account =  tssma602.pcda  
 	 	 	 endif  
 	 	 	 make.dump =  true  
 	 	 endif  
 	 	 if make.dump =  true then  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:ts
:SCMOD:sma
:SFLNO:602
:ICOD:S
:QURY:START
select 	 tssma602.*
from tssma602
order by tssma602._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:ts
:SCMOD:sma
:SFLNO:602
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:ts
:SCMOD:sma
:SFLNO:605
:ICOD:D
:QURY:START
set.min.max.for.leger.account.additions ()  
 	  
 	 if not isspace (tssma605.ctpc) then  
 	 	 var.service.contract.type.from =  tssma605.ctpc 	  
 	 	 var.service.contract.type.to =  var.service.contract.type.from  
 	 endif  
 	 if not isspace (tssma605.cint) then  
 	 	 var.cost.analysis.type.from =  tssma605.cint 	  
 	 	 var.cost.analysis.type.to =  var.cost.analysis.type.from  
 	 endif  
 	 if tssma605.tcst <>  empty then  
 	 	 var.cost.type.ts.from =  ibcint1400.convert.cost.type.ts (tssma605.tcst)  
 	 	 var.cost.type.ts.to =  var.cost.type.ts.from  
 	 endif  
 	 if not isspace (tssma605.ctpg) then  
 	 	 var.cost.type.group.from =  tssma605.ctpg 	  
 	 	 var.cost.type.group.to =  var.cost.type.group.from  
 	 endif  
 	 for counter =  1 to number.of.entries  
 	 	 INCREASE_VAR_SEQUENCE  
 	 	 FILL_VAR_INCL_PRIORITY_FROM_ARRAY  
 	 	 if var.recon.area =  0 then  
 	 	 	 continue  
 	 	 endif  
 	 	 var.fin.trans =  array.fin.trans (counter)  
 	 	 make.dump =  false  
 	 	 if var.fin.trans =  tcfitr.costs then  
 	 	 	 if (var.additional.type =  4 or  
 	 	 	 var.additional.type =  19) and 	  
 	 	 	 tssma605.tcst =  tssma.tcst.material then  
 	 	 	 	 make.dump =  true  
 	 	 	 endif  
 	 	 	 if var.additional.type <>  4 and  
 	 	 	 var.additional.type <>  19 and  
 	 	 	 tssma605.tcst <>  tssma.tcst.material then  
 	 	 	 	 make.dump =  true  
 	 	 	 endif  
 	 	 	  
 	 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 	 var.ledger.account =  tssma605.cdba  
 	 	 	 else  
 	 	 	 	 var.ledger.account =  tssma605.ccda  
 	 	 	 endif  
 	 	 else  
 	 	 	  
 	 	 	 if var.debit.credit =  tfgld.dbcr.debit then  
 	 	 	 	 var.ledger.account =  tssma605.pdba  
 	 	 	 else  
 	 	 	 	 var.ledger.account =  tssma605.pcda  
 	 	 	 endif  
 	 	 	 make.dump =  true  
 	 	 endif  
 	 	 if make.dump =  true then  
 	 	 	 write.dump.1 ()  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:ts
:SCMOD:sma
:SFLNO:605
:ICOD:S
:QURY:START
select 	 tssma605.*
from tssma605
order by tssma605._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:002
:SCPAC:ts
:SCMOD:sma
:SFLNO:605
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:020
:SCPAC:tf
:SCMOD:gld
:SFLNO:418
:ICOD:D
:QURY:START
	 old.warehouse =  ""                                                    
 	 if tfgld418.tror =  tctror.wrh.order then  
 	 	 temp.order =  str$(tfgld418.orno)  
 	 	 if temp.order(1;1) =  "7" then                                                    
 	 	 	 old.warehouse =  read.warehouse.wrh.order(  
 	 	 	 	 	 	 tfgld418.ocom,  
 	 	 	 	 	 	 tfgld418.tror,  
 	 	 	 	 	 	 tfgld418.fitr,  
 	 	 	 	 	 	 tfgld418.trdt,  
 	 	 	 	 	 	 tfgld418.trtm,  
 	 	 	 	 	 	 tfgld418.sern)  
 	 	 endif  
 	 endif  
 	 determine.order( 	 tfgld418.tror,  
 	 	 	 	 tfgld418.fitr,  
 	 	 	 	 tfgld418.orno,  
 	 	 	 	 old.warehouse,  
 	 	 	 	 var.order)  
 	 	 	 	 	 	 | #  SL214851.sn  
 	 determine.order.line( 	 tfgld418.tror,  
 	 	 	 	 tfgld418.fitr,  
 	 	 	 	 tfgld418.orno,  
 	 	 	 	 tfgld418.pono,  
 	 	 	 	 var.order.line)  
 	 	 	 	 	 	 | #  SL214851.en  
 	 determine.project(  
 	 	 	 	 tfgld418.ocom,  
 	 	 	 	 tfgld418.tror,  
 	 	 	 	 tfgld418.cprj,  
 	 	 	 	 var.project)  
 	 determine.kind.of.order(  
 	 	 	 	 tfgld418.tror,  
 	 	 	 	 tfgld418.fitr,  
 	 	 	 	 tfgld418.orno,  
 	 	 	 	 var.kind.of.order)  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:020
:SCPAC:tf
:SCMOD:gld
:SFLNO:418
:ICOD:S
:QURY:START
select 	 tfgld418.*
from 	 tfgld418
where 	 tfgld418.sint =  tfgld.sint.posted
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bc
:TCMOD:ttf
:TFLNO:020
:SCPAC:tf
:SCMOD:gld
:SFLNO:418
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bp
:TCMOD:tmm
:TFLNO:100
:SCPAC:ti
:SCMOD:hra
:SFLNO:100
:ICOD:D
:QURY:START
	 on case tihra100.koht  
 	 case tckoht.project:  
 	 	 fill.bptmm170()  
 	 	 break  
 	 case tckoht.production:  
 	 	 fill.bptmm120()  
 	 	 break  
 	 case tckoht.service:  
 	 	 if s.tano <>  tihra100.tano then  
 	 	 	 s.tano =  tihra100.tano  
 	 	 	 select 	 tssma320.tano  
 	 	 	 from 	 tssma320  
 	 	 	 where 	 tssma320._index1 =  {:tihra100.tano}  
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 	 s.service.rates.present =  true  
 	 	 	 selectempty  
 	 	 	 	 s.service.rates.present =  false  
 	 	 	 endselect  
 	 	 endif  
 	 	 if s.service.rates.present =  true then  
 	 	 	 fill.bptmm130()  
 	 	 endif  
 	 	 break  
 	 case tckoht.indirect:  
 	 case tckoht.absent:  
 	 	 fill.bptmm111()  
 	 	 break  
 	 case tckoht.prd.pmg:  
 	 	 break  
 	 default:  
 	 	 break  
 	 endcase
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bp
:TCMOD:tmm
:TFLNO:100
:SCPAC:ti
:SCMOD:hra
:SFLNO:100
:ICOD:S
:QURY:START
select 	 tihra100.*
from 	 tihra100
where 	 tihra100.koht <>  tckoht.prd.pmg  
 and 	 tihra100.htpr =  tcyesno.no
order by tihra100.year, tihra100.week, tihra100.emno, tihra100.koht 	 | #  158562.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bp
:TCMOD:tmm
:TFLNO:100
:SCPAC:ti
:SCMOD:hra
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bp
:TCMOD:tmm
:TFLNO:200
:SCPAC:ti
:SCMOD:hra
:SFLNO:100
:ICOD:D
:QURY:START
	 hra.period.definition =  true  
 	 on case tihra100.koht  
 	 case tckoht.project:  
 	 	 fill.and.dump.bptmm270()  
 	 	 break  
 	 case tckoht.production:  
 	 	 fill.and.dump.bptmm220()  
 	 	 break  
 	 case tckoht.service:  
 	 	 fill.and.dump.bptmm230.from.tihra100()  
 	 	 break  
 	 case tckoht.indirect:  
 	 case tckoht.absent:  
 	 	 fill.and.dump.bptmm211.from.tihra100()  
 	 	 break  
 	 case tckoht.prd.pmg:  
 	 	 break  
 	 default:  
 	 	 break  
 	 endcase
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bp
:TCMOD:tmm
:TFLNO:200
:SCPAC:ti
:SCMOD:hra
:SFLNO:100
:ICOD:S
:QURY:START
select 	 tihra100.*
from 	 tihra100
where 	 tihra100.koht <>  tckoht.prd.pmg  
 and 	 tihra100.htpr =  tcyesno.yes
order by tihra100.year, tihra100.week, tihra100.emno, tihra100.koht 	 | #  158562.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bp
:TCMOD:tmm
:TFLNO:200
:SCPAC:ti
:SCMOD:hra
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bp
:TCMOD:tmm
:TFLNO:200
:SCPAC:tp
:SCMOD:hrs
:SFLNO:100
:ICOD:D
:QURY:START
	 on case tphrs100.splt  
 	 case tphrs.splt.project:  
 	 case tphrs.splt.finance:  
 	 case tphrs.splt.no:  
 	 	 if expense.record.with.zero.amount(  
 	 	 	 	 	 tphrs100.amnt,  
 	 	 	 	 	 tphrs100.empr,  
 	 	 	 	 	 tphrs100.wgco) then  
 	 	 	 continue  
 	 	 endif  
 	 	 fill.and.dump.bptmm211.from.tphrs100()  
 	 	 break  
 	 case tphrs.splt.service:  
 	 	 fill.and.dump.bptmm230.from.tphrs100()  
 	 	 break  
 	 case tphrs.splt.ism.services:  
 	 case tphrs.splt.ism.man.equ:  
 	 	 break  
 	 default:  
 	 	 break  
 	 endcase
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bp
:TCMOD:tmm
:TFLNO:200
:SCPAC:tp
:SCMOD:hrs
:SFLNO:100
:ICOD:S
:QURY:START
select 	 tphrs100.*
from 	 tphrs100
where 	 (tphrs100.splt <>  tphrs.splt.ism.services  
 and 	 tphrs100.splt <>  tphrs.splt.ism.man.equ)  
 and 	 tphrs100.stat <>  tphrs.stat.free
order by tphrs100._index2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:bp
:TCMOD:tmm
:TFLNO:200
:SCPAC:tp
:SCMOD:hrs
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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()  
 	 	 	 	 get.tax.by.country.code( tdcms201.ccty, |ravi_july28th.sn  
 	 	 	 	 	 tdcms201.cvat,  
 	 	 	 	 	 new.txct,  
 	 	 	 	 	 new.txid,  
 	 	 	 	 	 err.mess)  
 	 	 	 	 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) 	  
 	 	 	 	 	 	 	 	 | #  ravi_array.en  
 	 	 	 	 	 	 	 	 	 | #  207750.eo  
 	 	 	 	 	 	 	 	 	 | #  207750.sn  
 	 	 	 if update.tax.amounts.array(new.txid, 	 	 	 	 | #  207750.sn  
 	 	 	 	 	 var.cisli295.txai, var.cisli295.amti) then 	 | #  207750.en  
 	 	 	 	 	 	 	 |ravi_july28th.sn  
 	 	 	 	 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))  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en  
 	 	 	  
 	 	 	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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)  
 	 	 	 	 	  
 	 	 	 if update.tax.amounts.array(new.txid, 	 	 	 | #  207750.sn  
 	 	 	 	 	 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)  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en  
 	 	 	 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))  
 	 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en  
 	 	 	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 	 	 get.tax.by.country.code (  
 	 	 	 	 	 tfacr401.vatc,  
 	 	 	 	 	 tfacr401.cvat,  
 	 	 	 	 	 new.txct,  
 	 	 	 	 	 new.txid,  
 	 	 	 	 	 err.mess)  
 	 	 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)  
 | 	 	 update.tax.amounts.array(new.txid, 	 	 	 	 | #  ravi_array.sn  
 | 	 	 	 	 amnt.cvat, nett.amnt) 	  
 	 	 	 	 	 	 	 	 	 	 | #  ravi_array.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  
 	 	 	 	 	 	  
 	 	 	 if update.tax.amounts.array(new.txid, 	 | #  207750.sn  
 	 	 	 	 amnt.cvat, nett.amnt) then 	 | #  207750.en  
 	 	 	 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  
 	 	 	  
 	 	 	 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  
 	 	  
 	 	 dump.cisli205 ()  
 	 	 reset.variables.cisli205 ()  
 	 endif 	 	 	 	 	 	 	 	 |bin.n  
 	 endif 	 	 	 	 	 	 | #  SL -  146520.n 	  
 	 free.memories() 	 	 	 	 |ravi_array.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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 (  
 	 	 	 	 	 	 	 	 tfacr200.vatc,  
 	 	 	 	 	 	 	 	 temp.txid,  
 	 	 	 	 	 	 	 	 var.cisli210.txct,  
 	 	 	 	 	 	 	 	 var.cisli210.txid,  
 	 	 	 	 	 	 	 	 err.mess)  
 	 	 	 	 	 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  
 	 	 	 	 	 	 	 | *  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  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  207750.sn  
 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 if update.tax.amounts.array(var.cisli210.txid, 	  
 	 	 	 	 	 	 	 	 	 	 var.cisli210.txai, var.tfacr510.amnt) then 	 	 	  
 	 	 	 	 	 	 	 	 	 	 	 	 	 | #  207750.en  
 	 	 	 	 	 	 	 	 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  
 	 | 	 	 	 	 	 endif 	 	 	 	 | #  200 -  101240.o  
 	 	 	 	 	 	 	 	 	 	 	 	 | #  207750.sn  
 	 	 	 	 	 	 	 	 cisli209.dumped =  true  
 	 	 	 	 	 	 else  
 	 	 	 	 	 	 	 	 cisli209.dumped =  false  
 	 	 	 	 	 	 endif  
 	 	 	 	 	 	 	 	 	 	 	 	 | #  207750.en  
 	 	 	 	 	 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))  
 	 	 	 	 	 	 	 	 	 	 | #  200 -  101927.en  
 	 	 	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 	 	 	 	 	 tssma611.ccty,  
 	 	 	 	 	 tssma220.cvat,  
 	 	 	 	 	 new.txct,  
 	 	 	 	 	 new.txid,  
 	 	 	 	 	 err.mess)  
 	 	 	 	 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  
 	 	 	 	 	 	 	 	 | #  207750.so  
 | 	 	 	 update.tax.amounts.array( tssma220.cvat,  
 | 	 	 	 	 	 var.cisli265.txai, var.cisli265.amti) 	  
 	 	 	 	 	 	 	 	 | #  ravi_array.en  
 	 	 	 	 	 	 	 	 | #  207750.eo  
 	 	 	 	 	 	 	 	 |ravi_july28th.sn  
 	 	 	 if update.tax.amounts.array( tssma220.cvat, 	 | #  207750.sn  
 	 	 	 	 	 var.cisli265.txai, var.cisli265.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.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 (  
 	 	 	 	 tssma611.ccty,  
 	 	 	 	 tssma612.cvat,  
 	 	 	 	 new.txct,  
 	 	 	 	 new.txid,  
 	 	 	 	 err.mess)  
 	 	 	 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)  
 	 	 	 	 	 	 	 	 	 	 	 | #  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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 	 	 	 	 	 	 tssma310.ccty,  
 	 	 	 	 	 	 tssma310.cvat,  
 	 	 	 	 	 	 new.txct,  
 	 	 	 	 	 	 new.txid,  
 	 	 	 	 	 	 err.mess) 	 	 |ravi_july28th.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)  
 	 	 	 if update.tax.amounts.array(tssma310.cvat, 	 	 	 | #  207750.sn  
 	 	 	 	 	 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 (  
 	 	 	 	 tssma301.ccty,  
 	 	 	 	 tssma612.cvat,  
 	 	 	 	 new.txct,  
 	 	 	 	 new.txid,  
 	 	 	 	 err.mess)  
 	 	 	 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)  
 	 	 	 	 	 	 	 	 	 	 	 	 | #  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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rmp
:TFLNO:300
:SCPAC:cp
:SCMOD:rmp
:SFLNO:300
:ICOD:D
:QURY:START
	 order.horizon.date =  date.num() +  plni.tmfc *  cprpd000.tfmf  
 	 get.scenario(get.compnr(), cprmp300.plnc, var.cprmp300.plnc, err.mess)  
 	 var.cprmp300.plni =  cp.segment.item.code(cprmp300.plni, itm.cprj, itm.clus)  
 	 if cprmp300.plni <>  tcitem.prev.plni then  
 	 	 select 	 tiitm001.kitm,  
 	 	 	 tiitm001.cuni:item.cuni  
 	 	 from 	 tiitm001  
 	 	 where 	 tiitm001._index1 =  {:cprmp300.plni}  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 if tiitm001.kitm =  tckitm.purchase then  
 	 	 	 	 create.purchase.plan =  true  
 	 	 	 else  
 	 	 	 	 create.purchase.plan =  false  
 	 	 	 endif  
 	 	 selectempty  
 	 	 	 create.purchase.plan =  false  
 	 	 	 item.cuni =  ""                                                
 	 	 endselect  
 	 	 tcitem.prev.plni =  cprmp300.plni  
 	 endif  
 	 if determine.conversion.factor(cprmp300.plnc, cprmp300.plni, cprmp300.cont, item.cuni, plni.cuni, conversion.factor, err.mess) <>  0 then  
 	 	 continue  
 	 endif  
 	 | *  Note the different mechanism: in BaanIV, the Plan acts like 'demand' to the Planned Orders.  
 	 | *  In Baan6, Plan and Planned Orders are separated.  
 	 | *  Therefore: Make Plan =  0 within Order Horizon  
 	 if cprmp300.sdat <  order.horizon.date then  
 	 	 var.cprmp300.prec =  0  
 	 	 var.cprmp300.pupl =  0  
 	 	 if create.purchase.plan then  
 	 	 	 var.cprmp300.ppur =  cprmp300.srec *  conversion.factor  
 	 	 	 var.cprmp300.ppor =  0  
 	 	 else  
 	 	 	 var.cprmp300.ppur =  0  
 	 	 	 var.cprmp300.ppor =  cprmp300.srec *  conversion.factor  
 	 	 endif  
 	 else  
 	 	 if create.purchase.plan then  
 	 	 	 var.cprmp300.prec =  0  
 	 	 	 var.cprmp300.pupl =  max((cprmp300.prec -  cprmp300.srec) *  conversion.factor, 0.0)  
 	 	 	 var.cprmp300.ppur =  cprmp300.srec *  conversion.factor  
 	 	 	 var.cprmp300.ppor =  0  
 	 	 else  
 	 	 	 var.cprmp300.prec =  max((cprmp300.prec -  cprmp300.srec) *  conversion.factor, 0.0)  
 	 	 	 var.cprmp300.pupl =  0  
 	 	 	 var.cprmp300.ppur =  0  
 	 	 	 var.cprmp300.ppor =  cprmp300.srec *  conversion.factor  
 	 	 endif  
 	 endif  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rmp
:TFLNO:300
:SCPAC:cp
:SCMOD:rmp
:SFLNO:300
:ICOD:S
:QURY:START
select 	 cprmp300.*  , cprpd100.cuni:plni.cuni, cprpd100.tmfc:plni.tmfc
from 	 cprmp300, cprpd100
where 	 cprmp300.cont =  ""                                                
 and 	 cprmp300.cmba refers to cprpd100
order by cprmp300._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rmp
:TFLNO:300
:SCPAC:cp
:SCMOD:rmp
:SFLNO:300
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rmp
:TFLNO:300
:SCPAC:ti
:SCMOD:mps
:SFLNO:300
:ICOD:D
:QURY:START
	 if timps300.plnc <>  timps.plnc.prev.plnc then  
 	 	 select 	 timps100.plsd:scenario.sdat  
 	 	 from 	 timps100  
 	 	 where 	 timps100._index1 =  {:timps300.plnc}  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 endselect  
 	 endif  
 	 if timps300.plnc =  timps.plnc.prev.plnc and  
 	 timps300.plvl =  timps.plvl.prev.plvl and  
 	 timps300.plni =  tcitem.prev.plni then  
 	 	 var.cprmp300.pern =  var.cprmp300.pern +  1  
 	 else  
 	 	 var.cprmp300.pern =  1  
 	 	 var.cprmp300.sdat =  scenario.sdat  
 	 	 timps.plnc.prev.plnc =  timps300.plnc  
 	 	 timps.plvl.prev.plvl =  timps300.plvl  
 	 	 tcitem.prev.plni =  timps300.plni  
 	 	 select 	 tiitm001.item:dum.item  
 	 	 from 	 tiitm001  
 	 	 where 	 tiitm001._index1 =  {:timps300.plni}  
 	 	 and 	 tiitm001.kitm =  tckitm.purchase  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 create.purchase.plan =  true  
 	 	 selectempty  
 	 	 	 create.purchase.plan =  false  
 	 	 endselect  
 	 endif 	  
 	 get.scenario(get.compnr(), timps300.plnc, var.cprmp300.plnc, err.mess)  
 	 var.cprmp300.plni =  cp.segment.item.code(timps300.plni, itm.cprj, itm.clus)  
 	 if create.purchase.plan then  
 	 	 	 var.cprmp300.prec =  0  
 	 	 	 var.cprmp300.pupl =  timps300.prec -  timps300.cspr  
 	 	 	 var.cprmp300.ppur =  timps300.srec  
 	 	 	 var.cprmp300.ppor =  0  
 	 else  
 	 	 	 var.cprmp300.prec =  timps300.prec -  timps300.cspr  
 	 	 	 var.cprmp300.pupl =  0  
 	 	 	 var.cprmp300.ppur =  0  
 	 	 	 var.cprmp300.ppor =  timps300.srec  
 	 endif  
 	 dump 1  
 	 var.cprmp300.sdat =  timps300.pdat +  1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rmp
:TFLNO:300
:SCPAC:ti
:SCMOD:mps
:SFLNO:300
:ICOD:S
:QURY:START
select timps300.*
from timps300
where timps300.plct =  ""
order by timps300._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rmp
:TFLNO:300
:SCPAC:ti
:SCMOD:mps
:SFLNO:300
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rpd
:TFLNO:000
:SCPAC:cp
:SCMOD:rpd
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rpd
:TFLNO:000
:SCPAC:ti
:SCMOD:mps
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rpd
:TFLNO:000
:SCPAC:ti
:SCMOD:mrp
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:011
:SCPAC:cp
:SCMOD:rmp
:SFLNO:530
:ICOD:D
:QURY:START

	 get.scenario(get.compnr(), cprmp530.plnc, var.cprmp530.plnc, err.mess)  
 	 var.cprmp530.plni =  cp.segment.item.code(cprmp530.ritm, itm.cprj, itm.clus)  
 	 var.cprmp530.opli =  cp.segment.item.code(cprmp530.plni, itm.cprj, itm.clus)  
 	 if determine.conversion.factor(cprmp530.plnc, cprmp530.ritm, cprmp530.rcon, "", plni.cuni, conversion.factor, err.mess) <>                                    0 then                                                                      
 	 	 continue  
 	 endif  
 	 var.cprmp530.rqua =  cprmp530.rqua *  conversion.factor  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:011
:SCPAC:cp
:SCMOD:rmp
:SFLNO:530
:ICOD:S
:QURY:START

select 	 cprmp530.*  , cprmp420.sdat:var.per.sdat, cprpd100.cuni:plni.cuni
from 	 cprmp530, cprmp420, cprpd100
where 	 cprmp530.cont =  ""                              
 and 	 cprmp530.rcon =  ""                      
 and 	 cprmp420._index1 =  {cprmp530.plnc, cprmp530.rper}  
 and 	 cprmp530.cmbb refers to cprpd100 unref clear
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:011
:SCPAC:cp
:SCMOD:rmp
:SFLNO:530
:ICOD:X
:QURY:START

  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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.cprrp110.oqan,  
 	 	 	 timps320.ssit:var.cprrp110.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.cprrp110.oqan,  
 	 	 	 cprmp150.ssit:var.cprrp110.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.cprrp110.suwa  
 	 from 	 tiitm001  
 	 where 	 tiitm001._index1 =  {:bcscp004.plni}  
 	 and 	 tiitm001._compnr =  :var.cprrp110.susi  
 	 as set with 1 rows  
 	 selectempty  
 	 	 | *  This can happen for Family Items. Select from other company !   
 	 	 select 	 bcscp000.cwar:var.cprrp110.suwa  
 	 	 from 	 bcscp000  
 	 	 where 	 bcscp000._compnr =  :var.cprrp110.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.cprrp110.supl =  var.cprrp100.item  
 	 dump 1  
 	 dump 2  
 	 dump 5
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:bc
:SCMOD:scp
:SFLNO:004
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:cp
:SCMOD:rmp
:SFLNO:140
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:td
:SCMOD:inv
:SFLNO:150
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:310
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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.cprrp110.susi =  timps510.iprl  
 	 	 select tiitm001.cwar:var.cprrp110.suwa  
 	 	 from 	 tiitm001  
 	 	 where 	 tiitm001._index1 =  {:timps510.item}  
 	 	 and 	 tiitm001._compnr =  :var.cprrp110.susi  
 	 	 as set with 1 rows  
 	 	 selectempty  
 	 	 	 select bcscp000.cwar:var.cprrp110.suwa  
 	 	 	 from 	 bcscp000  
 	 	 	 where 	 bcscp000._compnr =  :var.cprrp110.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.cprrp110.oqan =  timps510.oqan  
 	 	 var.cprrp110.supl =  var.cprrp100.item  
 	 	 dump 1 | *  Planned Orders  
 	 	 dump 2 	 | *  Planned Order Lines  
 	 	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:510
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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.cprrp110.oqan =  timps520.oqan  
 	 var.cprrp110.opro =  timps520.opro  
 | #  800 -  142873.sn  
 	 var.cprrp110.txta =  empty()  
 | #  800 -  142873.en  
 	 dump 1  
 	 dump 3  
 	 dump 5
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:520
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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.cprrp110.oqan =  timps530.oqan  
 	 var.cprrp110.suno =  get.business.partner.code(timps530.suno, bcstc.orgn.suno, err.mess)  
 | #  800 -  142873.sn  
 	 var.cprrp110.txta =  empty()  
 | #  800 -  142873.en  
 	 dump 1  
 	 dump 4  
 	 dump 5
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:530
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mrp
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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.cprrp110.oqan =  timrp020.oqan  
 	 var.cprrp100.cplb =  timrp020.cplb  
 	 var.cprrp100.osta =  get.mrp.osta(timrp020.osta)  
 	 var.cprrp100.dwar =  timrp020.cwar  
 	 var.cprrp110.opro =  timrp020.opro  
 | #  800 -  142873.sn  
 	 var.cprrp110.txta =  empty()  
 | #  800 -  142873.en  
 	 dump 1  
 	 dump 3  
 	 dump 5
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mrp
:SFLNO:020
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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.cprrp110.oqan =  timrp021.oqan  
 	 var.cprrp110.suno =  get.business.partner.code(timrp021.suno, bcstc.orgn.suno, err.mess)  
 | #  800 -  142873.sn  
 	 var.cprrp110.txta =  empty()  
 | #  800 -  142873.en  
 	 dump 1  
 	 dump 4  
 	 dump 5
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mrp
:SFLNO:021
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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.cprrp110.oqan =  timrp022.oqan  
 	 var.cprrp110.opro =  timrp022.opro  
 | #  800 -  142873.sn  
 	 var.cprrp110.txta =  empty()  
 | #  800 -  142873.en  
 	 dump 1  
 	 dump 3  
 	 dump 5
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mrp
:SFLNO:022
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 | #  200314.sn  
 	 itm.cprj =  get.ti.project(tipcs500.cprj)  
 | #  200314.en  
 	 if not get.cluster(var.curr.site, itm.cwar, err.mess) then  
 	 	 itm.clus =  bcswh001.dicl  
 	 else  
 	 	 itm.clus =  ""                                                                                                                                                                                                                                                                                                                                                                                                      
 	 endif  
 | #  200314.so  
 | 	 if get.plan.item(tipcs500.item, tipcs500.cprj, itm.clus, err.mess) then  
 | #  200314.eo  
 | #  200314.sn  
 	 if get.plan.item(tipcs500.item, itm.cprj, itm.clus, err.mess) then  
 | #  200314.en  
 	 | *  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
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:pcs
:SFLNO:500
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:pcs
:SFLNO:510
:ICOD:D
:QURY:START
| #  200314.so  
 | 	 itm.cprj =  tipcs510.cprj  
 | #  200314.eo  
 | #  200314.sn  
 	 itm.cprj =  get.ti.project(tipcs510.cprj)  
 | #  200314.en  
 	 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.cprrp110.oqan =  tipcs510.oqan  
 	 var.cprrp110.opro =  get.routing(tipcs510.cprj, tipcs510.item)  
 | #  800 -  142873.sn  
 	 var.cprrp110.txta =  tipcs510.txta  
 | #  800 -  142873.en  
 	 dump 1  
 	 dump 3  
 	 dump 5
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:pcs
:SFLNO:510
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:pcs
:SFLNO:520
:ICOD:D
:QURY:START
| #  200314.so  
 | 	 itm.cprj =  tipcs520.cprj  
 | #  200314.eo  
 | #  200314.sn  
 	 itm.cprj =  get.ti.project(tipcs520.cprj)  
 | #  200314.en  
 	 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.cprrp110.oqan =  tipcs520.oqan  
 	 var.cprrp110.suno =  get.business.partner.code(tipcs520.suno, bcstc.orgn.suno, err.mess)  
 | #  800 -  142873.sn  
 	 var.cprrp110.txta =  tipcs520.txta  
 | #  800 -  142873.en  
 	 dump 1  
 	 dump 4  
 	 dump 5
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:pcs
:SFLNO:520
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:tr
:SCMOD:drp
:SFLNO:015
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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.cprrp110.supl =  cp.segment.item.code(trdrp020.item, itm.cprj, sup.clus)  
 	 var.cprrp110.susi =  var.curr.site  
 	 var.cprrp110.suwa =  trdrp020.rwar  
 	 var.cprrp110.oqan =  trdrp020.oqua  
 	 dump 1  
 	 dump 2  
 	 dump 5
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:tr
:SCMOD:drp
:SFLNO:020
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ec
:TCMOD:edi
:TFLNO:200
:SCPAC:tc
:SCMOD:edi
:SFLNO:200
:ICOD:D
:QURY:START
| 	 	 	 	 	 	 	 	 | #  202607.so  
 | 	 var.ecedi200.orga =  ""        
 | 	 var.ecedi200.mess =  ""        
 | 	 if not get.EDI.mappings( tcedi200.orga,  
 | 	 	 	 	 tcedi200.mess,  
 | 	 	 	 	 dummy.errmess) then  
 | 	 	 var.ecedi200.orga =  bcstc028.norg  
 | 	 	 var.ecedi200.mess =  bcstc028.nmes  
 | 	 	 if var.ecedi200.orga =  bcstc028.orga then  
 | 	 	 	 select 	 bcstc028.norg  
 | 	 	 	 from 	 bcstc028  
 | 	 	 	 where 	 bcstc028._index1 =  {:tcedi200.orga, ""}        
 | 	 	 	 as set with 1 rows  
 | 	 	 	 selectdo  
 | 	 	 	 	 var.ecedi200.orga =  bcstc028.norg  
 | 	 	 	 endselect  
 | 	 	 endif  
 | 	 endif  
 | 	 if isspace(var.ecedi200.orga) then  
 | 	 	 var.ecedi200.orga =  tcedi200.orga  
 | 	 endif  
 | 	 if isspace(var.ecedi200.mess) then  
 | 	 	 var.ecedi200.mess =  tcedi200.mess  
 | 	 endif  
 | 	 dump 1  
 | 	 	 	 	 	 	 	 	 | #  202607.eo  
 	 	 	 	 	 	 	 	 | #  202607.sn  
 	 var.ecedi200.orga =  ""        
 	 var.ecedi200.mess =  ""        
 	 if not get.EDI.mappings(  
 	 	 	 	 tcedi200.orga,  
 	 	 	 	 tcedi200.mess,  
 	 	 	 	 "",        
 	 	 	 	 dummy.errmess) then  
 	 	 | *  specific organisation /  message mapping exist. Beware of  
 	 	 | *  possible duplicate values (aggregate messages).  
 	 	 if added.to.array() then  
 	 	 	 var.ecedi200.orga =  bcstc028.norg  
 	 	 	 var.ecedi200.mess =  bcstc028.nmes  
 	 	 else  
 	 	 	 |duplicate value in array skip inserting record  
 	 	 	 continue  
 	 	 endif  
 	 else  
 	 	 if not get.EDI.mappings( tcedi200.orga,  
 	 	 	 	 	 "",        
 	 	 	 	 	 "",        
 	 	 	 	 	 dummy.errmess) then  
 	 	 	 | *  All messages for organisation are mapped  
 	 	 	 var.ecedi200.orga =  bcstc028.norg  
 	 	 	 var.ecedi200.mess =  tcedi200.mess  
 	 	 else  
 	 	 	 | *  No mapping at all  
 	 	 	 var.ecedi200.orga =  tcedi200.orga  
 	 	 	 var.ecedi200.mess =  tcedi200.mess  
 	 	 endif  
 	 endif  
 	 dump 1  
 	 	 	 	 	 	 	 	 | #  202607.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ec
:TCMOD:edi
:TFLNO:200
:SCPAC:tc
:SCMOD:edi
:SFLNO:200
:ICOD:S
:QURY:START
select tcedi200.*
from tcedi200
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ec
:TCMOD:edi
:TFLNO:200
:SCPAC:tc
:SCMOD:edi
:SFLNO:200
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ec
:TCMOD:edi
:TFLNO:463
:SCPAC:tc
:SCMOD:edi
:SFLNO:448
:ICOD:D
:QURY:START
	 var.ecedi448.orga =  ""                          
 	 if not get.EDI.mappings( tcedi448.orga,  
 	 	 	 	 dummy.mess,  
 	 	 	 	 "",                                      
 	 	 	 	 dummy.errmess) then  
 	 	 var.ecedi448.orga =  bcstc028.norg  
 	 endif  
 	 if isspace(var.ecedi448.orga) then  
 	 	 var.ecedi448.orga =  tcedi448.orga  
 	 endif  
 	 var.ecedi463.bpid =  ""                          
 	 if not get.business.partner(tcedi448.cuno,  
 	 	 	 	 	 bcstc.orgn.cuno,  
 	 	 	 	 	 err.mess) then  
 	 	 var.ecedi463.bpid =  bcstc008.bpid  
 	 	 dump 1  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ec
:TCMOD:edi
:TFLNO:463
:SCPAC:tc
:SCMOD:edi
:SFLNO:448
:ICOD:S
:QURY:START
select tcedi448.*
from tcedi448
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ec
:TCMOD:edi
:TFLNO:463
:SCPAC:tc
:SCMOD:edi
:SFLNO:448
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ec
:TCMOD:edi
:TFLNO:463
:SCPAC:tc
:SCMOD:edi
:SFLNO:450
:ICOD:D
:QURY:START
	 var.ecedi450.orga =  ""                      
 	 if not get.EDI.mappings( tcedi450.orga,  
 	 	 	 	 dummy.mess,  
 	 	 	 	 "",                                  
 	 	 	 	 dummy.errmess) then  
 	 	 var.ecedi450.orga =  bcstc028.norg  
 	 endif  
 	 if isspace(var.ecedi450.orga) then  
 	 	 var.ecedi450.orga =  tcedi450.orga  
 	 endif  
 	 var.ecedi463.bpid =  ""                      
 	 if not get.business.partner( 	 tcedi450.cuno,  
 	 	 	 	 	 bcstc.orgn.cuno,  
 	 	 	 	 	 err.mess) then  
 	 	 var.ecedi463.bpid =  bcstc008.bpid  
 	 	 dump 2  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ec
:TCMOD:edi
:TFLNO:463
:SCPAC:tc
:SCMOD:edi
:SFLNO:450
:ICOD:S
:QURY:START
select tcedi450.*
from tcedi450
where not exists(  
 	 select tcedi448.cuno  
 	 from 	 tcedi448  
 	 where 	 tcedi448._index1 =  {tcedi450.cuno, tcedi450.orga, tcedi450.loct})
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ec
:TCMOD:edi
:TFLNO:463
:SCPAC:tc
:SCMOD:edi
:SFLNO:450
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ec
:TCMOD:edi
:TFLNO:463
:SCPAC:tc
:SCMOD:edi
:SFLNO:451
:ICOD:D
:QURY:START
	 var.ecedi451.orga =  ""                      
 	 if not get.EDI.mappings( tcedi451.orga,  
 	 	 	 	 dummy.mess,  
 	 	 	 	 "",                              
 	 	 	 	 dummy.errmess) then  
 	 	 var.ecedi451.orga =  bcstc028.norg  
 	 endif  
 	 if isspace(var.ecedi451.orga) then  
 	 	 var.ecedi451.orga =  tcedi451.orga  
 	 endif  
 	 var.ecedi463.bpid =  ""                      
 	 if not get.business.partner(tcedi451.suno,  
 	 	 	 	 bcstc.orgn.suno,  
 	 	 	 	 err.mess) then  
 	 	 var.ecedi463.bpid =  bcstc008.bpid  
 	 	 dump 3  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ec
:TCMOD:edi
:TFLNO:463
:SCPAC:tc
:SCMOD:edi
:SFLNO:451
:ICOD:S
:QURY:START
select tcedi451.*
from tcedi451
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ec
:TCMOD:edi
:TFLNO:463
:SCPAC:tc
:SCMOD:edi
:SFLNO:451
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:fm
:TCMOD:foc
:TFLNO:000
:SCPAC:tr
:SCMOD:toc
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:fm
:TCMOD:frc
:TFLNO:250
:SCPAC:td
:SCMOD:pur
:SFLNO:028
:ICOD:D
:QURY:START
	 if strip$(hold.item) =  strip$(tdpur028.item) and  
 	 strip$(hold.ccos) =  strip$(tdpur028.ccos) then  
 	 	 | *  skip duplicates  
 	 	 continue  
 	 else  
 	 	 hold.item =  tdpur028.item  
 	 	 hold.ccos =  tdpur028.ccos  
 	 	 fill.fmfrc.record.variables( 	 tdpur028.item,  
 	 	 	 	 	 	 etol(tdpur028.luni),  
 	 	 	 	 	 	 tdpur028.llim,  
 	 	 	 	 	 	 tdpur028.ulim)  
 	 	 dump 2  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:fm
:TCMOD:frc
:TFLNO:250
:SCPAC:td
:SCMOD:pur
:SFLNO:028
:ICOD:S
:QURY:START
select 	 tdpur028.*
from 	 tdpur028
where 	 tdpur028.crtr =  tcyesno.yes  
 and 	 not exists( 	 select 	 tdsls028.ccos  
 	 	 	 from 	 tdsls028  
 	 	 	 where 	 tdsls028._index1 =  {tdpur028.ccos}  
 	 	 	 and 	 tdsls028.crtr =  tcyesno.yes 	 )
order by tdpur028.ccos, tdpur028.item
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:fm
:TCMOD:frc
:TFLNO:250
:SCPAC:td
:SCMOD:pur
:SFLNO:028
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:fm
:TCMOD:frc
:TFLNO:250
:SCPAC:td
:SCMOD:sls
:SFLNO:028
:ICOD:D
:QURY:START
	 if strip$(hold.item) =  strip$(tdsls028.item) and  
 	 strip$(hold.ccos) =  strip$(tdsls028.ccos) then  
 	 	 | *  skip duplicates  
 	 	 continue  
 	 else  
 	 	 hold.item =  tdsls028.item  
 	 	 hold.ccos =  tdsls028.ccos  
 	 	 fill.fmfrc.record.variables( 	 tdsls028.item,  
 	 	 	 	 	 	 etol(tdsls028.luni),  
 	 	 	 	 	 	 tdsls028.llim,  
 	 	 	 	 	 	 tdsls028.ulim)  
 	 	 dump 1  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:fm
:TCMOD:frc
:TFLNO:250
:SCPAC:td
:SCMOD:sls
:SFLNO:028
:ICOD:S
:QURY:START
select 	 tdsls028.*
from 	 tdsls028
where 	 tdsls028.crtr =  tcyesno.yes
order by tdsls028.ccos, tdsls028.item
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:fm
:TCMOD:frc
:TFLNO:250
:SCPAC:td
:SCMOD:sls
:SFLNO:028
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:fm
:TCMOD:lbd
:TFLNO:000
:SCPAC:tr
:SCMOD:top
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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
from tccom000
where tccom000.ncmp =  :current.compnr
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:001
:SCPAC:bc
:SCMOD:sts
:SFLNO:000
:ICOD:D
:QURY:START
	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:001
:SCPAC:bc
:SCMOD:sts
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:001
:SCPAC:tc
:SCMOD:com
:SFLNO:001
:ICOD:X
:QURY:START
	 	 	 	 	 	 | #  205573.en  
 	 	 	 	 	 	  
 select 	 tccom001.*   
 from 	 tccom001  
 selectdo  
 	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 | 	 endif 	 	 	 	 	 	 	 | #  214051.o  
 	 if var.tccom100.sndr =  tcyesno.yes then 	 	 	 | #  214051.sn  
 	 | *  One -  Time BP should not get a Parent BP filled.  
 	 	 var.tccom100.prbp =  ""      
 	 else  
 	 	 var.tccom100.prbp =  hold.tccom100.prbp  
 	 endif 	 	 	 	 	 	 	 | #  214051.en  
 	 if tccom010.inrl =  empty 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  
 	  
 	 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  
 	 dump 3  
 	 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  
 	 dump 5  
 	 add.business.partner.to.list(var.tccom100.bpid) 	 | #  800 -  141749.n  
 	 create.bps.for.delivery.adresses() 	 	 | #  201931.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 	 | *  One -  Time BP should not get a Parent BP filled.  
 	 	 var.tccom100.prbp =  ""      
 	 else  
 	 	 var.tccom100.prbp =  hold.tccom100.prbp  
 	 endif 	 	 	 	 	 	 	 | #  214051.en  
 	 if tccom020.inrl =  empty 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  
 	 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  
 	 dump 8  
 	 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  
 	 dump 10
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 | 	 endif 	 	 	 	 	 	 	 | #  214051.o  
 	 if var.tccom100.sndr =  tcyesno.yes then 	 	 	 | #  214051.sn  
 	 | *  One -  Time BP should not get a Parent BP filled.  
 	 	 var.tccom100.prbp =  ""      
 	 else  
 	 	 var.tccom100.prbp =  hold.tccom100.prbp  
 	 endif 	 	 	 	 	 	 	 | #  214051.en  
 	 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  
 	 dump 12
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:100
:SCPAC:tc
:SCMOD:mcs
:SFLNO:025
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:115
:SCPAC:tc
:SCMOD:com
:SFLNO:015
:ICOD:D
:QURY:START


	 if get.business.partner(tccom015.cuno,bcstc.orgn.cuno, o.mess) then  
 	 	 var.tccom115.pfbp =  ""              
 	 else  
 	 	 var.tccom115.pfbp =  bcstc008.bpid  
 	 endif  
 	 if get.bank.code("tccom015", tccom015.cuno &  tccom015.cban, o.mess) then  
 	 	 var.tccom115.brch =  ""            
 	 else  
 	 	 var.tccom115.brch =  bcstf006.bank  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:115
:SCPAC:tc
:SCMOD:com
:SFLNO:015
:ICOD:S
:QURY:START


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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:115
:SCPAC:tc
:SCMOD:com
:SFLNO:015
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 	  
 	 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  
 	  
 	 dump 1 	  
 	 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:117
:SCPAC:tc
:SCMOD:com
:SFLNO:013
:ICOD:S
:QURY:START
select 	 tccom013.*
from 	 tccom013
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:125
:SCPAC:tc
:SCMOD:com
:SFLNO:025
:ICOD:D
:QURY:START


	 if get.business.partner(tccom025.suno,bcstc.orgn.suno, o.mess) then  
 	 	 var.tccom125.ptbp =  ""                                                      
 	 else  
 	 	 var.tccom125.ptbp =  bcstc008.bpid  
 	 endif  
 	 if get.bank.code("tccom025", tccom025.suno &  tccom025.cban, o.mess) then  
 	 	 var.tccom125.brch =  ""                                                            
 	 else  
 	 	 var.tccom125.brch =  bcstf006.bank  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:125
:SCPAC:tc
:SCMOD:com
:SFLNO:025
:ICOD:S
:QURY:START


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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:125
:SCPAC:tc
:SCMOD:com
:SFLNO:025
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:125
:SCPAC:tc
:SCMOD:mcs
:SFLNO:026
:ICOD:D
:QURY:START


	 | *  Factoring Company will be placed in a temp variable, based on the  
 	 | *  tccuno domain as used in table bcstc008.  
 	 tmp.cfcc(1;6) =  " "  
 	 tmp.cfcc(4;3) =  tcmcs026.cfcc  
 	 if get.business.partner(tmp.cfcc,bcstc.orgn.fcomp, o.mess) then  
 	 	 var.tccom125.ptbp =  ""                                                      
 	 else  
 	 	 var.tccom125.ptbp =  bcstc008.bpid  
 	 endif  
 	 if get.bank.code("tcmcs026", tcmcs026.cfcc &  tcmcs026.cban, o.mess) then  
 	 	 var.tccom125.brch =  ""                                                            
 	 else  
 	 	 var.tccom125.brch =  bcstf006.bank  
 	 endif  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:125
:SCPAC:tc
:SCMOD:mcs
:SFLNO:026
:ICOD:S
:QURY:START


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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:125
:SCPAC:tc
:SCMOD:mcs
:SFLNO:026
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:tc
:SCMOD:com
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:tc
:SCMOD:com
:SFLNO:020
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:td
:SCMOD:smi
:SFLNO:120
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:tp
:SCMOD:pdm
:SFLNO:046
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:140
:SCPAC:ts
:SCMOD:sma
:SFLNO:110
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:com
:TFLNO:999
:SCPAC:tc
:SCMOD:com
:SFLNO:999
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 | #  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 cprpd100.  
 	 dump 27
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:cp
:SCMOD:rpd
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:itm
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 | #  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
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:mps
:SFLNO:200
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 	 	  
 	 	 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  
 | #  206137.sn  
 	 check.var.tiipd001.drin.bfcp(tipcs002.bfcp)  
 | #  206137.en  
 	 	 | *  Dump for tiipd001 from tipcs002.  
 	 	 dump 21  
 	 	 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  
 | #  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 tipcs002.  
 	 	 dump 23  
 | #  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.  
 	 	 dump 32  
 | #  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  
 	 	 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  
 	 	 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  
 | #  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.  
 	 	 dump 32  
 | #  800 -  141474.en  
 	 endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:002
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 | #  sp1.n  
 	 | *  enum values in SP1 are now identical to Baan IV  
 	 var.tcibd001.umer =  tipcs021.umer  
 | #  sp1.en  
 | #  sp1.so  
 | 	 | *  Enum values for 'Update E -  Item Relationship are changed.  
 | 	 on case tipcs021.umer  
 | 	 case tiitm.umer.yes :  
 | | 	 	 var.tcibd001.umer =  target(tcibd.umer.automatic) |SP1.o  
 | 	 	 var.tcibd001.umer =  target(tcibd.umer.yes) 	 |SP1.n  
 | 	 	 break  
 | 	 case tiitm.umer.freeze :  
 | 	 	 var.tcibd001.umer =  target(tcibd.umer.freeze) 	 |SP1.sn  
 | 	 	 break 	 	 	 	 	 |SP1.en  
 | #  800 -  142021.sn  
 | 	 case tiitm.umer.break :  
 | | #  800 -  142021.en  
 | | 	 	 var.tcibd001.umer =  target(tcibd.umer.manual) |SP1.o  
 | 	 	 var.tcibd001.umer =  target(tcibd.umer.break) 	 |SP1.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  
 | #  sp1.eo  
 	  
 	  
 	 | *  Dump for tcibd001 from tipcs021.  
 	 dump 8  
 	 | *  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  
 	 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  
 	 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  
 	 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  
 | #  800 -  139367.en  
 	 | *  Dump for tcibd200 from tipcs021.  
 	 dump 11  
 	  
 	 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  
 	 else  
 	 	 var.whwmd400.lttr =  tcyesno.no  
 	 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  
 	 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  
 	 	 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. 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  
 | #  206137.sn  
 	 check.var.tiipd001.drin.bfcp(tipcs021.bfcp)  
 | #  206137.en  
 	 | *  Dump for tiipd001 from tipcs021.  
 	 dump 13  
 	 | *  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  
 	 	 	 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  
 	 	 endselect  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:021
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:022
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:110
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 	 	 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  
 	 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  
 	 | *  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  
 	 | *  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  
 	 | *  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  
 	 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  
 | #  200 -  99295.en  
 	 	 | *  Dump for whwmd400 from tppdm605.  
 	 	 dump 19  
 | #  800 -  140863.sn  
 	 endif  
 | #  800 -  140863.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:tp
:SCMOD:pdm
:SFLNO:605
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:ibd
:TFLNO:002
:SCPAC:bc
:SCMOD:stc
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 	 dump 1 | *  Dump for whwmd401.  
 	 dump 2 | *  Dump for tppdm006.  
 	 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  
 	 if ( tiitm002.kitm =  tckitm.subcontracting ) then  
 	 	 var.tcibd002.cosd =  2  
 	 else  
 	 	 var.tcibd002.cosd =  1  
 	 endif  
 	 | *  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  
 	 (tiitm002.osys =  tcosys.mps) then  
 	 	 var.tcibd002.plnd =  tcyesno.yes  
 	 else  
 	 	 var.tcibd002.plnd =  tcyesno.no  
 	 endif 	 	 	 	 	 | #  205411.en  
 	 	 	 	 	 	  
 	 determine.weight.unit(tiitm002.uset, var.tcibd002.cwun) 	 | #  206188.n  
 	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:ibd
:TFLNO:002
:SCPAC:ti
:SCMOD:itm
:SFLNO:002
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:ibd
:TFLNO:004
:SCPAC:bc
:SCMOD:stc
:SFLNO:022
:ICOD:D
:QURY:START
	 | *  When there is a customer or a supplier, convert to business partner.  
 	 if not isspace(bcstc022.obus) then  
 	 	 return.value =  get.business.partner(  
 	 	 	 bcstc022.obus,  
 	 	 	 bcstc022.type =  tccitt.type.customer ?   
 	 	 	 	 bcstc.orgn.cuno : bcstc.orgn.suno,  
 	 	 	 error.message)  
 	 	 var.tcibd004.bpid =  bcstc008.bpid  
 	 else  
 	 	 var.tcibd004.bpid =  ""              
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:ibd
:TFLNO:004
:SCPAC:bc
:SCMOD:stc
:SFLNO:022
:ICOD:S
:QURY:START
select bcstc022.*
from bcstc022
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:ibd
:TFLNO:004
:SCPAC:bc
:SCMOD:stc
:SFLNO:022
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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 	 tdltc001.cprj =  tipcs021.cprj 	 | #  215456  
 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:ibd
:TFLNO:401
:SCPAC:ts
:SCMOD:sma
:SFLNO:102
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:ibd
:TFLNO:401
:SCPAC:ts
:SCMOD:sma
:SFLNO:105
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:008
:SCPAC:tc
:SCMOD:cri
:SFLNO:700
:ICOD:D
:QURY:START
	 if skip.earlier.records =  true and  
 	 previous.currency =  tccri700.ccur then  
 	 	 continue  
 	 endif  
 	 previous.currency =  tccri700.ccur  
 	 if tccri700.stdt <  JAN_3_1970 then  
 	 	 var.tccri700.stdt =  utc (JAN_3_1970, 0)  
 	 	 skip.earlier.records =  true  
 	 	 | *  The last record before the first possible utc -  date is  
 	 	 | *  migrated. The earlier rates are skipped.  
 	 else  
 	 	 var.tccri700.stdt =  utc (tccri700.stdt, 0)  
 	 	 skip.earlier.records =  false  
 	 endif  
 	 | *  if post -  triangulation has been done we only migrate the EMU currencies from here  
 	 | *  other rates will come from tcmcs008  
 	 if transition.period =  tcyesno.no and tcmcs002.emuc =  tcyesno.no then  
 	 	 | *  skip the non -  EMU currency rates  
 	 	 continue  
 	 endif 	  
 	 for counter =  1 to nr.of.exchange.rate.types  
 	 	 var.tccri700.rtyp =  var.str.target.exchrate(1, counter)  
 	 	 on case var.str.source.exchrate(1, counter)  
 	 	 case "PUR":                                                                                                                                                                              
 	 	 	 var.tccri700.rate =  tccri700.ratp  
 	 	 	 break  
 	 	 case "SLS":                                                                                                                                                                              
 	 	 	 var.tccri700.rate =  tccri700.rats  
 	 	 	 break  
 	 	 case "EU ":  
 	 	 	 var.tccri700.rate =  tccri700.ecrt  
 	 	 	 break  
 	 	 endcase  
 	 	 | *  The flag 'express in base currency' does exist in tccri700, so that  
 	 	 | *  is be copied to ERP LN in rule for Dump 3  
 	 	  
 	 	 if not double.cmp(var.tccri700.rate, 0.0, 0.000001 ) then  
 	 	 	 | *  rate is mandatory so fill rate =  0 with fixed value.  
 	 	 	 var.tccri700.rate =  0.000001  
 	 	 endif  
 	 	 Dump 3  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:008
:SCPAC:tc
:SCMOD:cri
:SFLNO:700
:ICOD:S
:QURY:START
select 	 tccri700.*  , tcmcs002.emuc 	 | #  203428.sn
from 	 tccri700, tcmcs002
where 	 tccri700.ccur <>  :var.tccri700.bcur  
 and 	 tcmcs002.ccur =  tccri700.ccur
order by tccri700.ccur, tccri700.stdt desc
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:008
:SCPAC:tc
:SCMOD:cri
:SFLNO:700
:ICOD:X
:QURY:START
	 	 	 	 | #  202428.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:008
:SCPAC:tc
:SCMOD:mcs
:SFLNO:002
:ICOD:D
:QURY:START
	 var.tcmcs008.stdt =  utc (JAN_3_1970, 0)  
 	 for counter =  1 to nr.of.exchange.rate.types  
 	 	 var.tcmcs008.rtyp =  var.str.target.exchrate(1, counter)  
 	 	 Dump 2 	  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:008
:SCPAC:tc
:SCMOD:mcs
:SFLNO:002
:ICOD:S
:QURY:START
select 	 tcmcs002.*
from 	 tcmcs002
where 	 not exists(  
 	 	 select tcmcs008.ccur  
 	 	 from 	 tcmcs008  
 	 	 where 	 tcmcs008._index1 =  {tcmcs002.ccur})  
 and 	 not exists( 	 	 	 | #  203428.sn  
 	 	 select tccri700.ccur  
 	 	 from 	 tccri700  
 	 	 where 	 tccri700._index1 =  {tcmcs002.ccur})  
 	 	 	 	 	 | #  203428.en
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:008
:SCPAC:tc
:SCMOD:mcs
:SFLNO:008
:ICOD:D
:QURY:START
	 if skip.earlier.records =  true and  
 	 previous.currency =  tcmcs008.ccur then  
 	 	 continue  
 	 endif  
 	 previous.currency =  tcmcs008.ccur  
 	 if tcmcs008.stdt <  JAN_3_1970 then  
 	 	 var.tcmcs008.stdt =  utc (JAN_3_1970, 0)  
 	 	 skip.earlier.records =  true  
 	 	 | *  The last record before the first possible utc -  date is  
 	 	 | *  migrated. The earlier rates are skipped.  
 	 else  
 	 	 var.tcmcs008.stdt =  utc (tcmcs008.stdt, 0)  
 	 	 skip.earlier.records =  false  
 	 endif  
 	 	 	 	 	 | #  203428.sn  
 	 | *  We only get here if post -  triangulation has been done  
 	 | *  Only migrate the nonEMU currencies from here  
 	 | *  Other rates will come from tccri700  
 	 if tcmcs002.emuc =  tcyesno.yes then  
 	 	 | *  skip the EMU currency rates  
 	 	 continue  
 	 endif 	 	 	 	 | #  203428.en  
 	 for counter =  1 to nr.of.exchange.rate.types  
 	 	 var.tcmcs008.rtyp =  var.str.target.exchrate(1, counter)  
 	 	 on case var.str.source.exchrate(1, counter)  
 	 	 case "PUR":                                                                                                                                                                              
 	 	 	 var.tcmcs008.rate =  tcmcs008.ratp  
 	 	 	 break  
 	 	 case "SLS":                                                                                                                                                                              
 	 	 	 var.tcmcs008.rate =  tcmcs008.rats  
 	 	 	 break  
 	 	 case "EU ":  
 	 	 	 var.tcmcs008.rate =  tcmcs008.ecrt  
 	 	 	 break  
 	 	 endcase  
 	 	 | *  The flag 'express in base currency' must be present  
 	 	 | *  in baan6. So write always the rates  
 	 	 if not double.cmp(var.tcmcs008.rate, 0.0, 0.000001 ) then  
 	 	 	 | *  rate is mandatory so fill rate =  0 with fixed value.  
 	 	 	 var.tcmcs008.rate =  0.000001  
 	 	 endif  
 	 	 Dump 1  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:008
:SCPAC:tc
:SCMOD:mcs
:SFLNO:008
:ICOD:S
:QURY:START
select 	 tcmcs008.*  , tcmcs002.emuc 	 | #  203428.n
from 	 tcmcs008, tcmcs002 	 	 | #  203428.n  
 |select 	 tcmcs008.*  	 	 	 | #  203428.o  
 |from 	 tcmcs008 	 	 	 | #  203428.o
where 	 tcmcs008.ccur <>  :var.tcmcs008.bcur 	 	  
 and 	 tcmcs002.ccur =  tcmcs008.ccur | #  203428.n
order by tcmcs008.ccur, tcmcs008.stdt desc 	 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:008
:SCPAC:tc
:SCMOD:mcs
:SFLNO:008
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:010
:SCPAC:tc
:SCMOD:mcs
:SFLNO:010
:ICOD:D
:QURY:START
| 	 if var.tcmcs010.meec =  empty then 	 	 	 | #  SL149890.o  
 	 if tcmcs010.meec =  empty then 	 	 	 | #  SL149890.n  
 	 	 var.tcmcs010.meec =  tcyesno.no  
 	 else  
 	 	 var.tcmcs010.meec =  tcmcs010.meec  
 	 endif  
 	 var.tcmcs010.ppcd =  0  
 | 	 | *  in LN all ZIP Codes are checked against this 	 	 | #  214096.so  
 | 	 | *  'ZIP Code Base', which is too strict.  
 | 	 if tracs020.ppcd <>  0 then  
 | 	 	 var.tcmcs010.ppcd =  tracs020.ppcd  
 | 	 endif 	 	 	 	 	 	 	 | #  214096.eo  
 	 | *  read adress format from bcstc014. Use default format  
 	 | *  if not found for this country.  
 	 if not read.address.formats(tcmcs010.ccty, dummy.err.mess) then  
 	 	 var.tcmcs010.coaf =  bcstc014.coaf  
 	 else  
 | 	 	 var.tcmcs010.coaf =  empty() 	 	 | #  223304.o  
 | #  223304.sn  
 	 	 | *  try to use default format (country =  "")          
 	 	 if not read.address.formats("", dummy.err.mess) then  
 	 	 	 var.tcmcs010.coaf =  bcstc014.coaf  
 	 	 else  
 	 	 	 var.tcmcs010.coaf =  empty()  
 	 	 endif  
 | #  223304.en  
 	 endif  
 	 if not get.time.zone.per.country(tcmcs010.ccty, dummy.err.mess) then  
 	 	 var.tcmcs010.tzid =  bcstc026.tzid  
 	 else  
 	 	 var.tcmcs010.tzid =  empty()  
 	 endif  
 	 Dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:010
:SCPAC:tc
:SCMOD:mcs
:SFLNO:010
:ICOD:S
:QURY:START
select 	 tcmcs010.*  	 	 	 	 	 	 | #  214096.sn
from 	 tcmcs010 	 	 	 	 	 	 | #  214096.en  
 |select 	 	 tcmcs010.*  , tracs020.ppcd 	 	 	 | #  214096.so  
 |from 	 tcmcs010, tracs020  
 |where 	 tcmcs010.ccty refers to tracs020 unref clearunref 	 | #  214096.eo
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:010
:SCPAC:tc
:SCMOD:mcs
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:013
:SCPAC:tc
:SCMOD:mcs
:SFLNO:013
:ICOD:D
:QURY:START
	 | *  Field CDIS  
 | 	 if isspace (tcmcs013.cdis) then 	 	 	 | #  205451.o  
 	 | *  function isspace() cannot be used for enumerate fields  
 	 if tcmcs013.cdis =  empty then 	 	 	 | #  205451.n  
 	 	 var.tcmcs013.cdis =  target(tccdde.direct)  
 	 	 | *  tccdde.direct (Immediately)  
 	 else  
 	 	 var.tcmcs013.cdis =  etol(tcmcs013.cdis)  
 	 endif  
 	 | *  Field PTYP  
 | 	 if isspace (tcmcs013.ptyp) then 	 	 	 | #  205451.o  
 	 if tcmcs013.ptyp =  empty then 	 	 	 | #  205451.n  
 	 	 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 	 	 	 | #  205451.o  
 	 if tcmcs013.prio =  empty then 	 	 	 | #  205451.n  
 	 	 var.tcmcs013.prio =  target(tcmcs.prio.not.app)  
 	 	 | *  1: tcmcs.prio.not.app (Not Applicable)  
 	 else  
 	 	 if tcmcs013.cdde =  tccdde.direct then 	 	 	 | #  149445.sn  
 	 	 	 var.tcmcs013.prio =  target(tcmcs.prio.not.app)  
 	 	 else 	 	 	 	 	 	 	 | #  149445.en  
 	 	 	 var.tcmcs013.prio =  etol(tcmcs013.prio)  
 	 	 endif 	 	 	 	 	 	 	 | #  149445.n  
 	 endif  
 	 | *  Field PDYN  
 | 	 if isspace (tcmcs013.pdyn) then 	 	 	 | #  205451.o  
 	 if tcmcs013.pdyn =  empty then 	 	 	 | #  205451.n  
 	 	 var.tcmcs013.pdyn =  target(tcyesno.no)  
 	 	 | *  tcyesno.no (No)  
 	 else  
 	 	 var.tcmcs013.pdyn =  etol(tcmcs013.pdyn)  
 	 endif  
 	 | *  Field PDIS  
 | 	 if isspace (tcmcs013.pdis) then 	 	 	 | #  205451.o  
 	 if tcmcs013.pdis =  empty then 	 	 	 | #  205451.n  
 	 	 var.tcmcs013.pdis =  target(tcmcs.prio.not.app)  
 	 	 | *  tcmcs.prio.not.app (Not Applicable)  
 	 else  
 	 	 if var.tcmcs013.cdis =  target(tccdde.direct) then 	 | #  149445.sn  
 	 	 	 var.tcmcs013.pdis =  target(tcmcs.prio.not.app)  
 	 	 else 	 	 	 	 	 	 	 | #  149445.en  
 	 	 	 var.tcmcs013.pdis =  etol(tcmcs013.pdis)  
 	 	 endif 	 	 	 	 	 	 	 | #  149445.n  
 	 endif  
 	 Dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:013
:SCPAC:tc
:SCMOD:mcs
:SFLNO:013
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:024
:SCPAC:tc
:SCMOD:mcs
:SFLNO:024
:ICOD:S
:QURY:START
select 	 tcmcs024.*
from 	 tcmcs024
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:024
:SCPAC:tc
:SCMOD:mcs
:SFLNO:024
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:032
:SCPAC:tc
:SCMOD:mcs
:SFLNO:032
:ICOD:D
:QURY:START
	 if tcmcs032.edat =  0 then  
 	 	 var.tcmcs032.edat =  utc(date.num(), time.num())  
 	 else  
 	 	 var.tcmcs032.edat =  utc(tcmcs032.edat, 0)  
 	 endif  
 	 | *  var.tcmcs032.edat =  (var.tcmcs032.edat =  0 ?  utc(date.num(), time.num()) : utc(tcmcs032.edat, 0))  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:032
:SCPAC:tc
:SCMOD:mcs
:SFLNO:032
:ICOD:S
:QURY:START
select 	 tcmcs032.*
from 	 bcstc030, tcmcs032
where 	 tcmcs032.ccty =  bcstc030.ccty  
 and 	 tcmcs032.cvat =  bcstc030.cvat  
 and 	 bcstc030.expi =  tcyesno.no
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:032
:SCPAC:tc
:SCMOD:mcs
:SFLNO:032
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:036
:SCPAC:tc
:SCMOD:mcs
:SFLNO:036
:ICOD:S
:QURY:START
select 	 tcmcs036.*
from 	 bcstc030, tcmcs036
where 	 tcmcs036.ccty =  bcstc030.ccty  
 and 	 tcmcs036.cvat =  bcstc030.cvat  
 and 	 bcstc030.expi =  tcyesno.no
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:036
:SCPAC:tc
:SCMOD:mcs
:SFLNO:037
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 	 	 	 	 	 | #  215502.sn  
 	 | *  determine new project code.  
 	 if bcstc016.oprj =  bcstc.oprj.budget then  
 	 	 var.nprj =  get.budget.code(  
 	 	 	 	 bcstc016.ocod,  
 	 	 	 	 bcstc016.bccd)  
 	 endif  
 	 if bcstc016.oprj =  bcstc.oprj.ti.project then  
 	 	 var.nprj =  get.ti.project(  
 	 	 	 	 bcstc016.ocod)  
 	 endif  
 	 if bcstc016.oprj =  bcstc.oprj.tp.project then  
 	 	 var.nprj =  get.tp.project(  
 	 	 	 	 bcstc016.ocod)  
 	 endif  
 	 	 	 	 	 | #  215502.en  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:052
:SCPAC:bc
:SCMOD:stc
:SFLNO:016
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:201
:SCPAC:bc
:SCMOD:stc
:SFLNO:020
:ICOD:D
:QURY:START
	 on case bcstc020.pstp  
 	 case bcpstp.purchase:  
 	 	 Dump 1  
 	 	 break  
 	 case bcpstp.sales:  
 	 	 Dump 2  
 	 	 break  
 	 endcase
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:201
:SCPAC:bc
:SCMOD:stc
:SFLNO:020
:ICOD:S
:QURY:START
select 	 bcstc020.*
from 	 bcstc020
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tc
:TCMOD:mcs
:TFLNO:201
:SCPAC:bc
:SCMOD:stc
:SFLNO:020
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:isa
:TFLNO:001
:SCPAC:ti
:SCMOD:itm
:SFLNO:001
:ICOD:D
:QURY:START
	 convert.sales.and.sales.price.unit()  
 	 release.to.warehousing.allowed()  
 	 dump 1
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:isa
: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.tdisa001.item =  segment.item.code(  
 	 	 	 	 	 	 	 tipcs002.ccpc,  
 	 	 	 	 	 	 	 var.project.code)  
 	 	 	 dump 4  
 	 	 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.tdisa001.item =  segment.item.code(  
 	 	 	 	 	 	 tipcs002.ccpc,  
 	 	 	 	 	 	 var.project.code)  
 	 	 	 dump 4  
 	 	 endif  
 	 endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:isa
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:002
:ICOD:S
:QURY:START
select 	 tipcs002.txta,  
 	 tipcs002.cvat,  
 	 tipcs002.pris,  
 	 tipcs002.cuni,  
 	 tipcs002.seak,  
 	 tipcs002.ccpc,  
 	 tipcs002.cbdg,  
 	 tipcs002.dfit,  
 	 tiitm001.cpgs,  
 	 tiitm001.csgs,  
 	 tiitm001.cmgp,  
 	 tiitm001.rbgp,  
 	 tiitm001.prir,  
 	 tiitm001.umsp,  
 	 tiitm001.lmsp,  
 	 tiitm001.ddfq,  
 	 tiitm001.cwar
from 	 tipcs002, tiitm001
where 	 tipcs002.dfit refers to tiitm001 unref clear
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:isa
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:021
:ICOD:D
:QURY:START
	 var.project.code =  get.project(tipcs021.cprj)  
 	 var.tdisa001.item =  segment.item.code(  
 	 	 	 	 	 tipcs021.item,  
 	 	 	 	 	 var.project.code)  
 	 dump 3
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:isa
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:021
:ICOD:S
:QURY:START
select 	 tipcs021.cwar,  
 	 tipcs021.cvat,  
 	 tipcs021.csgs,  
 	 tipcs021.cuni,  
 	 tipcs021.seak,  
 	 tipcs021.cprj,  
 	 tipcs021.item,  
 	 tipcs021.dfit,  
 	 tiitm001.cpgs,  
 	 tiitm001.cmgp,  
 	 tiitm001.rbgp,  
 	 tiitm001.prir,  
 	 tiitm001.pris,  
 	 tiitm001.ltsp,  
 	 tiitm001.umsp,  
 	 tiitm001.lmsp,  
 	 tiitm001.ddfq,  
 	 tiitm001.cwar
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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:isa
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:021
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:isa
: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  
 	 convert.sales.and.sales.price.unit()  
 	 release.to.warehousing.allowed()  
 	 dump 5
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:isa
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:isa
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:022
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:isa
:TFLNO:001
:SCPAC:tp
:SCMOD:pdm
:SFLNO:605
:ICOD:D
:QURY:START
	 var.tdisa001.cuqs =  tppdm605.cuni  
 	 var.tdisa001.cups =  tppdm605.cuni  
 	 on case tppdm605.itmt  
 	 case tppdm.itmt.equipment:  
 	 	 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.tdisa001.cuqs =  tppdm625.cuti  
 	 	 	 var.tdisa001.cups =  tppdm625.cuti  
 	 	 endselect  
 	 	 break  
 	 case tppdm.itmt.subcontracting:  
 	 	 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.tdisa001.cuqs =  tppdm635.cuni  
 	 	 	 	 var.tdisa001.cups =  tppdm635.cuni  
 	 	 	 else  
 	 	 	 	 var.tdisa001.cuqs =  tppdm635.cuti  
 	 	 	 	 var.tdisa001.cups =  tppdm635.cuti  
 	 	 	 endif  
 	 	 endselect  
 	 	 break  
 	 default:  
 	 	 break  
 	 endcase  
 	 var.project.code =  get.tp.project(tppdm605.cprj)  
 	 var.tdisa001.item =  segment.item.code(  
 	 	 	 	 	 tppdm605.item,  
 	 	 	 	 	 var.project.code)  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:isa
:TFLNO:001
:SCPAC:tp
:SCMOD:pdm
:SFLNO:605
:ICOD:S
:QURY:START
select 	 tppdm605.cvat,  
 	 tppdm605.pris,  
 	 tppdm605.ltps,  
 	 tppdm605.csgs,  
 	 tppdm605.cuni,  
 	 tppdm605.seak,  
 	 tppdm605.cprj,  
 	 tppdm605.item,  
 	 tppdm605.dfit,  
 	 tppdm605.itmt,  
 	 tiitm001.cpgs,  
 	 tiitm001.cmgp,  
 	 tiitm001.rbgp,  
 	 tiitm001.prir,  
 	 tiitm001.umsp,  
 	 tiitm001.lmsp,  
 	 tiitm001.ddfq,  
 	 tiitm001.cwar
from 	 tppdm605, tiitm001
where 	 tppdm605.dfit refers to tiitm001 unref clear
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:isa
:TFLNO:010
:SCPAC:td
:SCMOD:sls
:SFLNO:020
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:isa
:TFLNO:010
:SCPAC:td
:SCMOD:sls
:SFLNO:020
:ICOD:S
:QURY:START
select 	 tdsls020.*  , tiitm001.citg, tiitm001.cuqs
from 	 tdsls020, tiitm001
where 	 tiitm001._index1 =  {tdsls020.item}
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:isa
:TFLNO:010
:SCPAC:td
:SCMOD:sls
:SFLNO:020
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:pur
:TFLNO:000
:SCPAC:td
:SCMOD:pur
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:pur
:TFLNO:150
:SCPAC:td
:SCMOD:pur
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:pur
:TFLNO:300
:SCPAC:td
:SCMOD:pur
:SFLNO:300
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:pur
:TFLNO:301
:SCPAC:td
:SCMOD:pur
:SFLNO:301
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:pur
:TFLNO:350
:SCPAC:td
:SCMOD:pur
:SFLNO:305
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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.no.of.receipt.lines =  get.number.of.receipt.lines()  
 	  
 	 | *  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  
 	 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  
 	 	 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  
 	 	 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  
 	 	 	 	 	 	 	 	 | #  208945.sn  
 	 	 dump 5 	 | *  tdpur456  
 	 	 	 	 	 	 	 	 | #  208945.en  
 	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:pur
:TFLNO:401
:SCPAC:td
:SCMOD:pur
:SFLNO:045
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:pur
:TFLNO:451
:SCPAC:td
:SCMOD:pur
:SFLNO:051
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:sls
:TFLNO:000
:SCPAC:td
:SCMOD:sls
:SFLNO:000
:ICOD:S
:QURY:START
select tdsls000.*
from tdsls000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:sls
:TFLNO:000
:SCPAC:td
:SCMOD:sls
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:sls
:TFLNO:094
:SCPAC:tc
:SCMOD:mcs
:SFLNO:042
:ICOD:D
:QURY:START
	 set.mem(var.tdsls094.pmsk, "n", 20)                                                                      
 	 select 	 bcstd001.acno  
 	 from 	 	 bcstd001  
 	 where 	 bcstd001._index1 =  {:tcmcs042.cotp}  
 	 selectdo  
 	 	 var.tdsls094.pmsk(bcstd001.acno;1) =  "y"                                                                      
 	 endselect  
 	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:sls
:TFLNO:094
:SCPAC:tc
:SCMOD:mcs
:SFLNO:042
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:sls
:TFLNO:150
:SCPAC:td
:SCMOD:sls
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:sls
:TFLNO:300
:SCPAC:td
:SCMOD:sls
:SFLNO:300
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:sls
:TFLNO:350
:SCPAC:td
:SCMOD:sls
:SFLNO:305
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:sls
:TFLNO:351
:SCPAC:td
:SCMOD:sls
:SFLNO:306
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

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

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

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:sls
:TFLNO:450
:SCPAC:td
:SCMOD:sls
:SFLNO:050
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:td
:TCMOD:sls
:TFLNO:451
:SCPAC:td
:SCMOD:sls
:SFLNO:051
:ICOD:S
:QURY:START
select 	 tdsls051.*
from 	 tdsls051
order by tdsls051._index1 desc
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acp
:TFLNO:000
:SCPAC:tf
:SCMOD:acp
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acp
:TFLNO:001
:SCPAC:tf
:SCMOD:acp
:SFLNO:001
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acp
:TFLNO:005
:SCPAC:tf
:SCMOD:acp
:SFLNO:005
:ICOD:D
:QURY:START


	 if hold.financial.bpg <>  tfacp005.fisu then  
 	 	 add.defaults.new.type.of.transactions()  
 	 	 hold.financial.bpg =  tfacp005.fisu  
 	 endif 	 	  
 	 if tfacp005.tran =  tfacp.tran.control then  
 	 	 if not isspace(tfacp005.leac) then  
 	 	 | *  In BaanIV the control account can be left empty. These records  
 	 	 | *  must not be migrated because they result in a fatal error after  
 	 	 | *  migration.  
 	 	 	 dump 1  
 	 	 endif  
 	 else  
 	 	 convert.kind.of.transaction(  
 	 	 	 tfacp005.tran,  
 	 	 	 var.tfacp005.tran)  
 	 	 dump 2  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acp
:TFLNO:005
:SCPAC:tf
:SCMOD:acp
:SFLNO:005
:ICOD:S
:QURY:START


select 	 tfacp005.*
from 	 tfacp005
order by tfacp005._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acp
:TFLNO:005
:SCPAC:tf
:SCMOD:acp
:SFLNO:005
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 	  
 	 ret.long =  get.tax.by.country.code(  
 	 	 	 tfacp200.vatc,  
 	 	 	 tfacp200.cvat,  
 	 	 	 var.tfacp200.vatc,  
 	 	 	 var.tfacp200.cvat,  
 	 	 	 error.message)  
 	  
 	 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(  
 	 	 	 get.compnr(),  
 	 	 	 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 	  
 	  
 	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acp
:TFLNO:200
:SCPAC:tf
:SCMOD:acp
:SFLNO:200
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acp
:TFLNO:202
:SCPAC:tf
:SCMOD:acp
:SFLNO:202
:ICOD:D
:QURY:START
	 var.tfacp202.cadr =  ""             
 	 var.tfacp202.brch =  ""             
 	  
 	 | *  Concate index fields to a string  
 	 var.str.temp.key(1;3) =  tfacp202.ttyp(1;3)  
 	 var.str.temp.key(4;8) =  edit$(tfacp202.ninv, "99999999")                      
 	 var.str.temp.key(12;5) =  edit$(tfacp202.line, "99999")                      
 	  
 	 ret.long =  get.addresses(  
 	 	 	 "tfacp202",                                              
 	 	 	 var.str.temp.key, 	 | *  index  
 	 	 	 error.message)  
 	 var.tfacp202.cadr =  bcstc004.cadr  
 	  
 	 ret.long =  get.bank.code(  
 	 	 	 "tfacp202",                                              
 	 	 	 var.str.temp.key, 	 | *  index  
 	 	 	 error.message)  
 	 var.tfacp202.brch =  bcstf006.bank  
 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acp
:TFLNO:202
:SCPAC:tf
:SCMOD:acp
:SFLNO:202
:ICOD:S
:QURY:START
select 	 tfacp202.*
from 	 tfacp202
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acp
:TFLNO:202
:SCPAC:tf
:SCMOD:acp
:SFLNO:202
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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)  
 	 	 	 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  
 	 	 | * -  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  
 	 	 	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acp
:TFLNO:240
:SCPAC:td
:SCMOD:pur
:SFLNO:045
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acp
:TFLNO:250
:SCPAC:td
:SCMOD:pur
:SFLNO:046
:ICOD:D
:QURY:START
	 select tdpur046.*  , 	  
 	 	 tfacp200.ccur, tfacp200.rate, tfacp200.ratf, tfacp200.docd,  
 	 	 tfacp200.tapr, tfacp200.dapr,  
 | 	 	 tdpur041.cvqp, tdpur041.cuqp, 	 	 	 | #  207117.o  
 | 	 	 	 	 	 	 	 	 | #  208878.so  
 | 	 	 tdpur041.cvqp, tdpur041.cuqp, tdpur041.oqua, 	 | #  207117.n  
 | 	 	 tiitm001.cuni, 	 	 	 	 	 | #  208878.eo  
 	 	 tdpur041.cvqp, tdpur041.cuqp, tdpur041.oqua, 	 | #  208878.sn  
 	 	 tdpur041.opol, tdpur041.cprj, tdpur041.item, 	 | #  208878.en  
 | 	 	 tdpur045.dino, tdpur045.reno, 	 	 	 | #  206420.o  
 	 	 tdpur045.dino, tdpur045.reno, tdpur045.date, 	 | #  206420.sn  
 	 	 tdpur045.orno, tdpur045.pono, tdpur045.srnb 	 | #  206420.en  
 | 	 from 	 tdpur046, tfacp200, tdpur041, tiitm001, tdpur045 | #  208878.o  
 	 from 	 tdpur046, tfacp200, tdpur041, tdpur045 	 	 | #  208878.n  
 	 where 	 tdpur046._compnr =  :logistic.company  
 	 and 	 tdpur041._compnr =  :logistic.company  
 	 and 	 tdpur045._compnr =  :logistic.company  
 	 and 	 tfacp200._compnr =  :current.company  
 	 and 	 tfacp200._index1 =  {tdpur046.ttyp, tdpur046.invn}  
 	 and 	 tfacp200.tdoc =  ""                                                                                              
 	 and 	 tfacp200.docn =  0  
 	 	 | *  Join the with invoice header  
 	 and 	 tdpur041._index1 =  {tdpur046.orno, tdpur046.pono}  
 | 	 and 	 tiitm001._index1 =  {tdpur041.item} 	 	 | #  208878.o  
 	 and 	 tdpur045._index1 =  {tdpur046.orno,  
 	 	 	 	 	 tdpur046.pono,  
 	 	 	 	 	 tdpur046.srnb}  
 	 and 	 tdpur046.icom =  :current.company 	 	 	  
 	 and 	 tdpur046._index1 >  {""}  
 	 | *  Don't remove the statement above. This statement triggers the query  
 	 | *  processor to handle the tdpur tables in the right sequence. Removing  
 	 | *  this statement will cause serious performance loss.  
 	 order by tdpur046._index1 	 	 	  
 	 selectdo  
 	 	 if hold.orno <>  tdpur046.orno then  
 	 	 	 read.purchase.order.and.order.type.data (  
 	 	 	 	 tdpur046.orno,  
 	 	 	 	 logistic.company)  
 	 	 	 var.tfacp250.orno =  convert.number(  
 	 	 	 	 	 	 bcckon.act.pur,  
 	 	 	 	 	 	 tdpur046.orno)  
 	 	 endif  
 	 	 var.tfacp250.ifbp =  get.business.partner.code(  
 	 	 	 	 	 tdpur046.suno,  
 	 	 	 	 	 bcstc.orgn.suno,  
 	 	 	 	 	 error.message)  
 	 	 var.tfacp250.ratd =  utc(tfacp200.docd, 0)  
 	 	 get.inventory.unit( 	 	 	 	 | #  208878.sn  
 	 	 	 logistic.company,  
 	 	 	 tdpur041.opol,  
 	 	 	 tdpur041.item,  
 	 	 	 tdpur041.cprj,  
 	 	 	 inventory.unit) 	 	 	 | #  208878.en  
 	 	 convert.quantity.from.order.unit.to.inventory.unit (  
 	 	 	 tdpur046.qana,  
 | 	 	 	 tiitm001.cuni, 	 	 	 	 | #  208878.o  
 	 	 	 inventory.unit, 	 	 	 | #  208878.n  
 	 	 	 tdpur041.cvqp,  
 	 	 	 "",                                                                                   
 	 	 	 "",                                                                                  
 	 	 	 "tcqrd1",                                                                                    
 	 	 	 var.tfacp250.iqan)  
 	 	 	 	 	  
 	 	 for element =  1 to 3  
 	 	 	 if calculate.amount.in.home.currency(  
 	 	 	 	 	 tdpur046.amtb,  
 	 	 	 	 	 tfacp200.ccur,  
 	 	 	 	 	 tfacp200.rate,  
 	 	 	 	 	 tfacp200.ratf,  
 	 	 	 	 	 element,  
 	 	 	 	 	 var.tfacp250.amth(element),  
 	 	 	 	 	 error.message) <>  0 then  
 	 	 	 	 var.tfacp250.amth(element) =  0.0  
 	 	 	 endif  
 	 	 	 var.tfacp250.rate(element) =  fill.mc.field.double(  
 	 	 	 	 tfacp200.rate,  
 	 	 	 	 element,  
 	 	 	 	 0.000001) 	  
 	 	 	 var.tfacp250.ratf(element) =  fill.mc.field.long(  
 	 	 	 	 tfacp200.ratf,  
 	 	 	 	 element,  
 	 	 	 	 1) 	  
 	 	 endfor  
 | 	 	 if tcmcs042.reto =  tcyesno.yes then 	 	 | #  207117.o  
 	 	 	 	 	 	 	 	 | #  207117.sn  
 	 	 if double.cmp(tdpur041.oqua, 0.0, 0.00000) = -  1 then  
 	 	 	 	 	 	 	 	 | #  207117.en  
 	 	 	 | *  Return order  
 | 	 	 	 var.tfacp251.rcno =  bcswh000.prsh 	 | #  215078.so  
 | 	 	 	 | *  Purchace Return Order  
 | 	 	 	 	 &  edit$(tdpur045.reno, "999999")      
 | 	 	 	 	 	 	 	 	 | #  215078.eo  
 	 	 	 ret.long =  get.shipment.number.and.line( | #  215078.sn  
 	 	 	 	 	 tckoor.act.pur,  
 	 	 	 	 	 tdpur045.orno,  
 	 	 	 	 	 tdpur045.pono,  
 	 	 	 	 	 get.order.line.sequence(tdpur045.srnb),  
 	 	 	 	 	 0,  
 	 	 	 	 	 error.message) 	 	 | *  ref  
 	 	 	 var.tfacp251.rcno =  bcswh008.shpm 	 | #  215078.en  
 	 	 else  
 	 	 	 var.tfacp251.rcno =  convert.number(  
 	 	 	 	 	 	 bcckon.receipt.number,  
 	 	 	 	 	 	 tdpur045.reno)  
 	 	 endif 	 	  
 	 	 | *  Only 1 receipt per order line.  
 	 	 dump 1  
 	 	 dump 2  
 	 endselect
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acp
:TFLNO:250
:SCPAC:td
:SCMOD:pur
:SFLNO:046
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acp
:TFLNO:301
:SCPAC:tf
:SCMOD:acp
:SFLNO:301
:ICOD:D
:QURY:START


	 ret.long =  get.addresses("tfacp301", tfacp301.ciab, error.message)  
 	 ret.long =  get.bank.code("tfacp301", tfacp301.ciab, error.message)  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acp
:TFLNO:301
:SCPAC:tf
:SCMOD:acp
:SFLNO:301
:ICOD:S
:QURY:START


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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acp
:TFLNO:301
:SCPAC:tf
:SCMOD:acp
:SFLNO:301
:ICOD:X
:QURY:START


  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acr
:TFLNO:000
:SCPAC:tf
:SCMOD:acr
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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 =  ""                                                                                                                    
 	 	 get.tax.by.country.code(  
 	 	 	 tfacr200.vatc,  
 	 	 	 tfacr200.cvat,  
 	 	 	 new.country,  
 	 	 	 new.tax,  
 	 	 	 var.err.mess)  
 	 	 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  
 	 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acr
:TFLNO:200
:SCPAC:tf
:SCMOD:acr
:SFLNO:200
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acr
:TFLNO:202
:SCPAC:tf
:SCMOD:acr
:SFLNO:202
:ICOD:D
:QURY:START

var.str.temp.key (1;3) =  tfacr202.ttyp (1;3)  
 	 var.str.temp.key (4;11) =  edit$ (tfacr202.ninv,"99999999")  
 	 var.str.temp.key (12;16) =  edit$ (tfacr202.line,"99999")  
 	 	 	 	 	 	 	 	 	 | #  ms.so  
 | 	 var.str.cadr (1;9) =  " "  
 | 	 var.str.badr (1;9) =  " " 	  
 	  
 | 	 if determine.bccnv901.address ("tfacr202", var.str.temp.key) =  1 then  
 | 	 	 var.str.cadr =  bccnv901.cadr  
 | 	 else  
 | 	 	 if determine.bccnv901.address ("tcmcs020", tfacr202.badr) =  1 then  
 | 	 	 	 var.str.badr =  bccnv901.cadr  
 | 	 	 endif  
 | 	 endif  
 	 	 	 	 	 	 	 	 	 | #  ms.eo  
 	  
 	 if not get.addresses("tfacr202", var.str.temp.key,var.err.mess) then  
 	 	 var.tfacr202.cadr =  bcstc004.cadr  
 	 else  
 	 	 var.tfacr202.cadr =  ""                            
 	 endif  
 	  
 	  
 	 if not get.bank.code("tfacr202", var.str.temp.key,var.err.mess) then  
 	 	 var.tfacr202.brch =  bcstf006.bank  
 	 else  
 	 	 var.tfacr202.brch =  ""                            
 	 endif  
 	 if record.present.in.tfacr200() then 	 	 	 	 | #  200 -  101236.n 	  
 	 	 dump 999  
 	 	 	 	 	 	 	 	 	 | #  200 -  101236.sn  
 	 else  
 	 	 continue  
 	 endif  
 	 	 	 	 	 	 	 	 	 | #  200 -  101236.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acr
:TFLNO:202
:SCPAC:tf
:SCMOD:acr
:SFLNO:202
:ICOD:S
:QURY:START

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:acr
:TFLNO:202
:SCPAC:tf
:SCMOD:acr
:SFLNO:202
:ICOD:X
:QURY:START

  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:000
:SCPAC:tf
:SCMOD:cmg
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:001
:SCPAC:tf
:SCMOD:cmg
:SFLNO:001
:ICOD:D
:QURY:START
var.key.tfcmg001 =  tfcmg001.bank  
 if not get.bank.code(i.table.name, var.key.tfcmg001,var.err.mess) then  
 	 var.tfcmg001.brch =  bcstf006.bank  
 else  
 	 var.tfcmg001.brch =  ""                                
 endif  
 	 	 	 	 	 	 	 | bin.so  
 | if determine.bccnv901.address ("tcmcs020", tfcmg001.badr) =  0 then  
 | 	 bccnv901.cadr =  ""                                
 | endif  
 	 	 	 	 	 	 	 | bin.eo  
 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:001
:SCPAC:tf
:SCMOD:cmg
:SFLNO:001
:ICOD:S
:QURY:START
select tfcmg001.*
from tfcmg001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:001
:SCPAC:tf
:SCMOD:cmg
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:003
:SCPAC:tf
:SCMOD:cmg
:SFLNO:003
:ICOD:D
:QURY:START
var.tfcmg003.rgrp =  0 	 	 	 	 	 	 	 | #  200 -  95855.sn  
 var.tfcmg003.rgr2 =  0 	 	 	 	 	 	 | #  200 -  95855.en  
 	 if etol(tfcmg003.copt) =  0 then  
 	 	 var.tfcmg003.copt =  4  
 	 else  
 	 	 var.tfcmg003.copt =  etol(tfcmg003.copt)  
 	 endif  
 	 if etol(tfcmg003.cact) =  0 then  
 	 	 var.tfcmg003.cact =  4  
 	 else  
 	 	 var.tfcmg003.cact =  etol(tfcmg003.cact)  
 	 endif  
 	 if etol(tfcmg003.dnum) =  0 then  
 	 	 var.tfcmg003.dnum =  4  
 	 else  
 	 	 var.tfcmg003.dnum =  etol(tfcmg003.dnum)  
 	 endif  
 	 if etol(tfcmg003.typp) =  0 then  
 	 	 var.tfcmg003.typp =  3  
 	 else  
 	 	 var.tfcmg003.typp =  etol(tfcmg003.typp)  
 	 endif  
 	 if etol(tfcmg003.odv1) =  0 then  
 	 	 var.tfcmg003.odv1 =  2  
 	 else  
 	 	 var.tfcmg003.odv1 =  etol(tfcmg003.odv1)  
 	 endif  
 	 if etol(tfcmg003.bodd) =  0 then  
 	 	 var.tfcmg003.bodd =  2  
 	 else  
 	 	 var.tfcmg003.bodd =  etol(tfcmg003.bodd)  
 	 endif  
 	 if etol(tfcmg003.uiba) =  0 then  
 	 	 var.tfcmg003.uiba =  2  
 	 else  
 	 	 var.tfcmg003.uiba =  etol(tfcmg003.uiba)  
 	 endif  
 on case strip$ (tfcmg003.sess)  
 	 case 	 "tfcmg1260s000" :                                                                                                          
 	 	 	 	 var.tfcmg003.sess =  get.string(18)  
 	 	 	 	 break  
 | 	 case 	 "tfcmg2113s000" :                                                                    	                     |#                     200-                     95852.so                                          
 | 	 	 	 	 var.tfcmg003.sess =  get.string(19)  
 | 	 	 	 	 break  
 | 	 case 	 "tfcmg2112s000" :                                                                                                          
 | 	 	 	 	 var.tfcmg003.sess =  get.string(20)  
 | 	 	 	 	 break 	 	 	 	 	 | #  200 -  95852.eo  
 	 case "tfcmg4260s000" :                                                  	                                                                                                    	                                                                                       	                                                                                                    	                                                                                                    	                                                                                                                                                  
 	 	 	 	 var.tfcmg003.sess =  get.string(43)  
 	 	 	 	 break  
 	 default :  
 	 	 	 if isspace (tfcmg003.sess) then 	 	  
 	 	 	 	 var.tfcmg003.sess =  empty.string(1;20)  
 	 	 	 endif 	  
 	 	 	 break 	 	 	 	 	 	  
 	 endcase  
 	 if tfcmg003.repa =  tfcmg.repa.payment and tfcmg003.auto =  tcyesno.yes then | #  200 -  97665.n  
 	 if tfcmg003.rgrp =  5 then 	 	 	 	 | #  200 -  95855.sn  
 	 	 var.tfcmg003.rgrp =  41  
 	 else  
 	 	 if tfcmg003.rgrp =  17 then 	 	 	 	  
 	 	 	 var.tfcmg003.rgrp =  15  
 	 	 else  
 	 	 	 var.tfcmg003.rgrp =  tfcmg003.rgrp  
 	 	 endif  
 | 	 	 var.tfcmg003.rgrp =  tfcmg003.rgrp  
 	 endif  
 	 if tfcmg003.rgr2 =  5 then 	 	 	 	  
 	 	 var.tfcmg003.rgr2 =  41  
 	 else  
 	 	 if tfcmg003.rgr2 =  17 then 	 	 	 	  
 	 	 	 var.tfcmg003.rgr2 =  15  
 	 	 else  
 	 	 	 var.tfcmg003.rgr2 =  tfcmg003.rgr2  
 	 	 endif 	 	 	 	 	 	 	  
 | 	 	 var.tfcmg003.rgr2 =  tfcmg003.rgr2  
 	 endif 	 	 	 	 	 	 	  
 	  
 	 | #  200 -  95855.en  
 	 else  
 	 	 var.tfcmg003.rgrp =  tfcmg003.rgrp  
 	 	 var.tfcmg003.rgr2 =  tfcmg003.rgr2  
 	 endif 	 	 	 	 	 	 	 | #  200 -  97665.n  
 	 select tfcmg007.*  	  
 	 from tfcmg007  
 	 where tfcmg007._index2 =  {:tfcmg003.paym}  
 	 as set with 1 rows  
 	 selectdo  
 	 	 var.tfcmg003.poda =  1  
 	 selectempty  
 	 	 var.tfcmg003.poda =  2  
 	 endselect 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:003
:SCPAC:tf
:SCMOD:cmg
:SFLNO:003
:ICOD:S
:QURY:START
select tfcmg003.*
from tfcmg003
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:003
:SCPAC:tf
:SCMOD:cmg
:SFLNO:003
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:011
:SCPAC:bc
:SCMOD:stf
:SFLNO:006
:ICOD:D
:QURY:START
if isspace(bcstf006.bank) then  
 	 	 continue  
 	 endif  
 	 	 	 	 	 	 	 	 |bin.so  
 | 	 if not isspace(bcstf006.badr) then  
 | 	 	 if not get.addresses("tcmcs020", bcstf006.badr,err.mess) then  
 | 	 	 	 var.tfcmg011.badr =  bcstc004.cadr  
 | 	 	 else  
 | 	 	 	 continue  
 | 	 	 endif  
 | 	 else  
 | 	 	  
 | 	 	 if not get.addresses(bcstf006.tabl, bcstf006.keys,err.mess) then  
 | 	 	 	 var.tfcmg011.badr =  bcstc004.cadr  
 | 	 	 else  
 | 	 	 	 continue  
 | 	 	 endif  
 | 	 endif  
 	 	 	 	 	 	 	 	 	 |bin.eo  
 	 if read.address.code.of.bank(bcstf006.tabl,  
 	 	 	 	 bcstf006.keys,  
 	 	 	 	 bcstf006.bank,  
 	 	 	 	 bcstf006.badr,  
 	 	 	 	 var.tfcmg011.badr,  
 	 	 	 	 err.mess) then  
 	 	 continue  
 	 endif  
 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:011
:SCPAC:bc
:SCMOD:stf
:SFLNO:006
:ICOD:S
:QURY:START
select bcstf006.*
from bcstf006
where bcstf006.reqd =  tcyesno.yes
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:011
:SCPAC:bc
:SCMOD:stf
:SFLNO:006
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:101
:SCPAC:tf
:SCMOD:cmg
:SFLNO:101
:ICOD:D
:QURY:START
new.country =  ""                                    
 	 new.tax =  ""                                    
 	 get.tax.by.country.code(tfcmg101.vatc, tfcmg101.cvat, new.country,  
 	 	 	 new.tax, var.str.err.mess)  
 	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:101
:SCPAC:tf
:SCMOD:cmg
:SFLNO:101
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:102
:SCPAC:tf
:SCMOD:cmg
:SFLNO:102
:ICOD:D
:QURY:START
new.country =  ""                                        
 	 new.tax =  ""                   
 var.tfcmg102.typ5 =  5 	 	 | #  206458.n  
 	 get.tax.by.country.code(tfcmg102.vatc, tfcmg102.cvat, new.country,  
 	 	 	 new.tax, err.mess)  
 if get.business.partner(tfcmg102.suno,bcstc.orgn.suno,err.mess) then  
 	 var.bcstc008.bpid =  ""                                            
 else  
 	 var.bcstc008.bpid =  bcstc008.bpid  
 	  
 endif  
 if tfcmg102.typ5 =  6 then 	 	 | #  206458.sn  
 	 var.tfcmg102.typ5 =  5  
 else  
 	 var.tfcmg102.typ5 =  tfcmg102.typ5  
 endif 	 	 	 	 	 | #  206458.en  
 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:102
:SCPAC:tf
:SCMOD:cmg
:SFLNO:102
:ICOD:S
:QURY:START
select tfcmg102.*
from tfcmg102
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:102
:SCPAC:tf
:SCMOD:cmg
:SFLNO:102
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:104
:SCPAC:tf
:SCMOD:cmg
:SFLNO:104
:ICOD:D
:QURY:START
new.country =  ""                          
 	 new.tax =  ""                          
 	 get.tax.by.country.code(tfcmg104.vatc, tfcmg104.cvat, new.country,  
 	 	 	 new.tax, err.mess)  
 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:104
:SCPAC:tf
:SCMOD:cmg
:SFLNO:104
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:108
:SCPAC:tf
:SCMOD:cmg
:SFLNO:108
:ICOD:D
:QURY:START


if not get.business.partner(tfcmg108.suno,bcstc.orgn.suno,var.err.mess) then  
 	 	 var.tfcmg108.bpid =  bcstc008.bpid  
 	 else  
 	 	 var.tfcmg108.bpid =  ""                              
 	 endif  
 	 var.str.tfcmg108.key (1;6) =  edit$ (tfcmg108.btno,"999999")  
 	 var.str.tfcmg108.key (7;9) =  edit$ (tfcmg108.comp,"999")  
 	 var.str.tfcmg108.key (10;15) =  edit$ (etol (tfcmg108.tpay) ,"999999")  
 	 var.str.tfcmg108.key (16;21) =  tfcmg108.suno (1;6)  
 	 var.str.tfcmg108.key (22;29) =  edit$ (tfcmg108.orno,"99999999")  
 	 	 	 	 	 	 	 	 	 | #  ms.so 	 	  
 | 	 var.tfcmg108.badr =  " "  
 | 	 var.tfcmg108.bpad =  " "  
 | 	 if (determine.bccnv901.address ("tcmcs020",tfcmg108.badr) =  1) then  
 | 	 	 var.tfcmg108.badr =  bccnv901.cadr  
 | 	 else 	 if (determine.bccnv901.address ("tfcmg108",var.str.tfcmg108.key) =  1) 	 then  
 | 	 	 	 var.tfcmg108.bpad =  bccnv901.cadr  
 | 	 	 endif  
 | 	 endif  
 	 	 	 	 	 	 	 	 | #  ms.eo  
 	 if not get.addresses("tfcmg108", var.str.tfcmg108.key,var.err.mess) then  
 	 	 var.tfcmg108.bpad =  bcstc004.cadr  
 	 else  
 	 	 var.tfcmg108.bpad =  ""                              
 	 endif  
 	  
 	  
 	 if not get.bank.code("tfcmg108", var.str.tfcmg108.key,var.err.mess) then  
 	 	 var.tfcmg108.brch =  bcstf006.bank  
 	 else  
 	 	 var.tfcmg108.brch =  ""                              
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:108
:SCPAC:tf
:SCMOD:cmg
:SFLNO:108
:ICOD:S
:QURY:START


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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:109
:SCPAC:tf
:SCMOD:cmg
:SFLNO:109
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:110
:SCPAC:tf
:SCMOD:cmg
:SFLNO:110
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:111
:SCPAC:tf
:SCMOD:cmg
:SFLNO:111
:ICOD:D
:QURY:START
new.country =  ""                                                          
 	 new.tax =  ""                                                          
 	 get.tax.by.country.code(tfcmg111.vatc, tfcmg111.cvat, new.country,  
 	 	 	 new.tax, err.mess)  
 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:111
:SCPAC:tf
:SCMOD:cmg
:SFLNO:111
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:114
:SCPAC:tf
:SCMOD:cmg
:SFLNO:114
:ICOD:D
:QURY:START
new.country =  ""                  
 new.tax =  ""                  
 get.tax.by.country.code(tfcmg114.vatc, tfcmg114.cvat, new.country,  
 	 	 	 new.tax, var.str.err.mess)  
 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:114
:SCPAC:tf
:SCMOD:cmg
:SFLNO:114
:ICOD:S
:QURY:START
select tfcmg114.*
from tfcmg114
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:114
:SCPAC:tf
:SCMOD:cmg
:SFLNO:114
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:204
:SCPAC:tf
:SCMOD:cmg
:SFLNO:204
:ICOD:D
:QURY:START
new.country =  ""                                
 	 new.tax =  ""                                
 	 get.tax.by.country.code(tfcmg204.vatc, tfcmg204.cvat, new.country,  
 	 	 	 new.tax, err.mess)  
 	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:204
:SCPAC:tf
:SCMOD:cmg
:SFLNO:204
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:401
:SCPAC:tf
:SCMOD:cmg
:SFLNO:401
:ICOD:D
:QURY:START
new.country =  ""                        
 	 new.tax =  ""                
 	 get.tax.by.country.code(tfcmg401.vatc, tfcmg401.cvat, new.country,  
 	 	 	 new.tax, err.mess)  
 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:401
:SCPAC:tf
:SCMOD:cmg
:SFLNO:401
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:408
:SCPAC:tf
:SCMOD:cmg
:SFLNO:408
:ICOD:D
:QURY:START


if not get.business.partner(tfcmg408.cuno,bcstc.orgn.cuno,var.err.mess) then  
 	 	 var.tfcmg408.bpid =  bcstc008.bpid  
 	 else  
 	 	 var.tfcmg408.bpid =  ""              
 	 endif  
 	 var.str.tfcmg408.key (1;6) =  edit$ (tfcmg408.btno,"999999")  
 	 var.str.tfcmg408.key (7;9) =  edit$ (tfcmg408.comp,"999")  
 	 var.str.tfcmg408.key (10;15) =  edit$ (etol (tfcmg408.tpay) ,"999999")  
 	 var.str.tfcmg408.key (16;21) =  tfcmg408.cuno (1;6)  
 	 	 	 	 	 	 	 	 	 | #  ms.so 	  
 | 	 cmg.badr =  " "  
 | 	 var.cmg408.bpad =  " "  
 	 	  
 | 	 if determine.bccnv901.address ("tcmcs020", tfcmg408.badr) =  1 then  
 | 	 	 cmg.badr =  bccnv901.cadr  
 | 	 else  
 | 	 	 if determine.bccnv901.address ("tfcmg408", var.str.key) =  1 then  
 | 	 	 	 var.cmg408.bpad =  bccnv901.cadr  
 | 	 	 endif  
 | 	 endif  
 	 	 	 	 	 	 	 	 	 | #  ms.eo  
 	 if not get.addresses("tfcmg408", var.str.tfcmg408.key,var.err.mess) then  
 	 	 var.tfcmg408.cadr =  bcstc004.cadr  
 	 else  
 	 	 var.tfcmg408.cadr =  ""              
 	 endif  
 	  
 	  
 	 if not get.bank.code("tfcmg408", var.str.tfcmg408.key,var.err.mess) then  
 	 	 var.tfcmg408.brch =  bcstf006.bank  
 	 else  
 	 	 var.tfcmg408.brch =  ""              
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:408
:SCPAC:tf
:SCMOD:cmg
:SFLNO:408
:ICOD:S
:QURY:START


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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:503
:SCPAC:tf
:SCMOD:cmg
:SFLNO:503
:ICOD:D
:QURY:START
new.country =  ""                              
 	 new.tax =  ""                              
 	 get.tax.by.country.code(tfcmg503.vatc, tfcmg503.cvat, new.country,  
 	 	 	 new.tax, err.mess)  
 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:cmg
:TFLNO:503
:SCPAC:tf
:SCMOD:cmg
:SFLNO:503
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:003
:SCPAC:tf
:SCMOD:gld
:SFLNO:003
:ICOD:D
:QURY:START
	 var.tfgld003.dim1 =  tfgld003.dim1  
 	 var.tfgld003.dim2 =  tfgld003.dim2  
 	 var.tfgld003.dim3 =  tfgld003.dim3  
 	 var.tfgld003.dim4 =  tfgld003.dim4  
 	 var.tfgld003.dim5 =  tfgld003.dim5  
 	 if tfgld003.dim1 =  tcyesno.yes then  
 	 	 if not description.present(1) then  
 	 	 	 var.tfgld003.dim1 =  tcyesno.no  
 	 	 endif  
 	 endif 	  
 	 if tfgld003.dim2 =  tcyesno.yes then  
 	 	 if not description.present(2) then  
 	 	 	 var.tfgld003.dim2 =  tcyesno.no  
 	 	 endif  
 	 endif 	  
 	 if tfgld003.dim3 =  tcyesno.yes then  
 	 	 if not description.present(3) then  
 	 	 	 var.tfgld003.dim3 =  tcyesno.no  
 	 	 endif  
 	 endif 	  
 	 if tfgld003.dim4 =  tcyesno.yes then  
 	 	 if not description.present(4) then  
 	 	 	 var.tfgld003.dim4 =  tcyesno.no  
 	 	 endif  
 	 endif 	  
 	 if tfgld003.dim5 =  tcyesno.yes then  
 	 	 if not description.present(5) then  
 	 	 	 var.tfgld003.dim5 =  tcyesno.no  
 	 	 endif  
 	 endif 	 	  
 	 var.tfgld003.indt =  utc(0,0)  
 	 var.tfgld003.dsca =  form.text$("bcstc00035") | *  Actual Set  
 	 dump 1  
 	 var.tfgld003.indt =  utc(date.num(), time.num())  
 	 var.tfgld003.dsca =  form.text$("bcstc00036") | *  Converted from BaanIVc4  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:003
:SCPAC:tf
:SCMOD:gld
:SFLNO:003
:ICOD:S
:QURY:START
select tfgld003.*
from tfgld003
as set with 1  rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:003
:SCPAC:tf
:SCMOD:gld
:SFLNO:003
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:008
:SCPAC:bc
:SCMOD:stf
:SFLNO:008
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:008
:SCPAC:tf
:SCMOD:gld
:SFLNO:008
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:008
:SCPAC:tf
:SCMOD:gld
:SFLNO:009
:ICOD:D
:QURY:START
	 dump 6
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:008
:SCPAC:tf
:SCMOD:gld
:SFLNO:009
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:013
:SCPAC:tf
:SCMOD:gld
:SFLNO:013
:ICOD:D
:QURY:START
	 if tfgld013.vtyp =  empty then  
 	 	 var.tfgld013.vtyp =  target(tfgld.vtyp.not.applicable)  
 	 else  
 	 	 var.tfgld013.vtyp =  etol(tfgld013.vtyp)  
 	 endif 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:013
:SCPAC:tf
:SCMOD:gld
:SFLNO:013
:ICOD:S
:QURY:START
select tfgld013.*
from 	 tfgld013
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:013
:SCPAC:tf
:SCMOD:gld
:SFLNO:013
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:021
:SCPAC:tf
:SCMOD:gld
:SFLNO:021
:ICOD:D
:QURY:START
	 if tfgld021.vtyp =  empty then  
 	 	 var.tfgld021.vtyp =  target(tfgld.vtyp.not.applicable)  
 	 else  
 	 	 var.tfgld021.vtyp =  etol(tfgld021.vtyp)  
 	 endif 	  
 	 dump 21
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:021
:SCPAC:tf
:SCMOD:gld
:SFLNO:021
:ICOD:S
:QURY:START
select 	 tfgld021.*
from 	 tfgld021
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:021
:SCPAC:tf
:SCMOD:gld
:SFLNO:021
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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(  
 	 	 	 tfgld102.ccty,  
 	 	 	 tfgld102.cvat,  
 	 	 	 var.tfgld102.ccty,  
 	 	 	 var.tfgld102.cvat,  
 	 	 	 error.message)  
 	 for element =  1 to 3  
 	 	 var.tfgld102.rate(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld102.rate,  
 	 	 	 	 element,  
 	 	 	 	 0.000001) 	  
 	 	 var.tfgld102.fact(element) =  fill.mc.field.long(  
 	 	 	 	 tfgld102.fact,  
 	 	 	 	 element,  
 	 	 	 	 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 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:102
:SCPAC:tf
:SCMOD:gld
:SFLNO:102
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:106
:SCPAC:tf
:SCMOD:gld
:SFLNO:106
:ICOD:D
:QURY:START
| *  	 Minimize calls to function for performance  
 | *  	 var.str.bpid =  ""                                        
 | *  	 var.str.rtyp =  var.str.eu.rtyp  
 	 if not isspace (tfgld106.cuno) then  
 	 	 if prev.tfgld106.cuno <>  tfgld106.cuno then  
 	 	 	 var.str.bpid =  get.business.partner.code(  
 	 	 	 tfgld106.cuno, bcstc.orgn.cuno, error.message)  
 	 	 	 var.str.rtyp =  var.str.sls.rtyp  
 	 	 	 prev.tfgld106.cuno =  tfgld106.cuno  
 	 	 	 prev.tfgld106.suno =  ""             	                      	           |#             200-             100975.n                          
 	 	 	 | *  Reset Supplier hold variable  
 	 	 endif  
 	 else  
 	 	 if not isspace (tfgld106.suno) then  
 	 	 	 if prev.tfgld106.suno <>  tfgld106.suno then  
 	 	 	 var.str.bpid =  get.business.partner.code(  
 	 	 	 	 tfgld106.suno, bcstc.orgn.suno, error.message)  
 	 	 	 var.str.rtyp =  var.str.pur.rtyp  
 	 	 	 prev.tfgld106.suno =  tfgld106.suno  
 	 	 	 prev.tfgld106.cuno =  ""             	                          	             |#             200-             100975.n                          
 	 	 	 | *  Reset Customer hold variable  
 	 	 	 endif  
 	 	 else  
 	 	 	 var.str.bpid =  ""                                                            
 	 	 	 prev.tfgld106.suno =  ""             	                          	             |#             200-             100975.sn                          
 	 	 	 prev.tfgld106.cuno =  ""             	                          	             |#             200-             100975.en                          
 	 	 	 | *  Reset Customer /  Supplier hold variable  
 	 	 	 var.str.rtyp =  var.str.eu.rtyp  
 	 	 endif  
 	 endif  
 	 if tfgld106.tcsh =  tfcmg.tcsh.empt then  
 	 	 | *  Baan4 enum 20 ( =  empt) changes into  
 	 	 | *  23( =  empty) in baan6  
 	 	 var.tfgld106.tcsh =  target(tfcmg.tcsh.empty)  
 	 else  
 	 	 if tfgld106.tcsh =  tfcmg.tcsh.ssgn.ant then  
 	 	 	 | *  Baan4 enum 21 ( =  ssgn.ant) changes  
 	 	 	 | *  into 20( =  ssgn.ant) in baan6  
 	 	 	 var.tfgld106.tcsh =  target(tfcmg.tcsh.ssgn.ant)  
 	 	 else  
 	 	 	 | *  Baan4 enum 1 till 19 have same value as baan6  
 	 	 	 var.tfgld106.tcsh =  etol(tfgld106.tcsh)  
 	 	 endif  
 	 endif  
 	 | *  PERF: Minimize calls to function  
 	 if prev.tfgld106.ccty <>  tfgld106.ccty or  
 	 prev.tfgld106.cvat <>  tfgld106.cvat then  
 	 	 ret.long =  get.tax.by.country.code(  
 	 	 	 tfgld106.ccty,  
 	 	 	 tfgld106.cvat,  
 	 	 	 var.tfgld106.ccty,  
 	 	 	 var.tfgld106.cvat,  
 	 	 	 error.message)  
 	 	 prev.tfgld106.ccty =  tfgld106.ccty  
 	 	 prev.tfgld106.cvat =  tfgld106.cvat  
 	 endif  
 	 | *  PERF end  
 	 for element =  1 to 3  
 	 	 var.tfgld106.rate(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld106.rate,  
 	 	 	 	 element,  
 	 	 	 	 0.000001)  
 	 	 var.tfgld106.fact(element) =  fill.mc.field.long(  
 	 	 	 	 tfgld106.fact,  
 	 	 	 	 element,  
 	 	 	 	 1)  
 	 	 var.tfgld106.amth(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld106.amth,  
 	 	 	 	 element,  
 	 	 	 	 0.0)  
 	 	 var.tfgld106.vamh(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld106.vamh,  
 	 	 	 	 element,  
 	 	 	 	 0.0)  
 	 endfor  
 	 if tfgld106.vtyp =  empty then  
 	 	 var.tfgld106.vtyp =  target(tfgld.vtyp.not.applicable)  
 	 else  
 	 	 var.tfgld106.vtyp =  etol(tfgld106.vtyp)  
 	 endif 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:106
:SCPAC:tf
:SCMOD:gld
:SFLNO:106
:ICOD:S
:QURY:START
select tfgld106.*
from tfgld106
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:106
:SCPAC:tf
:SCMOD:gld
:SFLNO:106
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:110
:SCPAC:tf
:SCMOD:gld
:SFLNO:110
:ICOD:D
:QURY:START
	 if not isspace (tfgld110.cuno) then  
 	 	 var.tfgld110.bpid =  get.business.partner.code(  
 	 	 	 	 	 tfgld110.cuno,  
 	 	 	 	 	 bcstc.orgn.cuno,  
 	 	 	 	 	 error.message)  
 	 else  
 	 	 if not isspace(tfgld110.suno) then  
 	 	 	 var.tfgld110.bpid =  get.business.partner.code(  
 	 	 	 	 	 	 tfgld110.suno,  
 	 	 	 	 	 	 bcstc.orgn.suno,  
 	 	 	 	 	 	 error.message)  
 	 	 else  
 	 	 	 var.tfgld110.bpid =  empty()  
 	 	 endif 	  
 	 endif  
 	 var.tfgld110.orno =  convert.number(bcckon.act.pur, tfgld110.orno)  
 	 ret.long =  get.tax.by.country.code(  
 	 	 	 tfgld110.ccty,  
 	 	 	 tfgld110.cvat,  
 	 	 	 var.tfgld110.ccty,  
 	 	 	 var.tfgld110.cvat,  
 	 	 	 error.message)  
 	 for element =  1 to 3  
 	 	 var.tfgld110.amth(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld110.amth,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 	 var.tfgld110.vamh(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld110.vamh,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 endfor 	  
 	 if tfgld110.vtyp =  empty then  
 	 	 var.tfgld110.vtyp =  target(tfgld.vtyp.not.applicable)  
 	 else  
 	 	 var.tfgld110.vtyp =  etol(tfgld110.vtyp)  
 	 endif 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:110
:SCPAC:tf
:SCMOD:gld
:SFLNO:110
:ICOD:S
:QURY:START
select 	 tfgld110.*
from 	 tfgld110
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:110
:SCPAC:tf
:SCMOD:gld
:SFLNO:110
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:201
:SCPAC:tf
:SCMOD:gld
:SFLNO:201
:ICOD:D
:QURY:START
	 for element =  1 to 3  
 	 	 var.tfgld201.fcah(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld201.fcah,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 	 var.tfgld201.fdah(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld201.fdah,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 	 var.tfgld201.ncah(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld201.ncah,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 	 var.tfgld201.ndah(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld201.ndah,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 endfor  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:201
:SCPAC:tf
:SCMOD:gld
:SFLNO:201
:ICOD:S
:QURY:START
select 	 tfgld201.*
from 	 tfgld201
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:201
:SCPAC:tf
:SCMOD:gld
:SFLNO:201
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:202
:SCPAC:tf
:SCMOD:gld
:SFLNO:202
:ICOD:D
:QURY:START
	 for element =  1 to 3  
 	 	 var.tfgld202.fcah(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld202.fcah,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 	 var.tfgld202.fdah(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld202.fdah,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 	 var.tfgld202.ncah(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld202.ncah,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 	 var.tfgld202.ndah(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld202.ndah,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 endfor  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:202
:SCPAC:tf
:SCMOD:gld
:SFLNO:202
:ICOD:S
:QURY:START
select 	 tfgld202.*
from 	 tfgld202
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:202
:SCPAC:tf
:SCMOD:gld
:SFLNO:202
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:203
:SCPAC:tf
:SCMOD:gld
:SFLNO:203
:ICOD:D
:QURY:START
	 for element =  1 to 3  
 	 	 var.tfgld203.fobh(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld203.fobh,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 	 var.tfgld203.nobh(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld203.nobh,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 endfor  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:203
:SCPAC:tf
:SCMOD:gld
:SFLNO:203
:ICOD:S
:QURY:START
select 	 tfgld203.*
from 	 tfgld203
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:203
:SCPAC:tf
:SCMOD:gld
:SFLNO:203
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:204
:SCPAC:tf
:SCMOD:gld
:SFLNO:204
:ICOD:D
:QURY:START
	 for element =  1 to 3  
 	 	 var.tfgld204.fobh(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld204.fobh,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 	 var.tfgld204.nobh(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld204.nobh,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 endfor  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:204
:SCPAC:tf
:SCMOD:gld
:SFLNO:204
:ICOD:S
:QURY:START
select 	 tfgld204.*
from 	 tfgld204
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:204
:SCPAC:tf
:SCMOD:gld
:SFLNO:204
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:205
:SCPAC:tf
:SCMOD:gld
:SFLNO:205
:ICOD:D
:QURY:START
	 for element =  1 to 3  
 	 	 var.tfgld205.fcah(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld205.fcah,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 	 var.tfgld205.fdah(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld205.fdah,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 	 var.tfgld205.ncah(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld205.ncah,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 	 var.tfgld205.ndah(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld205.ndah,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 endfor  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:205
:SCPAC:tf
:SCMOD:gld
:SFLNO:205
:ICOD:S
:QURY:START
select 	 tfgld205.*
from 	 tfgld205
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:205
:SCPAC:tf
:SCMOD:gld
:SFLNO:205
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:206
:SCPAC:tf
:SCMOD:gld
:SFLNO:206
:ICOD:D
:QURY:START
	 for element =  1 to 3  
 	 	 var.tfgld206.fobh(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld206.fobh,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 	 var.tfgld206.nobh(element) =  fill.mc.field.double(  
 	 	 	 	 tfgld206.nobh,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 endfor  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:206
:SCPAC:tf
:SCMOD:gld
:SFLNO:206
:ICOD:S
:QURY:START
select 	 tfgld206.*
from 	 tfgld206
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:206
:SCPAC:tf
:SCMOD:gld
:SFLNO:206
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:450
:SCPAC:tf
:SCMOD:gld
:SFLNO:450
:ICOD:S
:QURY:START
select 	 tfgld450.*
from 	 tfgld450
where 	 tfgld450._index1 =  {1}
as set with 1  rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tf
:TCMOD:gld
:TFLNO:450
:SCPAC:tf
:SCMOD:gld
:SFLNO:450
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:bom
:TFLNO:010
:SCPAC:ti
:SCMOD:bom
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:bom
:TFLNO:010
:SCPAC:ti
:SCMOD:pcs
:SFLNO:022
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:bom
:TFLNO:010
:SCPAC:ti
:SCMOD:pcs
:SFLNO:110
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:cpr
:TFLNO:000
:SCPAC:ti
:SCMOD:cpr
:SFLNO:000
:ICOD:S
:QURY:START
select ticpr000.*
from ticpr000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:cpr
:TFLNO:000
:SCPAC:ti
:SCMOD:cpr
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:cpr
:TFLNO:010
:SCPAC:bc
:SCMOD:sti
:SFLNO:008
:ICOD:D
:QURY:START
	 get.cost.components(bcorig.ticpr, bcsti008.cpcp, "",  err.mess)                 
 	 var.ticpr010.chrt =  bcsti008.chrt | #  210766.n  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:cpr
:TFLNO:010
:SCPAC:bc
:SCMOD:sti
:SFLNO:008
:ICOD:S
:QURY:START
select 	 bcsti008.*
from 	 bcsti008
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:cpr
:TFLNO:010
:SCPAC:bc
:SCMOD:sti
:SFLNO:008
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:cpr
:SFLNO:200
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:cpr
:SFLNO:300
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:pcs
:SFLNO:150
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:pcs
:SFLNO:350
:ICOD:S
:QURY:START
select 	 tipcs350.*  , ticpr010.cref 	 	 | *  Cost Price Customized Items
from 	 tipcs350, ticpr010  
 |where ticpr010.cpcp =  tipcs350.cpcp 	 	 | #  205224.o
where 	 tipcs350.cpcp refers to ticpr010.cpcp 	 | #  205224.n
order by tipcs350._index1 | *  cprj, item, cpcp =  new item code, cpcp
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:pcs
:SFLNO:350
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:cpr
:TFLNO:320
:SCPAC:ti
:SCMOD:cpr
:SFLNO:320
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:cpr
:TFLNO:330
:SCPAC:ti
:SCMOD:cpr
:SFLNO:330
:ICOD:D
:QURY:START
	 get.cost.components(bcorig.ticpr, ticpr330.cpcp, "", tmp.errmess)        
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:cpr
:TFLNO:330
:SCPAC:ti
:SCMOD:cpr
:SFLNO:330
:ICOD:S
:QURY:START
select ticpr330.*
from ticpr330
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:cpr
:TFLNO:330
:SCPAC:ti
:SCMOD:cpr
:SFLNO:330
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:cst
:TFLNO:001
:SCPAC:ti
:SCMOD:cst
:SFLNO:001
:ICOD:D
:QURY:START
	 | *  initialize vars if next production order  
 	 if ticst001.pdno <>  prev.pdno then  
 	 	 var.first.operation = -  1  
 	 endif  
 	 	  
 	 var.ticst001.pdno =  convert.number( bcckon.act.sfc, ticst001.pdno)  
 	  
 	 | *  Determine project number var.ticst001.cprj.  
 	 | *  This is needed to determine the item code  
 	 | *  (see Rules)  
 	 if not isspace (ticst001.cprj) then  
 	 	 if (ticst001.opol =  tcittb.standard) then  
 	 	 	 var.ticst001.cprj =  empty()  
 	 	 else  
 	 	 	 var.ticst001.cprj =  get.ti.project(ticst001.cprj)  
 	 	 endif  
 	 else  
 	 	 var.ticst001.cprj =  empty()  
 	 endif  
 	  
 	 | *  determine operation in case operation is empty in Baan IV:  
 	 | *  get first operation, if no ops, then get first est. hours.  
 	 | *  Do this only once per production order.  
 	 var.ticst001.opno =  ticst001.opno  
 	 if (ticst001.opno =  0) then  
 	 	 if ticst001.pdno =  prev.pdno or var.first.operation = -  1 then  
 	 	 	 var.first.operation =  determine.first.operation (ticst001.pdno)  
 	 	 endif  
 	 	 | *  no else required: var.first.operation can be used  
 	 	 var.ticst001.opno =  var.first.operation  
 	 endif  
 	  
 	 | *  Direct Initiate Invenetory Issue (at release)  
 	 var.ticst001.drin =  tcyesno.no  
 	 	 	  
 	 | *  Direct Issue ( =  automatic Wh activities)  
 	 var.ticst001.dris =  tcyesno.no  
 	 	 	  
 	 | *  Floor Stock  
 	 select 	 tiitm001.pics  
 	 from 	 tiitm001  
 	 where 	 tiitm001._index1 =  {:ticst001.sitm}  
 	 and 	 tiitm001.pics =  tcyesno.yes  
 	 as set with 1 rows  
 	 selectdo  
 	 	 var.ticst001.drin =  tcyesno.yes  
 	 	 var.ticst001.dris =  tcyesno.yes  
 	 endselect  
 	  
 	 | *  Backflush items  
 	 if ticst001.bfls =  tcyesno.yes then  
 	 	 var.ticst001.drin =  tcyesno.no 	 	 | #  207801.n  
 	 	 var.ticst001.dris =  tcyesno.yes  
 	 endif  
 	 | *  Fill Amount and Cost fields. Note: Actual Amount =  actual qty *  actual price  
 	 for element =  1 to 3  
 	 	 var.ticst001.aamt(element) =  ticst001.qucs *  fill.mc.field.double(  
 	 	 	 	 	 	 	 	 ticst001.cpcs,  
 	 	 	 	 	 	 	 	 element,  
 	 	 	 	 	 	 	 	 0.0)  
 	 	 var.ticst001.cpcs(element) =  fill.mc.field.double( 	 ticst001.cpcs,  
 	 	 	 	 	 	 	 	 element,  
 	 	 	 	 	 	 	 	 0.0)  
 	 	 var.ticst001.cpes(element) =  fill.mc.field.double( 	 ticst001.cpes,  
 	 	 	 	 	 	 	 	 element,  
 	 	 	 	 	 	 	 	 0.0)  
 	 endfor  
 	 	 	 	 	  
 	 dump 999  
 	  
 	 | *  set previous production order  
 	 prev.pdno =  ticst001.pdno
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:cst
:TFLNO:001
:SCPAC:ti
:SCMOD:cst
:SFLNO:001
:ICOD:S
:QURY:START
select 	 ticst001.*
from 	 ticst001
order by ticst001._index1 	 | *  (pdno, pono)
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 	 | *--------------------------------------------------------------------------------   
 	  
 	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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,  
 	 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 	 | *  skip "not for finance" transactions
order by tfgld410.ocom, tfgld410.tror, tfgld410.fitr 	 | *  index 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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,  
 	 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 >  "")                                                             	                                                                                                                        	                                                                                                                        	                                                            |*                                                             only PCS related transactions                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
 and 	 tipcs020.psts <  tcpsts.closed 	 	 | *  no closed projects  
 | and 	 tfgld410.sint <>  tfgld.sint.no.fin 	 | *  skip "not for finance" transactions  |#                                                            209375.o                                                                                                                        
 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  
 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  
 	 | *------------------------------------------------------------------------   
 	  
 	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:cst
:TFLNO:300
:SCPAC:ti
:SCMOD:cst
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:cst
:TFLNO:300
:SCPAC:ti
:SCMOD:pcs
:SFLNO:360
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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)  
 	  
 	 | *  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.cprj.f 	 =  var.cprj 	 	 	 	 	 | #  213976.n  
 	 	 var.cprj.t 	 =  var.cprj 	 	 	 	 	 | #  213976.n  
 	 	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:cst
:TFLNO:300
:SCPAC:ti
:SCMOD:sfc
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:edm
:TFLNO:110
:SCPAC:ti
:SCMOD:edm
:SFLNO:110
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:pcf
:TFLNO:520
:SCPAC:ti
:SCMOD:pcf
:SFLNO:520
:ICOD:D
:QURY:START
	 select 	 bcsti001.cpvl  
 	 from 	 bcsti001  
 	 where 	 bcsti001._index1 =  {:tipcf520.cpva}  
 	 as set with 1 rows  
 	 selectdo  
 	 selectempty  
 	 	 cpva.not.found =  true  
 	 endselect 	  
 	 if cpva.not.found then  
 	 	 cpva.not.found =  false  
 	 	 continue  
 	 endif  
 | #  205226.en  
 	 var.tipcf520.cpva =  bcsti001.cpvl  
 	 | *  In case standard variants are used on calculation parts,  
 	 | *  the standard variant is also present in bcsti002. In case  
 	 | *  the standard variant is NOT present in bcsti002, the array  
 	 | *  with new product variant numbers will only contain the  
 	 | *  input bcsti001.cpvl.  
 	 if tipcf500.reft <>  tcreft.budget and  
 	 tipcf500.reft <>  tcreft.standard then  
 	 	 | *  Only one new product variant was created.  
 	 	 dump 1  
 	 else  
 	 	 read.budget.product.variants(  
 	 	 	 	 tipcf520.cpva,  
 	 	 	 	 bcsti001.cpvl)  
 	 	 for g.pvar.counter =  1 to g.nr.new.pvars  
 	 	 	 var.tipcf520.cpva =  gt.new.pvars(g.pvar.counter)  
 	 	 	 dump 1  
 	 	 endfor  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:pcf
:TFLNO:520
:SCPAC:ti
:SCMOD:pcf
:SFLNO:520
:ICOD:S
:QURY:START
select tipcf520.cpva , tipcf520.cpva , tipcf520.opts , tipcf520.sern ,  
 	 tipcf520.cpft , tipcf520.dsca , tipcf520.copt , tipcf520.txta ,  
 	 tipcf500.reft
from 	 tipcf520, tipcf500
where 	 tipcf520.cpva refers to tipcf500
order by tipcf520._index1 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:pcf
:TFLNO:520
:SCPAC:ti
:SCMOD:pcf
:SFLNO:520
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:pcs
:TFLNO:030
:SCPAC:ti
:SCMOD:pcs
:SFLNO:020
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:rou
:TFLNO:000
:SCPAC:ti
:SCMOD:rou
:SFLNO:000
:ICOD:S
:QURY:START
select tirou000.*
from tirou000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:rou
:TFLNO:000
:SCPAC:ti
:SCMOD:rou
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:rou
:TFLNO:001
:SCPAC:ti
:SCMOD:rou
:SFLNO:001
:ICOD:D
:QURY:START
	 get.business.partner(tirou001.suno, bcstc.orgn.suno,error.message)  
 	 var.tirou001.bpid =  bcstc008.bpid  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:rou
:TFLNO:001
:SCPAC:ti
:SCMOD:rou
:SFLNO:001
:ICOD:S
:QURY:START
select tirou001.*
from tirou001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:rou
:TFLNO:001
:SCPAC:ti
:SCMOD:rou
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:rou
:TFLNO:003
:SCPAC:ti
:SCMOD:rou
:SFLNO:003
:ICOD:D
:QURY:START
	 | *  tirou003 (operation)  
 	 dump 1  
 | 	 dump 2 	 	 	 	 	 | #  215498.o  
 	 	 	 	 	 	 	 | #  215498.sn  
 	 | *  tirou004 (Task relatationship).  
 	 | *  two records are created: one for the specific taks /  default workcenter /  default machine,  
 	 | *  and one for task /  " " /  " ". This one will be used as fall -  back during the  
 	 | *  cost price calculation, when the work center does not equal the default work center  
 	 var.cwoc =  tirou003.cwoc  
 	 var.mcno =  tirou003.mcno  
 	 dump 2  
 	  
 	 var.cwoc =  ""                                
 	 var.mcno =  ""                                
 	 dump 2  
 	 	 	 	 	 	 	 | #  215498.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:rou
:TFLNO:003
:SCPAC:ti
:SCMOD:rou
:SFLNO:003
:ICOD:S
:QURY:START
select 	 tirou003.*
from 	 tirou003
where 	 tirou003.ckot =  tcckot.mach.oper or  
 	 tirou003.ckot =  tcckot.non.mach.oper
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:rou
:TFLNO:003
:SCPAC:ti
:SCMOD:rou
:SFLNO:003
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:rou
:TFLNO:102
:SCPAC:ti
:SCMOD:pcs
:SFLNO:023
:ICOD:D
:QURY:START
	  
 	 if tipcs023.olap =  0 then 	 	 	 | #  204367.sn  
 	 	 var.tlyn =  tcyesno.no  
 	 	 var.trls =  0 	  
 	 else  
 	 	 var.tlyn =  tcyesno.yes  
 	 	 var.trls =  100 -  tipcs023.olap  
 	 endif 	 	 	 	 	 	 | #  204367.en  
 	  
 	 set.var.fields( 	 tipcs023.mnoc,  
 	 	 	 tipcs023.mcoc,  
 	 	 	 tirou001.ccap,  
 	 	 	 tipcs023.sutm,  
 	 	 	 tipcs023.rutm)  
 	  
 	 dump 9
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 	 tirou001.wttm 	 | *  Waitting Time 	 | #  209286.n
from 	 tipcs023, tirou001
where 	 tipcs023.cwoc =  tirou001.cwoc  
 and 	 tipcs023.cprj >=  ""
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:rou
:TFLNO:102
:SCPAC:ti
:SCMOD:pcs
:SFLNO:120
:ICOD:D
:QURY:START
	  
 	 if tipcs120.olap =  0 then 	 	 	 | #  204367.sn  
 	 	 var.tlyn =  tcyesno.no  
 	 	 var.trls =  0 	  
 	 else  
 	 	 var.tlyn =  tcyesno.yes  
 	 	 var.trls =  100 -  tipcs120.olap 	  
 	 endif 	 	 	 	 	 	 | #  204367.en  
 	 set.var.fields( 	 tipcs120.mnoc,  
 	 	 	 tipcs120.mcoc,  
 	 	 	 tirou001.ccap,  
 	 	 	 tipcs120.sutm,  
 	 	 	 tipcs120.rutm)  
 	 dump 222
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 	 tirou001.wttm 	 | *  Waitting Time 	 | #  209286.n
from 	 tipcs120, tirou001
where 	 tipcs120.cwoc =  tirou001.cwoc  
 and 	 tipcs120.cbdg >=  ""
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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)  
 	  
 	 if tirou102.olap =  0 then 	 	 	 | #  204367.sn  
 	 	 var.tlyn =  tcyesno.no  
 	 	 var.trls =  0  
 	 else  
 	 	 var.tlyn =  tcyesno.yes  
 	 	 var.trls =  100 -  tirou102.olap 	  
 	 endif 	 	 	 	 	 	 | #  204367.en  
 	 set.var.fields( 	 tirou102.mnoc,  
 	 	 	 tirou102.mcoc,  
 	 	 	 tirou001.ccap,  
 	 	 	 tirou102.sutm,  
 	 	 	 tirou102.rutm)  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 	 tirou001.wttm 	 | *  Waitting Time 	 | #  209286.n
from 	 tirou102, tirou001
where 	 tirou102.cwoc =  tirou001.cwoc  
 | and 	 tirou102.mitm >=  ""
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:sfc
:TFLNO:001
:SCPAC:ti
:SCMOD:sfc
:SFLNO:001
:ICOD:D
:QURY:START
	 var.tisfc001.osta =  sfc.order.status(tisfc001.pdno, tisfc001.cprj, tisfc001.osta)  
 	 if tisfc001.osta >=  tcosta.hours.adj then 	 	 	 	  
 	 	 var.tisfc001.fres =  tcyesno.yes  
 	 	 if tisfc001.osta =  tcosta.closed then  
 	 	 	 var.tisfc001.cada =  tisfc001.cldt  
 	 	 else  
 	 	 	 var.tisfc001.cada =  date.num()  
 	 	 endif  
 	 else  
 	 	 var.tisfc001.fres =  tcyesno.no  
 	 	 var.tisfc001.cada =  0  
 	 endif  
 	  
 	 | *  Fill Company Number in case it is empty  
 	 if tisfc001.ncmp =  0 then  
 	 	 tisfc001.ncmp =  current.compnr  
 	 endif  
 	 var.tisfc001.clco =  get.calculation.office(tisfc001.pdno, tisfc001.ncmp, current.compnr)  
 	 if isspace(var.tisfc001.clco) then  
 	 	 | error: calculation office must be filled  
 	 endif  
 	  
 	 var.tisfc001.defc =  tcyesno.no  
 	 if (tisfc001.osta =  tcosta.closed or tisfc001.osta =  tcosta.archived) then  
 	 	 | *  Closed or Archived orders are always set to Definitif Closed, unless the  
 	 	 | *  related pcs project is still open.  
 	 	 if tisfc001.osta =  tcosta.closed then  
 	 	 	 var.tisfc001.defc =  tcyesno.yes  
 	 	 	 if not isspace(tisfc001.cprj) then  
 	 	 	 	 | *  customized item: check status of project  
 	 	 	 	 select 	 tipcs020.psts  
 	 	 	 	 from 	 tipcs020  
 	 	 	 	 where 	 tipcs020.cprj =  :tisfc001.cprj  
 	 	 	 	 selectdo  
 	 	 	 	 	 if tipcs020.psts <  tcpsts.closed then  
 	 	 	 	 	 	 var.tisfc001.defc =  tcyesno.no  
 	 	 	 	 	 endif  
 	 	 	 	 endselect  
 	 	 	 endif  
 | 	 	 	 select 	 tfgld410.orno  
 | 	 	 	 from 	 tfgld410  
 | 	 	 	 where 	 tfgld410._index2 =  {:current.compnr,  
 | 	 	 	 	 :tisfc001.cprj, tctror.prd, :tisfc001.pdno}  
 | 	 	 	 as set with 1 rows  
 | 	 	 	 selectempty  
 | 	 	 	 	 var.tisfc001.defc =  tcyesno.yes  
 | 	 	 	 endselect  
 	 	 else  
 	 	 	 var.tisfc001.defc =  tcyesno.yes  
 	 	 endif  
 	 endif  
 	  
 	 var.start.time =  (var.tisfc001.shift.time *  tisfc001.prdp) /  100  
 	 var.end.time =  (var.tisfc001.shift.time *  tisfc001.dldp) /  100  
 	 var.tisfc001.adld =  0  
 	 select 	 tfgld410.trdt, tfgld410.sern  
 	 from 	 tfgld410  
 	 where 	 tfgld410._index2 =  {:current.compnr, :tisfc001.cprj, tctror.prd,  
 	 	 	 	 	 	 :tisfc001.pdno, 0, tcfitr.receipt}  
 	 and 	 tfgld410.item =  :tisfc001.mitm  
 	 order by tfgld410.sern desc  
 	 as set with 1 rows  
 	 selectdo  
 	 	 var.tisfc001.adld =  tfgld410.trdt  
 	 endselect  
 	  
 	 var.tisfc001.clot =  tisfc001.clot  
 	 if not isspace(tisfc001.clot) then  
 	 	 if serialized.item(tisfc001.cprj, tisfc001.mitm) then  
 	 	 	 var.tisfc001.clot =  empty()  
 	 	 endif  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:sfc
:TFLNO:001
:SCPAC:ti
:SCMOD:sfc
:SFLNO:001
:ICOD:S
:QURY:START
select 	 tisfc001.*
from 	 tisfc001  
 | *  Skip SFC orders for TP -  project -  items, because: 	 	 | #  214978.sn  
 | * -  these items are also not migrated to LN.  
 | * -  LN does not allow production of TP -  project -  items.  
 | *  	 (IPD data can only be of PCS projects)
where 	 tisfc001.cprj =  ""      
 	 or exists (select tipcs020.prtp  
 	 	 from tipcs020  
 	 	 where tipcs020._index1 =  { tisfc001.cprj }  
 	 	 and tipcs020.prtp <>  tcyesno.yes) 	 	 | #  214978.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:sfc
:TFLNO:001
:SCPAC:ti
:SCMOD:sfc
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:sfc
:TFLNO:010
:SCPAC:ti
:SCMOD:sfc
:SFLNO:010
:ICOD:D
:QURY:START
	 if (prev.pdno <>  tisfc010.pdno) then  
 	 	 select 	 count( *  ):operation.counter  
 	 	 from 	 tisfc010  
 	 	 where 	 tisfc010._index1 =  {:tisfc010.pdno}  
 	 	 endselect  
 	 	 var.tisfc010.nopr =  0  
 	 endif  
 	  
 	 var.tisfc010.bpid =  get.business.partner.code(tisfc010.suno,  
 	 	 	 	 	 	 bcstc.orgn.suno, error.message)  
 	 if tisfc010.noru =  0.0 then  
 	 	 tisfc010.noru =  1.0  
 	 endif  
 	 var.tisfc010.mcoc =  tisfc010.noru  
 	 var.tisfc010.mopr =  tisfc010.noru  
 	 var.tisfc010.prtm =  tisfc010.prtm /  tisfc010.noru  
 	 var.tisfc010.retm =  tisfc010.retm /  tisfc010.noru  
 	 var.tisfc010.mcho =  tisfc010.prtm  
 	 var.tisfc010.maho =  tisfc010.prtm  
 	 var.tisfc010.prte =  tisfc010.prte *  tisfc010.noru  
 	 var.tisfc010.rutm =  tisfc010.rutm /  tisfc010.noru  
 	  
 	 if tisfc010.sutm <>  0 then  
 	 	 var.tisfc010.most =  tisfc010.noru  
 	 else  
 	 	 var.tisfc010.most =  0  
 	 endif  
 	 if tirou001.ccap =  tcccap.man.capacity then  
 	 	 if isspace(tisfc010.mcno) then  
 	 	 	 var.tisfc010.mcho =  0.0  
 	 	 	 var.tisfc010.mcoc =  0  
 	 	 else  
 	 	 	 if tisfc010.mmrt <>  0 then  
 	 	 	 	 var.tisfc010.mcho =  tisfc010.prtm /  tisfc010.mmrt  
 	 	 	 	 var.tisfc010.mcoc =  tisfc010.noru /  tisfc010.mmrt  
 	 	 	 endif  
 	 	 endif  
 	 else  
 	 	 var.tisfc010.maho =  tisfc010.prtm *  tisfc010.mmrt  
 	 	 var.tisfc010.mopr =  tisfc010.noru *  tisfc010.mmrt  
 	 	 if tisfc010.sutm <>  0 then  
 	 	 	 var.tisfc010.most =  tisfc010.noru *  tisfc010.mmrt  
 	 	 endif  
 	 endif  
 	 if var.tisfc010.most <>  0 then  
 	 	 var.tisfc010.sutm =  tisfc010.sutm /  var.tisfc010.most  
 	 endif  
 	 if (operation.counter =  1) then  
 	 	 var.tisfc010.sopr =  tcyesno.yes  
 	 else  
 	 	 var.tisfc010.sopr =  tcyesno.no  
 	 endif  
 	 if prev.pdno <>  tisfc010.pdno then  
 	 	 tmp.tisfc010.lfdt =  tisfc001.dldt  
 	 	 var.tisfc010.lfdp =  tisfc001.dldp  
 	 else  
 	 	 tmp.tisfc010.lfdt =  prdt.next.operation  
 	 	 var.tisfc010.lfdp =  prdp.next.operation  
 	 endif  
 	  
 	 var.tisfc010.opst =  determine.operation.status()  
 	  
 	 var.tisfc010.ardt =  0  
 	 var.tisfc010.asdt =  0  
 	 if var.tisfc010.opst >=  3 then  
 	 	 var.tisfc010.ardt =  date.num()  
 	 endif  
 	 if var.tisfc010.opst >=  4 then  
 	 	 var.tisfc010.asdt =  date.num()  
 	 endif  
 | 	 compl.day.perc.shift =  (1.0 *  shift.time *  tisfc001.dldp) /  100 	 	 | #  211665.o  
 	 if tisfc010.comp =  tcyesno.yes then 	 	 	 	 	 | #  211665.sn  
 	 	 compl.day.perc.shift =  (1.0 *  shift.time *  tisfc001.dldp) /  100  
 	 	 var.tisfc010.cmdt =  utc(tisfc001.dldt, start.time +  compl.day.perc.shift)  
 	 else  
 	 	 var.tisfc010.cmdt =  utc(0,0)  
 	 endif 	 	 	 	 	 	 	 	 	 | #  211665.en  
 	 prod.day.perc.shift =  (1.0 *  shift.time *  tisfc010.prdp) /  100  
 	 start.day.remainder.perc.shift =  (1.0 *  shift.time *  tisfc010.rsdp) /  100  
 	 earl.finish.date.perc.shift =  (1.0 *  shift.time *  tisfc010.fidp) /  100  
 	 latest.finish.date.perc.shift =  (1.0 *  shift.time *  var.tisfc010.lfdp) /  100  
 	 var.tisfc010.qpli =  tisfc010.qpln +  tisfc010.qcpd +  tisfc010.qrpd  
 	 var.tisfc010.qplo =  var.tisfc010.qpli  
 	 var.tisfc010.qcmp =  tisfc010.qcmp +  tisfc010.qcpd  
 	 var.tisfc010.qrjc =  tisfc010.qrjc +  tisfc010.qrpd  
 	 if tisfc010.olap =  0 then  
 	 	 var.tisfc010.tlyn =  tcyesno.no  
 	 	 var.tisfc010.trls =  0  
 	 else  
 	 	 var.tisfc010.tlyn =  tcyesno.yes  
 | *  the parameter tirou000.tbmd is now set to % in this migration. 	 | #  204367.so  
 | *  so the olap must now also remain a % i.s.o. a calculated qty.  
 | 	 	 var.tisfc010.trls =  (1.0 *  tisfc010.qpln *  min(0, 100 -  tisfc010.olap)) /  100  
 | 	 	 var.tisfc010.trls =  max(1.0, var.tisfc010.trls) 	 | #  204367.eo  
 	 	 var.tisfc010.trls =  100 -  tisfc010.olap 	 	 | #  204367.n  
 	 endif  
 	 	 	 	 	 	 	 	 | #  209289.sn  
 	 if tisfc010.olap =  100 then  
 	 	 | *  in case of 100 % overlap the tisfc010.lfdt and tisfc010.mvdt are made  
 	 	 | *  equal to tisfc010.fidt.  
 	 	 var.tisfc010.lfdt =  utc(tisfc010.fidt, start.time +   
 	 	 	 	 	 earl.finish.date.perc.shift)  
 	 	 var.tisfc010.mvrd =  var.tisfc010.lfdt 	 	 | #  214558.n  
 	 else  
 	 	 var.tisfc010.lfdt =  utc(tmp.tisfc010.lfdt, start.time +   
 	 	 	 	 	 latest.finish.date.perc.shift)  
 	 	 var.tisfc010.mvrd =  var.tisfc010.lfdt 	 	 | #  214558.sn  
 	 	 | *  Observed: MVRD <  FIDT, which is wrong in LN.  
 	 	 | *  Cause: MVRD: =  LFDT, for last operation this is  
 	 	 | *  derived from tisfc001.dldt /  dldp, which in IVc  
 	 	 | *  can be less than FIDT of last operation.  
 	 	 | *  Solution: introduced var.tisfc010.mvrd, and  
 	 	 | *  if LFDT <  FIDT, then MVRD =  FIDT.  
 	 	 if tmp.tisfc010.lfdt <  tisfc010.fidt  
 	 	 or (tmp.tisfc010.lfdt =  tisfc010.fidt  
 	 	 	 and var.tisfc010.lfdp <  tisfc010.fidp) then  
 	 	 	 var.tisfc010.mvrd =  utc(tisfc010.fidt, start.time +   
 	 	 	 	 	 	 earl.finish.date.perc.shift)  
 	 	 endif 	 	 	 	 	 	 | #  214558.en  
 	 endif  
 	 	 	 	 	 	 	 	 | #  209289.en  
 	 dump 1  
 	 var.tisfc010.nopr =  tisfc010.opno  
 	 operation.counter =  operation.counter -  1  
 	 prev.pdno =  tisfc010.pdno  
 	 prdt.next.operation =  tisfc010.prdt  
 	 prdp.next.operation =  tisfc010.prdp
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:sfc
:TFLNO:010
:SCPAC:ti
:SCMOD:sfc
:SFLNO:010
:ICOD:S
:QURY:START
select 	 tisfc001.*  , tisfc010.*  , tirou001.ccap
from 	 tisfc001, tisfc010, tirou001
where 	 tisfc001._index1 =  {tisfc010.pdno}  
 | *  Skip SFC orders for TP - project - items, because: 	 	 | # 214978.sn  
 | * -  these items are also not migrated to LN.  
 | * -  LN does not allow production of TP - project - items.  
 | *  	 (IPD data can only be of PCS projects)  
 and 	 tisfc001.cprj =  ""  
 or exists (select tipcs020.prtp  
 from tipcs020  
 where tipcs020._index1 =  { tisfc001.cprj }  
 	 	 and tipcs020.prtp <>  tcyesno.yes) 	 	 | # 214978.en  
 and 	 tirou001._index1 =  {tisfc010.cwoc}
order by tisfc010.pdno asc, tisfc010.opno desc
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ti
:TCMOD:sfc
:TFLNO:010
:SCPAC:ti
:SCMOD:sfc
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:pdm
:TFLNO:000
:SCPAC:tp
:SCMOD:pdm
:SFLNO:000
:ICOD:D
:QURY:START
	 var.tppdm000.indt =  utc(0,0)  
 	 var.tppdm000.dsca =  form.text$("bcstc00035") 	  
 	 dump 1  
 	 var.tppdm000.indt =  utc(date.num(),time.num())  
 	 var.tppdm000.dsca =  form.text$("bcstc00036")  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:pdm
:TFLNO:000
:SCPAC:tp
:SCMOD:pdm
:SFLNO:000
:ICOD:S
:QURY:START
select 	 tppdm000.*
from 	 tppdm000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:pdm
:TFLNO:000
:SCPAC:tp
:SCMOD:pdm
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:pdm
:TFLNO:001
:SCPAC:tp
:SCMOD:pdm
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:pdm
:TFLNO:500
:SCPAC:tp
:SCMOD:pdm
:SFLNO:000
:ICOD:D
:QURY:START


var.tppdm000.indt =  utc(0,0)  
 	 var.tppdm000.dsca =  form.text$("bcstc00035")  
 	 dump 3 	  
 	 var.tppdm000.indt =  utc(date.num(),time.num())  
 	 var.tppdm000.dsca =  form.text$("bcstc00036")  
 	 dump 3  
 	 dump 1  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:pdm
:TFLNO:500
:SCPAC:tp
:SCMOD:pdm
:SFLNO:000
:ICOD:S
:QURY:START


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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:pdm
:TFLNO:600
:SCPAC:tp
:SCMOD:pdm
:SFLNO:600
:ICOD:D
:QURY:START
if not get.addresses ("tppdm600",tppdm600.cprj,o.err.mess) then  
 	 else  
 	 	 bcstc004.cadr =  ""                                
 	 endif  
 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:pdm
:TFLNO:600
:SCPAC:tp
:SCMOD:pdm
:SFLNO:600
:ICOD:S
:QURY:START
select tppdm600.*
from tppdm600
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:pdm
:TFLNO:600
:SCPAC:tp
:SCMOD:pdm
:SFLNO:600
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:pdm
:TFLNO:650
:SCPAC:tp
:SCMOD:pdm
:SFLNO:650
:ICOD:S
:QURY:START
select tppdm650.*
from tppdm650
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:pdm
:TFLNO:650
:SCPAC:tp
:SCMOD:pdm
:SFLNO:650
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:pdm
:TFLNO:790
:SCPAC:tp
:SCMOD:pdm
:SFLNO:790
:ICOD:D
:QURY:START
	 var.tppdm790.cprj =  get.tp.project(tppdm790.cprj)  
 	 if isspace(var.tppdm790.cprj) then  
 	 	 tt.align.according.domain(  
 	 	 	 	 tppdm790.cprj,  
 	 	 	 	 var.tppdm790.cprj,  
 	 	 	 	 "bcstc.nprj")              
 	 endif  
 	 if not get.addresses("tppdm600",tppdm790.cprj,o.err.mess) then  
 	 	 var.tppdm790.padr =  bcstc004.cadr  
 	 else  
 	 	 var.tppdm790.padr =  ""                              
 	 endif  
 	 if not get.business.partner(tppdm790.cuno,bcstc.orgn.cuno,o.err.mess) then  
 	 	 var.tppdm790.itbp =  bcstc008.bpid  
 	 	 var.tppdm790.ofbp =  bcstc008.bpid  
 	 	 var.tppdm790.pfbp =  bcstc008.bpid  
 	 else  
 	 	 var.tppdm790.itbp =  ""                              
 	 	 var.tppdm790.ofbp =  ""                              
 	 	 var.tppdm790.pfbp =  ""                              
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:pdm
:TFLNO:790
:SCPAC:tp
:SCMOD:pdm
:SFLNO:790
:ICOD:S
:QURY:START
select tppdm790.*
from tppdm790
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:pdm
:TFLNO:790
:SCPAC:tp
:SCMOD:pdm
:SFLNO:790
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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
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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:pin
:TFLNO:010
:SCPAC:tp
:SCMOD:pin
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:pin
:TFLNO:011
:SCPAC:tp
:SCMOD:pin
:SFLNO:010
:ICOD:D
:QURY:START
if tppin010.ninv <>  0 and tppin010.adsu =  tppdm.yeno.yes then  
 	 	 get.business.partner(tppin010.cuno,bcstc.orgn.cuno,err.mess)  
 	 	 var.tppin011.ityp =  " "  
 	 	 var.tppin011.idoc =  0  
 	 	 var.tppin011.fcmp =  0  
 	 	 if set.settled.invoice.lines() then  
 	 	 	 dump 1  
 	 	 endif  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:pin
:TFLNO:011
:SCPAC:tp
:SCMOD:pin
:SFLNO:010
:ICOD:S
:QURY:START
select tppin010.*
from tppin010
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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
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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:pin
:TFLNO:020
:SCPAC:tp
:SCMOD:pin
:SFLNO:020
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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)  
 	 dump 1
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:ppc
:TFLNO:305
:SCPAC:tp
:SCMOD:ppc
:SFLNO:305
:ICOD:D
:QURY:START
	 var.tpppc305.cprj =  get.tp.project(tpppc305.cprj)  
 	 if not get.cost.components (bcorig.tppdm,"",tpppc305.ccco,o.err.mess) then  
 	 	 var.tpppc305.ccco =  bcstc006.cost  
 	 else  
 	 	 var.tpppc305.ccco =  ""                                         
 	 endif  
 	 get.business.partner(tpppc305.cuno,bcstc.orgn.cuno,o.err.mess)  
 	 get.enterprise.unit(tppdm600.ncmp,ext.lng.comp , o.err.mess) 	  
 	 var.tpppc305.nadv =  0  
 	 var.tpppc305.nins =  0  
 	 var.tpppc305.ccty =  ""                            
 	 var.tpppc305.cvat =  ""                            
 	 on case tpppc305.rest  
 	 case tppdm.invt.advance:  
 	 	 var.tpppc305.rest =  etol(tpppc305.rest)  
 	 	 select 	 tppin120.cuno,tppin120.sera,tppin120.cvat,tppin100.ccty  
 	 	 from 	 tppin120,tppin100  
 	 	 where 	 tppin120.ninv =  :tpppc305.ninv 	  
 	 	 and 	 tppin120.sern =  :tpppc305.serf  
 	 	 and 	 tppin100.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin100.invt =  tppdm.invt.advance  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 var.tpppc305.nadv =  tppin120.sera  
 	 	 	 get.tax.by.country.code(tppin100.ccty,  
 	 	 	 	 	 tppin120.cvat,  
 	 	 	 	 	 var.tpppc305.ccty,  
 	 	 	 	 	 var.tpppc305.cvat,  
 	 	 	 	 	 o.err.mess )  
 	 	 selectempty  
 	 	 	 var.tpppc305.nadv =  0  
 	 	 	 var.tpppc305.ccty =  ""                            
 	 	 	 var.tpppc305.cvat =  ""                             
 	 	 endselect  
 	 	 break  
 	 case tppdm.invt.instalment:  
 	 	 var.tpppc305.rest =  etol(tpppc305.rest)  
 	 	 select 	 tppin130.cuno,tppin130.nins,tppin130.cvat,tppin100.ccty  
 	 	 from 	 tppin130  
 	 	 where 	 tppin130.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin130.sern =  :tpppc305.serf  
 	 	 and tppin130.cdmt <>  tppin.cdmt.advance  
 	 	 and 	 tppin100.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin100.invt =  tppdm.invt.instalment  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 var.tpppc305.nins =  tppin130.nins  
 	 	 	 get.tax.by.country.code(tppin100.ccty,  
 	 	 	 	 	 tppin130.cvat,  
 	 	 	 	 	 var.tpppc305.ccty,  
 	 	 	 	 	 var.tpppc305.cvat,  
 	 	 	 	 	 o.err.mess)  
 	 	 selectempty  
 	 	 	 var.tpppc305.nins =  0  
 	 	 	 var.tpppc305.ccty =  ""                        
 	 	 	 var.tpppc305.cvat =  ""                        
 	 	 endselect  
 	 	 break  
 	 case tppdm.invt.prime.cost:  
 	 	 var.tpppc305.rest =  4  
 	 	 select 	 tppin100.ccty,tppin140.cvat  
 	 	 from 	 tppin100,tppin140  
 	 	 where 	 tppin100.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin100.invt =  tppdm.invt.prime.cost  
 	 	 and tppin140.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin140.sern =  :tpppc305.serf 	 	  
 	 	 and tppin140.cdmt <>  tppin.cdmt.advance  
 	 	 as set with 1 rows  
 	 	 selectdo 	 	 	  
 	 	 	 get.tax.by.country.code(tppin100.ccty,  
 	 	 	 	 	 tppin140.cvat,  
 	 	 	 	 	 var.tpppc305.ccty,  
 	 	 	 	 	 var.tpppc305.cvat,  
 	 	 	 	 	 o.err.mess)  
 	 	 selectempty 	 	 	  
 	 	 	 var.tpppc305.ccty =  ""                            
 	 	 	 var.tpppc305.cvat =  ""                             
 	 	 endselect  
 	 	 select 	 tppin100.ccty,tppin150.cvat  
 	 	 from 	 tppin100,tppin150  
 	 	 where 	 tppin100.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin100.invt =  tppdm.invt.prime.cost  
 	 	 and tppin150.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin150.sern =  :tpppc305.serf 	 	  
 	 	 and tppin150.cdmt <>  tppin.cdmt.advance  
 	 	 as set with 1 rows  
 	 	 selectdo 	 	 	  
 	 	 	 get.tax.by.country.code(tppin100.ccty,  
 	 	 	 	 	 tppin150.cvat,  
 	 	 	 	 	 var.tpppc305.ccty,  
 	 	 	 	 	 var.tpppc305.cvat,  
 	 	 	 	 	 o.err.mess)  
 	 	 selectempty 	 	 	  
 	 	 	 var.tpppc305.ccty =  ""                            
 	 	 	 var.tpppc305.cvat =  ""                             
 	 	 endselect  
 	 	 select tppin100.ccty,tppin160.cvat  
 	 	 from 	 tppin100,tppin160  
 	 	 where 	 tppin100.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin100.invt =  tppdm.invt.prime.cost  
 	 	 and tppin160.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin160.sern =  :tpppc305.serf  
 	 	 and tppin160.cdmt <>  tppin.cdmt.advance  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 get.tax.by.country.code(tppin100.ccty,  
 	 	 	 	 	 tppin160.cvat,  
 	 	 	 	 	 var.tpppc305.ccty,  
 	 	 	 	 	 var.tpppc305.cvat,  
 	 	 	 	 	 o.err.mess)  
 	 	 selectempty  
 	 	 	 var.tpppc305.ccty =  ""                            
 	 	 	 var.tpppc305.cvat =  ""                             
 	 	 endselect  
 	 	 select tppin100.ccty,tppin170.cvat  
 	 	 from 	 tppin100,tppin170  
 	 	 where 	 tppin100.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin100.invt =  tppdm.invt.prime.cost  
 	 	 and tppin170.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin170.sern =  :tpppc305.serf  
 	 	 and tppin170.cdmt <>  tppin.cdmt.advance  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 get.tax.by.country.code(tppin100.ccty,  
 	 	 	 	 	 tppin170.cvat,  
 	 	 	 	 	 var.tpppc305.ccty,  
 	 	 	 	 	 var.tpppc305.cvat,  
 	 	 	 	 	 o.err.mess)  
 	 	 selectempty  
 	 	 	 var.tpppc305.ccty =  ""                            
 	 	 	 var.tpppc305.cvat =  ""                             
 	 	 endselect  
 	 	 select tppin100.ccty,tppin180.cvat  
 	 	 from 	 tppin100,tppin180  
 	 	 where 	 tppin100.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin100.invt =  tppdm.invt.prime.cost  
 	 	 and tppin180.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin180.sern =  :tpppc305.serf  
 	 	 and tppin180.cdmt <>  tppin.cdmt.advance  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 get.tax.by.country.code(tppin100.ccty,  
 	 	 	 	 	 tppin180.cvat,  
 	 	 	 	 	 var.tpppc305.ccty,  
 	 	 	 	 	 var.tpppc305.cvat,  
 	 	 	 	 	 o.err.mess)  
 	 	 selectempty  
 	 	 	 var.tpppc305.ccty =  ""                            
 	 	 	 var.tpppc305.cvat =  ""                             
 	 	 endselect  
 	 	 break  
 	 case tppdm.invt.settlement:  
 	 	 var.tpppc305.rest =  5  
 	 	 select 	 tppin100.ccty,tppin140.cvat  
 	 	 from 	 tppin100,tppin140  
 	 	 where 	 tppin100.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin100.invt =  tppdm.invt.settlement  
 	 	 and tppin140.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin140.sern =  :tpppc305.serf 	 	  
 	 	 and tppin140.cdmt <>  tppin.cdmt.advance  
 	 	 as set with 1 rows  
 	 	 selectdo 	 	 	  
 	 	 	 get.tax.by.country.code(tppin100.ccty,  
 	 	 	 	 	 tppin140.cvat,  
 	 	 	 	 	 var.tpppc305.ccty,  
 	 	 	 	 	 var.tpppc305.cvat,  
 	 	 	 	 	 o.err.mess)  
 	 	 selectempty 	 	 	  
 	 	 	 var.tpppc305.ccty =  ""                            
 	 	 	 var.tpppc305.cvat =  ""                             
 	 	 endselect  
 	 	 select 	 tppin100.ccty,tppin150.cvat  
 	 	 from 	 tppin100,tppin150  
 	 	 where 	 tppin100.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin100.invt =  tppdm.invt.settlement  
 	 	 and tppin150.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin150.sern =  :tpppc305.serf 	 	  
 	 	 and tppin150.cdmt <>  tppin.cdmt.advance  
 	 	 as set with 1 rows  
 	 	 selectdo 	 	 	  
 	 	 	 get.tax.by.country.code(tppin100.ccty,  
 	 	 	 	 	 tppin150.cvat,  
 	 	 	 	 	 var.tpppc305.ccty,  
 	 	 	 	 	 var.tpppc305.cvat,  
 	 	 	 	 	 o.err.mess)  
 	 	 selectempty 	 	 	  
 	 	 	 var.tpppc305.ccty =  ""                            
 	 	 	 var.tpppc305.cvat =  ""                             
 	 	 endselect  
 	 	 select tppin100.ccty,tppin160.cvat  
 	 	 from 	 tppin100,tppin160  
 	 	 where 	 tppin100.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin100.invt =  tppdm.invt.settlement  
 	 	 and tppin160.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin160.sern =  :tpppc305.serf  
 	 	 and tppin160.cdmt <>  tppin.cdmt.advance  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 get.tax.by.country.code(tppin100.ccty,  
 	 	 	 	 	 tppin160.cvat,  
 	 	 	 	 	 var.tpppc305.ccty,  
 	 	 	 	 	 var.tpppc305.cvat,  
 	 	 	 	 	 o.err.mess)  
 	 	 selectempty  
 	 	 	 var.tpppc305.ccty =  ""                            
 	 	 	 var.tpppc305.cvat =  ""                             
 	 	 endselect  
 	 	 select tppin100.ccty,tppin170.cvat  
 	 	 from 	 tppin100,tppin170  
 	 	 where 	 tppin100.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin100.invt =  tppdm.invt.settlement  
 	 	 and tppin170.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin170.sern =  :tpppc305.serf  
 	 	 and tppin170.cdmt <>  tppin.cdmt.advance  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 get.tax.by.country.code(tppin100.ccty,  
 	 	 	 	 	 tppin170.cvat,  
 	 	 	 	 	 var.tpppc305.ccty,  
 	 	 	 	 	 var.tpppc305.cvat,  
 	 	 	 	 	 o.err.mess)  
 	 	 selectempty  
 	 	 	 var.tpppc305.ccty =  ""                            
 	 	 	 var.tpppc305.cvat =  ""                             
 	 	 endselect  
 	 	 select tppin100.ccty,tppin180.cvat  
 	 	 from 	 tppin100,tppin180  
 	 	 where 	 tppin100.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin100.invt =  tppdm.invt.settlement  
 	 	 and tppin180.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin180.sern =  :tpppc305.serf  
 	 	 and tppin180.cdmt <>  tppin.cdmt.advance  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 get.tax.by.country.code(tppin100.ccty,  
 	 	 	 	 	 tppin180.cvat,  
 	 	 	 	 	 var.tpppc305.ccty,  
 	 	 	 	 	 var.tpppc305.cvat,  
 	 	 	 	 	 o.err.mess)  
 	 	 selectempty  
 	 	 	 var.tpppc305.ccty =  ""                            
 	 	 	 var.tpppc305.cvat =  ""                             
 	 	 endselect  
 	 	  
 	 	 break  
 	 case tppdm.invt.unit.rate:  
 	 	 var.tpppc305.rest =  6  
 	 	 select tppin100.ccty,tppin190.cvat  
 	 	 from 	 tppin100,tppin190  
 	 	 where 	 tppin100.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin100.invt =  tppdm.invt.settlement  
 	 	 and tppin190.ninv =  :tpppc305.ninv  
 	 	 and 	 tppin190.sern =  :tpppc305.serf  
 	 	 and tppin190.cdmt <>  tppin.cdmt.advance  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 get.tax.by.country.code(tppin100.ccty,  
 	 	 	 	 	 tppin190.cvat,  
 	 	 	 	 	 var.tpppc305.ccty,  
 	 	 	 	 	 var.tpppc305.cvat,  
 	 	 	 	 	 o.err.mess)  
 	 	 selectempty  
 	 	 	 var.tpppc305.ccty =  ""                            
 	 	 	 var.tpppc305.cvat =  ""                             
 	 	 endselect  
 	 	 break  
 	 default:  
 	 endcase  
 	 dump 1
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:ppc
:TFLNO:305
:SCPAC:tp
:SCMOD:ppc
:SFLNO:305
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:ptc
:TFLNO:410
:SCPAC:tp
:SCMOD:ptc
:SFLNO:410
:ICOD:D
:QURY:START


dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:tp
:TCMOD:ptc
:TFLNO:410
:SCPAC:tp
:SCMOD:ptc
:SFLNO:410
:ICOD:S
:QURY:START


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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ts
:TCMOD:cfg
:TFLNO:210
:SCPAC:ts
:SCMOD:sma
:SFLNO:104
:ICOD:S
:QURY:START
select 	 tssma102.item, tssma102.cprj, 	 tssma102.cgua, tssma104.*
from 	 tssma102, tssma104
where 	 tssma104.cins refers to tssma102
order by tssma104._index1
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ts
:TCMOD:clm
:TFLNO:330
:SCPAC:ts
:SCMOD:spf
:SFLNO:102
:ICOD:D
:QURY:START
Dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ts
:TCMOD:clm
:TFLNO:330
:SCPAC:ts
:SCMOD:spf
:SFLNO:102
:ICOD:S
:QURY:START
select tsspf102.*
from tsspf102
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ts
:TCMOD:clm
:TFLNO:330
:SCPAC:ts
:SCMOD:spf
:SFLNO:102
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ts
:TCMOD:clm
:TFLNO:335
:SCPAC:ts
:SCMOD:spf
:SFLNO:103
:ICOD:D
:QURY:START
Dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ts
:TCMOD:clm
:TFLNO:335
:SCPAC:ts
:SCMOD:spf
:SFLNO:103
:ICOD:S
:QURY:START
select tsspf103.*
from tsspf103
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ts
:TCMOD:clm
:TFLNO:335
:SCPAC:ts
:SCMOD:spf
:SFLNO:103
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ts
:TCMOD:soc
:TFLNO:000
:SCPAC:ts
:SCMOD:sma
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ts
:TCMOD:soc
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:301
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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() 	 	 	  
 	 fill.cluster()  
 	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ts
:TCMOD:soc
:TFLNO:220
:SCPAC:ts
:SCMOD:sma
:SFLNO:310
:ICOD:S
:QURY:START
select 	 tssma310.*  , tssma301.ddt6, 	 tssma301.dtm6, tssma301.ccty, 	 tssma301.emno, tssma301.cloc, 	 tssma301.cuno, tiitm001.dsca, 	 tiitm001.kitm, tiitm001.cuni
from 	 tssma310, tssma301, tiitm001
where 	 tssma310.orno refers to tssma301  
 and 	 tssma310.item refers to tiitm001
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ts
:TCMOD:soc
:TFLNO:850
:SCPAC:ts
:SCMOD:sma
:SFLNO:501
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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()  
 	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:ts
:TCMOD:soc
:TFLNO:860
:SCPAC:ts
:SCMOD:sma
:SFLNO:510
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:wh
:TCMOD:ina
:TFLNO:000
:SCPAC:td
:SCMOD:inv
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:wh
:TCMOD:ina
:TFLNO:300
:SCPAC:td
:SCMOD:inv
:SFLNO:300
:ICOD:D
:QURY:START
	 var.whina300.orno =  convert.number( 	 bcckon.prod.advice,  
 	 	 	 	 	 	 	 tdinv300.orno)  
 	 var.whina300.item =  segment.item.code( 	 tdinv300.item,  
 	 	 	 	 	 	 	 "")      
 	 var.whina300.dldt =  utc(tdinv300.dldt,0)  
 	 var.whina300.prdt =  utc(tdinv300.prdt,0)  
 	 var.whina300.cplb =  format.emno(tdinv300.cplb)  
 	 dump 1 | *  Production Order Advices.
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:wh
:TCMOD:ina
:TFLNO:300
:SCPAC:td
:SCMOD:inv
:SFLNO:300
:ICOD:S
:QURY:START
select 	 tdinv300.*  , tiitm001.cuni
from 	 tdinv300, tiitm001
where 	 tdinv300.cntr =  ""    
 and 	 tdinv300.item refers to tiitm001.item
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:wh
:TCMOD:ina
:TFLNO:310
:SCPAC:td
:SCMOD:inv
:SFLNO:310
:ICOD:D
:QURY:START
	 if not isspace(tdinv310.cntr) then  
 	 	 continue  
 	 endif  
 	 var.whina310.orno =  convert.number( 	 bcckon.pur.advice,  
 	 	 	 	 	 	 	 tdinv310.orno)  
 	 var.whina310.item =  segment.item.code( 	 tdinv310.item,  
 	 	 	 	 	 	 	 "")                                
 	 if not isspace(tdinv310.cwar) then  
 	 	 var.whina310.cwar =  tdinv310.cwar  
 	 else  
 	 	 | *  Take the warehouse from the item table.  
 	 	 select tiitm001.cwar  
 	 	 from tiitm001  
 	 	 where tiitm001._index1 =  {:tdinv310.item}  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 var.whina310.cwar =  tiitm001.cwar  
 	 	 selectempty  
 	 	 	 var.whina310.cwar =  ""                                
 	 	 endselect  
 	 endif  
 	 var.whina310.ordt =  utc(tdinv310.ordt,0)  
 	 var.whina310.dldt =  utc(tdinv310.dldt,0)  
 	 | *  Field whina310.suno is not mandatory.  
 	 if not isspace(tdinv310.suno) then  
 	 	 if get.business.partner ( tdinv310.suno,  
 	 	 	 	 bcstc.orgn.suno,  
 	 	 	 	 error.message) <>  0 then  
 	 	 	 | *  Skip business partners which are not found.  
 	 	 	 continue  
 	 	 endif  
 	 	 var.whina310.suno =  bcstc008.bpid  
 	 else  
 	 	 var.whina310.suno =  empty()  
 	 endif  
 	 if tdinv310.sorn <>  0 then  
 	 	 | *  Sales order number is filled.  
 	 	 var.whina310.rorn =  convert.number( 	 bcckon.act.sls,  
 	 	 	 	 	 	 	 tdinv310.sorn)  
 	 	 var.whina310.rpon =  tdinv310.spon  
 	 else  
 	 	 | *  Service order number is filled.  
 	 	 var.whina310.rorn =  convert.number( 	 bcckon.sma.order,  
 	 	 	 	 	 	 	 tdinv310.srvo)  
 	 	 var.whina310.rpon =  tdinv310.srvp  
 	 endif  
 	 var.whina310.cplb =  format.emno(tdinv310.cplb)  
 	 var.whina310.buyr =  format.emno(tdinv310.buyr)  
 	 dump 1 | *  Purchase Order Advices.
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:wh
:TCMOD:ina
:TFLNO:310
:SCPAC:td
:SCMOD:inv
:SFLNO:310
:ICOD:S
:QURY:START
select 	 tdinv310.*  , tiitm001.cuni
from 	 tdinv310, tiitm001
where 	 tdinv310.orno >  0  
 and 	 tdinv310.srvo =  0  
 and 	 tdinv310.cntr =  ""    
 and 	 tdinv310.item refers to tiitm001
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:wh
:TCMOD:inh
:TFLNO:000
:SCPAC:td
:SCMOD:ilc
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:wh
:TCMOD:inr
:TFLNO:100
:SCPAC:td
:SCMOD:ilc
:SFLNO:301
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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  
 	 	 	 var.whinr110.valm =  5 | *  lot  
 	 	 	 	 	 	 	 	 	 | #  800 -  145084.sn  
 	 	 	 determine.lot.inventory.onhand( 	 tdinv700.item,  
 	 	 	 	 	 	 	 tdinv700.cwar,  
 	 	 	 	 	 	 	 nr.lots,  
 	 	 	 	 	 	 	 arr.lots)  
 	 	 	 	 	 	 	 	 	 | #  800 -  145084.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  
 	 	 var.whinr110.kost =  convert.tckost(tdinv700.kost, tdinv700.quan)  
 	 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  
 | 	 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  
 	 	 if var.whinr110.valm =  5 then 	 	 	 	 	 | #  800 -  145084.sn  
 	 	 	 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  
 	 	 	 	 	 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  
 	 	 	 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  
 	 	 	 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  
 	 	 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)  
 	 	 	 	 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  
 	 	 	 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  
 	 	 	 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  
 	 	 	 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  
 	 	 	 	 	 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  
 	 	 	 	 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  
 	 	 if var.whinr110.valm =  5 then 	 	 	 	 	 | #  800 -  145084.sn  
 	 	 	 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  
 	 	 	 	 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  
 	 	 	 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  
 	 	 	 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  
 	 	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:wh
:TCMOD:inr
:TFLNO:110
:SCPAC:td
:SCMOD:inv
:SFLNO:700
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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.sn  
 	 	 	 	 	 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.en  
 	 	 	 	 	 	 	 	 | #  SL204550.sn  
 	 	 	 if tipcs700.quan <  0 then  
 	 	 	 	 	 	 	 	 | #  213329.so  
 | 	 	 	 	 get.return.purchase.order.line.data(  
 | 	 	 	 	 	 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  
 	 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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:wh
:TCMOD:inr
:TFLNO:110
:SCPAC:ti
:SCMOD:pcs
:SFLNO:700
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:wh
:TCMOD:inr
:TFLNO:120
:SCPAC:td
:SCMOD:inv
:SFLNO:750
:ICOD:D
:QURY:START
	 for var.lng.cnt =  1 to var.whinr120.nopr  
 | 	 	 if (tdinv750.aupp (var.lng.cnt) >  0 or tdinv750.fupp (var.lng.cnt) >  0) then 	 | #  205004.o  
 	 	 if (tdinv750.aupp (var.lng.cnt) <>  0 or tdinv750.fupp (var.lng.cnt) <>  0) then 	 | #  205004.n  
 	 	 	 dump 1  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:wh
:TCMOD:inr
:TFLNO:120
:SCPAC:td
:SCMOD:inv
:SFLNO:750
:ICOD:S
:QURY:START
select 	 tdinv750.*
from 	 tdinv750
where 	 tdinv750.cntr =  ""
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:wh
:TCMOD:inr
:TFLNO:120
:SCPAC:td
:SCMOD:inv
:SFLNO:750
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:wh
:TCMOD:inr
:TFLNO:130
:SCPAC:td
:SCMOD:inv
:SFLNO:760
:ICOD:D
:QURY:START
	 for var.lng.cnt =  1 to var.whinr130.nopr  
 | 	 	 if (tdinv760.aupp (var.lng.cnt) >  0 or tdinv760.fupp (var.lng.cnt) >  0) then 	 | #  205004.o  
 	 	 if (tdinv760.aupp (var.lng.cnt) <>  0 or tdinv760.fupp (var.lng.cnt) <>  0) then 	 | #  205004.n  
 	 	 	 dump 1  
 	 	 endif  
 	 endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:wh
:TCMOD:inr
:TFLNO:130
:SCPAC:td
:SCMOD:inv
:SFLNO:760
:ICOD:S
:QURY:START
select 	 tdinv760.*
from 	 tdinv760
where 	 tdinv760.cntr =  ""
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:wh
:TCMOD:inr
:TFLNO:130
:SCPAC:td
:SCMOD:inv
:SFLNO:760
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
: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:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:wh
:TCMOD:inr
:TFLNO:140
:SCPAC:ti
:SCMOD:pcs
:SFLNO:021
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:wh
:TCMOD:wmd
:TFLNO:300
:SCPAC:td
:SCMOD:ilc
:SFLNO:001
:ICOD:D
:QURY:START
	 if var.previous.cwar <>  tdilc001.cwar then 	 | #  209021.n  
 	 	 select tcmcs003.arlo,  
 	 	 	 tcmcs003.sloc  
 	 	 from 	 tcmcs003  
 	 	 where tcmcs003._index1 =  {:tdilc001.cwar}  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 endselect  
 	 endif 	 	 	 	 	 	 | #  209021.n  
 	 if tdilc001.loca =  tcmcs003.arlo then  
 	 	 var.whwmd300.loct =  3 | *  Receiving  
 	 	 set.location.type.values.for.inspection.and.receiving()  
 	 else  
 	 	 if tdilc001.aplo =  tcyesno.yes then  
 	 	 	 var.whwmd300.loct =  1 | *  Inspection  
 	 	 	 set.location.type.values.for.inspection.and.receiving()  
 	 	 else  
 	 	 	 var.whwmd300.loct =  5 | *  Bulk  
 	 	 	 set.location.type.values.for.bulk()  
 	 	 endif  
 	 endif  
 	 dump 1 | *  Locations  
 	 if ( 	 tcmcs003.sloc =  tcyesno.yes and  
 	 	 tdilc001.cwar <>  var.previous.cwar) then  
 	 	 var.whwmd300.loct =  6 | *  Staging bcswh000.sloc  
 	 	 var.whwmd300.loca =  bcswh000.sloc  
 	 	 var.whwmd300.dsca =  bcswh000.slod  
 	 	 var.whwmd300.inlo =  tcyesno.no  
 	 	 dump 2 | *  Locations  
 	 endif  
 	 if ( 	 tcmcs003.sloc =  tcyesno.yes and  
 	 	 tdilc001.cwar <>  var.previous.cwar) then  
 	 	 var.whwmd300.loct =  5 | *  Bulk bcswh000.ploc  
 	 	 var.whwmd300.loca =  bcswh000.ploc  
 	 	 var.whwmd300.dsca =  bcswh000.plod  
 	 	 var.whwmd300.inlo =  tcyesno.yes  
 	 	 dump 2 | *  Locations  
 	 endif  
 | #  209021.sn  
 	 if ( 	 tcmcs003.sloc =  tcyesno.yes and  
 	 	 tdilc001.cwar <>  var.previous.cwar and  
 	 	 bcswh000.ploc <>  bcswh000.tloc and  
 	 	 not isspace(bcswh000.tloc)) then  
 	 	 var.whwmd300.loct =  5 | *  Bulk bcswh000.ploc  
 	 	 var.whwmd300.loca =  bcswh000.tloc  
 	 	 var.whwmd300.dsca =  bcswh000.tlod  
 	 	 var.whwmd300.inlo =  tcyesno.yes  
 	 	 dump 2 | *  Locations  
 	 endif  
 | #  209021.en  
 	 var.previous.cwar =  tdilc001.cwar  
 	 if tdilc001.inca =  tcyesno.no then  
 	 	 | *  Location does not have infinite capacity.  
 	 	 select tcmcs001.tccu  
 	 	 from 	 tcmcs001  
 	 	 where tcmcs001._index1 =  {:tdilc001.capu}  
 	 	 selectdo  
 	 	 	 var.whwmd301.totw =  0  
 	 	 	 var.whwmd301.totv =  0  
 	 	 	 var.whwmd301.tots =  0  
 	 	 	 on case (tcmcs001.tccu)  
 	 	 	 case tctccu.mass :  
 	 	 	 	 | *  Fill Total Weight  
 	 	 	 	 var.whwmd301.totw =  tdilc001.calo  
 	 	 	 	 break  
 	 	 	 case tctccu.volume :  
 	 	 	 	 | *  Fill Total Volume  
 	 	 	 	 var.whwmd301.totv =  tdilc001.calo  
 	 	 	 	 break  
 	 	 	 case tctccu.area :  
 	 	 	 	 | *  Fill Total Floor Space  
 	 	 	 	 var.whwmd301.tots =  tdilc001.calo  
 	 	 	 	 break  
 	 	 	 endcase  
 	 	 endselect  
 	 	 | *  Warning when exceeding capacity percentage  
 	 	 if tdilc001.sigp >  100 then  
 	 	 	 var.whwmd301.wexc =  100  
 	 	 else  
 	 	 	 var.whwmd301.wexc =  tdilc001.sigp  
 	 	 endif  
 	 	 dump 3 | *  Location Capacity  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:wh
:TCMOD:wmd
:TFLNO:300
:SCPAC:td
:SCMOD:ilc
:SFLNO:001
:ICOD:S
:QURY:START
select tdilc001.*
from tdilc001
where 	 tdilc001.cwar >  ""    	    |*     for better performance |#    209021.n
order by tdilc001._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:18
:VERS:B4st
:RELE:61
:CUST:sy25
:TCPAC:wh
:TCMOD:wmd
:TFLNO:300
:SCPAC:td
:SCMOD:ilc
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
